Skip to content

Commit c8efbd8

Browse files
authored
Only default Android release format to Aab if building with Gradle (#119)
The current `xbuild` setup does not support building AABs by hand yet, yet calling `x build --release` for an Android target still switches the output file extension to `.aab` despite being a regular APK file.
1 parent 327388c commit c8efbd8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: xbuild/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ impl std::str::FromStr for Format {
183183
}
184184

185185
impl Format {
186-
pub fn platform_default(platform: Platform, opt: Opt) -> Self {
186+
pub fn platform_default(platform: Platform, opt: Opt, gradle: bool) -> Self {
187187
match (platform, opt) {
188-
(Platform::Android, Opt::Debug) => Self::Apk,
189-
(Platform::Android, Opt::Release) => Self::Aab,
188+
(Platform::Android, Opt::Release) if gradle => Self::Aab,
189+
(Platform::Android, _) => Self::Apk,
190190
(Platform::Ios, Opt::Debug) => Self::Appbundle,
191191
(Platform::Ios, Opt::Release) => Self::Ipa,
192192
(Platform::Linux, Opt::Debug) => Self::Appdir,
@@ -410,7 +410,7 @@ pub struct BuildTargetArgs {
410410
}
411411

412412
impl BuildTargetArgs {
413-
pub fn build_target(self) -> Result<BuildTarget> {
413+
pub fn build_target(self, config: &Config) -> Result<BuildTarget> {
414414
let signer = if let Some(pem) = self.pem.as_ref() {
415415
anyhow::ensure!(pem.exists(), "pem file doesn't exist {}", pem.display());
416416
Some(Signer::from_path(pem)?)
@@ -463,7 +463,7 @@ impl BuildTargetArgs {
463463
} else if store == Some(Store::Play) {
464464
Format::Aab
465465
} else {
466-
Format::platform_default(platform, opt)
466+
Format::platform_default(platform, opt, config.android().gradle)
467467
};
468468
let provisioning_profile = if let Some(profile) = self.provisioning_profile {
469469
anyhow::ensure!(
@@ -574,12 +574,12 @@ impl BuildEnv {
574574
let verbose = args.verbose;
575575
let offline = args.cargo.offline;
576576
let cargo = args.cargo.cargo()?;
577-
let build_target = args.build_target.build_target()?;
578577
let build_dir = cargo.target_dir().join("x");
579578
let cache_dir = dirs::cache_dir().unwrap().join("x");
580579
let package = cargo.manifest().package.as_ref().unwrap(); // Caller should guarantee that this is a valid package
581580
let manifest = cargo.package_root().join("manifest.yaml");
582581
let mut config = Config::parse(manifest)?;
582+
let build_target = args.build_target.build_target(&config)?;
583583
config.apply_rust_package(package, cargo.workspace_manifest(), build_target.opt())?;
584584
let icon = config
585585
.icon(build_target.platform())

0 commit comments

Comments
 (0)