Skip to content

Commit e0a4141

Browse files
committed
Add --build-id to the linker flags
1 parent c24dfbd commit e0a4141

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ cargo {
341341
}
342342
```
343343

344+
### generateBuildId
345+
346+
Generate a build-id for the shared library during the link phase.
347+
344348
### exec
345349

346350
This is a callback taking the `ExecSpec` we're going to use to invoke `cargo build`, and

plugin/src/main/kotlin/com/nishtahir/CargoBuildTask.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ open class CargoBuildTask : DefaultTask() {
228228
environment("RUST_ANDROID_GRADLE_LINKER_WRAPPER_PY",
229229
File(project.rootProject.buildDir, "linker-wrapper/linker-wrapper.py").path)
230230
environment("RUST_ANDROID_GRADLE_CC", cc)
231-
environment("RUST_ANDROID_GRADLE_CC_LINK_ARG", "-Wl,-soname,lib${cargoExtension.libname!!}.so")
231+
if (cargoExtension.generateBuildId) {
232+
environment("RUST_ANDROID_GRADLE_CC_LINK_ARG", "-Wl,--build-id,-soname,lib${cargoExtension.libname!!}.so")
233+
} else {
234+
environment("RUST_ANDROID_GRADLE_CC_LINK_ARG", "-Wl,-soname,lib${cargoExtension.libname!!}.so")
235+
}
232236
}
233237

234238
cargoExtension.extraCargoBuildArguments?.let {

plugin/src/main/kotlin/com/nishtahir/CargoExtension.kt

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ open class CargoExtension {
4444
var apiLevel: Int? = null
4545
var apiLevels: Map<String, Int> = mapOf()
4646
var extraCargoBuildArguments: List<String>? = null
47+
var generateBuildId: Boolean = false
4748

4849
// It would be nice to use a receiver here, but there are problems interoperating with Groovy
4950
// and Kotlin that are just not worth working out. Another JVM language, yet another dynamic

0 commit comments

Comments
 (0)