Refactor BuildInfo to always require packageConfigPath (#150559)
Refactor warming up to #150196
This commit is contained in:
@@ -1163,13 +1163,18 @@ abstract class FlutterCommand extends Command<void> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns a [FlutterProject] view of the current directory or a ToolExit error,
|
||||
/// if `pubspec.yaml` or `example/pubspec.yaml` is invalid.
|
||||
FlutterProject get project => FlutterProject.current();
|
||||
|
||||
/// Compute the [BuildInfo] for the current flutter command.
|
||||
///
|
||||
/// Commands that build multiple build modes can pass in a [forcedBuildMode]
|
||||
/// to be used instead of parsing flags.
|
||||
///
|
||||
/// Throws a [ToolExit] if the current set of options is not compatible with
|
||||
/// each other.
|
||||
Future<BuildInfo> getBuildInfo({ BuildMode? forcedBuildMode, File? forcedTargetFile }) async {
|
||||
Future<BuildInfo> getBuildInfo({BuildMode? forcedBuildMode, File? forcedTargetFile}) async {
|
||||
final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation') &&
|
||||
boolArg('track-widget-creation');
|
||||
|
||||
@@ -1177,10 +1182,12 @@ abstract class FlutterCommand extends Command<void> {
|
||||
? stringArg('build-number')
|
||||
: null;
|
||||
|
||||
final File packagesFile = globals.fs.file(
|
||||
packagesPath ?? globals.fs.path.absolute('.dart_tool', 'package_config.json'));
|
||||
final File packageConfigFile = globals.fs.file(packagesPath ?? project.packageConfigFile.path);
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
packagesFile, logger: globals.logger, throwOnError: false);
|
||||
packageConfigFile,
|
||||
logger: globals.logger,
|
||||
throwOnError: false,
|
||||
);
|
||||
|
||||
final List<String> experiments =
|
||||
argParser.options.containsKey(FlutterOptions.kEnableExperiment)
|
||||
@@ -1281,12 +1288,14 @@ abstract class FlutterCommand extends Command<void> {
|
||||
|
||||
final Map<String, Object?> defineConfigJsonMap = extractDartDefineConfigJsonMap();
|
||||
final List<String> dartDefines = extractDartDefines(defineConfigJsonMap: defineConfigJsonMap);
|
||||
|
||||
final bool useCdn = !argParser.options.containsKey(FlutterOptions.kWebResourcesCdnFlag)
|
||||
|| boolArg(FlutterOptions.kWebResourcesCdnFlag);
|
||||
final bool useLocalWebSdk = argParser.options.containsKey(FlutterGlobalOptions.kLocalWebSDKOption)
|
||||
&& stringArg(FlutterGlobalOptions.kLocalWebSDKOption, global: true) != null;
|
||||
final bool useLocalCanvasKit = !useCdn || useLocalWebSdk;
|
||||
final String? defaultFlavor = FlutterProject.current().manifest.defaultFlavor;
|
||||
|
||||
final String? defaultFlavor = project.manifest.defaultFlavor;
|
||||
final String? cliFlavor = argParser.options.containsKey('flavor') ? stringArg('flavor') : null;
|
||||
final String? flavor = cliFlavor ?? defaultFlavor;
|
||||
if (flavor != null) {
|
||||
@@ -1326,7 +1335,7 @@ abstract class FlutterCommand extends Command<void> {
|
||||
bundleSkSLPath: bundleSkSLPath,
|
||||
dartExperiments: experiments,
|
||||
performanceMeasurementFile: performanceMeasurementFile,
|
||||
packagesPath: packagesPath ?? globals.fs.path.absolute('.dart_tool', 'package_config.json'),
|
||||
packageConfigPath: packagesPath ?? packageConfigFile.path,
|
||||
nullSafetyMode: nullSafetyMode,
|
||||
codeSizeDirectory: codeSizeDirectory,
|
||||
androidGradleDaemon: androidGradleDaemon,
|
||||
|
||||
Reference in New Issue
Block a user