Browse Source

eliminate native Bullet from build scripts

Stephen Gold 4 years ago
parent
commit
671a90b7f0

+ 2 - 123
.github/workflows/main.yml

@@ -3,8 +3,6 @@
 ######################################################################################
 # Quick overview of what is going on in this script:
 #   - Build natives for android
-#   - Build natives for linux arm
-#   - Build natives for windows,mac,linux x86_64 and x86
 #   - Merge the natives, build the engine, create the zip release, maven artifacts, javadoc and native snapshot
 #   - (only when there is a change in the native code) Deploy the native snapshot to bintray
 #   - (only when building a release) Deploy everything else to github releases, github packet registry and bintray
@@ -58,34 +56,6 @@ on:
   
 jobs:
   
-  # Builds the natives on linux arm
-  BuildLinuxArmNatives:
-    name: Build natives for linux (arm)
-    runs-on: ubuntu-18.04
-    container:
-      image: riccardoblb/buildenv-jme3:linuxArm
-   
-    steps:
-      - name: Clone the repo
-        uses: actions/checkout@v2     
-        with:
-          fetch-depth: 1
-      - name: Validate the Gradle wrapper
-        uses: gradle/wrapper-validation-action@v1
-      - name: Build
-        run: |
-          # Build
-          # Note: since this is crossbuild we use the buildForPlatforms filter to tell
-          # the buildscript wich platforms it should build for.
-          ./gradlew -PuseCommitHashAsVersionName=true --no-daemon -PbuildForPlatforms=LinuxArm,LinuxArmHF,LinuxArm64 -PbuildNativeProjects=true \
-          :jme3-bullet-native:assemble 
-
-      - name: Upload natives
-        uses: actions/upload-artifact@master
-        with:
-          name: linuxarm-natives
-          path: build/native 
-
   # Build the natives on android
   BuildAndroidNatives:
     name: Build natives for android
@@ -103,8 +73,7 @@ jobs:
       - name: Build
         run: |
           ./gradlew -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \
-          :jme3-android-native:assemble \
-          :jme3-bullet-native-android:assemble 
+          :jme3-android-native:assemble 
      
       - name: Upload natives
         uses: actions/upload-artifact@master
@@ -112,71 +81,9 @@ jobs:
           name: android-natives
           path: build/native
 
-  # Build the natives
-  BuildNatives:
-    strategy:
-      fail-fast: true
-      matrix:
-        os: [ubuntu-18.04,windows-2019,macOS-latest] 
-        jdk: [8.x.x]
-        include:
-          - os: ubuntu-18.04
-            osName: linux
-          - os: windows-2019
-            osName: windows
-          - os: macOS-latest
-            osName: mac
-              
-    name: Build natives for ${{ matrix.osName }}
-    runs-on: ${{ matrix.os }}    
-    steps:    
-    
-      - name: Clone the repo
-        uses: actions/checkout@v2     
-        with:
-          fetch-depth: 1
-           
-      - name: Prepare java environment
-        uses: actions/setup-java@v1
-        with:
-          java-version: ${{ matrix.jdk }}
-          architecture: x64
-      - name: Validate the Gradle wrapper
-        uses: gradle/wrapper-validation-action@v1
-      - name: Build Natives
-        shell: bash
-        env:
-          OS_NAME: ${{ matrix.osName }}
-        run: |
-          # Install dependencies
-          if [ "$OS_NAME" = "mac" ];
-          then
-            echo "Prepare mac"        
-          
-          elif [ "$OS_NAME" = "linux" ];
-          then
-            echo "Prepare linux"
-            sudo apt-get update
-            sudo apt-get install -y gcc-multilib g++-multilib
-          else
-            echo "Prepare windows"
-          fi
-          
-          # Build
-          ./gradlew  -PuseCommitHashAsVersionName=true --no-daemon  -PbuildNativeProjects=true -Dmaven.repo.local="$PWD/dist/maven" \
-          :jme3-bullet-native:build
-                  
-      # Upload natives to be used later by the BuildJMonkey job
-      - name: Upload natives
-        uses: actions/upload-artifact@master
-        with:
-          name: ${{ matrix.osName }}-natives
-          path: build/native
- 
-
   # Build the engine, we only deploy from ubuntu-18.04 jdk8
   BuildJMonkey:  
-    needs: [BuildNatives,BuildAndroidNatives]
+    needs: [BuildAndroidNatives]
     name: Build on ${{ matrix.osName }} jdk${{ matrix.jdk }}
     runs-on: ${{ matrix.os }}    
     strategy:
