-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add java swig * add java binding package
- Loading branch information
1 parent
0a7d99f
commit 0fba05a
Showing
25 changed files
with
904 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
if(NOT BUILD_JAVA) | ||
return() | ||
endif() | ||
|
||
# Will need swig | ||
set(CMAKE_SWIG_FLAGS) | ||
find_package(SWIG REQUIRED) | ||
include(UseSWIG) | ||
|
||
if(${SWIG_VERSION} VERSION_GREATER_EQUAL 4) | ||
list(APPEND CMAKE_SWIG_FLAGS "-doxygen") | ||
endif() | ||
|
||
if(UNIX AND NOT APPLE) | ||
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE64") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
file(GLOB_RECURSE SRCS *.cpp) | ||
add_library(${SERVICE_CLIENT_TARGET} ${SRCS}) | ||
target_link_libraries(${SERVICE_CLIENT_TARGET} PUBLIC ${SERVICE_PB_TARGET} ${PB_PROTOCOL_TARGET}) | ||
target_link_libraries(${SERVICE_CLIENT_TARGET} PUBLIC ${SERVICE_PB_TARGET} ${PROTOCOL_TARGET} ${PB_PROTOCOL_TARGET}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
file(GLOB_RECURSE SRCS *.cpp) | ||
add_library(${SERVICE_SERVER_TARGET} ${SRCS}) | ||
target_link_libraries(${SERVICE_SERVER_TARGET} PUBLIC ${SERVICE_PB_TARGET} ${PB_PROTOCOL_TARGET}) | ||
target_link_libraries(${SERVICE_SERVER_TARGET} PUBLIC ${SERVICE_PB_TARGET} ${PROTOCOL_TARGET} ${PB_PROTOCOL_TARGET}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
file(GLOB_RECURSE SRCS *.i) | ||
set_source_files_properties(${SRCS} PROPERTIES CPLUSPLUS ON) | ||
|
||
set(WEDPR_TRANSPORT_PACKAGE "com.webank.wedpr.sdk.jni.transport") | ||
|
||
set_property(SOURCE swig/wedpr_java_transport.i PROPERTY COMPILE_OPTIONS | ||
-package ${WEDPR_TRANSPORT_PACKAGE}) | ||
|
||
swig_add_library(${WEDPR_JAVA_TRANSPORT} | ||
TYPE MODULE | ||
LANGUAGE java | ||
OUTPUT_DIR ${WEDPR_JAVA_TRANSPORT_DIR} | ||
SOURCES ${SRCS}) | ||
|
||
SET(LIBRARY_OUTPUT_PATH ${WEDPR_JAVA_TRANSPORT_DIR}) | ||
message("LIBRARY_OUTPUT_PATH: ${WEDPR_JAVA_TRANSPORT_DIR}") | ||
|
||
set_target_properties(${WEDPR_JAVA_TRANSPORT} PROPERTIES | ||
SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON | ||
POSITION_INDEPENDENT_CODE ON) | ||
|
||
target_include_directories(${WEDPR_JAVA_TRANSPORT} PRIVATE ${JNI_INCLUDE_DIRS}) | ||
|
||
target_link_libraries(${WEDPR_JAVA_TRANSPORT} PRIVATE ${WEDPR_TRANSPORT_SDK_TARGET} ${JAVA_LIBRARIES}) |
199 changes: 199 additions & 0 deletions
199
cpp/wedpr-transport/sdk-wrapper/java/bindings/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
plugins { | ||
id 'java' | ||
id 'idea' | ||
id 'java-library' | ||
id 'maven-publish' | ||
//id 'org.ajoberstar.grgit' version '4.1.1' | ||
//id "de.undercouch.download" version "4.1.2" | ||
// id 'com.github.sherter.google-java-format' version '0.9' | ||
} | ||
|
||
println("Notice: current gradle version is " + gradle.gradleVersion) | ||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
|
||
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8' | ||
|
||
repositories { | ||
maven { url "https://maven.aliyun.com/nexus/content/groups/public/" } | ||
maven { url "https://oss.sonatype.org/service/local/staging/deploy/maven2"} | ||
maven { url "https://oss.sonatype.org/content/repositories/snapshots" } | ||
maven {url "https://plugins.gradle.org/m2/"} | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
|
||
// googleJavaFormat { | ||
// toolVersion = '1.7' | ||
// options style: 'AOSP' | ||
// source = sourceSets*.allJava | ||
// include '**/*.java' | ||
// exclude '**/*Test.java' | ||
// exclude '**/Test*.java' | ||
// exclude '**/Mock*.java' | ||
// } | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
srcDir 'src/main/java' | ||
} | ||
resources { | ||
srcDir 'src/main/resources' | ||
} | ||
} | ||
|
||
jmh { | ||
java { | ||
srcDir 'src/jmh/java' | ||
} | ||
resources { | ||
srcDir 'src/jmh/resources' | ||
} | ||
|
||
runtimeClasspath += sourceSets.main.runtimeClasspath | ||
compileClasspath += sourceSets.main.compileClasspath | ||
|
||
compileClasspath += main.output | ||
runtimeClasspath += main.output | ||
} | ||
} | ||
dependencies { | ||
api ('org.slf4j:slf4j-api:1.7.36') | ||
|
||
jmhImplementation 'org.openjdk.jmh:jmh-core:1.36' | ||
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.36' | ||
|
||
testImplementation ('org.slf4j:slf4j-log4j12:1.7.36') | ||
testImplementation ('junit:junit:4.13.2') | ||
} | ||
|
||
archivesBaseName = 'wedpr-java-transport-jni' | ||
group = 'com.webank.wedpr' | ||
version = '1.0.0' | ||
|
||
// Additional attribute definition | ||
ext { | ||
if (!project.hasProperty("ossrhUsername")) { | ||
ossrhUsername="xxx" | ||
} | ||
|
||
if (!project.hasProperty("ossrhPassword")) { | ||
ossrhPassword="xxx" | ||
} | ||
} | ||
|
||
jar { | ||
exclude '**/*.xml' | ||
exclude '**/*.properties' | ||
/*manifest { | ||
try { | ||
def repo = grgit.open(currentDir: project.rootDir) | ||
if (repo != null) { | ||
def date = new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") | ||
def branch = repo.branch.getCurrent().getName() | ||
def commit = repo.head().getAbbreviatedId(40) | ||
attributes(["Implementation-Timestamp": date, | ||
"Git-Branch" : branch, | ||
"Git-Commit" : commit]) | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace() | ||
} | ||
} from sourceSets.main.output*/ | ||
|
||
doLast { | ||
copy { | ||
from destinationDirectory | ||
into 'dist/apps' | ||
} | ||
|
||
copy { | ||
from configurations.runtimeClasspath | ||
into 'dist/lib' | ||
} | ||
} | ||
} | ||
|
||
javadoc { | ||
options.addStringOption('Xdoclint:none', '-quiet') | ||
options.addStringOption('encoding', 'UTF-8') | ||
options.addStringOption('charSet', 'UTF-8') | ||
} | ||
|
||
task sourcesJar(type: Jar) { | ||
from sourceSets.main.allJava | ||
archiveClassifier = 'sources' | ||
duplicatesStrategy 'exclude' | ||
} | ||
tasks.withType(Copy).all { | ||
duplicatesStrategy 'exclude' | ||
} | ||
|
||
|
||
task javadocJar(type: Jar) { | ||
from javadoc | ||
archiveClassifier = 'javadoc' | ||
} | ||
|
||
task jmh(type: JavaExec, dependsOn: jmhClasses) { | ||
main = 'com.webank.wedpr.sdk.jni.jmh.BenchmarkMain' | ||
classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
|
||
artifactId project.name | ||
groupId project.group | ||
version project.version | ||
|
||
from components.java | ||
artifact sourcesJar | ||
artifact javadocJar | ||
|
||
pom { | ||
name = 'wedpr' | ||
description = 'wedpr java transport jni' | ||
url = 'http://www.fisco-bcos.org' | ||
|
||
licenses { | ||
license { | ||
name = 'The Apache License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
} | ||
} | ||
scm { | ||
connection = 'http://github.com/WeBankBlockchain/wedpr-components.git' | ||
url = 'http://github.com/WeBankBlockchain/wedpr-components.git' | ||
} | ||
|
||
developers { | ||
developer { | ||
id = 'zhangsan' | ||
name = 'zhangsan' | ||
email = '[email protected]' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
def releasesRepoURL = "https://oss.sonatype.org/service/local/staging/deploy/maven2" | ||
def snapshotsRepoURL = "https://oss.sonatype.org/content/repositories/snapshots" | ||
allowInsecureProtocol = true | ||
url = !version.endsWith("SNAPSHOT") ? releasesRepoURL : snapshotsRepoURL | ||
|
||
credentials { | ||
username 'deployment' | ||
password 'deployment123' | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
Binary file added
BIN
+57.8 KB
cpp/wedpr-transport/sdk-wrapper/java/bindings/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
cpp/wedpr-transport/sdk-wrapper/java/bindings/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
# distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip | ||
distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-7.3-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.