fix(shorebird_cli): use correct local-engine out dirs for Android on macOS (#3466)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:mason_logger/mason_logger.dart';
|
||||
import 'package:shorebird_cli/src/artifact_builder/artifact_builder.dart';
|
||||
import 'package:shorebird_cli/src/code_push_client_wrapper.dart';
|
||||
@@ -34,13 +35,22 @@ class AndroidReleaser extends Releaser {
|
||||
String get artifactDisplayName => 'Android app bundle';
|
||||
|
||||
/// The architectures to build for.
|
||||
Set<Arch> get architectures => (argResults['target-platform'] as List<String>)
|
||||
.map(
|
||||
(platform) => AndroidArch.availableAndroidArchs.firstWhere(
|
||||
Set<Arch> get architectures =>
|
||||
(argResults['target-platform'] as List<String>).map((platform) {
|
||||
final arch = AndroidArch.availableAndroidArchs.firstWhereOrNull(
|
||||
(arch) => arch.targetPlatformCliArg == platform,
|
||||
),
|
||||
)
|
||||
.toSet();
|
||||
);
|
||||
if (arch == null) {
|
||||
final availablePlatforms = AndroidArch.availableAndroidArchs
|
||||
.map((a) => a.targetPlatformCliArg)
|
||||
.join(', ');
|
||||
throw Exception(
|
||||
'Unknown target platform: $platform. '
|
||||
'Available platforms: $availablePlatforms',
|
||||
);
|
||||
}
|
||||
return arch;
|
||||
}).toSet();
|
||||
|
||||
/// Whether to generate an APK in addition to the AAB.
|
||||
late bool generateApk = argResults['artifact'] as String == 'apk';
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:shorebird_cli/src/abi.dart';
|
||||
import 'package:shorebird_cli/src/engine_config.dart';
|
||||
import 'package:shorebird_cli/src/platform/platform.dart';
|
||||
|
||||
@@ -39,15 +36,7 @@ extension AndroidArch on Arch {
|
||||
Arch.arm64 => 'android_release_arm64',
|
||||
Arch.x86_64 => 'android_release_x64',
|
||||
};
|
||||
// arm64 host architectures (i.e., Apple Silicon Macs) append _arm64 to the
|
||||
// base arch.
|
||||
// This check ignores linux and windows arm64 architectures, as this has
|
||||
// only been verified on Apple Silicon Macs.
|
||||
if (abi.current == Abi.macosArm64) {
|
||||
return '${baseArch}_arm64';
|
||||
} else {
|
||||
return baseArch;
|
||||
}
|
||||
return baseArch;
|
||||
}
|
||||
|
||||
/// Returns the available Android architectures.
|
||||
|
||||
@@ -130,6 +130,31 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('architectures', () {
|
||||
test('returns all architectures by default', () {
|
||||
final architectures = runWithOverrides(
|
||||
() => androidReleaser.architectures,
|
||||
);
|
||||
expect(architectures, equals(Arch.values.toSet()));
|
||||
});
|
||||
|
||||
test('throws exception when unknown platform is provided', () {
|
||||
when(
|
||||
() => argResults['target-platform'],
|
||||
).thenReturn(['android-arm', 'unknown-platform']);
|
||||
expect(
|
||||
() => runWithOverrides(() => androidReleaser.architectures),
|
||||
throwsA(
|
||||
isA<Exception>().having(
|
||||
(e) => e.toString(),
|
||||
'toString',
|
||||
contains('Unknown target platform: unknown-platform'),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('assertPreconditions', () {
|
||||
setUp(() {
|
||||
when(
|
||||
|
||||
@@ -50,7 +50,7 @@ void main() {
|
||||
setUp(() {
|
||||
when(
|
||||
() => engineConfig.localEngine,
|
||||
).thenReturn('android_release_arm64_arm64');
|
||||
).thenReturn('android_release_arm64');
|
||||
});
|
||||
|
||||
test('returns archs matching local engine arch', () async {
|
||||
@@ -123,15 +123,15 @@ void main() {
|
||||
test('returns correct path', () {
|
||||
expect(
|
||||
runWithOverrides(() => Arch.arm32.androidEnginePath),
|
||||
equals('android_release_arm64'),
|
||||
equals('android_release'),
|
||||
);
|
||||
expect(
|
||||
runWithOverrides(() => Arch.arm64.androidEnginePath),
|
||||
equals('android_release_arm64_arm64'),
|
||||
equals('android_release_arm64'),
|
||||
);
|
||||
expect(
|
||||
runWithOverrides(() => Arch.x86_64.androidEnginePath),
|
||||
equals('android_release_x64_arm64'),
|
||||
equals('android_release_x64'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user