summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorKalle Lindström <karl.lindstrom@mullvad.net>2025-01-23 17:50:06 +0100
committerKalle Lindström <karl.lindstrom@mullvad.net>2025-01-23 17:50:06 +0100
commit1a58706ffd5cb0702a1ba3281fd648deb9b6501e (patch)
tree48c607aeefc99a1b06a28dd786172eb695197ede /android
parentdfa29794bdc5e8f6211b3eaf6c5fd15a220265d2 (diff)
downloadmullvadvpn-1a58706ffd5cb0702a1ba3281fd648deb9b6501e.tar.xz
mullvadvpn-1a58706ffd5cb0702a1ba3281fd648deb9b6501e.zip
Add script to generate rustc --remap-path-prefix
This is needed for reproducible builds. The script gets the file paths to the user's Cargo and Rustup home dirs, as well as the path to the Mullvad app source dir. These paths are then remapped to fixed values which is needed to make the build reproducible.
Diffstat (limited to 'android')
-rw-r--r--android/app/build.gradle.kts5
-rw-r--r--android/buildSrc/src/main/kotlin/Utils.kt26
2 files changed, 23 insertions, 8 deletions
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index 26db17f1bb..5bd78f7906 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -291,6 +291,11 @@ cargo {
add("--locked")
}
}
+ exec = { spec, _ ->
+ val remaps = generateRemapArguments()
+ println("rustc path prefix remaps: $remaps")
+ spec.environment("RUSTFLAGS", remaps)
+ }
}
tasks.register<Exec>("generateRelayList") {
diff --git a/android/buildSrc/src/main/kotlin/Utils.kt b/android/buildSrc/src/main/kotlin/Utils.kt
index ffea7ce51f..5c70b6f290 100644
--- a/android/buildSrc/src/main/kotlin/Utils.kt
+++ b/android/buildSrc/src/main/kotlin/Utils.kt
@@ -1,7 +1,5 @@
-import java.io.ByteArrayOutputStream
import java.util.*
import org.gradle.api.Project
-import org.gradle.process.ExecSpec
fun Project.generateVersionCode(localProperties: Properties): Int {
return localProperties.getProperty("OVERRIDE_VERSION_CODE")?.toIntOrNull()
@@ -12,12 +10,24 @@ fun Project.generateVersionName(localProperties: Properties): String {
return localProperties.getProperty("OVERRIDE_VERSION_NAME") ?: execVersionNameCargoCommand()
}
+fun Project.generateRemapArguments(): String {
+ val script = "${projectDir.parent}/../building/rustc-remap-path-prefix.sh"
+ return providers.exec { commandLine(script) }.standardOutput.asText.get().trim()
+}
+
private fun Project.execVersionCodeCargoCommand() =
- providers.exec {
- commandLine("cargo", "run", "-q", "--bin", "mullvad-version", "versionCode")
- }.standardOutput.asText.get().trim().toInt()
+ providers
+ .exec { commandLine("cargo", "run", "-q", "--bin", "mullvad-version", "versionCode") }
+ .standardOutput
+ .asText
+ .get()
+ .trim()
+ .toInt()
private fun Project.execVersionNameCargoCommand() =
- providers.exec {
- commandLine("cargo", "run", "-q", "--bin", "mullvad-version", "versionName")
- }.standardOutput.asText.get().trim()
+ providers
+ .exec { commandLine("cargo", "run", "-q", "--bin", "mullvad-version", "versionName") }
+ .standardOutput
+ .asText
+ .get()
+ .trim()