forked from btraceio/btrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
68 lines (55 loc) · 1.89 KB
/
Copy pathbuild.gradle
File metadata and controls
68 lines (55 loc) · 1.89 KB
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
import org.gradle.internal.os.OperatingSystem
import org.gradle.internal.jvm.Jvm
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java'
}
def nativeHeadersDir = "${buildDir}/generated/native/include"
def dtraceLibDir = "${buildDir}/dtrace"
def javaHome = Jvm.current().javaHome
def isSolaris = OperatingSystem.current() == OperatingSystem.SOLARIS
def osArch = System.getProperty("os.arch")
dependencies {
implementation project(':btrace-core')
}
task nativeHeaders(type:Exec) {
def classpath = sourceSets.main.runtimeClasspath.asPath
commandLine "javah", "-d", nativeHeadersDir, "-classpath", classpath, "org.openjdk.btrace.core.BTraceRuntime"
dependsOn classes
}
if (isSolaris) {
task makedirs(type: Exec) {
commandLine "mkdir", "-p", "${dtraceLibDir}", "${dtraceLibDir}/libs/${osArch}"
}
task compileC(type: Exec) {
commandLine "gcc", "-c", "-I${javaHome}/include", "-I${javaHome}/include/solaris", "-I${nativeHeadersDir}", "-o${dtraceLibDir}/btrace.o", "${projectDir}/src/main/native/btrace.c"
dependsOn nativeHeaders, makedirs
}
task dtrace(type: Exec) {
commandLine "/usr/sbin/dtrace", "-G", "-o", "${dtraceLibDir}/btraced.o", "-s", "${projectDir}/src/main/native/btraced.d", "${dtraceLibDir}/btrace.o"
dependsOn compileC, makedirs
}
task linkDTraceLib(type: Exec) {
commandLine "gcc", "-G", "${dtraceLibDir}/btrace.o", "${dtraceLibDir}/btraced.o", "-o", "${dtraceLibDir}/libs/${osArch}/libbtrace.so"
dependsOn dtrace, makedirs
}
}
sourceSets {
main {
java {
srcDirs "src/main/java"
srcDirs "src/mock/java"
}
}
}
shadowJar {
include 'org/openjdk/btrace/dtrace/**/*'
classifier = null
}
sourcesJar {
duplicatesStrategy DuplicatesStrategy.EXCLUDE
}
build.dependsOn shadowJar
if (isSolaris) {
jar.dependsOn linkDTraceLib
}