mach: Android: Support custom profiles (#39982)

Use Release mode for gradle for production builds and Debug for any
other builds.
This fixes an exception when building for android with a custom cargo
profile.
`SERVO_TARGET_DIR` is read in `apk/jni/Android.mk` and specifies the
folder
libservoshell.so is expected to be in.

Testing: Tested manually with `./mach build --android --production`
Fixes: #34564

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com>
This commit is contained in:
Jonathan Schwender
2025-10-20 19:00:00 +02:00
committed by GitHub
parent 76bb1c80f8
commit 205b049fcd
3 changed files with 12 additions and 4 deletions

View File

@@ -77,7 +77,7 @@ class BuildType:
return self.kind == BuildType.Kind.RELEASE
def is_prod(self) -> bool:
return self.kind == BuildType.Kind.CUSTOM and self.profile == "production"
return self.is_custom() and (self.profile in ["production", "production-stripped"])
def is_custom(self) -> bool:
return self.kind == BuildType.Kind.CUSTOM

View File

@@ -136,10 +136,14 @@ class PackageCommands(CommandBase):
if build_type.is_dev():
build_type_string = "Debug"
elif build_type.is_release():
elif build_type.is_release() or build_type.is_prod():
build_type_string = "Release"
else:
raise Exception("TODO what should this be?")
print(f"Servo was built with custom cargo profile `{build_type.profile}`.")
print("Using Debug build for gradle.")
build_type_string = "Debug"
# Inform the android build of where `libservoshell.so` is located.
env["SERVO_TARGET_DIR"] = target_dir
flavor_name = "Basic"
if flavor is not None: