2
0

Rename native lib to libmpw & native library loading for eg. Android.

This commit is contained in:
Maarten Billemont 2018-06-19 01:28:27 -04:00
parent a8263b276c
commit 4c48bfb1af
5 changed files with 14 additions and 4 deletions

View File

@ -8,7 +8,8 @@ add_library( mpw SHARED
"${PROJECT_SOURCE_DIR}/../platform-independent/c/core/src/mpw-types.c"
"${PROJECT_SOURCE_DIR}/../platform-independent/c/core/src/mpw-util.c"
"${PROJECT_SOURCE_DIR}/../platform-independent/c/core/src/mpw-marshal-util.c"
"${PROJECT_SOURCE_DIR}/../platform-independent/c/core/src/mpw-marshal.c" )
"${PROJECT_SOURCE_DIR}/../platform-independent/c/core/src/mpw-marshal.c"
"${PROJECT_SOURCE_DIR}/../platform-independent/c/core/src/mpw-jni.c" )
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" )

View File

@ -1,5 +1,5 @@
### CMAKE
project( mpw-cli C )
project( masterpassword-cli C )
cmake_minimum_required( VERSION 3.0.2 )

View File

@ -21,6 +21,7 @@ artifacts {
}
library {
baseName.set( "mpw" )
linkage.set( [Linkage.STATIC, Linkage.SHARED] )
// Reconfigure the toolchain from C++ to C.

View File

@ -42,7 +42,7 @@ public class MPAlgorithmV0 extends MPAlgorithm {
protected static final int AES_BLOCKSIZE = 128 /* bit */;
static {
Native.load( MPAlgorithmV0.class, "masterpassword-core" );
Native.load( MPAlgorithmV0.class, "mpw" );
}
public final Version version = MPAlgorithm.Version.V0;

View File

@ -40,8 +40,16 @@ public final class Native {
@SuppressWarnings({ "HardcodedFileSeparator", "LoadLibraryWithNonConstantString" })
public static void load(final Class<?> context, final String name) {
// Try to load the library using the native system.
try {
System.loadLibrary( name );
return;
} catch (@SuppressWarnings("ErrorNotRethrown") final UnsatisfiedLinkError ignored) {
}
// Try to find and open a stream to the packaged library resource.
try {
// Find and open a stream to the packaged library resource.
String library = System.mapLibraryName( name );
int libraryDot = library.lastIndexOf( EXTENSION_SEPARATOR );
String libraryName = (libraryDot > 0)? library.substring( 0, libraryDot ): library;