Skip to content

Commit bab6fa3

Browse files
committed
Make 'rustup target add *' to Gradle tasks
Signed-off-by: Hui-Hong You <hiroshi@ghostsinthelab.org>
1 parent 152cf88 commit bab6fa3

2 files changed

Lines changed: 67 additions & 9 deletions

File tree

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ The libchewingAndroidAppModule is a byproduct of the [Guileless Bopomofo](https:
66

77
libchewingAndroidAppModule 是[樸實注音鍵盤](https://github.com/hiroshiyui/GuilelessBopomofo)專案的副產品,將[新酷音函式庫](https://github.com/chewing/libchewing)打包為 Android App Module (AAR) 格式,透過模組化途徑方便開發與元件再利用。
88

9-
# Prerequisites for Rust targets 編譯 Rust 程式碼的必備項目
10-
11-
* [rustup](https://rustup.rs/) - installer for the systems programming language Rust
12-
* `rustup target add aarch64-linux-android`
13-
* `rustup target add armv7-linux-androideabi`
14-
* `rustup target add i686-linux-android`
15-
* `rustup target add x86_64-linux-android`
16-
179
# Build 組建
1810

1911
1. `git clone --recursive https://github.com/hiroshiyui/libchewingAndroidAppModule.git`

app/build.gradle.kts

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,74 @@ android {
9999
}
100100
}
101101

102+
tasks.register<Exec>("rustupTargetAddAarch64LinuxAndroid") {
103+
onlyIf {
104+
try {
105+
val result = exec {
106+
isIgnoreExitValue = true
107+
commandLine("rustup", "-V")
108+
}
109+
result.exitValue != 0
110+
} catch (e: Exception) {
111+
return@onlyIf false
112+
}
113+
}
114+
commandLine("rustup", "target", "add", "aarch64-linux-android")
115+
}
116+
117+
tasks.register<Exec>("rustupTargetAddArmv7LinuxAndroideabi") {
118+
onlyIf {
119+
try {
120+
val result = exec {
121+
isIgnoreExitValue = true
122+
commandLine("rustup", "-V")
123+
}
124+
result.exitValue != 0
125+
} catch (e: Exception) {
126+
return@onlyIf false
127+
}
128+
}
129+
commandLine("rustup", "target", "add", "armv7-linux-androideabi")
130+
}
131+
132+
tasks.register<Exec>("rustupTargetAddI686LinuxAndroid") {
133+
onlyIf {
134+
try {
135+
val result = exec {
136+
isIgnoreExitValue = true
137+
commandLine("rustup", "-V")
138+
}
139+
result.exitValue != 0
140+
} catch (e: Exception) {
141+
return@onlyIf false
142+
}
143+
}
144+
commandLine("rustup", "target", "add", "i686-linux-android")
145+
}
146+
147+
tasks.register<Exec>("rustupTargetAddX64LinuxAndroid") {
148+
onlyIf {
149+
try {
150+
val result = exec {
151+
isIgnoreExitValue = true
152+
commandLine("rustup", "-V")
153+
}
154+
result.exitValue != 0
155+
} catch (e: Exception) {
156+
return@onlyIf false
157+
}
158+
}
159+
commandLine("rustup", "target", "add", "x86_64-linux-android")
160+
}
161+
102162
tasks.preBuild {
103-
dependsOn("copyChewingDataFiles")
163+
dependsOn(
164+
"copyChewingDataFiles",
165+
"rustupTargetAddAarch64LinuxAndroid",
166+
"rustupTargetAddArmv7LinuxAndroideabi",
167+
"rustupTargetAddI686LinuxAndroid",
168+
"rustupTargetAddX64LinuxAndroid"
169+
)
104170
}
105171

106172
tasks.register<Delete>("cleanChewingDataFiles") {

0 commit comments

Comments
 (0)