Skip to content

Commit c86bec6

Browse files
committed
Configure GitHub Actions for native
1 parent b352449 commit c86bec6

File tree

12 files changed

+539
-135
lines changed

12 files changed

+539
-135
lines changed

.github/actions/upload-build-artifacts/action.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright 2019-2022 Mamoe Technologies and contributors.
3+
*
4+
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
5+
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
6+
*
7+
* https://github.com/mamoe/mirai/blob/dev/LICENSE
8+
*/
9+
10+
val env = "\${{ env.gradleArgs }}"
11+
12+
val isUbunutu = "\${{ env.isUbuntu == 'true' }}"
13+
val isWindows = "\${{ env.isWindows == 'true' }}"
14+
val isMac = "\${{ env.isMac == 'true' }}"
15+
16+
17+
val template = """
18+
- if: CONDITION
19+
name: "Compile mirai-core-api for macosArm64"
20+
run: ./gradlew :mirai-core-api:compileKotlinMacosArm64 :mirai-core-api:compileTestKotlinMacosArm64 $env
21+
22+
- if: CONDITION
23+
name: "Link mirai-core-api for macosArm64"
24+
run: ./gradlew mirai-core-api:linkDebugTestMacosArm64 $env
25+
26+
- if: CONDITION
27+
name: "Test mirai-core-api for macosArm64"
28+
run: ./gradlew :mirai-core-api:macosArm64Test $env
29+
""".trimIndent()
30+
31+
val output = buildString {
32+
val title = "############# GENERATED FROM generate-build-native.ws.kts #############"
33+
appendLine("#".repeat(title.length))
34+
appendLine(title)
35+
appendLine("#".repeat(title.length))
36+
appendLine()
37+
38+
39+
40+
listOf("mirai-core-utils", "mirai-core-api", "mirai-core").forEach { moduleName ->
41+
appendLine(
42+
"""
43+
- name: "Commonize mirai-core-api"
44+
run: ./gradlew :mirai-core-api:commonize $env
45+
""".trimIndent().replace("mirai-core-api", moduleName)
46+
)
47+
appendLine()
48+
}
49+
50+
listOf("mirai-core-utils", "mirai-core-api", "mirai-core").forEach { moduleName ->
51+
appendLine("# $moduleName")
52+
appendLine()
53+
appendLine(
54+
"""
55+
- name: "Compile mirai-core-api for common"
56+
run: ./gradlew :mirai-core-api:compileCommonMainKotlinMetadata $env
57+
58+
- name: "Compile mirai-core-api for native"
59+
run: ./gradlew :mirai-core-api:compileNativeMainKotlinMetadata $env
60+
61+
- name: "Compile mirai-core-api for unix-like"
62+
run: ./gradlew :mirai-core-api:compileUnixMainKotlinMetadata $env
63+
""".trimIndent().replace("mirai-core-api", moduleName)
64+
)
65+
appendLine()
66+
67+
listOf("macosX64" to isMac, "mingwX64" to isWindows, "linuxX64" to isUbunutu).forEach { (target, condition) ->
68+
appendLine(useTemplate(moduleName, target, condition))
69+
appendLine()
70+
appendLine()
71+
}
72+
appendLine()
73+
}
74+
75+
this.trimEnd().let { c -> clear().appendLine(c) } // remove trailing empty lines
76+
77+
appendLine()
78+
appendLine("#".repeat(title.length))
79+
}
80+
println(output.prependIndent(" ".repeat(6)))
81+
82+
fun useTemplate(moduleName: String, target: String, condition: String) = template
83+
.replace("mirai-core-api", moduleName)
84+
.replace("macosArm64", target)
85+
.replace("MacosArm64", target.replaceFirstChar { it.uppercaseChar() })
86+
.replace("CONDITION", condition)
87+
// Link release artifacts to save memory
88+
.replace("linkDebugTestMingwX64", "linkReleaseTestMingwX64")

0 commit comments

Comments
 (0)