forked from wizzardo/epoll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
72 lines (55 loc) · 1.98 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
apply plugin: 'java'
repositories {
jcenter()
}
sourceCompatibility = 1.6
targetCompatibility = 1.6
archivesBaseName = "epoll"
ext {
descriptionString = 'Event-based socket server, which uses epoll'
cWorkDir = 'src/main/c/com/wizzardo/epoll'
jdk = System.getenv('JAVA_HOME')
if (!jdk)
throw new IllegalArgumentException('please specify JAVA_HOME')
linux64 = 'build/libepoll-core_x64.so'
linux32 = 'build/libepoll-core_x32.so'
}
apply from: 'gradle/sonatype.gradle'
dependencies {
// compile files(
// '../Utils/build/libs/tools-all-0.13-SNAPSHOT.jar'
// )
compile 'com.wizzardo.tools:tools-io:0.+'
compile 'com.wizzardo.tools:tools-reflection:0.+'
testCompile 'junit:junit:4.+'
testCompile 'com.wizzardo.tools:tools:0.+'
}
jar {
dependsOn 'compileLinux32'
dependsOn 'compileLinux64'
from 'build/libepoll-core_x64.so'
from 'build/libepoll-core_x32.so'
}
task jar32(type: Jar, dependsOn: ['compileLinux32']) {
baseName = project.name + '-x32'
from 'build/libepoll-core_x32.so'
from sourceSets.main.output
}
task jar64(type: Jar, dependsOn: ['compileLinux64']) {
baseName = project.name + '-x64'
from 'build/libepoll-core_x64.so'
from sourceSets.main.output
}
task compileLinux64(type: Exec, dependsOn: ['prepareHeaders']) {
workingDir cWorkDir
commandLine 'gcc', '-shared', '-fpic', '-o', new File(linux64).absolutePath, '-I',
jdk + '/include/', '-I', jdk + '/include/linux/', 'EpollCore.c', '-lssl', '-lcrypto'
}
task compileLinux32(type: Exec, dependsOn: ['prepareHeaders']) {
workingDir cWorkDir
commandLine 'gcc', '-shared', '-fpic', '-o', new File(linux32).absolutePath, '-I',
jdk + '/include/', '-I', jdk + '/include/linux/', 'EpollCore.c', '-m32', '-lssl', '-lcrypto'
}
task prepareHeaders(type: Exec, dependsOn: ['compileJava']) {
commandLine 'javah', '-classpath', 'build/classes/main', '-jni', '-v', '-d', cWorkDir, 'com.wizzardo.epoll.EpollCore'
}