diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 45d13348..67650d29 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -89,17 +89,6 @@ set(ALL_SOURCE_LIST wedpr-computing/ppc-psi wedpr-computing/ppc-mpc wedpr-computing/ppc-pir ${CEM_SOURCE} wedpr-initializer wedpr-main) -if(BUILD_WEDPR_TOOLKIT) - # fetch the python dependencies - option(FETCH_PYTHON_DEPS "Install python required modules if not available" ON) - message(STATUS "Python fetch dependencies: ${FETCH_PYTHON_DEPS}") - if(WIN32) - message(STATUS "Getting SWIG for Windows: ...") - include(swig) - message(STATUS "Getting SWIG for Windows: ...DONE") - endif() -endif() - if(BUILD_ALL) add_sources("${ALL_SOURCE_LIST}") elseif(BUILD_UDF) diff --git a/cpp/wedpr-transport/sdk-wrapper/CMakeLists.txt b/cpp/wedpr-transport/sdk-wrapper/CMakeLists.txt index 08c97539..e1d6cf3d 100644 --- a/cpp/wedpr-transport/sdk-wrapper/CMakeLists.txt +++ b/cpp/wedpr-transport/sdk-wrapper/CMakeLists.txt @@ -6,6 +6,9 @@ include(${SWIG_USE_FILE}) # Add subdirectories for each language if desired option(BUILD_PYTHON "Build Python SWIG module" ON) if(BUILD_PYTHON) + # fetch the python dependencies + option(FETCH_PYTHON_DEPS "Install python required modules if not available" ON) + message(STATUS "Python fetch dependencies: ${FETCH_PYTHON_DEPS}") include(python) add_subdirectory(python) endif() @@ -13,6 +16,5 @@ endif() # Add subdirectories for each language if desired option(BUILD_JAVA "Build JAVA SWIG module" ON) if(BUILD_JAVA) - include(java) add_subdirectory(java) endif() diff --git a/cpp/wedpr-transport/sdk-wrapper/java/CMakeLists.txt b/cpp/wedpr-transport/sdk-wrapper/java/CMakeLists.txt index 9276c9e6..a184200f 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/CMakeLists.txt +++ b/cpp/wedpr-transport/sdk-wrapper/java/CMakeLists.txt @@ -1,19 +1,32 @@ -file(GLOB_RECURSE SRCS wedpr_java_transport.i) -set_source_files_properties(${SRCS} PROPERTIES CPLUSPLUS ON) - -set(WEDPR_TRANSPORT_PACKAGE "com.webank.wedpr.sdk.jni.generated") - -set_property(SOURCE swig/wedpr_java_transport.i PROPERTY COMPILE_OPTIONS - -package ${WEDPR_TRANSPORT_PACKAGE}) - -file(MAKE_DIRECTORY ${WEDPR_JAVA_TRANSPORT_DIR}) -file(MAKE_DIRECTORY ${WEDPR_JAVA_TRANSPORT_LIB_DIR}) - -swig_add_library(${WEDPR_JAVA_TRANSPORT} - TYPE MODULE - LANGUAGE java - OUTPUT_DIR ${WEDPR_JAVA_TRANSPORT_DIR} - SOURCES ${SRCS}) +option(AUTO_GENERATE "Auto generate the targes" OFF) +if(AUTO_GENERATE) + if(WIN32) + message(STATUS "Getting SWIG for Windows: ...") + include(swig) + message(STATUS "Getting SWIG for Windows: ...DONE") + endif() + # only auto-generate should find swig + include(java) + file(GLOB_RECURSE SRCS wedpr_java_transport.i) + set_source_files_properties(${SRCS} PROPERTIES CPLUSPLUS ON) + + set(WEDPR_TRANSPORT_PACKAGE "com.webank.wedpr.sdk.jni.generated") + + set_property(SOURCE swig/wedpr_java_transport.i PROPERTY COMPILE_OPTIONS + -package ${WEDPR_TRANSPORT_PACKAGE}) + + file(MAKE_DIRECTORY ${WEDPR_JAVA_TRANSPORT_DIR}) + file(MAKE_DIRECTORY ${WEDPR_JAVA_TRANSPORT_LIB_DIR}) + + swig_add_library(${WEDPR_JAVA_TRANSPORT} + TYPE MODULE + LANGUAGE java + OUTPUT_DIR ${WEDPR_JAVA_TRANSPORT_DIR} + SOURCES ${SRCS}) +else() + file(GLOB_RECURSE SRCS src/*.cxx) + add_library(${WEDPR_JAVA_TRANSPORT} SHARED ${SRCS}) +endif() SET(LIBRARY_OUTPUT_PATH ${WEDPR_JAVA_TRANSPORT_LIB_DIR}) message("LIBRARY_OUTPUT_PATH: ${WEDPR_JAVA_TRANSPORT_LIB_DIR}") diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/build.gradle b/cpp/wedpr-transport/sdk-wrapper/java/bindings/build.gradle index 67e5940e..362b0ba3 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/build.gradle +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/build.gradle @@ -7,6 +7,9 @@ plugins { id "de.undercouch.download" version "4.1.2" id 'com.github.sherter.google-java-format' version '0.9' } +apply plugin: 'maven-publish' +apply plugin: 'java' +apply plugin: 'signing' // Additional attribute definition ext { @@ -93,7 +96,7 @@ version = '1.0.0-SNAPSHOT' jar { exclude '**/*.xml' exclude '**/*.properties' - /*manifest { + manifest { try { def repo = grgit.open(currentDir: project.rootDir) if (repo != null) { @@ -109,7 +112,7 @@ jar { } catch (Exception e) { e.printStackTrace() } - } from sourceSets.main.output*/ + } from sourceSets.main.output doLast { copy { @@ -164,7 +167,7 @@ publishing { pom { name = 'wedpr' - description = 'wedpr java transport jni' + description = 'wedpr java gateway sdk' url = 'http://www.fisco-bcos.org' licenses { @@ -200,7 +203,8 @@ publishing { password 'deployment123' } } + signing { + sign publishing.publications.mavenJava + } } - } - diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/settings.gradle b/cpp/wedpr-transport/sdk-wrapper/java/bindings/settings.gradle index 5c90d6b7..4a6f5d4e 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/settings.gradle +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/settings.gradle @@ -1,2 +1,2 @@ -rootProject.name = 'wedpr-java-transport-jni' +rootProject.name = 'wedpr-gateway-sdk' diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/common/JniLibLoader.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/common/JniLibLoader.java index f30e9165..ff34a1de 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/common/JniLibLoader.java +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/common/JniLibLoader.java @@ -101,9 +101,9 @@ public static String getLibName(String baseName) { } else if (osName.contains(MAC)) { String arch = getArch(); if ("arm".equals(arch)) { - return "lib" + baseName + "-aarch64" + ".jnilib"; + return "lib" + baseName + "-aarch64" + ".dylib"; } - return "lib" + baseName + ".jnilib"; + return "lib" + baseName + ".dylib"; } else { throw new RuntimeException("unrecognized OS: " + osName); } diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/IFrontClient.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/IFrontClient.java index ac777ec8..a9d97546 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/IFrontClient.java +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/IFrontClient.java @@ -43,8 +43,6 @@ public synchronized void delete() { /** * : receive message from gateway, call by gateway
*
- * - * @return void */ public void onReceiveMessage( Message _msg, diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/c/wedpr_java_transportJAVA_wrap.cxx b/cpp/wedpr-transport/sdk-wrapper/java/src/wedpr_java_transportJAVA_wrap.cxx similarity index 100% rename from cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/c/wedpr_java_transportJAVA_wrap.cxx rename to cpp/wedpr-transport/sdk-wrapper/java/src/wedpr_java_transportJAVA_wrap.cxx diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/c/wedpr_java_transportJAVA_wrap.h b/cpp/wedpr-transport/sdk-wrapper/java/src/wedpr_java_transportJAVA_wrap.h similarity index 100% rename from cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/c/wedpr_java_transportJAVA_wrap.h rename to cpp/wedpr-transport/sdk-wrapper/java/src/wedpr_java_transportJAVA_wrap.h