-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle.kts
51 lines (44 loc) · 1.49 KB
/
build.gradle.kts
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
val wasmDir = layout.buildDirectory.dir("wasm")
val outputDir = layout.buildDirectory.dir("web")
val versionIndex = layout.buildDirectory.file("version_index.json")
val compileWasm = tasks.register<Exec>("compileWasm") {
commandLine("wasm-pack", "build", "--target", "web", "-d", wasmDir.get().asFile.absolutePath)
inputs.dir("src")
inputs.dir("version_resolver/src")
outputs.dir(wasmDir)
}
val generateVersionIndex = tasks.register<Exec>("generateVersionIndex") {
inputs.dir("version_resolver/src")
commandLine("cargo", "run", "-p", "version_resolver", "--", "-o", versionIndex.get().asFile.absolutePath)
outputs.file(versionIndex)
}
val buildWeb = tasks.register<Copy>("buildWeb") {
dependsOn(compileWasm, generateVersionIndex)
from(fileTree(wasmDir)) {
include("*.wasm", "*.js")
}
from(fileTree("res"))
from(fileTree("src/templates")) {
into("templates")
exclude("**/*.rs")
includeEmptyDirs = false
}
from(versionIndex)
into(outputDir)
doFirst {
delete(outputDir)
}
}
tasks.register<Exec>("runTestServer") {
outputs.upToDateWhen { false }
dependsOn(buildWeb)
commandLine("python", file("test/server.py").absolutePath, "-d", outputDir.get().asFile.absolutePath)
}
tasks.register<Sync>("refreshWebFiles") {
dependsOn(buildWeb)
from(fileTree(buildWeb.map { it.destinationDir }))
into("pages") // must match the path used in the build workflow
preserve {
include("CNAME")
}
}