Procházet zdrojové kódy

Store prebuild libraries outside the source folder, download prebuilt libraries from bintray

Riccardo Balbo před 6 roky
rodič
revize
88e9c8482c
34 změnil soubory, kde provedl 98 přidání a 23 odebrání
  1. 5 7
      .gitignore
  2. 66 0
      build.gradle
  3. 4 1
      gradle.properties
  4. 2 1
      jme3-android-native/decode.gradle
  5. binární
      jme3-android-native/libs/decode/arm64-v8a/libdecodejme.so
  6. binární
      jme3-android-native/libs/decode/armeabi-v7a/libdecodejme.so
  7. binární
      jme3-android-native/libs/decode/armeabi/libdecodejme.so
  8. binární
      jme3-android-native/libs/decode/mips/libdecodejme.so
  9. binární
      jme3-android-native/libs/decode/mips64/libdecodejme.so
  10. binární
      jme3-android-native/libs/decode/x86/libdecodejme.so
  11. binární
      jme3-android-native/libs/decode/x86_64/libdecodejme.so
  12. binární
      jme3-android-native/libs/openalsoft/arm64-v8a/libopenalsoftjme.so
  13. binární
      jme3-android-native/libs/openalsoft/armeabi-v7a/libopenalsoftjme.so
  14. binární
      jme3-android-native/libs/openalsoft/armeabi/libopenalsoftjme.so
  15. binární
      jme3-android-native/libs/openalsoft/mips/libopenalsoftjme.so
  16. binární
      jme3-android-native/libs/openalsoft/mips64/libopenalsoftjme.so
  17. binární
      jme3-android-native/libs/openalsoft/x86/libopenalsoftjme.so
  18. binární
      jme3-android-native/libs/openalsoft/x86_64/libopenalsoftjme.so
  19. 2 1
      jme3-android-native/openalsoft.gradle
  20. 2 1
      jme3-bullet-native-android/build.gradle
  21. binární
      jme3-bullet-native-android/libs/arm64-v8a/libbulletjme.so
  22. binární
      jme3-bullet-native-android/libs/armeabi-v7a/libbulletjme.so
  23. binární
      jme3-bullet-native-android/libs/armeabi/libbulletjme.so
  24. binární
      jme3-bullet-native-android/libs/mips/libbulletjme.so
  25. binární
      jme3-bullet-native-android/libs/mips64/libbulletjme.so
  26. binární
      jme3-bullet-native-android/libs/x86/libbulletjme.so
  27. binární
      jme3-bullet-native-android/libs/x86_64/libbulletjme.so
  28. 17 12
      jme3-bullet-native/build.gradle
  29. binární
      jme3-bullet-native/libs/native/linux/x86/libbulletjme.so
  30. binární
      jme3-bullet-native/libs/native/linux/x86_64/libbulletjme.so
  31. binární
      jme3-bullet-native/libs/native/osx/x86/libbulletjme.dylib
  32. binární
      jme3-bullet-native/libs/native/osx/x86_64/libbulletjme.dylib
  33. binární
      jme3-bullet-native/libs/native/windows/x86/bulletjme.dll
  34. binární
      jme3-bullet-native/libs/native/windows/x86_64/bulletjme.dll

+ 5 - 7
.gitignore

@@ -34,12 +34,6 @@
 /jme3-android-native/src/native/jme_decode/STBI/
 /jme3-android-native/src/native/jme_decode/Tremor/
 /jme3-android-native/stb_image.h
-!/jme3-bullet-native/libs/native/windows/x86_64/bulletjme.dll
-!/jme3-bullet-native/libs/native/windows/x86/bulletjme.dll
-!/jme3-bullet-native/libs/native/osx/x86/libbulletjme.dylib
-!/jme3-bullet-native/libs/native/osx/x86_64/libbulletjme.dylib
-!/jme3-bullet-native/libs/native/linux/x86/libbulletjme.so
-!/jme3-bullet-native/libs/native/linux/x86_64/libbulletjme.so
 /jme3-examples/private/
 !/jme3-vr/src/main/resources/**/*.dylib
 !/jme3-vr/src/main/resources/**/*.so
@@ -47,4 +41,8 @@
 !/jme3-vr/src/main/resources/**/*.dll
 !/jme3-vr/src/main/resources/**/*.pdb
 /buildMaven.bat
-
+/private
+.travis.yml
+appveyor.yml
+javadoc_deploy
+javadoc_deploy.pub

+ 66 - 0
build.gradle

