summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2025-01-24 10:44:10 +0100
committerAlbin <albin@mullvad.net>2025-01-24 10:44:10 +0100
commit7a05e4215969cdcac0a1021139c96df224940301 (patch)
treecec5f7166a62f60b33e4e36d248b1e581a1462e1
parentdfa29794bdc5e8f6211b3eaf6c5fd15a220265d2 (diff)
parent205ba4726628c440f3ab3095ecf6bb55e898e784 (diff)
downloadmullvadvpn-7a05e4215969cdcac0a1021139c96df224940301.tar.xz
mullvadvpn-7a05e4215969cdcac0a1021139c96df224940301.zip
Merge branch 'create-rustc-path-prefix-remap-script-droid-1747'
-rw-r--r--android/app/build.gradle.kts3
-rw-r--r--android/buildSrc/src/main/kotlin/Utils.kt7
-rwxr-xr-xbuilding/rustc-remap-path-prefix.sh15
3 files changed, 23 insertions, 2 deletions
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index 26db17f1bb..0e1f9ffa62 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -291,6 +291,9 @@ cargo {
add("--locked")
}
}
+ exec = { spec, _ ->
+ spec.environment("RUSTFLAGS", generateRemapArguments())
+ }
}
tasks.register<Exec>("generateRelayList") {
diff --git a/android/buildSrc/src/main/kotlin/Utils.kt b/android/buildSrc/src/main/kotlin/Utils.kt
index ffea7ce51f..af00586bea 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,6 +10,11 @@ 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")
diff --git a/building/rustc-remap-path-prefix.sh b/building/rustc-remap-path-prefix.sh
new file mode 100755
index 0000000000..0531d206e7
--- /dev/null
+++ b/building/rustc-remap-path-prefix.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+# Returns the rustc `--remap-path-prefix` flags needed to replace file paths
+# that gets put in the build artifacts with fixed values in order to make
+# the build reproducible across different machines.
+
+set -eu
+
+SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
+CARGO_HOME_PATH=${CARGO_HOME:-$HOME/.cargo}
+RUSTUP_HOME_PATH=${RUSTUP_HOME:-$HOME/.rustup}
+
+echo "--remap-path-prefix $CARGO_HOME_PATH=/CARGO_HOME \
+--remap-path-prefix $RUSTUP_HOME_PATH=/RUSTUP_HOME \
+--remap-path-prefix $SOURCE_DIR=/SOURCE_DIR"