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

This commit is contained in:
Riccardo Balbo 2019-09-20 14:43:45 +02:00 committed by Riccardo Balbo
parent 8a6bd1947c
commit 88e9c8482c
34 changed files with 98 additions and 23 deletions

12
.gitignore vendored
View File

@ -34,12 +34,6 @@
/jme3-android-native/src/native/jme_decode/STBI/ /jme3-android-native/src/native/jme_decode/STBI/
/jme3-android-native/src/native/jme_decode/Tremor/ /jme3-android-native/src/native/jme_decode/Tremor/
/jme3-android-native/stb_image.h /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-examples/private/
!/jme3-vr/src/main/resources/**/*.dylib !/jme3-vr/src/main/resources/**/*.dylib
!/jme3-vr/src/main/resources/**/*.so !/jme3-vr/src/main/resources/**/*.so
@ -47,4 +41,8 @@
!/jme3-vr/src/main/resources/**/*.dll !/jme3-vr/src/main/resources/**/*.dll
!/jme3-vr/src/main/resources/**/*.pdb !/jme3-vr/src/main/resources/**/*.pdb
/buildMaven.bat /buildMaven.bat
/private
.travis.yml
appveyor.yml
javadoc_deploy
javadoc_deploy.pub

View File

@ -1,3 +1,6 @@
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
buildscript { buildscript {
repositories { repositories {
google() 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 { //class IncrementalReverseTask extends DefaultTask {
// @InputDirectory // @InputDirectory
// def File inputDir // def File inputDir

View File

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

View File

@ -8,7 +8,8 @@ String decodeBuildJniDir = decodeBuildDir + File.separator + 'jni'
String decodeBuildLibsDir = decodeBuildDir + File.separator + 'libs' String decodeBuildLibsDir = decodeBuildDir + File.separator + 'libs'
// Pre-compiled libs directory // 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 // jME Android Native source files path
String decodeSourceDir = 'src/native/jme_decode' String decodeSourceDir = 'src/native/jme_decode'

View File

@ -14,7 +14,8 @@ String openalsoftBuildJniDir = openalsoftBuildDir + File.separator + 'jni'
String openalsoftBuildLibsDir = openalsoftBuildDir + File.separator + 'libs' String openalsoftBuildLibsDir = openalsoftBuildDir + File.separator + 'libs'
//Pre-compiled libs directory //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 // jME Android Native source files path
String openalsoftJmeAndroidPath = 'src/native/jme_openalsoft' String openalsoftJmeAndroidPath = 'src/native/jme_openalsoft'

View File

@ -14,7 +14,8 @@ String jniPath = ndkWorkingPath + '/jni'
String ndkOutputPath = ndkWorkingPath + '/libs' String ndkOutputPath = ndkWorkingPath + '/libs'
//Pre-compiled libs directory //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')) { if (!hasProperty('mainClass')) {
ext.mainClass = '' ext.mainClass = ''

View File

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