@@ -1,3 +1,6 @@
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+
 buildscript {
     repositories {
         google()
@@ -146,6 +149,69 @@ task configureAndroidNDK {
     }
 }
 
+gradle.rootProject.ext.set("usePrebuildNatives", buildNativeProjects!="true");
+
+if(skipPrebuildLibraries!="true"&&buildNativeProjects!="true"){
+    String rootPath = rootProject.projectDir.absolutePath
+
+    Properties nativesSnasphotProp = new Properties()
+    File nativesSnasphotPropF=new File("${rootPath}/natives-snapshot.properties");
+    
+    if(nativesSnasphotPropF.exists()){
+
+        nativesSnasphotPropF.withInputStream { nativesSnasphotProp.load(it) }
+
+        String nativesSnasphot=nativesSnasphotProp.getProperty("natives.snapshot");
+        String nativesUrl=PREBUILD_NATIVES_URL.replace('${natives.snapshot}',nativesSnasphot)
+        println "Use natives snapshot: "+nativesUrl
+
+        String nativesZipFile="${rootPath}" + File.separator + "build"+ File.separator +nativesSnasphot+"-natives.zip"
+        String nativesPath="${rootPath}" + File.separator + "build"+ File.separator +"native"
+
+        build.dependsOn('getPrebuiltNatives')
+
+        task getPrebuiltNatives() { 
+            doFirst {
+                File target = file(nativesZipFile);
+                    
+                if (!target.exists()) {    
+                    println("Download natives from "+nativesUrl+" to "+nativesZipFile);
+                    target.getParentFile().mkdirs();
+                    ant.get(src: nativesUrl, dest: target);
+                }
+
+                for(File src : zipTree(nativesZipFile)){
+                    String srcRel=src.getAbsolutePath().substring((int)(nativesZipFile.length()+1));
+                    srcRel=srcRel.substring(srcRel.indexOf("/")+1);
+
+                    File dest=new File(nativesPath+File.separator+srcRel);
+
+                    boolean include=false;
+                    if(!dest.exists()){
+                        include=true;
+                        println("Copy "+src+" "+dest+  ". Destination does not exist");
+                    }else if(dest.lastModified()<src.lastModified()){
+                        include=true;
+                        println("Copy "+src+" "+dest+  ". Source is newer. src "+src.lastModified()+ " dest "+dest.lastModified());
+                    }
+                    else{
+                        println(""+dest+" Up to date. Skip.");
+                    }
+
+                    if(include){
+                        dest.getParentFile().mkdirs();
+                        Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
+                    }
+                }
+            }
+        }
+    }
+}
+
+
+
+
+
 //class IncrementalReverseTask extends DefaultTask {
 //    @InputDirectory
 //    def File inputDir

+ 4 - 1
gradle.properties

@@ -15,7 +15,8 @@ buildNativeProjects = false
 buildAndroidExamples = false
 
 buildForPlatforms = Linux64,Linux32,Windows64,Windows32,Mac64,Mac32
-
+# Forcefully ignore prebuilt libraries
+skipPrebuildLibraries=false
 # Path to android NDK for building native libraries
 #ndkPath=/Users/normenhansen/Documents/Code-Import/android-ndk-r7
 ndkPath = /opt/android-ndk-r16b
@@ -40,3 +41,5 @@ POM_INCEPTION_YEAR=2009
 # Bintray settings to override in $HOME/.gradle/gradle.properties or ENV or commandline
 bintray_user=
 bintray_api_key=
+
+PREBUILD_NATIVES_URL=https://dl.bintray.com/riccardoblsandbox/jmonkeyengine-files/${natives.snapshot}/jme3-natives.zip

+ 2 - 1
jme3-android-native/decode.gradle

@@ -8,7 +8,8 @@ String decodeBuildJniDir = decodeBuildDir + File.separator + 'jni'
 String decodeBuildLibsDir = decodeBuildDir + File.separator + 'libs'
 
 // Pre-compiled libs directory
-String decodePreCompiledLibsDir = 'libs' + File.separator + 'decode'
+def rootPath = rootProject.projectDir.absolutePath
+String decodePreCompiledLibsDir = rootPath + File.separator + 'build' + File.separator + 'native' + File.separator +  'android' + File.separator + 'decode'
 
 // jME Android Native source files path
 String decodeSourceDir = 'src/native/jme_decode'

binární
jme3-android-native/libs/decode/arm64-v8a/libdecodejme.so


binární
jme3-android-native/libs/decode/armeabi-v7a/libdecodejme.so


binární
jme3-android-native/libs/decode/armeabi/libdecodejme.so


binární
jme3-android-native/libs/decode/mips/libdecodejme.so


binární
jme3-android-native/libs/decode/mips64/libdecodejme.so


binární
jme3-android-native/libs/decode/x86/libdecodejme.so


binární
jme3-android-native/libs/decode/x86_64/libdecodejme.so


binární
jme3-android-native/libs/openalsoft/arm64-v8a/libopenalsoftjme.so


binární
jme3-android-native/libs/openalsoft/armeabi-v7a/libopenalsoftjme.so


binární
jme3-android-native/libs/openalsoft/armeabi/libopenalsoftjme.so


binární
jme3-android-native/libs/openalsoft/mips/libopenalsoftjme.so


binární
jme3-android-native/libs/openalsoft/mips64/libopenalsoftjme.so


binární
jme3-android-native/libs/openalsoft/x86/libopenalsoftjme.so


binární
jme3-android-native/libs/openalsoft/x86_64/libopenalsoftjme.so


+ 2 - 1
jme3-android-native/openalsoft.gradle

@@ -14,7 +14,8 @@ String openalsoftBuildJniDir = openalsoftBuildDir + File.separator + 'jni'
 String openalsoftBuildLibsDir = openalsoftBuildDir + File.separator + 'libs'
 
 //Pre-compiled libs directory
-String openalsoftPreCompiledLibsDir = 'libs' + File.separator + 'openalsoft'
+def rootPath = rootProject.projectDir.absolutePath
+String openalsoftPreCompiledLibsDir = rootPath + File.separator + 'build' + File.separator + 'native' + File.separator +  'android' + File.separator + 'openalsoft'
 
 // jME Android Native source files path
 String openalsoftJmeAndroidPath = 'src/native/jme_openalsoft'

+ 2 - 1
jme3-bullet-native-android/build.gradle

@@ -14,7 +14,8 @@ String jniPath = ndkWorkingPath + '/jni'
 String ndkOutputPath = ndkWorkingPath + '/libs'
 
 //Pre-compiled libs directory
-String bulletPreCompiledLibsDir = 'libs'
+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 = ''

binární
jme3-bullet-native-android/libs/arm64-v8a/libbulletjme.so


binární
jme3-bullet-native-android/libs/armeabi-v7a/libbulletjme.so


binární
jme3-bullet-native-android/libs/armeabi/libbulletjme.so


binární
jme3-bullet-native-android/libs/mips/libbulletjme.so


binární
jme3-bullet-native-android/libs/mips64/libbulletjme.so


binární
jme3-bullet-native-android/libs/x86/libbulletjme.so


binární
jme3-bullet-native-android/libs/x86_64/libbulletjme.so


+ 17 - 12
jme3-bullet-native/build.gradle

@@ -43,12 +43,17 @@ model {
                 "LinuxArm64"    
             ];
           
-            String[] filter=buildForPlatforms.split(",");
+            String[] filter=gradle.rootProject.ext.usePrebuildNatives==true?null:buildForPlatforms.split(",");
+            if(filter==null)println("No filter set. build for all");
             for(String target:targets){
-                for(String f:filter){
-                    if(f.equals(target)){
-                        targetPlatform(target);
-                        break;
+                if(filter==null){
+                    targetPlatform(target);
+                }else{
+                    for(String f:filter){
+                        if(f.equals(target)){
+                            targetPlatform(target);
+                            break;
+                        }
                     }
                 }
             }
@@ -79,8 +84,8 @@ model {
             }
         }
     }
-    
-   
+
+     
     toolChains {
         visualCpp(VisualCpp)
         gcc(Gcc)
@@ -110,12 +115,12 @@ model {
                 linker.executable = "aarch64-linux-gnu-gcc-8"
                 assembler.executable = "aarch64-linux-gnu-as"
             }
-        }
+        }  
     }
 
     binaries {
         withType(SharedLibraryBinarySpec) {
-            def projectPath = project.projectDir.absolutePath
+            def rootPath = rootProject.projectDir.absolutePath
             def javaHome = org.gradle.internal.jvm.Jvm.current().javaHome
             def os = targetPlatform.operatingSystem.name
             def arch = targetPlatform.architecture.name
@@ -139,7 +144,7 @@ model {
                     }
                 } else {
                     // Get from libs folder if no fresh build is available in the build folder and add to jar file
-                    def precompiledFile = Paths.get(projectPath, 'libs', 'native', os, arch, fileName).toFile()
+                    def precompiledFile = Paths.get(rootPath, 'build', 'native', 'bullet', os, arch, fileName).toFile()
                     if (precompiledFile.exists()) {
                         jar.into("native/${os}/${arch}") {
                             from precompiledFile
@@ -203,8 +208,8 @@ model {
             // Add output to libs folder
             task "copyBinaryToLibs${targetPlatform.name}"(type: Copy, dependsOn: tasks) {
                 from sharedLibraryFile
-                into "libs/native/${os}/${arch}"
-            }
+                into "${rootPath}/build/native/bullet/${os}/${arch}"
+            } 
             // Add depend on copy
             jar.dependsOn("copyBinaryToLibs${targetPlatform.name}")
         }

binární
jme3-bullet-native/libs/native/linux/x86/libbulletjme.so


binární
jme3-bullet-native/libs/native/linux/x86_64/libbulletjme.so


binární
jme3-bullet-native/libs/native/osx/x86/libbulletjme.dylib


binární
jme3-bullet-native/libs/native/osx/x86_64/libbulletjme.dylib


binární
jme3-bullet-native/libs/native/windows/x86/bulletjme.dll


binární
jme3-bullet-native/libs/native/windows/x86_64/bulletjme.dll