[tool][android] Allow --target-platform work properly with --debug mode (#154476)
This PR addresses an issue where the `--target-platform` flag was not being respected when building APKs in debug mode. Previously, debug builds would always include `x86` and `x64` architectures, regardless of the specified target platform. This change ensures that the `--target-platform` flag is honored across all build modes, including debug. To achieve this, `BuildApkCommand` has been slightly changed to become responsible for list of archs that should be built in the current run,rather than just parsing arguments. Previously, this responsibility was distributed to gradle, which could be frustrating (in my opinion) Fixes #153359
This commit is contained in:
committed by
GitHub
parent
6bba08cbcc
commit
0975e612c0
@@ -48,8 +48,9 @@ void main() {
|
||||
testUsingContext('indicate the default target platforms', () async {
|
||||
final String projectPath = await createProject(tempDir,
|
||||
arguments: <String>['--no-pub', '--template=app']);
|
||||
await runBuildApkCommand(projectPath);
|
||||
|
||||
// Without buildMode flag.
|
||||
await runBuildApkCommand(projectPath);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
@@ -62,6 +63,157 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await runBuildApkCommand(projectPath, arguments: <String>['--debug']);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'apk',
|
||||
commandHasTerminal: false,
|
||||
buildApkTargetPlatform: 'android-arm,android-arm64,android-x86,android-x64',
|
||||
buildApkBuildMode: 'debug',
|
||||
buildApkSplitPerAbi: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await runBuildApkCommand(projectPath, arguments: <String>['--jit-release']);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'apk',
|
||||
commandHasTerminal: false,
|
||||
buildApkTargetPlatform: 'android-arm,android-arm64,android-x86,android-x64',
|
||||
buildApkBuildMode: 'jit_release',
|
||||
buildApkSplitPerAbi: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await runBuildApkCommand(projectPath, arguments: <String>['--profile']);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'apk',
|
||||
commandHasTerminal: false,
|
||||
buildApkTargetPlatform: 'android-arm,android-arm64,android-x64',
|
||||
buildApkBuildMode: 'profile',
|
||||
buildApkSplitPerAbi: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await runBuildApkCommand(projectPath, arguments: <String>['--release']);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'apk',
|
||||
commandHasTerminal: false,
|
||||
buildApkTargetPlatform: 'android-arm,android-arm64,android-x64',
|
||||
buildApkBuildMode: 'release',
|
||||
buildApkSplitPerAbi: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidBuilder: () => FakeAndroidBuilder(),
|
||||
Analytics: () => fakeAnalytics,
|
||||
});
|
||||
|
||||
testUsingContext('Each build mode respects --target-platform', () async {
|
||||
final String projectPath = await createProject(tempDir,
|
||||
arguments: <String>['--no-pub', '--template=app']);
|
||||
|
||||
// Without buildMode flag.
|
||||
await runBuildApkCommand(
|
||||
projectPath,
|
||||
arguments: <String>['--target-platform=android-arm'],
|
||||
);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'apk',
|
||||
commandHasTerminal: false,
|
||||
buildApkTargetPlatform: 'android-arm',
|
||||
buildApkBuildMode: 'release',
|
||||
buildApkSplitPerAbi: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await runBuildApkCommand(
|
||||
projectPath,
|
||||
arguments: <String>['--debug', '--target-platform=android-arm'],
|
||||
);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'apk',
|
||||
commandHasTerminal: false,
|
||||
buildApkTargetPlatform: 'android-arm',
|
||||
buildApkBuildMode: 'debug',
|
||||
buildApkSplitPerAbi: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await runBuildApkCommand(
|
||||
projectPath,
|
||||
arguments: <String>['--release', '--target-platform=android-arm'],
|
||||
);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'apk',
|
||||
commandHasTerminal: false,
|
||||
buildApkTargetPlatform: 'android-arm',
|
||||
buildApkBuildMode: 'release',
|
||||
buildApkSplitPerAbi: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await runBuildApkCommand(
|
||||
projectPath,
|
||||
arguments: <String>['--profile', '--target-platform=android-arm'],
|
||||
);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'apk',
|
||||
commandHasTerminal: false,
|
||||
buildApkTargetPlatform: 'android-arm',
|
||||
buildApkBuildMode: 'profile',
|
||||
buildApkSplitPerAbi: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await runBuildApkCommand(
|
||||
projectPath,
|
||||
arguments: <String>['--jit-release', '--target-platform=android-arm'],
|
||||
);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'apk',
|
||||
commandHasTerminal: false,
|
||||
buildApkTargetPlatform: 'android-arm',
|
||||
buildApkBuildMode: 'jit_release',
|
||||
buildApkSplitPerAbi: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidBuilder: () => FakeAndroidBuilder(),
|
||||
Analytics: () => fakeAnalytics,
|
||||
|
||||
Reference in New Issue
Block a user