diff options
| -rw-r--r-- | Cargo.toml | 5 | ||||
| -rw-r--r-- | android/app/build.gradle.kts | 23 | ||||
| -rw-r--r-- | android/gradle.properties | 6 |
3 files changed, 27 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml index 3254d41173..515d8de0bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,3 +152,8 @@ quinn-udp.opt-level = 3 quinn.opt-level = 3 mullvad-masque-proxy.opt-level = 3 ring.opt-level = 3 + +[profile.release-debuginfo] +inherits = "release" +debug = true +strip = false diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 63c2e477ff..470f23cd97 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -86,11 +86,6 @@ android { "proguard-rules.pro", ) } - getByName(BuildTypes.DEBUG) { - if (getBooleanProperty("mullvad.app.build.keepDebugSymbols")) { - packaging { jniLibs.keepDebugSymbols.add("**/*.so") } - } - } create(BuildTypes.FDROID) { initWith(buildTypes.getByName(BuildTypes.RELEASE)) signingConfig = null @@ -164,6 +159,9 @@ android { } packaging { + if (getBooleanProperty("mullvad.app.build.keepDebugSymbols")) { + jniLibs.keepDebugSymbols.add("**/*.so") + } jniLibs.useLegacyPackaging = true resources { pickFirsts += @@ -248,6 +246,8 @@ junitPlatform { cargo { val isReleaseBuild = isReleaseBuild() + val generateDebugSymbolsForReleaseBuilds = + getBooleanProperty("mullvad.app.build.cargo.generateDebugSymbolsForReleaseBuilds") val enableBoringTun = getBooleanProperty("mullvad.app.build.boringtun.enable") val enableApiOverride = !isReleaseBuild || isDevBuild() || isAlphaBuild() module = repoRootPath @@ -257,7 +257,7 @@ cargo { targets = getStringListProperty("mullvad.app.build.cargo.targets") profile = if (isReleaseBuild) { - "release" + if (generateDebugSymbolsForReleaseBuilds) "release-debuginfo" else "release" } else { "debug" } @@ -280,6 +280,17 @@ cargo { add("--locked") } exec = { spec, _ -> + // Due to a limitation/bug in rust-android-gradle the profile given to cargo is either + // empty (in the default debug case) or specified as `--{profile}` (in the release case). + // However, this breaks when custom profiles are used so we need to fix the broken arg here + // to use the correct `--profile={CUSTOM_PROFILE}` syntax. + spec.commandLine = + spec.commandLine.map { + if (it == "--release-debuginfo") "--profile=release-debuginfo" else it + } + + println("Executing Cargo: ${spec.commandLine.joinToString(" ")}") + if (getBooleanProperty("mullvad.app.build.replaceRustPathPrefix")) spec.environment("RUSTFLAGS", generateRemapArguments()) } diff --git a/android/gradle.properties b/android/gradle.properties index 8ea46b2cab..2f55e4e852 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -29,9 +29,13 @@ mullvad.app.build.cargo.targets=arm,arm64,x86,x86_64 # Perform a clean the cargo before each build mullvad.app.build.cargo.cleanBuild=true -# Keep debug symbols in debug builds, this will cause the debug artifacts +# If true, debug symbols are generated for release builds and not just debug builds. +mullvad.app.build.cargo.generateDebugSymbolsForReleaseBuilds=false + +# Keep debug symbols if they exist. This will cause the artifacts # to be substantially larger. mullvad.app.build.keepDebugSymbols=false + # Replace source file path prefixes in the Rust build artifacts with fixed values. # This must be set to true for the app build to be reprodcible, but should be set to false # when debugging to the Rust native libs from Android Studio. |
