86 lines
3.4 KiB
Groovy
86 lines
3.4 KiB
Groovy
import org.gradle.internal.jvm.Jvm
|
|
|
|
|
|
plugins {
|
|
id 'base'
|
|
id 'cpp-library'
|
|
}
|
|
|
|
description = 'Master Password Algorithm Implementation'
|
|
|
|
artifacts {
|
|
'default' task( type: Zip, 'archive' ) {
|
|
// TODO: exclude lib files that are produced by the build.
|
|
from 'lib'
|
|
|
|
components.withType( ComponentWithRuntimeFile ) {
|
|
if (optimized)
|
|
from runtimeFile, {
|
|
into targetMachine.getOperatingSystemFamily().getName() + '/' + targetMachine.getArchitecture().getName()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
library {
|
|
baseName.set( 'mpw' )
|
|
linkage.set( [Linkage.SHARED] )
|
|
source.from fileTree( '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='] ) }
|
|
}
|
|
}
|
|
withType( GccCompatibleToolChain ) {
|
|
eachPlatform {
|
|
cppCompiler.withArguments { addAll( ['-x', 'c', '-O3', '-Werror', '-DMPW_SODIUM=1'] ) }
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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 )] )
|
|
targetMachines.set( [
|
|
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 } }
|
|
|
|
binaries.whenElementFinalized {
|
|
project.dependencies {
|
|
def system = targetMachine.getOperatingSystemFamily().getName()
|
|
|
|
// libsodium
|
|
archive.dependsOn project.tasks.maybeCreate( "build_libsodium-${system}", Exec ).configure {
|
|
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" ) )
|
|
}
|
|
clean.dependsOn project.tasks.maybeCreate( "clean_libsodium-${system}", Exec ).configure {
|
|
commandLine 'bash', "$rootDir/lib/bin/build_libsodium-${system}", 'clean'
|
|
}
|
|
|
|
// libjson-c
|
|
/*archive.dependsOn project.tasks.maybeCreate( "build_libjson-c-${system}", Exec ).configure {
|
|
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" ) )
|
|
}
|
|
clean.dependsOn project.tasks.maybeCreate( "clean_libjson-c-${system}", Exec ).configure {
|
|
commandLine 'bash', "$rootDir/lib/bin/build_libjson-c-${system}", 'clean'
|
|
}*/
|
|
}
|
|
}
|
|
}
|
|
}
|