mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] Clean up build_aot code post assemble migration (#48771)
This commit is contained in:
parent
8092f6a2b6
commit
63c65e5cdb
@ -38,9 +38,13 @@ class AotBuilder {
|
|||||||
if (platform == null) {
|
if (platform == null) {
|
||||||
throwToolExit('No AOT build platform specified');
|
throwToolExit('No AOT build platform specified');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This code is currently dead, but will be updated as we move iOS to assemble.
|
||||||
|
// See also: https://github.com/flutter/flutter/issues/32925
|
||||||
if (_canUseAssemble(platform)
|
if (_canUseAssemble(platform)
|
||||||
&& extraGenSnapshotOptions?.isEmpty != false
|
&& extraGenSnapshotOptions?.isEmpty != false
|
||||||
&& extraFrontEndOptions?.isEmpty != false) {
|
&& extraFrontEndOptions?.isEmpty != false) {
|
||||||
|
assert(false);
|
||||||
await _buildWithAssemble(
|
await _buildWithAssemble(
|
||||||
targetFile: mainDartFile,
|
targetFile: mainDartFile,
|
||||||
outputDir: outputPath,
|
outputDir: outputPath,
|
||||||
@ -175,7 +179,6 @@ class AotBuilder {
|
|||||||
case TargetPlatform.android_arm64:
|
case TargetPlatform.android_arm64:
|
||||||
case TargetPlatform.android_x86:
|
case TargetPlatform.android_x86:
|
||||||
case TargetPlatform.darwin_x64:
|
case TargetPlatform.darwin_x64:
|
||||||
return true;
|
|
||||||
case TargetPlatform.android_x64:
|
case TargetPlatform.android_x64:
|
||||||
case TargetPlatform.ios:
|
case TargetPlatform.ios:
|
||||||
case TargetPlatform.linux_x64:
|
case TargetPlatform.linux_x64:
|
||||||
@ -196,6 +199,9 @@ class AotBuilder {
|
|||||||
String outputDir,
|
String outputDir,
|
||||||
bool quiet
|
bool quiet
|
||||||
}) async {
|
}) async {
|
||||||
|
// This code is currently dead, but will be updated as we move iOS to assemble.
|
||||||
|
// See also: https://github.com/flutter/flutter/issues/32925
|
||||||
|
assert(false);
|
||||||
Status status;
|
Status status;
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
final String typeName = globals.artifacts.getEngineType(targetPlatform, buildMode);
|
final String typeName = globals.artifacts.getEngineType(targetPlatform, buildMode);
|
||||||
@ -205,10 +211,7 @@ class AotBuilder {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
final FlutterProject flutterProject = FlutterProject.current();
|
final FlutterProject flutterProject = FlutterProject.current();
|
||||||
// Currently this only supports android, per the check above.
|
const Target target = null;
|
||||||
final Target target = buildMode == BuildMode.profile
|
|
||||||
? const ProfileCopyFlutterAotBundle()
|
|
||||||
: const ReleaseCopyFlutterAotBundle();
|
|
||||||
|
|
||||||
final BuildResult result = await buildSystem.build(target, Environment.test(
|
final BuildResult result = await buildSystem.build(target, Environment.test(
|
||||||
flutterProject.directory,
|
flutterProject.directory,
|
||||||
|
@ -359,32 +359,6 @@ abstract class CopyFlutterAotBundle extends Target {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a one-off rule for implementing build aot in terms of assemble.
|
|
||||||
class ProfileCopyFlutterAotBundle extends CopyFlutterAotBundle {
|
|
||||||
const ProfileCopyFlutterAotBundle();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get name => 'profile_android_flutter_bundle';
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Target> get dependencies => const <Target>[
|
|
||||||
AotElfProfile(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a one-off rule for implementing build aot in terms of assemble.
|
|
||||||
class ReleaseCopyFlutterAotBundle extends CopyFlutterAotBundle {
|
|
||||||
const ReleaseCopyFlutterAotBundle();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get name => 'release_android_flutter_bundle';
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Target> get dependencies => const <Target>[
|
|
||||||
AotElfRelease(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Dart defines are encoded inside [Environment] as a JSON array.
|
/// Dart defines are encoded inside [Environment] as a JSON array.
|
||||||
List<String> parseDartDefines(Environment environment) {
|
List<String> parseDartDefines(Environment environment) {
|
||||||
if (!environment.defines.containsKey(kDartDefines)) {
|
if (!environment.defines.containsKey(kDartDefines)) {
|
||||||
|
@ -41,9 +41,7 @@ const List<Target> _kDefaultTargets = <Target>[
|
|||||||
FastStartAndroidApplication(),
|
FastStartAndroidApplication(),
|
||||||
ProfileAndroidApplication(),
|
ProfileAndroidApplication(),
|
||||||
ReleaseAndroidApplication(),
|
ReleaseAndroidApplication(),
|
||||||
// These are one-off rules for bundle and aot compat
|
// This is a one-off rule for bundle and aot compat.
|
||||||
ReleaseCopyFlutterAotBundle(),
|
|
||||||
ProfileCopyFlutterAotBundle(),
|
|
||||||
CopyFlutterBundle(),
|
CopyFlutterBundle(),
|
||||||
// Android ABI specific AOT rules.
|
// Android ABI specific AOT rules.
|
||||||
androidArmProfileBundle,
|
androidArmProfileBundle,
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
|
||||||
import 'package:flutter_tools/src/build_system/targets/dart.dart';
|
|
||||||
import 'package:flutter_tools/src/cache.dart';
|
|
||||||
import 'package:flutter_tools/src/commands/build.dart';
|
|
||||||
import 'package:mockito/mockito.dart';
|
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
|
|
||||||
import '../../src/common.dart';
|
|
||||||
import '../../src/mocks.dart';
|
|
||||||
import '../../src/testbed.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
Testbed testbed;
|
|
||||||
|
|
||||||
setUpAll(() {
|
|
||||||
Cache.disableLocking();
|
|
||||||
});
|
|
||||||
|
|
||||||
tearDownAll(() {
|
|
||||||
Cache.enableLocking();
|
|
||||||
});
|
|
||||||
|
|
||||||
setUp(() {
|
|
||||||
testbed = Testbed(overrides: <Type, Generator>{
|
|
||||||
BuildSystem: () => MockBuildSystem(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('invokes assemble for android aot build.', () => testbed.run(() async {
|
|
||||||
globals.fs.file('pubspec.yaml').createSync();
|
|
||||||
globals.fs.file('.packages').createSync();
|
|
||||||
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
|
|
||||||
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
|
|
||||||
return BuildResult(success: true);
|
|
||||||
});
|
|
||||||
final BuildCommand command = BuildCommand();
|
|
||||||
applyMocksToCommand(command);
|
|
||||||
|
|
||||||
await createTestCommandRunner(command).run(<String>[
|
|
||||||
'build',
|
|
||||||
'aot',
|
|
||||||
'--target-platform=android-arm',
|
|
||||||
'--no-pub',
|
|
||||||
]);
|
|
||||||
|
|
||||||
final Environment environment = verify(buildSystem.build(any, captureAny)).captured.single as Environment;
|
|
||||||
expect(environment.defines, <String, String>{
|
|
||||||
kTargetFile: globals.fs.path.absolute(globals.fs.path.join('lib', 'main.dart')),
|
|
||||||
kBuildMode: 'release',
|
|
||||||
kTargetPlatform: 'android-arm',
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockBuildSystem extends Mock implements BuildSystem {}
|
|
@ -404,14 +404,6 @@ flutter_tools:lib/''');
|
|||||||
ProcessManager: () => mockProcessManager,
|
ProcessManager: () => mockProcessManager,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('Profile/ReleaseCopyFlutterAotBundle copies .so to correct output directory', () => testbed.run(() async {
|
|
||||||
androidEnvironment.buildDir.createSync(recursive: true);
|
|
||||||
androidEnvironment.buildDir.childFile('app.so').createSync();
|
|
||||||
await const ProfileCopyFlutterAotBundle().build(androidEnvironment);
|
|
||||||
|
|
||||||
expect(androidEnvironment.outputDir.childFile('app.so').existsSync(), true);
|
|
||||||
}));
|
|
||||||
|
|
||||||
test('kExtraGenSnapshotOptions passes values to gen_snapshot', () => testbed.run(() async {
|
test('kExtraGenSnapshotOptions passes values to gen_snapshot', () => testbed.run(() async {
|
||||||
androidEnvironment.defines[kExtraGenSnapshotOptions] = 'foo,bar,baz=2';
|
androidEnvironment.defines[kExtraGenSnapshotOptions] = 'foo,bar,baz=2';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user