2
0

Fix gradle build.

This commit is contained in:
Maarten Billemont 2018-06-30 11:56:33 -04:00
parent 0dddcef28e
commit 86f4e8ec06
3 changed files with 36 additions and 27 deletions

View File

@ -1 +1,3 @@
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M

View File

@ -55,11 +55,13 @@ dependencies {
} }
preBuild { preBuild {
dependsOn task( type: Exec, 'buildLibSodium', { dependsOn task( type: Exec, 'build_libsodium-android', {
commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-android" commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-android"
environment 'ANDROID_NDK_HOME', android.ndkDirectory
} ) } )
dependsOn task( type: Exec, 'buildLibJson-c', { dependsOn task( type: Exec, 'build_libjson-c-android', {
commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-android" commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-android"
environment 'ANDROID_NDK_HOME', android.ndkDirectory
} ) } )
} }

View File

@ -21,7 +21,7 @@ artifacts {
library { library {
baseName.set( "mpw" ) baseName.set( "mpw" )
linkage.set( [ Linkage.SHARED ] ) linkage.set( [Linkage.SHARED] )
// Reconfigure the toolchain from C++ to C. // Reconfigure the toolchain from C++ to C.
toolChains { toolChains {
@ -36,47 +36,49 @@ library {
} }
} }
} }
components.withType( CppComponent ) {
cppSource.from fileTree( dir: "src", include: "**/*.c" )
}
// Cross-compile for these host platforms. // Cross-compile for these host platforms.
// TODO: Cross-compiling, blocked by: https://github.com/gradle/gradle-native/issues/169 - CppLibraryPlugin.java:163 // TODO: Cross-compiling, blocked by: https://github.com/gradle/gradle-native/issues/169 - CppLibraryPlugin.java:163
operatingSystems.set( [objects.named( OperatingSystemFamily, OperatingSystemFamily.WINDOWS ), operatingSystems.set( [objects.named( OperatingSystemFamily, OperatingSystemFamily.LINUX ),
objects.named( OperatingSystemFamily, OperatingSystemFamily.LINUX ), objects.named( OperatingSystemFamily, OperatingSystemFamily.MAC_OS ),
objects.named( OperatingSystemFamily, OperatingSystemFamily.MAC_OS )] ) objects.named( OperatingSystemFamily, OperatingSystemFamily.WINDOWS )] )
publicHeaders { components.withType( CppComponent ) {
// Depend on JDK for JNI support. cppSource.from fileTree( "src" )
privateHeaders {
// JDK for JNI support.
from files( new File( Jvm.current().javaHome, "include" ) ) { first().eachDir { from it } } from files( new File( Jvm.current().javaHome, "include" ) ) { first().eachDir { from it } }
publicHeaders.from files( "$rootDir/../lib/libsodium/src/libsodium/include" )
} }
binaries.configureEach { binaries.configureEach {
def system = standardOperatingSystem( targetPlatform ) def system = standardOperatingSystem( targetPlatform )
dependencies { project.dependencies {
implementation fileTree( "$rootDir/../lib/libsodium/build-${system}~/out/lib" ) add( linkLibraries.name,
fileTree( "../../../lib/libsodium/build-${system}~/out/lib" ) )
} }
if (project.tasks.findByName('build_libsodium') == null) archive.dependsOn project.tasks.maybeCreate( "build_libsodium-${system}", Exec.class ).configure {
archive.dependsOn task( type: Exec, 'build_libsodium', {
commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-${system}" commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-${system}"
} ) privateHeaders.from "$rootDir/../lib/libsodium/src/libsodium/include"
// if (project.tasks.findByName('build_libjson-c') == null) }
// archive.dependsOn task( type: Exec, 'build_libjson-c', { archive.dependsOn project.tasks.maybeCreate( "build_libjson-c-${system}", Exec.class ).configure {
// commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-${system}" commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-${system}"
// } ) privateHeaders.from "$rootDir/../lib/libjson-c/build-${system}~/out"
}
}
} }
} }
static String standardOperatingSystem(NativePlatform platform) { static String standardOperatingSystem(NativePlatform platform) {
OperatingSystem os = platform.getOperatingSystem() OperatingSystem os = platform.getOperatingSystem()
if (os.isWindows()) if (os.isWindows())
return OperatingSystemFamily.WINDOWS return OperatingSystemFamily.WINDOWS
else if (os.isMacOsX()) else if (os.isMacOsX())
return OperatingSystemFamily.MAC_OS return OperatingSystemFamily.MAC_OS
else if (os.isLinux()) else if (os.isLinux())
return OperatingSystemFamily.LINUX return OperatingSystemFamily.LINUX
@ -88,10 +90,13 @@ static String standardArchitecture(NativePlatform platform) {
Architecture arch = platform.getArchitecture() Architecture arch = platform.getArchitecture()
if (arch.isArm()) if (arch.isArm())
return "arm" return "arm"
else if (arch.name.toLowerCase( Locale.ROOT ).startsWith( "arm" )) else if (arch.name.toLowerCase( Locale.ROOT ).startsWith( "arm" ))
return "arm64" return "arm64"
else if (arch.isAmd64()) else if (arch.isAmd64())
return "x86_64" return "x86_64"
else if (arch.isI386()) else if (arch.isI386())
return "x86" return "x86"