-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
executable file
·283 lines (259 loc) · 10.3 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
buildscript {
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
}
plugins {
id 'java'
id 'idea'
id 'application'
id 'cpp'
}
group 'p'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
mainClassName = 'com.zerocoinj.tests.Application'
idea {
module {
inheritOutputDirs = false
outputDir = file("$buildDir/classes/main/")
}
}
repositories {
mavenCentral()
jcenter()
google()
maven { url 'https://jitpack.io' }
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/resources'
}
}
test {
java {
srcDirs 'src/test/java'
}
resources {
srcDirs 'src/test/resources'
includes ['**/*.txt']
}
}
}
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': mainClassName
)
}
}
run {
systemProperty "java.library.path", file("${buildDir}/libs/bridge/shared/debug/").absolutePath
}
test {
jvmArgs += [ "-Xmx1024M" ]
systemProperty "java.library.path", file("${buildDir}/libs/bridge/shared/debug/").absolutePath
}
println "Building on OS: " + System.properties['os.name']
println "Using JDK: " + System.properties['java.home']
def SYS_INCLUDE_DIR = this.properties['system.include.dir']
def SYS_LOCAL_INCLUDE_DIR = this.properties['system.local.include.dir']
def JNI_INCLUDE_DIR = this.properties['jni.include.dir']
def JNI_LIB_DIR = this.properties['jni.lib.dir']
def OPEN_SSL_LIB = this.properties['system.local.include.openssl.dir']
println "Using system include directory: " + SYS_INCLUDE_DIR
println "Using system local include directory: " + SYS_LOCAL_INCLUDE_DIR
println "Using JNI include directory: " + JNI_INCLUDE_DIR
println "Using JNI lib directory: " + JNI_LIB_DIR
// TODO: Complete this for the others OS.
model {
repositories {
libs(PrebuiltLibraries) {
boost{
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("libs/libboost_thread-mt.dylib")
}
}
boost_system{
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("libs/libboost_system.dylib")
}
}
crypto {
//headers.srcDir "3rd-party-lib/util/src/util/headers"
//binaries.withType(StaticLibraryBinary) {
// def libName = targetPlatform.operatingSystem.windows ? 'util.lib' : 'libutil.a'
// staticLibraryFile = file("3rd-party-lib/util/build/libs/util/static/${buildType.name}/${libName}")
//}
binaries.withType(SharedLibraryBinary) {
def os = targetPlatform.operatingSystem
//def baseDir = "3rd-party-lib/util/build/libs/util/shared/${buildType.name}"
sharedLibraryFile = file("libs/libcrypto.1.0.0.dylib")
// TODO: Complete this..
// if (os.windows) {
// // Windows uses a .dll file, with a different link file if it exists (not Cygwin or MinGW)
// sharedLibraryFile = file("${baseDir}/util.dll")
// if (file("${baseDir}/util.lib").exists()) {
// sharedLibraryLinkFile = file("${baseDir}/util.lib")
// }
// } else if (os.macOsX) {
// sharedLibraryFile = file("${baseDir}/libutil.dylib")
// } else {
// sharedLibraryFile = file("${baseDir}/libutil.so")
// }
}
}
}
}
components {
bridge(NativeLibrarySpec) {
sources {
cpp {
source {
srcDir 'src/main/jni'
include "**/*.cpp"
}
}
//cpp.lib library: 'boost', linkage: 'api'
cpp.lib library: 'crypto', linkage: 'shared'
cpp.lib library: 'boost', linkage: 'shared'
cpp.lib library: 'boost_system', linkage: 'shared'
}
buildTypes {
debug
release
}
}
}
toolChains {
gcc(Gcc) {
eachPlatform {
if (System.properties['os.name'].equals('Mac OS X')) {
println "Using gcc"
cppCompiler.withArguments { args ->
args << "-O2"
args << "-I" + SYS_INCLUDE_DIR
args << "-I" + SYS_LOCAL_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR + "/darwin"
args << "-L" + OPEN_SSL_LIB
args << "-I" + this.properties['system.local.include.openssl.dir2']
args << "-L/usr/local/opt/openssl/lib"
args << "-I/usr/local/opt/openssl/include"
args << "-I/usr/local/Cellar/openssl/1.0.2o_1/lib/"
args << "-L" + this.properties['system.local.lib.boost.dir']
args << "-I" + this.properties['system.local.include.boost.dir']
args << "-std=c++11"
}
linker.withArguments { args ->
args << "-O2"
args << "-lc++"
args << "lcrypto"
args << "-L" + this.properties['system.local.include.openssl.dir2']
args << "-L/usr/local/opt/openssl/lib"
args << "-I/usr/local/opt/openssl/include"
args << "-I/usr/local/Cellar/openssl/1.0.2o_1/lib/"
args << "-L" + this.properties['system.local.lib.boost.dir']
args << "-I" + this.properties['system.local.include.boost.dir']
args << "lboost"
args << "-L" + OPEN_SSL_LIB
}
} else {
path "/opt/rh/devtoolset-2/root/usr/bin/gcc"
cppCompiler.withArguments { args ->
args << "-O2"
args << "-I" + SYS_INCLUDE_DIR
args << "-I" + SYS_LOCAL_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR + "/linux"
args << "-std=c++11"
}
linker.withArguments { args ->
args << "-O2"
args << "-lstdc++"
}
}
}
}
clang(Clang) {
eachPlatform {
if (System.properties['os.name'].equals('Mac OS X')) {
println "using clang.."
cppCompiler.withArguments { args ->
args << "-O2"
args << "-I" + SYS_INCLUDE_DIR
args << "-I" + SYS_LOCAL_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR + "/darwin"
args << "-L" + OPEN_SSL_LIB
args << "-I" + this.properties['system.local.include.openssl.dir2']
args << "-L/usr/local/opt/openssl/lib"
args << "-I/usr/local/opt/openssl/include"
args << "-I/usr/local/Cellar/openssl/1.0.2o_1/lib/"
args << "-L" + this.properties['system.local.lib.boost.dir']
args << "-I" + this.properties['system.local.include.boost.dir']
args << "-std=c++11"
}
linker.withArguments { args ->
args << "-O2"
args << "-lc++"
args << "-L" + this.properties['system.local.include.openssl.dir2']
args << "-L/usr/local/opt/openssl/lib"
args << "-I/usr/local/opt/openssl/include"
args << "-I/usr/local/Cellar/openssl/1.0.2o_1/lib/"
args << "-L" + OPEN_SSL_LIB
args << "-L" + this.properties['system.local.lib.boost.dir']
args << "-I" + this.properties['system.local.include.boost.dir']
}
} else {
cppCompiler.withArguments { args ->
args << "-O2"
args << "-I" + SYS_INCLUDE_DIR
args << "-I" + SYS_LOCAL_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR
args << "-I" + JNI_INCLUDE_DIR + "/linux"
args << "-std=c++11"
}
linker.withArguments { args ->
args << "-O2"
args << "-lstdc++"
}
}
}
}
}
}
task copyLibBridge(type: Copy) {
if (System.properties['os.name'].equals('Mac OS X')) {
from "$projectDir/build/binaries/bridgeSharedLibrary/libbridge.dylib"
}
else {
from "$projectDir/build/binaries/bridgeSharedLibrary/libbridge.so"
}
into 'libs'
}
dependencies {
implementation 'org.slf4j:slf4j-simple:1.7.5'
implementation 'org.slf4j:slf4j-api:1.7.20'
implementation 'com.lambdaworks:scrypt:1.4.0'
implementation 'com.google.protobuf:protobuf-java:2.6.1'
implementation 'com.google.guava:guava:20.0'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'commons-codec:commons-codec:1.10'
implementation 'com.madgag.spongycastle:core:1.54.0.0'
implementation 'org.fusesource.leveldbjni:leveldbjni-all:1.8'
implementation files('libs/pivxj-core-0.14.3-12.1.jar')
implementation group: 'org.json', name: 'json', version: '20180130'
testCompile "junit:junit:4.11"
testCompile 'org.slf4j:slf4j-api:1.7.20'
}
tasks.withType(JavaExec) {
systemProperty "java.library.path", file("${buildDir}/libs/bridge/shared/debug/").absolutePath
}