From b25130f4d293537fdefb8d09eac81741ebb4b906 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Tue, 3 Jul 2018 11:21:48 -0400 Subject: [PATCH] Tweak include paths & add clean support to android libs. --- platform-android/CMakeLists.txt | 4 ++-- platform-android/build.gradle | 14 ++++++++++++-- platform-independent/c/core/build.gradle | 14 +++++++------- platform-independent/java/algorithm/build.gradle | 9 +++++---- platform-independent/java/model/build.gradle | 1 + platform-independent/java/tests/build.gradle | 4 +--- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/platform-android/CMakeLists.txt b/platform-android/CMakeLists.txt index 87dcea9b..abdd7dcd 100644 --- a/platform-android/CMakeLists.txt +++ b/platform-android/CMakeLists.txt @@ -13,12 +13,12 @@ add_library( mpw SHARED add_library( sodium SHARED IMPORTED ) set_target_properties( sodium PROPERTIES IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../lib/libsodium/build-android~/out/lib/${ANDROID_ABI}/libsodium.so" ) -target_include_directories( mpw PRIVATE "${PROJECT_SOURCE_DIR}/../lib/libsodium/build-android~/out" ) +target_include_directories( mpw PRIVATE "${PROJECT_SOURCE_DIR}/../lib/libsodium/src/libsodium/include" ) target_compile_definitions( mpw PRIVATE -DMPW_SODIUM=1 ) target_link_libraries( mpw PRIVATE sodium ) add_library( json-c SHARED IMPORTED ) set_target_properties( json-c PROPERTIES IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../lib/libjson-c/build-android~/out/lib/${ANDROID_ABI}/libjson-c.so" ) -target_include_directories( mpw PRIVATE "${PROJECT_SOURCE_DIR}/../lib/libjson-c/build-android~/out" ) +target_include_directories( mpw PRIVATE "${PROJECT_SOURCE_DIR}/../lib/libjson-c/build-android~/out/include" ) target_compile_definitions( mpw PRIVATE -DMPW_JSON=1 ) target_link_libraries( mpw PRIVATE json-c ) diff --git a/platform-android/build.gradle b/platform-android/build.gradle index d5b229b5..10a9bfc6 100644 --- a/platform-android/build.gradle +++ b/platform-android/build.gradle @@ -22,8 +22,8 @@ android { } sourceSets { main { - jniLibs.srcDirs "$projectDir/../lib/libsodium/build-android~/out/lib", - "$projectDir/../lib/libjson-c/build-android~/out/lib" + jniLibs.srcDirs "$rootDir/../lib/libsodium/build-android~/out/lib", + "$rootDir/../lib/libjson-c/build-android~/out/lib" } } @@ -65,3 +65,13 @@ preBuild { } ) } +clean { + dependsOn task( type: Exec, 'clean_libsodium-android', { + commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-android", 'clean' + environment 'ANDROID_NDK_HOME', android.ndkDirectory + } ) + dependsOn task( type: Exec, 'clean_libjson-c-android', { + commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-android", 'clean' + environment 'ANDROID_NDK_HOME', android.ndkDirectory + } ) +} diff --git a/platform-independent/c/core/build.gradle b/platform-independent/c/core/build.gradle index 61128857..0b166216 100644 --- a/platform-independent/c/core/build.gradle +++ b/platform-independent/c/core/build.gradle @@ -60,22 +60,22 @@ library { project.dependencies { add( linkLibraries.name, - fileTree( "../../../lib/libsodium/build-${system}~/out/lib" ) ) + fileTree( "$rootDir/../lib/libsodium/build-${system}~/out/lib" ) ) } archive.dependsOn project.tasks.maybeCreate( "build_libsodium-${system}", Exec.class ).configure { - commandLine 'bash', '-x', "$rootDir/../lib/bin/build_libsodium-${system}" + commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-${system}" privateHeaders.from "$rootDir/../lib/libsodium/src/libsodium/include" } clean.dependsOn project.tasks.maybeCreate( "clean_libsodium-${system}", Exec.class ).configure { - commandLine 'bash', '-x', "$rootDir/../lib/bin/build_libsodium-${system}", 'clean' + commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-${system}", 'clean' } archive.dependsOn project.tasks.maybeCreate( "build_libjson-c-${system}", Exec.class ).configure { - commandLine 'bash', '-x', "$rootDir/../lib/bin/build_libjson-c-${system}" - privateHeaders.from "$rootDir/../lib/libjson-c/build-${system}~/out" + commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-${system}" + privateHeaders.from "$rootDir/../lib/libjson-c/build-${system}~/out/include" } clean.dependsOn project.tasks.maybeCreate( "clean_libjson-c-${system}", Exec.class ).configure { - commandLine 'bash', '-x', "$rootDir/../lib/bin/build_libjson-c-${system}", 'clean' + commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-${system}", 'clean' } } } @@ -92,7 +92,7 @@ static String standardOperatingSystem(NativePlatform platform) { else if (os.isLinux()) return OperatingSystemFamily.LINUX - // Other systems will need to use a Linux compatibility layer for now. + // Other systems will need to use a Linux compatibility layer. return OperatingSystemFamily.LINUX } diff --git a/platform-independent/java/algorithm/build.gradle b/platform-independent/java/algorithm/build.gradle index dcbb3923..2d61df49 100644 --- a/platform-independent/java/algorithm/build.gradle +++ b/platform-independent/java/algorithm/build.gradle @@ -20,11 +20,12 @@ dependencies { } processResources { - dependsOn task( type: Sync, 'copyResources', { + dependsOn task( type: Sync, 'processResources-lib', { + into new File( processResources.outputs.files.singleFile, "lib" ) + dependsOn configurations.lib { files.each { libFile -> - from zipTree( libFile ) - into new File( processResources.outputs.files.singleFile, "lib" ) + from( zipTree( libFile ) ) } } } ) @@ -33,7 +34,7 @@ processResources { compileJava { doLast { ant.javah( class: 'com.lyndir.masterpassword.impl.MPAlgorithmV0', - outputFile: '../../c/core/src/mpw-jni.h', + outputFile: new File( project( ':masterpassword-core' ).projectDir, 'src/mpw-jni.h' ), classpath: files( sourceSets.main.compileClasspath, sourceSets.main.output ).asPath ) } } diff --git a/platform-independent/java/model/build.gradle b/platform-independent/java/model/build.gradle index a2b00d23..786f25df 100644 --- a/platform-independent/java/model/build.gradle +++ b/platform-independent/java/model/build.gradle @@ -21,4 +21,5 @@ dependencies { testImplementation group: 'org.testng', name: 'testng', version: '6.8.5' testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2' } + test.useTestNG() diff --git a/platform-independent/java/tests/build.gradle b/platform-independent/java/tests/build.gradle index 3f26e7b1..7ebd626c 100644 --- a/platform-independent/java/tests/build.gradle +++ b/platform-independent/java/tests/build.gradle @@ -13,7 +13,5 @@ dependencies { testImplementation group: 'org.testng', name: 'testng', version: '6.8.5' testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2' } -//tasks.withType(Test) { -// systemProperty "java.library.path", "/Users/lhunath/Documents/workspace/lyndir/MasterPassword/core/java/algorithm/build/libs/mpw/shared" -//} + test.useTestNG()