@@ -209,35 +116,12 @@ jobs:
           java-version: ${{ matrix.jdk }}
           architecture: x64
 
-      - name: Download natives for linux
-        uses: actions/download-artifact@master
-        with:
-          name: linux-natives
-          path: build/native
-
-      - name: Download natives for windows
-        uses: actions/download-artifact@master
-        with:
-          name: windows-natives
-          path: build/native
-
-      - name: Download natives for mac
-        uses: actions/download-artifact@master
-        with:
-          name: mac-natives
-          path: build/native
-
       - name: Download natives for android
         uses: actions/download-artifact@master
         with:
           name: android-natives
           path: build/native
 
-      - name: Download natives for linux (arm)
-        uses: actions/download-artifact@master
-        with:
-          name: linuxarm-natives
-          path: build/native
       - name: Validate the Gradle wrapper
         uses: gradle/wrapper-validation-action@v1
       - name: Build Engine
@@ -348,12 +232,7 @@ jobs:
               else
                 # We check if the native code changed.
                 echo "Detect changes"
-                NATIVE_CHANGES="$(git diff-tree --name-only "$GITHUB_SHA" "$nativeSnapshot" -- jme3-bullet-native/)"
                 if [ "$NATIVE_CHANGES" = "" ];then NATIVE_CHANGES="$(git diff-tree --name-only "$GITHUB_SHA" "$nativeSnapshot"  --  jme3-android-native/)"; fi
-                if [ "$NATIVE_CHANGES" = "" ];then NATIVE_CHANGES="$(git diff-tree --name-only "$GITHUB_SHA" "$nativeSnapshot"  --  jme3-bullet-native-android/)"; fi
-                if [ "$NATIVE_CHANGES" = "" ];then NATIVE_CHANGES="$(git diff-tree --name-only "$GITHUB_SHA" "$nativeSnapshot"  --  jme3-bullet/)"; fi
-                # The bulletUrl (in gradle.properties) might have changed.
-                if [ "$NATIVE_CHANGES" = "" ];then NATIVE_CHANGES="$(git diff-tree --name-only "$GITHUB_SHA" "$nativeSnapshot"  --  gradle.properties)"; fi
               fi
             fi
 

+ 1 - 1
build.gradle

@@ -44,7 +44,7 @@ subprojects {
         apply from: rootProject.file('common-android-app.gradle')
     }
 
