-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
214 lines (188 loc) · 5.19 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
plugins {
id "java"
id "c"
}
sourceCompatibility = 1.6
version = '0.1'
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
repositories {
maven {
url "http://repo.bukkit.org/content/groups/public/"
}
flatDir {
dirs 'lib'
}
}
dependencies {
compile 'org.bukkit:bukkit:1.7.9-R0.2'
compile ':jnlua-0.9.6'
}
void downloadFile(String url, File dest) {
if(dest.exists()) return
print "Downloading "
println url
HttpURLConnection con = (HttpURLConnection) (new URL(url)).openConnection()
con.connect()
java.nio.file.Files.copy(con.inputStream, dest.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING)
}
void dummyFile(File dummy) {
if(dummy.exists()) return
dummy.getParentFile().mkdirs()
dummy.createNewFile()
}
dummyFile(new File("build/lib/lua-5.1.5/src/lapi.c"))
dummyFile(new File("build/lib/lua-5.1.5/src/lua.c"))
//dummyFile(new File("build/lib/jnlua-0.9.6/src/main/c/jnlua.c"))
model {
components {
lua51(NativeLibrarySpec) {
sources {
c {
source {
srcDir "build/lib/lua-5.1.5/src"
include("lapi.c", "lcode.c", "ldebug.c", "ldo.c", "ldump.c", "lfunc.c", "lgc.c", "llex.c",
"lmem.c", "lobject.c", "lopcodes.c", "lparser.c", "lstate.c", "lstring.c",
"ltable.c", "ltm.c", "lundump.c", "lvm.c", "lzio.c",
"lauxlib.c", "lbaselib.c", "ldblib.c", "liolib.c", "lmathlib.c", "loslib.c",
"ltablib.c", "lstrlib.c", "loadlib.c", "linit.c")
}
exportedHeaders {
srcDir "build/lib/lua-5.1.5/src"
include "**/*.h"
}
binaries.withType(StaticLibraryBinarySpec) { bin ->
binaries.remove(bin)
}
binaries.withType(SharedLibraryBinarySpec) { bin ->
bin.sharedLibraryFile file("build/staging/lua5.1.dll")
bin.sharedLibraryLinkFile bin.sharedLibraryFile
}
}
}
}
lua(NativeExecutableSpec) {
sources {
c {
source {
srcDir "build/lib/lua-5.1.5/src"
include "lua.c"
}
lib library: "lua51"
binaries.all { bin ->
bin.executableFile file("build/staging/lua.exe")
}
}
}
}
//jnlua51(NativeLibrarySpec) {
// sources {
// c {
// source {
// srcDir "build/lib/jnlua-0.9.6/src/main/c"
// include "jnlua.c"
// }
// exportedHeaders {
// srcDir "C:\\Program Files (x86)\\Java\\jdk1.8.0_25\\include"
// srcDir "C:\\Program Files (x86)\\Java\\jdk1.8.0_25\\include\\win32"
// srcDir "build/lib/lua-5.1.5/src"
// include "**/*.h"
// }
// lib library: "lua51"
// binaries.withType(StaticLibraryBinarySpec) { bin ->
// binaries.remove(bin)
// }
// binaries.withType(SharedLibraryBinarySpec) { bin ->
// bin.sharedLibraryFile file("build/staging/Plugins/MokaPot/jnlua5.1.dll")
// bin.sharedLibraryLinkFile bin.sharedLibraryFile
// cCompiler.define "LUA_USE_LINUX"
// }
// }
// }
//}
//javavm(NativeLibrarySpec) {
//}
mokapot(NativeLibrarySpec) {
sources {
c {
source {
srcDir "src/main/c"
include "**/*.c"
}
lib library: 'lua51'
binaries.withType(StaticLibraryBinarySpec) { bin ->
binaries.remove(bin)
}
binaries.withType(SharedLibraryBinarySpec) { bin ->
bin.sharedLibraryFile file("build/staging/Plugins/MokaPot/mokapot.dll")
bin.sharedLibraryLinkFile bin.sharedLibraryFile
}
}
}
}
}
}
task downloadLuaSource {
description "Downloads the lua source"
outputs.dir new File(buildDir, "lib/lua-5.1.5")
doLast {
File tar = new File(gradle.gradleUserHomeDir, "caches/lua-5.1.5.tar.gz")
downloadFile("http://www.lua.org/ftp/lua-5.1.5.tar.gz", tar)
copy {
from tarTree(tar)
into "build/lib"
}
}
}
/*
task downloadJnluaSource {
description "Downloads the jnlua source"
outputs.dir new File(buildDir, "lib/jnlua-0.9.6")
doLast {
File tar = new File(gradle.gradleUserHomeDir, "caches/jnlua-0.9.6.tar.gz")
downloadFile("https://github.com/airminer/jnlua/archive/0.9.6.tar.gz", tar)
copy {
from tarTree(tar)
into "build/lib"
}
}
}
*/
tasks.whenTaskAdded { task ->
if(task.name == "compileLua51SharedLibraryLua51C") task.dependsOn downloadLuaSource
//if(task.name == "compileJnlua51SharedLibraryJnlua51C") task.dependsOn downloadLuaSource
//if(task.name == "compileJnlua51SharedLibraryJnlua51C") task.dependsOn downloadJnluaSource
}
jar {
archiveName "mokapot.jar"
destinationDir file("build/staging/Plugins/MokaPot")
}
task luaScripts(type: Copy) {
description "Copies the lua scripts to the staging directory."
group "build"
from "src/main/lua"
into "build/staging/Plugins/MokaPot"
}
assemble.dependsOn luaScripts
task copyLibs(type: Copy) {
group "build"
from "lib", "natives"
exclude "**/lua*"
into "build/staging/Plugins/MokaPot"
}
assemble.dependsOn copyLibs
task runTest(type: Exec) {
dependsOn assemble
workingDir "build/staging"
commandLine "lua", "../../src/test/lua/test.lua"
}
check.dependsOn -= test
test {
dependsOn.clear()
dependsOn runTest
deleteAllActions()
description 'Runs the tests.'
}
check.dependsOn test
check.dependsOn -= testClasses