2
0

Linux build fixes.

This commit is contained in:
Maarten Billemont
2019-09-25 15:27:04 -04:00
parent bf5e30c2c7
commit 87913326a5
4 changed files with 38 additions and 33 deletions

View File

@@ -25,37 +25,36 @@ artifacts {
library {
baseName.set( 'mpw' )
linkage.set( [Linkage.SHARED] )
source.from fileTree( 'src' )
source.from files( 'src' )
// Reconfigure the toolchain from C++ to C.
toolChains {
withType( VisualCpp ) {
eachPlatform {
cppCompiler.withArguments { addAll( ['/TC', '/MT', '/Ox', '/DMPW_SODIUM=1', '/DSODIUM_STATIC', '/DSODIUM_EXPORT=', '/DMPW_LOG=mpw_log_app'] ) }
}
}
withType( GccCompatibleToolChain ) {
eachPlatform {
cppCompiler.withArguments { addAll( ['-x', 'c', '-O3', '-Werror', '-DMPW_SODIUM=1', '-DMPW_LOG=mpw_log_app'] ) }
}
}
}
// JDK for JNI support.
privateHeaders.from files( new File( Jvm.current().javaHome, 'include' ) ) { first().eachDir { from it } }
// Cross-compile for these host platforms.
// TODO: Cross-compiling, blocked by: https://github.com/gradle/gradle-native/issues/169 - CppLibraryPlugin.java:163
// operatingSystems.set( [objects.named( OperatingSystemFamily, OperatingSystemFamily.LINUX ),
// objects.named( OperatingSystemFamily, OperatingSystemFamily.MAC_OS ),
// objects.named( OperatingSystemFamily, OperatingSystemFamily.WINDOWS )] )
// Cross-compile for these target platforms.
// TODO: Cross-compiling, blocked by: https://github.com/gradle/gradle-native/issues/1031
targetMachines.set( [
machines.linux.x86_64,
machines.linux.x86, machines.linux.x86_64,
machines.windows.x86, machines.windows.x86_64,
machines.macOS.x86_64
] )
components.withType( CppComponent ) {
// JDK for JNI support.
privateHeaders.from files( new File( Jvm.current().javaHome, 'include' ) ) { first().eachDir { from it } }
tasks.withType(CppCompile).configureEach {
// Define a preprocessor macro for every binary
macros.put("MPW_SODIUM", "1")
macros.put("MPW_LOG", "mpw_log_app")
// Reconfigure the toolchain from C++ to C.
compilerArgs.addAll toolChain.map { toolChain ->
if (toolChain in GccCompatibleToolChain) {
return ['-x', 'c', '-O3', '-Werror']
} else if (toolChain in VisualCpp) {
return ['/TC', '/MT', '/Ox', '/DSODIUM_STATIC', '/DSODIUM_EXPORT=']
}
return []
}
}
components.withType( CppComponent ) {
binaries.whenElementFinalized {
project.dependencies {
def system = targetMachine.getOperatingSystemFamily().getName()