2018-05-25 13:08:05 -04:00
|
|
|
import org.gradle.internal.jvm.Jvm
|
|
|
|
|
|
|
|
|
|
|
|
plugins {
|
2018-05-26 01:22:41 -04:00
|
|
|
id 'base'
|
2019-09-23 14:13:03 -04:00
|
|
|
id 'cpp-library'
|
2018-05-25 13:08:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
description = 'Master Password Algorithm Implementation'
|
|
|
|
|
2018-05-27 23:43:35 -04:00
|
|
|
artifacts {
|
2018-06-30 12:35:40 -04:00
|
|
|
'default' task( type: Zip, 'archive' ) {
|
|
|
|
// TODO: exclude lib files that are produced by the build.
|
|
|
|
from 'lib'
|
|
|
|
|
2018-05-27 23:43:35 -04:00
|
|
|
components.withType( ComponentWithRuntimeFile ) {
|
2018-07-18 15:46:06 -04:00
|
|
|
if (optimized)
|
2018-06-30 12:35:40 -04:00
|
|
|
from runtimeFile, {
|
2019-09-23 14:13:03 -04:00
|
|
|
into targetMachine.getOperatingSystemFamily().getName() + '/' + targetMachine.getArchitecture().getName()
|
2018-06-30 12:35:40 -04:00
|
|
|
}
|
2018-05-26 01:22:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-25 13:08:05 -04:00
|
|
|
library {
|
2018-06-30 12:35:40 -04:00
|
|
|
baseName.set( 'mpw' )
|
2018-06-30 11:56:33 -04:00
|
|
|
linkage.set( [Linkage.SHARED] )
|
2019-09-23 14:13:03 -04:00
|
|
|
source.from fileTree( 'src' )
|
2018-05-25 13:08:05 -04:00
|
|
|
|
2018-05-26 01:22:41 -04:00
|
|
|
// Reconfigure the toolchain from C++ to C.
|
|
|
|
toolChains {
|
2018-06-24 16:20:42 -04:00
|
|
|
withType( VisualCpp ) {
|
|
|
|
eachPlatform {
|
2019-09-24 17:46:33 -04:00
|
|
|
cppCompiler.withArguments { addAll( ['/TC', '/MT', '/Ox', '/DMPW_SODIUM=1', '/DSODIUM_STATIC', '/DSODIUM_EXPORT=', '/DMPW_LOG=mpw_log_app'] ) }
|
2018-06-24 16:20:42 -04:00
|
|
|
}
|
|
|
|
}
|
2018-05-26 01:22:41 -04:00
|
|
|
withType( GccCompatibleToolChain ) {
|
|
|
|
eachPlatform {
|
2019-09-24 17:46:33 -04:00
|
|
|
cppCompiler.withArguments { addAll( ['-x', 'c', '-O3', '-Werror', '-DMPW_SODIUM=1', '-DMPW_LOG=mpw_log_app'] ) }
|
2018-05-26 01:22:41 -04:00
|
|
|
}
|
2018-05-25 13:08:05 -04:00
|
|
|
}
|
2018-05-26 01:22:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cross-compile for these host platforms.
|
2018-06-10 19:11:22 -04:00
|
|
|
// TODO: Cross-compiling, blocked by: https://github.com/gradle/gradle-native/issues/169 - CppLibraryPlugin.java:163
|
2019-09-23 14:13:03 -04:00
|
|
|
// operatingSystems.set( [objects.named( OperatingSystemFamily, OperatingSystemFamily.LINUX ),
|
|
|
|
// objects.named( OperatingSystemFamily, OperatingSystemFamily.MAC_OS ),
|
|
|
|
// objects.named( OperatingSystemFamily, OperatingSystemFamily.WINDOWS )] )
|
|
|
|
targetMachines.set( [
|
|
|
|
machines.linux.x86_64,
|
|
|
|
machines.windows.x86, machines.windows.x86_64,
|
|
|
|
machines.macOS.x86_64
|
|
|
|
] )
|
2018-06-27 02:54:31 -04:00
|
|
|
|
2018-06-30 11:56:33 -04:00
|
|
|
components.withType( CppComponent ) {
|
2019-09-23 14:13:03 -04:00
|
|
|
// JDK for JNI support.
|
|
|
|
privateHeaders.from files( new File( Jvm.current().javaHome, 'include' ) ) { first().eachDir { from it } }
|
2018-05-25 13:08:05 -04:00
|
|
|
|
2018-07-18 15:46:06 -04:00
|
|
|
binaries.whenElementFinalized {
|
2018-06-30 11:56:33 -04:00
|
|
|
project.dependencies {
|
2019-09-23 14:13:03 -04:00
|
|
|
def system = targetMachine.getOperatingSystemFamily().getName()
|
2018-06-30 11:56:33 -04:00
|
|
|
|
2018-07-18 15:46:06 -04:00
|
|
|
// libsodium
|
|
|
|
archive.dependsOn project.tasks.maybeCreate( "build_libsodium-${system}", Exec ).configure {
|
2019-09-23 14:13:03 -04:00
|
|
|
commandLine 'bash', "$rootDir/lib/bin/build_libsodium-${system}"
|
|
|
|
privateHeaders.from "$rootDir/lib/libsodium/build-${system}~/out/include"
|
|
|
|
add( linkLibraries.name, fileTree( "$rootDir/lib/libsodium/build-${system}~/out/lib" ) )
|
2018-07-18 15:46:06 -04:00
|
|
|
}
|
|
|
|
clean.dependsOn project.tasks.maybeCreate( "clean_libsodium-${system}", Exec ).configure {
|
2019-09-23 14:13:03 -04:00
|
|
|
commandLine 'bash', "$rootDir/lib/bin/build_libsodium-${system}", 'clean'
|
2018-07-18 15:46:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// libjson-c
|
2018-08-02 01:32:55 -04:00
|
|
|
/*archive.dependsOn project.tasks.maybeCreate( "build_libjson-c-${system}", Exec ).configure {
|
2019-09-23 14:13:03 -04:00
|
|
|
commandLine 'bash', "$rootDir/lib/bin/build_libjson-c-${system}"
|
|
|
|
privateHeaders.from "$rootDir/lib/libjson-c/build-${system}~/out/include"
|
|
|
|
add( linkLibraries.name, fileTree( "$rootDir/lib/libjson-c/build-${system}~/out/lib" ) )
|
2018-07-18 15:46:06 -04:00
|
|
|
}
|
|
|
|
clean.dependsOn project.tasks.maybeCreate( "clean_libjson-c-${system}", Exec ).configure {
|
2019-09-23 14:13:03 -04:00
|
|
|
commandLine 'bash', "$rootDir/lib/bin/build_libjson-c-${system}", 'clean'
|
2018-08-02 01:32:55 -04:00
|
|
|
}*/
|
2018-07-01 21:20:56 -04:00
|
|
|
}
|
2018-06-30 11:56:33 -04:00
|
|
|
}
|
2018-05-26 01:22:41 -04:00
|
|
|
}
|
|
|
|
}
|