Refactor BuildInfo to always require packageConfigPath (#150559)
Refactor warming up to #150196
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'package:package_config/package_config_types.dart';
|
||||
|
||||
import 'artifacts.dart';
|
||||
@@ -37,7 +39,7 @@ class BuildInfo {
|
||||
List<String>? dartExperiments,
|
||||
required this.treeShakeIcons,
|
||||
this.performanceMeasurementFile,
|
||||
this.packagesPath = '.dart_tool/package_config.json', // TODO(zanderso): make this required and remove the default.
|
||||
required this.packageConfigPath,
|
||||
this.nullSafetyMode = NullSafetyMode.sound,
|
||||
this.codeSizeDirectory,
|
||||
this.androidGradleDaemon = true,
|
||||
@@ -75,7 +77,7 @@ class BuildInfo {
|
||||
///
|
||||
/// This is used by package:package_config to locate the actual package_config.json
|
||||
/// file. If not provided, defaults to `.dart_tool/package_config.json`.
|
||||
final String packagesPath;
|
||||
final String packageConfigPath;
|
||||
|
||||
final List<String> fileSystemRoots;
|
||||
final String? fileSystemScheme;
|
||||
@@ -184,10 +186,47 @@ class BuildInfo {
|
||||
/// If set, web builds will use the locally built CanvasKit instead of using the CDN
|
||||
final bool useLocalCanvasKit;
|
||||
|
||||
static const BuildInfo debug = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, treeShakeIcons: false);
|
||||
static const BuildInfo profile = BuildInfo(BuildMode.profile, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
|
||||
static const BuildInfo jitRelease = BuildInfo(BuildMode.jitRelease, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
|
||||
static const BuildInfo release = BuildInfo(BuildMode.release, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
|
||||
/// Can be used when the actual information is not needed.
|
||||
static const BuildInfo dummy = BuildInfo(
|
||||
BuildMode.debug,
|
||||
null,
|
||||
trackWidgetCreation: true,
|
||||
treeShakeIcons: false,
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
|
||||
@visibleForTesting
|
||||
static const BuildInfo debug = BuildInfo(
|
||||
BuildMode.debug,
|
||||
null,
|
||||
trackWidgetCreation: true,
|
||||
treeShakeIcons: false,
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
|
||||
@visibleForTesting
|
||||
static const BuildInfo profile = BuildInfo(
|
||||
BuildMode.profile,
|
||||
null,
|
||||
treeShakeIcons: kIconTreeShakerEnabledDefault,
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
|
||||
@visibleForTesting
|
||||
static const BuildInfo jitRelease = BuildInfo(
|
||||
BuildMode.jitRelease,
|
||||
null,
|
||||
treeShakeIcons: kIconTreeShakerEnabledDefault,
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
|
||||
@visibleForTesting
|
||||
static const BuildInfo release = BuildInfo(
|
||||
BuildMode.release,
|
||||
null,
|
||||
treeShakeIcons: kIconTreeShakerEnabledDefault,
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
);
|
||||
|
||||
/// Returns whether a debug build is requested.
|
||||
///
|
||||
@@ -293,7 +332,7 @@ class BuildInfo {
|
||||
'PERFORMANCE_MEASUREMENT_FILE': performanceMeasurementFile!,
|
||||
if (bundleSkSLPath != null)
|
||||
'BUNDLE_SKSL_PATH': bundleSkSLPath!,
|
||||
'PACKAGE_CONFIG': packagesPath,
|
||||
'PACKAGE_CONFIG': packageConfigPath,
|
||||
if (codeSizeDirectory != null)
|
||||
'CODE_SIZE_DIRECTORY': codeSizeDirectory!,
|
||||
if (flavor != null)
|
||||
|
||||
@@ -78,6 +78,7 @@ class BuildAarCommand extends BuildSubCommand {
|
||||
DevelopmentArtifact.androidGenSnapshot,
|
||||
};
|
||||
|
||||
@override
|
||||
late final FlutterProject project = _getProject();
|
||||
|
||||
@override
|
||||
@@ -196,7 +197,7 @@ class BuildAarCommand extends BuildSubCommand {
|
||||
FlutterProject _getProject() {
|
||||
final List<String> remainingArguments = argResults!.rest;
|
||||
if (remainingArguments.isEmpty) {
|
||||
return FlutterProject.current();
|
||||
return super.project;
|
||||
}
|
||||
final File mainFile = _fileSystem.file(remainingArguments.first);
|
||||
final String path;
|
||||
|
||||
@@ -137,7 +137,6 @@ class BuildAppBundleCommand extends BuildSubCommand {
|
||||
if (globals.androidSdk == null) {
|
||||
exitWithNoSdkMessage();
|
||||
}
|
||||
|
||||
final AndroidBuildInfo androidBuildInfo = AndroidBuildInfo(await getBuildInfo(),
|
||||
targetArchs: stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName),
|
||||
);
|
||||
@@ -146,7 +145,7 @@ class BuildAppBundleCommand extends BuildSubCommand {
|
||||
final List<DeferredComponent>? deferredComponents = FlutterProject.current().manifest.deferredComponents;
|
||||
if (deferredComponents != null && boolArg('deferred-components') && boolArg('validate-deferred-components') && !boolArg('debug')) {
|
||||
final DeferredComponentsPrebuildValidator validator = DeferredComponentsPrebuildValidator(
|
||||
FlutterProject.current().directory,
|
||||
project.directory,
|
||||
globals.logger,
|
||||
globals.platform,
|
||||
title: 'Deferred components prebuild validation',
|
||||
@@ -160,7 +159,7 @@ class BuildAppBundleCommand extends BuildSubCommand {
|
||||
// Delete intermediates libs dir for components to resolve mismatching
|
||||
// abis supported by base and dynamic feature modules.
|
||||
for (final DeferredComponent component in deferredComponents) {
|
||||
final Directory deferredLibsIntermediate = FlutterProject.current().directory
|
||||
final Directory deferredLibsIntermediate = project.directory
|
||||
.childDirectory('build')
|
||||
.childDirectory(component.name)
|
||||
.childDirectory('intermediates')
|
||||
@@ -177,7 +176,7 @@ class BuildAppBundleCommand extends BuildSubCommand {
|
||||
displayNullSafetyMode(androidBuildInfo.buildInfo);
|
||||
globals.terminal.usesTerminalUi = true;
|
||||
await androidBuilder?.buildAab(
|
||||
project: FlutterProject.current(),
|
||||
project: project,
|
||||
target: targetFile,
|
||||
androidBuildInfo: androidBuildInfo,
|
||||
validateDeferredComponents: boolArg('validate-deferred-components'),
|
||||
|
||||
@@ -20,7 +20,6 @@ import '../cache.dart';
|
||||
import '../flutter_plugins.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../macos/cocoapod_utils.dart';
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart' show DevelopmentArtifact, FlutterCommandResult;
|
||||
import '../version.dart';
|
||||
import 'build.dart';
|
||||
@@ -108,9 +107,6 @@ abstract class BuildFrameworkCommand extends BuildSubCommand {
|
||||
@override
|
||||
bool get reportNullSafety => false;
|
||||
|
||||
@protected
|
||||
late final FlutterProject project = FlutterProject.current();
|
||||
|
||||
Future<List<BuildInfo>> getBuildInfos() async {
|
||||
return <BuildInfo>[
|
||||
if (boolArg('debug')) await getBuildInfo(forcedBuildMode: BuildMode.debug),
|
||||
|
||||
@@ -12,7 +12,6 @@ import '../cache.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../linux/build_linux.dart';
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart' show FlutterCommandResult;
|
||||
import 'build.dart';
|
||||
|
||||
@@ -60,7 +59,6 @@ class BuildLinuxCommand extends BuildSubCommand {
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
final TargetPlatform targetPlatform =
|
||||
getTargetPlatformForName(stringArg('target-platform')!);
|
||||
final bool needCrossBuild =
|
||||
@@ -87,7 +85,7 @@ class BuildLinuxCommand extends BuildSubCommand {
|
||||
displayNullSafetyMode(buildInfo);
|
||||
final Logger logger = globals.logger;
|
||||
await buildLinux(
|
||||
flutterProject.linux,
|
||||
project.linux,
|
||||
buildInfo,
|
||||
target: targetFile,
|
||||
sizeAnalyzer: SizeAnalyzer(
|
||||
|
||||
@@ -9,7 +9,6 @@ import '../cache.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../macos/build_macos.dart';
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart' show FlutterCommandResult;
|
||||
import 'build.dart';
|
||||
|
||||
@@ -51,7 +50,6 @@ class BuildMacosCommand extends BuildSubCommand {
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
if (!featureFlags.isMacOSEnabled) {
|
||||
throwToolExit('"build macos" is not currently supported. To enable, run "flutter config --enable-macos-desktop".');
|
||||
}
|
||||
@@ -60,7 +58,7 @@ class BuildMacosCommand extends BuildSubCommand {
|
||||
}
|
||||
displayNullSafetyMode(buildInfo);
|
||||
await buildMacOS(
|
||||
flutterProject: flutterProject,
|
||||
flutterProject: project,
|
||||
buildInfo: buildInfo,
|
||||
targetOverride: targetFile,
|
||||
verboseLogging: globals.logger.isVerbose,
|
||||
|
||||
@@ -10,6 +10,7 @@ import '../base/io.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_info.dart';
|
||||
import '../cache.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart' show FlutterCommandResult;
|
||||
@@ -45,13 +46,6 @@ class BuildPreviewCommand extends BuildSubCommand {
|
||||
final ProcessUtils processUtils;
|
||||
final Artifacts artifacts;
|
||||
|
||||
static const BuildInfo buildInfo = BuildInfo(
|
||||
BuildMode.debug,
|
||||
null, // no flavor
|
||||
// users may add icons later
|
||||
treeShakeIcons: false,
|
||||
);
|
||||
|
||||
@override
|
||||
void requiresPubspecYaml() {}
|
||||
|
||||
@@ -65,6 +59,19 @@ class BuildPreviewCommand extends BuildSubCommand {
|
||||
final Directory targetDir = fs.systemTempDirectory.createTempSync('flutter-build-preview');
|
||||
try {
|
||||
final FlutterProject flutterProject = await _createProject(targetDir);
|
||||
|
||||
final BuildInfo buildInfo = BuildInfo(
|
||||
BuildMode.debug,
|
||||
null, // no flavor
|
||||
// users may add icons later
|
||||
packageConfigPath: flutterProject.packageConfigFile.path,
|
||||
packageConfig: await loadPackageConfigWithLogging(
|
||||
flutterProject.packageConfigFile,
|
||||
logger: logger,
|
||||
),
|
||||
treeShakeIcons: false,
|
||||
);
|
||||
|
||||
// TODO(loic-sharma): Support windows-arm64 preview device, https://github.com/flutter/flutter/issues/139949.
|
||||
await buildWindows(
|
||||
flutterProject.windows,
|
||||
|
||||
@@ -8,7 +8,6 @@ import '../base/utils.dart';
|
||||
import '../build_info.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart'
|
||||
show DevelopmentArtifact, FlutterCommandResult, FlutterOptions;
|
||||
import '../web/compile.dart';
|
||||
@@ -184,7 +183,6 @@ class BuildWebCommand extends BuildSubCommand {
|
||||
)];
|
||||
}
|
||||
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
final String target = stringArg('target')!;
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
if (buildInfo.isDebug) {
|
||||
@@ -197,7 +195,7 @@ class BuildWebCommand extends BuildSubCommand {
|
||||
'--base-href should start and end with /',
|
||||
);
|
||||
}
|
||||
if (!flutterProject.web.existsSync()) {
|
||||
if (!project.web.existsSync()) {
|
||||
throwToolExit('Missing index.html.');
|
||||
}
|
||||
if (!_fileSystem.currentDirectory
|
||||
@@ -227,7 +225,7 @@ class BuildWebCommand extends BuildSubCommand {
|
||||
analytics: globals.analytics,
|
||||
);
|
||||
await webBuilder.buildWeb(
|
||||
flutterProject,
|
||||
project,
|
||||
target,
|
||||
buildInfo,
|
||||
ServiceWorkerStrategy.fromCliName(stringArg('pwa-strategy')),
|
||||
|
||||
@@ -11,7 +11,6 @@ import '../build_info.dart';
|
||||
import '../cache.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart' show FlutterCommandResult;
|
||||
import '../windows/build_windows.dart';
|
||||
import '../windows/visual_studio.dart';
|
||||
@@ -49,7 +48,6 @@ class BuildWindowsCommand extends BuildSubCommand {
|
||||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
if (!featureFlags.isWindowsEnabled) {
|
||||
throwToolExit('"build windows" is not currently supported. To enable, run "flutter config --enable-windows-desktop".');
|
||||
@@ -64,7 +62,7 @@ class BuildWindowsCommand extends BuildSubCommand {
|
||||
|
||||
displayNullSafetyMode(buildInfo);
|
||||
await buildWindows(
|
||||
flutterProject.windows,
|
||||
project.windows,
|
||||
buildInfo,
|
||||
targetPlatform,
|
||||
target: targetFile,
|
||||
|
||||
@@ -1190,7 +1190,7 @@ class DeviceDomain extends Domain {
|
||||
debuggingOptions: DebuggingOptions.fromJson(
|
||||
castStringKeyedMap(args['debuggingOptions'])!,
|
||||
// We are using prebuilts, build info does not matter here.
|
||||
BuildInfo.debug,
|
||||
BuildInfo.dummy,
|
||||
),
|
||||
mainPath: _getStringArg(args, 'mainPath'),
|
||||
route: _getStringArg(args, 'route'),
|
||||
|
||||
@@ -593,7 +593,7 @@ class RunCommand extends RunCommandBase {
|
||||
runTargetName: deviceType,
|
||||
runTargetOsVersion: deviceOsVersion,
|
||||
runModeName: modeName,
|
||||
runProjectModule: FlutterProject.current().isModule,
|
||||
runProjectModule: project.isModule,
|
||||
runProjectHostLanguage: hostLanguage.join(','),
|
||||
runAndroidEmbeddingVersion: androidEmbeddingVersion,
|
||||
runEnableImpeller: enableImpeller.asBool,
|
||||
@@ -753,9 +753,9 @@ class RunCommand extends RunCommandBase {
|
||||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
// Enable hot mode by default if `--no-hot` was not passed and we are in
|
||||
// debug mode.
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
final bool hotMode = shouldUseHotMode(buildInfo);
|
||||
final String? applicationBinaryPath = stringArg(FlutterOptions.kUseApplicationBinary);
|
||||
|
||||
@@ -817,7 +817,6 @@ class RunCommand extends RunCommandBase {
|
||||
stringsArg(FlutterOptions.kEnableExperiment).isNotEmpty) {
|
||||
expFlags = stringsArg(FlutterOptions.kEnableExperiment);
|
||||
}
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
final List<FlutterDevice> flutterDevices = <FlutterDevice>[
|
||||
for (final Device device in devices!)
|
||||
await FlutterDevice.create(
|
||||
@@ -833,7 +832,7 @@ class RunCommand extends RunCommandBase {
|
||||
final ResidentRunner runner = await createRunner(
|
||||
applicationBinaryPath: applicationBinaryPath,
|
||||
flutterDevices: flutterDevices,
|
||||
flutterProject: flutterProject,
|
||||
flutterProject: project,
|
||||
hotMode: hotMode,
|
||||
);
|
||||
|
||||
|
||||
@@ -505,8 +505,8 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
collector = CoverageCollector(
|
||||
verbose: !machine,
|
||||
libraryNames: packagesToInclude,
|
||||
packagesPath: buildInfo.packagesPath,
|
||||
resolver: await CoverageCollector.getResolver(buildInfo.packagesPath),
|
||||
packagesPath: buildInfo.packageConfigPath,
|
||||
resolver: await CoverageCollector.getResolver(buildInfo.packageConfigPath),
|
||||
testTimeRecorder: testTimeRecorder,
|
||||
branchCoverage: boolArg('branch-coverage'),
|
||||
);
|
||||
|
||||
@@ -21,15 +21,17 @@ class FuchsiaKernelCompiler {
|
||||
Future<void> build({
|
||||
required FuchsiaProject fuchsiaProject,
|
||||
required String target, // E.g., lib/main.dart
|
||||
BuildInfo buildInfo = BuildInfo.debug,
|
||||
BuildInfo buildInfo = BuildInfo.dummy,
|
||||
}) async {
|
||||
// TODO(zanderso): Use filesystem root and scheme information from buildInfo.
|
||||
const String multiRootScheme = 'main-root';
|
||||
final String packagesFile = fuchsiaProject.project.packagesFile.path;
|
||||
final String outDir = getFuchsiaBuildDirectory();
|
||||
final String appName = fuchsiaProject.project.manifest.appName;
|
||||
final String fsRoot = fuchsiaProject.project.directory.path;
|
||||
final String relativePackagesFile = globals.fs.path.relative(packagesFile, from: fsRoot);
|
||||
final String relativePackageConfigPath = globals.fs.path.relative(
|
||||
buildInfo.packageConfigPath,
|
||||
from: fsRoot,
|
||||
);
|
||||
final String manifestPath = globals.fs.path.join(outDir, '$appName.dilpmanifest');
|
||||
final String? kernelCompiler = globals.artifacts?.getArtifactPath(
|
||||
Artifact.fuchsiaKernelCompiler,
|
||||
@@ -58,7 +60,7 @@ class FuchsiaKernelCompiler {
|
||||
'--filesystem-root',
|
||||
fsRoot,
|
||||
'--packages',
|
||||
'$multiRootScheme:///$relativePackagesFile',
|
||||
'$multiRootScheme:///$relativePackageConfigPath',
|
||||
'--output',
|
||||
globals.fs.path.join(outDir, '$appName.dil'),
|
||||
'--component-name',
|
||||
|
||||
@@ -559,7 +559,7 @@ Please provide a valid TCP port (an integer between 0 and 65535, inclusive).
|
||||
if (rebuildBundle) {
|
||||
_logger.printTrace('Updating assets');
|
||||
final int result = await assetBundle.build(
|
||||
packagesPath: debuggingOptions.buildInfo.packagesPath,
|
||||
packagesPath: debuggingOptions.buildInfo.packageConfigPath,
|
||||
targetPlatform: TargetPlatform.web_javascript,
|
||||
);
|
||||
if (result != 0) {
|
||||
|
||||
@@ -64,7 +64,7 @@ class FlutterDevice {
|
||||
fileSystemScheme: buildInfo.fileSystemScheme,
|
||||
targetModel: targetModel,
|
||||
dartDefines: buildInfo.dartDefines,
|
||||
packagesPath: buildInfo.packagesPath,
|
||||
packagesPath: buildInfo.packageConfigPath,
|
||||
frontendServerStarterPath: buildInfo.frontendServerStarterPath,
|
||||
extraFrontEndOptions: buildInfo.extraFrontEndOptions,
|
||||
artifacts: globals.artifacts!,
|
||||
@@ -164,7 +164,7 @@ class FlutterDevice {
|
||||
dartDefines: buildInfo.dartDefines,
|
||||
librariesSpec: globals.fs.file(globals.artifacts!
|
||||
.getHostArtifact(HostArtifact.flutterWebLibrariesJson)).uri.toString(),
|
||||
packagesPath: buildInfo.packagesPath,
|
||||
packagesPath: buildInfo.packageConfigPath,
|
||||
artifacts: globals.artifacts!,
|
||||
processManager: globals.processManager,
|
||||
logger: globals.logger,
|
||||
@@ -197,7 +197,7 @@ class FlutterDevice {
|
||||
extraFrontEndOptions: extraFrontEndOptions,
|
||||
),
|
||||
assumeInitializeFromDillUpToDate: buildInfo.assumeInitializeFromDillUpToDate,
|
||||
packagesPath: buildInfo.packagesPath,
|
||||
packagesPath: buildInfo.packageConfigPath,
|
||||
artifacts: globals.artifacts!,
|
||||
processManager: globals.processManager,
|
||||
logger: globals.logger,
|
||||
@@ -1103,7 +1103,7 @@ abstract class ResidentRunner extends ResidentHandlers {
|
||||
this.machine = false,
|
||||
ResidentDevtoolsHandlerFactory devtoolsHandler = createDefaultHandler,
|
||||
}) : mainPath = globals.fs.file(target).absolute.path,
|
||||
packagesFilePath = debuggingOptions.buildInfo.packagesPath,
|
||||
packagesFilePath = debuggingOptions.buildInfo.packageConfigPath,
|
||||
projectRootPath = projectRootPath ?? globals.fs.currentDirectory.path,
|
||||
_dillOutputPath = dillOutputPath,
|
||||
artifactDirectory = dillOutputPath == null
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -121,7 +121,7 @@ class FlutterTesterTestDevice extends TestDevice {
|
||||
'--non-interactive',
|
||||
'--use-test-fonts',
|
||||
'--disable-asset-fonts',
|
||||
'--packages=${debuggingOptions.buildInfo.packagesPath}',
|
||||
'--packages=${debuggingOptions.buildInfo.packageConfigPath}',
|
||||
if (testAssetDirectory != null)
|
||||
'--flutter-assets-dir=$testAssetDirectory',
|
||||
if (debuggingOptions.nullAssertions)
|
||||
|
||||
@@ -801,7 +801,7 @@ class SpawnPlugin extends PlatformPlugin {
|
||||
'--non-interactive',
|
||||
'--use-test-fonts',
|
||||
'--disable-asset-fonts',
|
||||
'--packages=${debuggingOptions.buildInfo.packagesPath}',
|
||||
'--packages=${debuggingOptions.buildInfo.packageConfigPath}',
|
||||
if (testAssetDirectory != null)
|
||||
'--flutter-assets-dir=$testAssetDirectory',
|
||||
if (debuggingOptions.nullAssertions)
|
||||
|
||||
@@ -122,7 +122,7 @@ class TestCompiler {
|
||||
trackWidgetCreation: buildInfo.trackWidgetCreation,
|
||||
initializeFromDill: testFilePath,
|
||||
dartDefines: buildInfo.dartDefines,
|
||||
packagesPath: buildInfo.packagesPath,
|
||||
packagesPath: buildInfo.packageConfigPath,
|
||||
frontendServerStarterPath: buildInfo.frontendServerStarterPath,
|
||||
extraFrontEndOptions: buildInfo.extraFrontEndOptions,
|
||||
platform: globals.platform,
|
||||
|
||||
@@ -174,7 +174,7 @@ class WebTestCompiler {
|
||||
platformDill: _fileSystem.file(platformDillPath).absolute.uri.toString(),
|
||||
dartDefines: dartDefines,
|
||||
librariesSpec: _artifacts.getHostArtifact(HostArtifact.flutterWebLibrariesJson).uri.toString(),
|
||||
packagesPath: buildInfo.packagesPath,
|
||||
packagesPath: buildInfo.packageConfigPath,
|
||||
artifacts: _artifacts,
|
||||
processManager: _processManager,
|
||||
logger: _logger,
|
||||
|
||||
@@ -166,7 +166,7 @@ class FlutterTesterDevice extends Device {
|
||||
'--non-interactive',
|
||||
if (debuggingOptions.enableDartProfiling)
|
||||
'--enable-dart-profiling',
|
||||
'--packages=${debuggingOptions.buildInfo.packagesPath}',
|
||||
'--packages=${debuggingOptions.buildInfo.packageConfigPath}',
|
||||
'--flutter-assets-dir=${assetDirectory.path}',
|
||||
if (debuggingOptions.startPaused)
|
||||
'--start-paused',
|
||||
|
||||
@@ -585,7 +585,7 @@ class IosProject extends XcodeBasedProject {
|
||||
if (globals.cache.isOlderThanToolsStamp(generatedXcodePropertiesFile)) {
|
||||
await xcode.updateGeneratedXcodeProperties(
|
||||
project: parent,
|
||||
buildInfo: BuildInfo.debug,
|
||||
buildInfo: BuildInfo.dummy,
|
||||
targetOverride: bundle.defaultMainPath,
|
||||
);
|
||||
}
|
||||
@@ -757,7 +757,7 @@ class MacOSProject extends XcodeBasedProject {
|
||||
if (globals.cache.isOlderThanToolsStamp(generatedXcodePropertiesFile)) {
|
||||
await xcode.updateGeneratedXcodeProperties(
|
||||
project: parent,
|
||||
buildInfo: BuildInfo.debug,
|
||||
buildInfo: BuildInfo.dummy,
|
||||
useMacOSConfig: true,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user