Speed up native assets target (#134523)
Speeds up the native assets target in the backend by 1. changing other targets `gen_dart_plugin_registrant` and `release_unpack_ios` to do async I/O, 2. not reparsing the package config, and 3. not calling `dart pub deps --json` for 0 or 1 packages (fixed package:native_assets_builder). * https://github.com/flutter/flutter/issues/134427 ``` [ +2 ms] native_assets: Starting due to {} [ +2 ms] Skipping target: gen_localizations [ +1 ms] gen_dart_plugin_registrant: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents: /Users/dacoharkes/flt/engine/flutter/examples/hello_world/.dart_tool/package_config_subset} [ +33 ms] gen_dart_plugin_registrant: Complete [ +107 ms] release_unpack_ios: Complete [ +60 ms] Writing native_assets.yaml. [ +7 ms] Writing /Users/dacoharkes/flt/engine/flutter/examples/hello_world/.dart_tool/flutter_build/be2692bbfbc0b9a27fcd2422d52354c6/native_assets.yaml done. [ ] native_assets: Complete ``` -> ``` [ +4 ms] native_assets: Starting due to {} [ ] Skipping target: gen_localizations [ +1 ms] gen_dart_plugin_registrant: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents: /Users/dacoharkes/flt/engine/flutter/examples/hello_world/.dart_tool/package_config_subset} [ +31 ms] Writing native_assets.yaml. [ +8 ms] Writing /Users/dacoharkes/flt/engine/flutter/examples/hello_world/.dart_tool/flutter_build/f9451a65a465bfab70d004e21d6cc1d6/native_assets.yaml done. [ +1 ms] native_assets: Complete ``` ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
This commit is contained in:
@@ -55,11 +55,15 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('NativeAssets throws error if missing ios archs', () async {
|
||||
await createPackageConfig(iosEnvironment);
|
||||
|
||||
iosEnvironment.defines.remove(kIosArchs);
|
||||
expect(const NativeAssets().build(iosEnvironment), throwsA(isA<MissingDefineException>()));
|
||||
});
|
||||
|
||||
testUsingContext('NativeAssets throws error if missing sdk root', () async {
|
||||
await createPackageConfig(iosEnvironment);
|
||||
|
||||
iosEnvironment.defines.remove(kSdkRoot);
|
||||
expect(const NativeAssets().build(iosEnvironment), throwsA(isA<MissingDefineException>()));
|
||||
});
|
||||
@@ -78,6 +82,8 @@ void main() {
|
||||
),
|
||||
},
|
||||
() async {
|
||||
await createPackageConfig(iosEnvironment);
|
||||
|
||||
final NativeAssetsBuildRunner buildRunner = FakeNativeAssetsBuildRunner();
|
||||
await NativeAssets(buildRunner: buildRunner).build(iosEnvironment);
|
||||
|
||||
@@ -95,6 +101,8 @@ void main() {
|
||||
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
|
||||
},
|
||||
() async {
|
||||
await createPackageConfig(iosEnvironment);
|
||||
|
||||
final NativeAssetsBuildRunner buildRunner = FakeNativeAssetsBuildRunner(
|
||||
buildResult: FakeNativeAssetsBuilderResult(assets: <native_assets_cli.Asset>[
|
||||
native_assets_cli.Asset(
|
||||
@@ -138,3 +146,11 @@ void main() {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> createPackageConfig(Environment iosEnvironment) async {
|
||||
final File packageConfig = iosEnvironment.projectDir
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json');
|
||||
await packageConfig.parent.create();
|
||||
await packageConfig.create();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/dart/package_map.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/macos/native_assets.dart';
|
||||
@@ -373,7 +374,22 @@ InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault
|
||||
return;
|
||||
}
|
||||
|
||||
final NativeAssetsBuildRunner runner = NativeAssetsBuildRunnerImpl(projectUri, fileSystem, logger);
|
||||
final File packagesFile = fileSystem
|
||||
.directory(projectUri)
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json');
|
||||
await packagesFile.parent.create();
|
||||
await packagesFile.create();
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
packagesFile,
|
||||
logger: environment.logger,
|
||||
);
|
||||
final NativeAssetsBuildRunner runner = NativeAssetsBuildRunnerImpl(
|
||||
projectUri,
|
||||
packageConfig,
|
||||
fileSystem,
|
||||
logger,
|
||||
);
|
||||
final CCompilerConfig result = await runner.cCompilerConfig;
|
||||
expect(
|
||||
result.cc,
|
||||
|
||||
Reference in New Issue
Block a user