-
Notifications
You must be signed in to change notification settings - Fork 98
/
build.gradle
148 lines (130 loc) · 4.42 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
sourceSets.main.java.srcDirs = ["src"]
sourceSets.test.java.srcDirs = ["test"]
sourceSets.test.resources.srcDirs = ["test/resources"]
dependencies{
testImplementation libraries.junit
testImplementation aproj(":natives:natives-desktop")
}
test{
testLogging{
exceptionFormat = 'full'
showStandardStreams = true
}
}
apply plugin: "com.badlogicgames.gdx.gdx-jnigen"
file("jni").mkdir()
jnigen{
sharedLibName = "arc"
temporaryDir = file("build/target/native").absolutePath
libsDir = file("libs").absolutePath
all{
headerDirs += ["soloud/include"]
cppIncludes = ["*.cpp", "soloud/src/core/**", "soloud/src/audiosource/wav/**", "soloud/src/filter/**"]
cIncludes = ["*.c", "soloud/src/core/**", "soloud/src/audiosource/wav/**", "soloud/src/filter/**"]
}
add(Linux, x64){
cppIncludes += ["soloud/src/backend/miniaudio/*.cpp"]
cppFlags = "-DWITH_MINIAUDIO " + cppFlags
libraries += " -lpthread -lrt -lm -ldl"
}
add(Windows, x32){
cppIncludes += ["soloud/src/backend/miniaudio/*.cpp"]
cppFlags = "-msse -DWITH_MINIAUDIO " + cppFlags
}
add(Windows, x64){
cppIncludes += ["soloud/src/backend/miniaudio/*.cpp"]
cppFlags = "-msse -DWITH_MINIAUDIO " + cppFlags
}
add(Android){
linkerFlags += " -llog -lOpenSLES"
cppIncludes += ["soloud/src/backend/opensles/*.cpp"]
cppFlags = "-DWITH_OPENSLES " + cppFlags
}
add(MacOsX, x64){
cppIncludes += ["soloud/src/backend/coreaudio/*.cpp"]
cppFlags = "-std=c++11 -DWITH_COREAUDIO " + cppFlags
libraries += "-Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
}
add(MacOsX, x64, ARM){
cppIncludes += ["soloud/src/backend/coreaudio/*.cpp"]
cppFlags = "-std=c++11 -DWITH_COREAUDIO " + cppFlags.replace("x86_64", "arm64")
cFlags = cFlags.replace("x86_64", "arm64")
libraries += "-Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
linkerFlags = linkerFlags.replace("x86_64", "arm64")
}
add(IOS){
headerDirs += ["iosgl"]
cppIncludes += ["soloud/src/backend/coreaudio/*.cpp", "iosgl/**"]
cppFlags = "-stdlib=libc++ -std=c++11 -DWITH_COREAUDIO " + cppFlags
}
}
task fixWrap{
doFirst{
println "--FIXING SCRIPTS--"
copy{
from "../natives/memcpy_wrap.c"
into "jni/"
}
def f = file("$rootDir/arc-core/jni/build-linux64.xml");
if(f.exists()){
f.text = f.text.replace("-Wl,-wrap,memcpy", "-Wl,-wrap,memcpy,-wrap,pow,-wrap,powf,-wrap,log,-wrap,logf,-wrap,exp,-wrap,expf,-wrap,clock_gettime")
}
}
}
getTasksByName("jnigen", true).each{
it.finalizedBy fixWrap
}
task cleanNatives{
doLast{
delete{delete "$rootDir/arc-core/jni"}
delete{delete "$rootDir/arc-core/libs"}
delete{delete "$rootDir/arc-core/csrc/soloud"}
delete{delete "$rootDir/arc-core/csrc/stb_image.h"}
}
}
task preJni{
doFirst{
if(!file("csrc/stb_image.h").exists()){
println "Fetching stb_image source..."
//currently locked to a specific commit
"curl -o $rootDir/arc-core/csrc/stb_image.h https://raw.githubusercontent.com/nothings/stb/e140649ccf40818781b7e408f6228a486f6d254b/stb_image.h".execute().waitFor()
}
if(!file("csrc/soloud").exists()){
println "Fetching soloud source..."
"git clone --depth 1 --branch v0.11 https://github.com/Anuken/soloud.git $rootDir/arc-core/csrc/soloud".execute().waitFor()
}
copy{
from "csrc/"
into "jni/"
include "**"
}
}
}
//copies files into the right locations
task postJni{
doLast{
copy{
from "libs/linux64", "libs/windows32", "libs/windows64", "libs/macosx64"
into "../natives/natives-desktop/libs"
include "**"
}
["arm64-v8a", "x86", "x86_64", "armeabi-v7a"].each{ p ->
copy{
from "libs/$p"
into "../natives/natives-android/libs/$p/"
include "**"
}
}
[".tvos", ""].each{ p ->
copy{
from "libs/ios32/libarc.a$p"
into "../natives/natives-ios/libs/"
include "**"
}
}
}
}
jnigenBuild.finalizedBy postJni
getTasksByName("jnigen", true).each{
it.dependsOn preJni
}