forked from JetBrains/kotlin-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
72 lines (63 loc) · 2.22 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
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import org.jetbrains.kotlin.CompileCppToBitcode
// TODO: consider using some Gradle plugins to build and test
void includeRuntime(CompileCppToBitcode task) {
task.compilerArgs '-I' + project.file('../common/src/hash/headers')
task.compilerArgs '-I' + project.file('src/main/cpp')
}
targetList.each { targetName ->
task("${targetName}Runtime", type: CompileCppToBitcode) {
name "runtime"
srcRoot file('src/main')
dependsOn ":common:${targetName}Hash"
dependsOn "${targetName}Launcher"
dependsOn "${targetName}Debug"
dependsOn "${targetName}Release"
target targetName
includeRuntime(delegate)
linkerArgs project.file("../common/build/$targetName/hash.bc").path
}
task("${targetName}Launcher", type: CompileCppToBitcode) {
name "launcher"
srcRoot file('src/launcher')
target targetName
includeRuntime(delegate)
}
task ("${targetName}Debug", type: CompileCppToBitcode) {
name "debug"
srcRoot file('src/debug')
target targetName
includeRuntime(delegate)
}
task ("${targetName}Release", type: CompileCppToBitcode) {
name "release"
srcRoot file('src/release')
target targetName
includeRuntime(delegate)
}
}
task hostRuntime(dependsOn: "${hostName}Runtime")
task clean {
doLast {
delete buildDir
}
}
task generateJsMath {
dependsOn ':distCompiler'
doLast {
def jsinteropScript = isWindows() ? "jsinterop.bat" : "jsinterop"
def jsinterop = "$distDir/bin/$jsinteropScript"
def targetDir = "$buildDir/generated"
"$jsinterop -pkg kotlinx.interop.wasm.math -o $targetDir/math -target wasm32".execute().waitFor()
def generated = file("$targetDir/math-build/natives/js_stubs.js")
def mathJs = file('src/main/js/math.js')
mathJs.write("// NOTE: THIS FILE IS AUTO-GENERATED!\n" +
"// Run ':runtime:generateJsMath' to re-generate it.\n\n")
generated.withReader {
mathJs.append(it)
}
}
}