-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
103 lines (82 loc) · 2.52 KB
/
build.gradle
File metadata and controls
103 lines (82 loc) · 2.52 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
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
buildscript {
repositories {
mavenCentral()
}
dependencies {
// required to publish to maven central
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
}
}
// plugins
plugins {
id 'java' // for building java
id 'cpp' // for building natives
}
// apply plugins
apply plugin: 'java'
apply plugin: 'cpp'
// project info
group 'io.github.orbyfied'
version '2.0.1'
sourceCompatibility = 13
targetCompatibility = 13
// JAR task config
jar {
// enable the task
enabled true
// make sure that the DLLs are built
dependsOn 'win32X64SharedLibrary', 'win32X86SharedLibrary'
/* include resources */
// win32 DLLs (x64/x86)
from("build/libs/win32/shared/x64") { include("*.dll") duplicatesStrategy DuplicatesStrategy.EXCLUDE }
from("build/libs/win32/shared/x86") { include("*.dll") duplicatesStrategy DuplicatesStrategy.EXCLUDE }
}
// natives
model {
// supported architectures
platforms {
x86 {
architecture "x86"
}
x64 {
architecture "x86_64"
}
}
components {
// Win32 library (Spruce.Win32)
win32(NativeLibrarySpec) {
// target platforms
targetPlatform "x86"
targetPlatform "x64"
// DLL info
String v_baseName = "spruce-win32"
String v_version = "1_3"
String v_arch = "64"
String v_name = v_baseName + "-v" + v_version + "_" + v_arch
setBaseName(v_name)
// describe binaries (DLL)
binaries.all {
// linker params
linker.args '--kill-at'
if (v_arch == "64") {
cppCompiler.args '-m64'
linker.args '-m64'
}
linker.args '-shared'
linker.args '-flinker-output=dyn'
// include JNI headers
cppCompiler.args "-I${buildDir}/generated/sources/headers/java/main/"
// check if target is Windows
if (targetPlatform.operatingSystem.windows) {
// add JNI includes
cppCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include"
cppCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"
// add more linker parameters
linker.args "Shlwapi.lib", "Advapi32.lib"
}
}
}
}
}
dependencies {
}