-    if (!project.name.endsWith("-native") && project.name != "jme3-bullet-native-android" && enableSpotBugs != "false" ) {
+    if (!project.name.endsWith("-native") && enableSpotBugs != "false" ) {
         apply plugin: 'com.github.spotbugs'
 
         // Currently we only warn about issues and try to fix them as we go, but those aren't mission critical.

+ 0 - 6
gradle.properties

@@ -30,12 +30,6 @@ enableSpotBugs=false
 #ndkPath=/Users/normenhansen/Documents/Code-Import/android-ndk-r7
 ndkPath = /opt/android-ndk-r16b
 
-# Path for downloading native Bullet
-# 2.89+ (circa 26 April 2020, to avoid jMonkeyEngine issue #1283)
-bulletUrl = https://github.com/bulletphysics/bullet3/archive/cd8cf7521cbb8b7808126a6adebd47bb83ea166a.zip
-bulletFolder = bullet3-cd8cf7521cbb8b7808126a6adebd47bb83ea166a
-bulletZipFile = bullet3.zip
-
 # POM settings
 POM_NAME=jMonkeyEngine
 POM_DESCRIPTION=jMonkeyEngine is a 3-D game engine for adventurous Java developers

+ 0 - 131
jme3-bullet-native-android/build.gradle

@@ -1,131 +0,0 @@
-String jmeBulletNativeProjectPath = project(":jme3-bullet-native").projectDir
-
-String localUnzipPath = jmeBulletNativeProjectPath
-String localZipFile = jmeBulletNativeProjectPath + File.separator + bulletZipFile
-String localZipFolder = jmeBulletNativeProjectPath + File.separator + bulletFolder
-String bulletSrcPath = localZipFolder + File.separator + 'src'
-
-String jmeAndroidPath = 'src/native/android'
-String jmeCppPath = jmeBulletNativeProjectPath + '/src/native/cpp'
-
-//Working directories for the ndk build.
-String ndkWorkingPath = "${buildDir}" + '/bullet'
-String jniPath = ndkWorkingPath + '/jni'
-String ndkOutputPath = ndkWorkingPath + '/libs'
-
-//Pre-compiled libs directory
-def rootPath = rootProject.projectDir.absolutePath
-String bulletPreCompiledLibsDir = rootPath + File.separator + 'build' + File.separator + 'native' + File.separator +  'android' + File.separator + 'bullet'
-
-if (!hasProperty('mainClass')) {
-    ext.mainClass = ''
-}
-
-dependencies {
-    compile project(':jme3-bullet')
-}
-
-// Java source sets for IDE access and source jar bundling / mavenization
-sourceSets {
-    main {
-        java {
-            srcDir jmeCppPath
-            srcDir jmeAndroidPath
-        }
-    }
-}
-
-// Download bullet if not available
-task downloadBullet(type: MyDownload) {
-    sourceUrl = bulletUrl
-    target = file(localZipFile)
-}
-
-// Unzip bullet if not available
-task unzipBullet(type: Copy) {
-    from zipTree(localZipFile)
-    into file(localUnzipPath)
-}
-
-unzipBullet.dependsOn {
-    if (!file(localZipFile).exists()) {
-        downloadBullet
-    }
-}
-
-// Copy Bullet files to jni directory
-task copyBullet(type: Copy) {
-    from file(bulletSrcPath)
-    into file(jniPath)
-}
-
-copyBullet.dependsOn {
-    if (!file(localZipFolder).isDirectory()) {
-        unzipBullet
-    }
-}
-
-// Copy jME cpp native files to jni directory
-task copyJmeCpp(type: Copy) {
-    from file(jmeCppPath)
-    into file(jniPath)
-}
-
-// Copy jME android native files to jni directory
-task copyJmeAndroid(type: Copy) {
-    from file(jmeAndroidPath)
-    into file(jniPath)
-}
-
-task buildBulletNativeLib(type: Exec, dependsOn: [copyJmeAndroid, ':jme3-bullet:compileJava', copyJmeCpp, copyBullet]) {
-//    args 'TARGET_PLATFORM=android-9'
-//    println "buildBulletNativeLib ndkWorkingPath: " + ndkWorkingPath
-//    println "buildBulletNativeLib rootProject.ndkCommandPath: " + rootProject.ndkCommandPath
-    workingDir ndkWorkingPath
-    executable rootProject.ndkCommandPath
-    args "-j" + Runtime.runtime.availableProcessors()
-}
-
-/* The following two tasks: We store a prebuilt version in the repository, so nobody has to build
- * natives in order to build the engine. When building these natives however, the prebuilt libraries
- * can be updated (which is what the CI does). That's what the following two tasks do
- */
-
-task updatePreCompiledBulletLibs(type: Copy, dependsOn: buildBulletNativeLib) {
-    from file(ndkOutputPath)
-    into file(bulletPreCompiledLibsDir)
-}
-
-// Copy pre-compiled libs to build directory (when not building new libs)
-task copyPreCompiledBulletLibs(type: Copy) {
-    from file(bulletPreCompiledLibsDir)
-    into file(ndkOutputPath)
-}
-
-// ndkExists is a boolean from the build.gradle in the root project
-// buildNativeProjects is a string set to "true"
-if (ndkExists && buildNativeProjects == "true") {
-    // build native libs and update stored pre-compiled libs to commit
-    compileJava.dependsOn { updatePreCompiledBulletLibs }
-} else {
-    // use pre-compiled native libs (not building new ones)
-    compileJava.dependsOn { copyPreCompiledBulletLibs }
-}
-
-jar.into("lib") { from ndkOutputPath }
-
-
-// Helper class to wrap ant download task
-class MyDownload extends DefaultTask {
-    @Input
-    String sourceUrl
-
-    @OutputFile
-    File target
-
-    @TaskAction
-    void download() {
-       ant.get(src: sourceUrl, dest: target)
-    }
-}
-

+ 0 - 276
jme3-bullet-native/build.gradle

@@ -1,276 +0,0 @@
-apply plugin: 'cpp'
-
-import java.nio.file.Paths
-
-def rootPath = rootProject.projectDir.absolutePath
-
-String bulletSrcPath = bulletFolder + '/src'
-
-if (!hasProperty('mainClass')) {
-    ext.mainClass = ''
-}
-
-dependencies {
-    compile project(':jme3-bullet')
-}
-clean { dependsOn 'cleanHeaders', 'cleanUnzipped' }
-
-// clean up auto-generated C++ headers
-task cleanHeaders(type: Delete) {
-    delete fileTree(dir: 'src/native/cpp', include: 'com_jme3_bullet_*.h')
-}
-// clean up unzipped files
-task cleanUnzipped(type: Delete) {
-    delete bulletFolder
-}
-// clean up the downloaded archive
-task cleanZipFile(type: Delete) {
-    delete bulletZipFile
-}
-
-model {
-    components {
-        bulletjme(NativeLibrarySpec) {
-
-
-            String[] targets=[
-                "Windows64",
-                "Windows32",
-                "Mac64",
-                "Linux64",
-                "Linux32",
-                "LinuxArm",
-                "LinuxArmHF",
-                "LinuxArm64"    
-            ];
-          
-            String[] filter=gradle.rootProject.ext.usePrebuildNatives==true?null:buildForPlatforms.split(",");
-            if(filter==null)println("No filter set. build for all");
-            for(String target:targets){
-                if(filter==null){
-                    targetPlatform(target);
-                }else{
-                    for(String f:filter){
-                        if(f.equals(target)){
-                            targetPlatform(target);
-                            break;
-                        }
-                    }
-                }
-            }
-
-            sources {
-                cpp {
-                    source {
-                        srcDir 'src/native/cpp'
-                        srcDir bulletSrcPath
-                        exclude 'Bullet3Collision/**'
-                        exclude 'Bullet3Dynamics/**'
-                        exclude 'Bullet3Geometry/**'
-                        exclude 'Bullet3OpenCL/**'
-                        exclude 'Bullet3Serialize/**'
-                        include '**/*.cpp'
-                        exclude '**/*All.cpp'
-                    }
-                    exportedHeaders {
-                        srcDir 'src/native/cpp'
-                        srcDir bulletSrcPath
-                        exclude 'Bullet3Collision/**'
-                        exclude 'Bullet3Dynamics/**'
-                        exclude 'Bullet3Geometry/**'
-                        exclude 'Bullet3OpenCL/**'
-                        exclude 'Bullet3Serialize/**'
-                        include '**/*.h'
-                    }
-                }
-            }
-        }
-    }
-
-     
-    toolChains {
-        visualCpp(VisualCpp)
-        gcc(Gcc)
-        clang(Clang)
-        gccArm(Gcc) {
-            // Fun Fact: Gradle uses gcc as linker frontend, so we don't specify ld directly here
-            target("LinuxArm"){
-                path "/usr/bin"
-                cCompiler.executable = "arm-linux-gnueabi-gcc-8"
-                cppCompiler.executable = "arm-linux-gnueabi-g++-8"
-                linker.executable = "arm-linux-gnueabi-gcc-8"
-                assembler.executable = "arm-linux-gnueabi-as"
-            }
-
-            target("LinuxArmHF"){
-                path "/usr/bin"
-                cCompiler.executable = "arm-linux-gnueabihf-gcc-8"
-                cppCompiler.executable = "arm-linux-gnueabihf-g++-8"
-                linker.executable = "arm-linux-gnueabihf-gcc-8"
-                assembler.executable = "arm-linux-gnueabihf-as"
-            }
-
-            target("LinuxArm64"){
-                path "/usr/bin"
-                cCompiler.executable = "aarch64-linux-gnu-gcc-8"
-                cppCompiler.executable = "aarch64-linux-gnu-g++-8"
-                linker.executable = "aarch64-linux-gnu-gcc-8"
-                assembler.executable = "aarch64-linux-gnu-as"
-            }
-        }  
-    }
-
-    binaries {
-        withType(SharedLibraryBinarySpec) {
-            def javaHome = org.gradle.internal.jvm.Jvm.current().javaHome
-            def os = targetPlatform.operatingSystem.name
-            def arch = targetPlatform.architecture.name
-            def fileName = sharedLibraryFile.name
-
-            // Gradle decided to change underscores to dashes - fix that.
-            arch = arch.replaceAll('-', '_')
-
-            // For all binaries that can't be built on the current system
-            if (buildNativeProjects != "true")  buildable = false
-
-            if (buildable) {            
-                cppCompiler.define('BT_NO_PROFILE')
-                if (toolChain in VisualCpp) {
-                    cppCompiler.args "/I$javaHome\\include"
-                } else{
-                    cppCompiler.args '-I', "$javaHome/include"
-                }
-
-                if (os == "osx") {
-                    cppCompiler.args '-I', "$javaHome/include/darwin"
-                    cppCompiler.args "-O3"
-                    cppCompiler.args "-U_FORTIFY_SOURCE"
-                } else if (os == "linux") {
-                    cppCompiler.args "-fvisibility=hidden"
-                    cppCompiler.args '-I', "$javaHome/include/linux"
-                    cppCompiler.args "-fPIC"
-                    cppCompiler.args "-O3"
-                    cppCompiler.args "-U_FORTIFY_SOURCE"
-                    cppCompiler.args "-fpermissive"
-                    linker.args "-fvisibility=hidden"
-                } else if (os == "windows") {
-                    if (toolChain in Gcc) {
-                        if (toolChain.name.startsWith('mingw'))  cppCompiler.args '-I', "$projectDir/src/native/cpp/fake_win32"
-                        else  cppCompiler.args '-I', "$javaHome/include/win32"                        
-                        cppCompiler.args "-fpermissive"
-                        cppCompiler.args "-static"
-                        cppCompiler.args "-O3"
-                        cppCompiler.args "-U_FORTIFY_SOURCE"
-                        linker.args "-static"
-                        linker.args "-Wl,--exclude-all-symbols"
-                    } else if (toolChain in VisualCpp) {
-                        cppCompiler.args "/I$javaHome\\include\\win32"
-                    }
-                    cppCompiler.define('WIN32')
-                }
-                tasks.all { 
-                    dependsOn unzipBulletIfNeeded
-                    dependsOn ':jme3-bullet:compileJava'
-                }
-
-                task "copyBinaryToLibs${targetPlatform.name}"(type: Copy, dependsOn: tasks) {
-                    from sharedLibraryFile
-                    into "${rootPath}/build/native/bullet/native/${os}/${arch}"
-                } 
-
-                // Add depend on copy
-                jar.dependsOn("copyBinaryToLibs${targetPlatform.name}")
-
-            }
-        }
-        withType(StaticLibraryBinarySpec) {
-            buildable = false
-        }
-    }
-
-    platforms {
-        Windows32 {
-            architecture "x86"
-            operatingSystem "windows"
-        }
-        Windows64 {
-            architecture "x86_64"
-            operatingSystem "windows"
-        }
-        Mac64 {
-            architecture "x86_64"
-            operatingSystem "osx"
-        }
-        Linux32 {
-            architecture "x86"
-            operatingSystem "linux"
-        }
-        Linux64 {
-            architecture "x86_64"
-            operatingSystem "linux"
-        }
-        LinuxArm {
-            architecture "arm"
-            operatingSystem "linux"
-        }
-        LinuxArmHF {
-            architecture "armhf"
-            operatingSystem "linux"        
-        }
-        LinuxArm64 {
-            architecture "aarch64"
-            operatingSystem "linux"
-        }
-    }
-}
-
-// Java source sets for IDE access and source jar bundling / mavenization
-sourceSets {
-    main {
-        java {
-            srcDir 'src/native/cpp'
-        }
-        resources {
-            srcDir file(Paths.get(rootPath, 'build', 'native', 'bullet'))
-        }
-    }
-}
-
-task downloadBullet(type: MyDownload) {
-    sourceUrl = bulletUrl
-    target = file(bulletZipFile)
-}
-
-task unzipBullet(type: Copy) {
-    from zipTree(bulletZipFile)
-    into file('.')
-}
-
-unzipBullet.dependsOn {
-    if (!file(bulletZipFile).exists()) {
-        downloadBullet
-    }
-}
-
-task unzipBulletIfNeeded {
-}
-
-unzipBulletIfNeeded.dependsOn {
-    if (buildNativeProjects == "true") {
-        unzipBullet
-    }
-}
-
-// Helper class to wrap ant download task
-class MyDownload extends DefaultTask {
-    @Input
-    String sourceUrl
-
-    @OutputFile
-    File target
-
-    @TaskAction
-    void download() {
-        ant.get(src: sourceUrl, dest: target)
-    }
-}

+ 0 - 27
jme3-bullet/build.gradle

@@ -1,27 +0,0 @@
-apply plugin: 'java'
-
-if (!hasProperty('mainClass')) {
-    ext.mainClass = ''
-}
-
-String classBuildDir = "${buildDir}" + File.separator + 'classes'
-def nativeIncludes = new File(project(":jme3-bullet-native").projectDir, "src/native/cpp")
-
-sourceSets {
-    main {
-        java {
-            srcDir 'src/main/java'
-            srcDir 'src/common/java'
-        }
-    }
-}
-
-dependencies {
-    compile project(':jme3-core')
-    compile project(':jme3-terrain')
-}
-
-compileJava {
-    // The Android-Native Project requires the jni headers to be generated, so we do that here
-    options.compilerArgs += ["-h", nativeIncludes]
-}

+ 0 - 3
settings.gradle

@@ -26,9 +26,6 @@ include 'jme3-android'
 include 'jme3-ios'
 
 //native builds
-include 'jme3-bullet' //java
-include 'jme3-bullet-native' //cpp
-include 'jme3-bullet-native-android' //cpp
 include 'jme3-android-native' //cpp
 
 // Test Data project