Auto-format Framework (#160545)

This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -32,9 +32,10 @@ const List<String> _kRequiredOptions = <String>[
];
Future<void> main(List<String> args) {
return runInContext<void>(() => run(args), overrides: <Type, Generator>{
Analytics: () => const NoOpAnalytics(),
});
return runInContext<void>(
() => run(args),
overrides: <Type, Generator>{Analytics: () => const NoOpAnalytics()},
);
}
Future<void> writeAssetFile(libfs.File outputFile, AssetBundleEntry asset) async {
@@ -44,17 +45,16 @@ Future<void> writeAssetFile(libfs.File outputFile, AssetBundleEntry asset) async
}
Future<void> run(List<String> args) async {
final ArgParser parser = ArgParser()
..addOption(_kOptionPackages, help: 'The .dart_tool/package_config file')
..addOption(_kOptionAsset,
help: 'The directory where to put temporary files')
..addOption(_kOptionManifest, help: 'The manifest file')
..addOption(_kOptionAssetManifestOut)
..addOption(_kOptionComponentName)
..addOption(_kOptionDepfile);
final ArgParser parser =
ArgParser()
..addOption(_kOptionPackages, help: 'The .dart_tool/package_config file')
..addOption(_kOptionAsset, help: 'The directory where to put temporary files')
..addOption(_kOptionManifest, help: 'The manifest file')
..addOption(_kOptionAssetManifestOut)
..addOption(_kOptionComponentName)
..addOption(_kOptionDepfile);
final ArgResults argResults = parser.parse(args);
if (_kRequiredOptions
.any((String option) => !argResults.options.contains(option))) {
if (_kRequiredOptions.any((String option) => !argResults.options.contains(option))) {
globals.printError('Missing option! All options must be specified.');
exit(1);
}
@@ -64,9 +64,10 @@ Future<void> run(List<String> args) async {
final AssetBundle? assets = await buildAssets(
manifestPath: argResults[_kOptionManifest] as String? ?? defaultManifestPath,
assetDirPath: assetDir,
packageConfigPath: argResults[_kOptionPackages] as String? ??
packageConfigPath:
argResults[_kOptionPackages] as String? ??
findPackageConfigFileOrDefault(globals.fs.currentDirectory).path,
targetPlatform: TargetPlatform.fuchsia_arm64 // This is not arch specific.
targetPlatform: TargetPlatform.fuchsia_arm64, // This is not arch specific.
);
if (assets == null) {
@@ -81,7 +82,12 @@ Future<void> run(List<String> args) async {
await Future.wait<void>(calls);
final String outputMan = argResults[_kOptionAssetManifestOut] as String;
await writeFuchsiaManifest(assets, argResults[_kOptionAsset] as String, outputMan, argResults[_kOptionComponentName] as String);
await writeFuchsiaManifest(
assets,
argResults[_kOptionAsset] as String,
outputMan,
argResults[_kOptionComponentName] as String,
);
final String? depfilePath = argResults[_kOptionDepfile] as String?;
if (depfilePath != null) {
@@ -90,10 +96,9 @@ Future<void> run(List<String> args) async {
}
Future<void> writeDepfile(AssetBundle assets, String outputManifest, String depfilePath) async {
final Depfile depfileContent = Depfile(
assets.inputFiles,
<libfs.File>[globals.fs.file(outputManifest)],
);
final Depfile depfileContent = Depfile(assets.inputFiles, <libfs.File>[
globals.fs.file(outputManifest),
]);
final DepfileService depfileService = DepfileService(
fileSystem: globals.fs,
logger: globals.logger,
@@ -104,8 +109,12 @@ Future<void> writeDepfile(AssetBundle assets, String outputManifest, String depf
depfileService.writeToFile(depfileContent, depfile);
}
Future<void> writeFuchsiaManifest(AssetBundle assets, String outputBase, String fileDest, String componentName) async {
Future<void> writeFuchsiaManifest(
AssetBundle assets,
String outputBase,
String fileDest,
String componentName,
) async {
final libfs.File destFile = globals.fs.file(fileDest);
await destFile.create(recursive: true);
final libfs.IOSink outFile = destFile.openWrite();

View File

@@ -41,35 +41,45 @@ const String _kOptionCoverage = 'coverage';
const String _kOptionCoveragePath = 'coverage-path';
void main(List<String> args) {
runInContext<void>(() => run(args), overrides: <Type, Generator>{
Analytics: () => const NoOpAnalytics(),
});
runInContext<void>(
() => run(args),
overrides: <Type, Generator>{Analytics: () => const NoOpAnalytics()},
);
}
Future<void> run(List<String> args) async {
final ArgParser parser = ArgParser()
..addOption(_kOptionPackages, help: 'The .packages file')
..addOption(_kOptionShell, help: 'The Flutter shell binary')
..addOption(_kOptionTestDirectory, help: 'Directory containing the tests')
..addOption(_kOptionSdkRoot, help: 'Path to the SDK platform files')
..addOption(_kOptionIcudtl, help: 'Path to the ICU data file')
..addOption(_kOptionTests, help: 'Path to json file that maps Dart test files to precompiled dill files')
..addOption(_kOptionCoverageDirectory, help: 'The path to the directory that will have coverage collected')
..addFlag(_kOptionCoverage,
negatable: false,
help: 'Whether to collect coverage information.',
)
..addOption(_kOptionCoveragePath,
defaultsTo: 'coverage/lcov.info',
help: 'Where to store coverage information (if coverage is enabled).',
);
final ArgParser parser =
ArgParser()
..addOption(_kOptionPackages, help: 'The .packages file')
..addOption(_kOptionShell, help: 'The Flutter shell binary')
..addOption(_kOptionTestDirectory, help: 'Directory containing the tests')
..addOption(_kOptionSdkRoot, help: 'Path to the SDK platform files')
..addOption(_kOptionIcudtl, help: 'Path to the ICU data file')
..addOption(
_kOptionTests,
help: 'Path to json file that maps Dart test files to precompiled dill files',
)
..addOption(
_kOptionCoverageDirectory,
help: 'The path to the directory that will have coverage collected',
)
..addFlag(
_kOptionCoverage,
negatable: false,
help: 'Whether to collect coverage information.',
)
..addOption(
_kOptionCoveragePath,
defaultsTo: 'coverage/lcov.info',
help: 'Where to store coverage information (if coverage is enabled).',
);
final ArgResults argResults = parser.parse(args);
if (_kRequiredOptions
.any((String option) => !argResults.options.contains(option))) {
if (_kRequiredOptions.any((String option) => !argResults.options.contains(option))) {
throwToolExit('Missing option! All options must be specified.');
}
final Directory tempDir =
globals.fs.systemTempDirectory.createTempSync('flutter_fuchsia_tester.');
final Directory tempDir = globals.fs.systemTempDirectory.createTempSync(
'flutter_fuchsia_tester.',
);
try {
Cache.flutterRoot = tempDir.path;
@@ -94,13 +104,13 @@ Future<void> run(List<String> args) async {
// Put the tester shell where runTests expects it.
// TODO(garymm): Switch to a Fuchsia-specific Artifacts impl.
final Artifacts artifacts = globals.artifacts!;
final Link testerDestLink =
globals.fs.link(artifacts.getArtifactPath(Artifact.flutterTester));
final Link testerDestLink = globals.fs.link(artifacts.getArtifactPath(Artifact.flutterTester));
testerDestLink.parent.createSync(recursive: true);
testerDestLink.createSync(globals.fs.path.absolute(shellPath));
final Directory sdkRootDest =
globals.fs.directory(artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath));
final Directory sdkRootDest = globals.fs.directory(
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
);
sdkRootDest.createSync(recursive: true);
for (final FileSystemEntity artifact in sdkRootSrc.listSync()) {
globals.fs.link(sdkRootDest.childFile(artifact.basename).path).createSync(artifact.path);
@@ -113,23 +123,27 @@ Future<void> run(List<String> args) async {
if (argResults['coverage'] as bool? ?? false) {
// If we have a specified coverage directory then accept all libraries by
// setting libraryNames to null.
final Set<String>? libraryNames = coverageDirectory != null ? null :
<String>{FlutterProject.current().manifest.appName};
final String packagesPath = globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String));
final Set<String>? libraryNames =
coverageDirectory != null ? null : <String>{FlutterProject.current().manifest.appName};
final String packagesPath = globals.fs.path.normalize(
globals.fs.path.absolute(argResults[_kOptionPackages] as String),
);
collector = CoverageCollector(
packagesPath: packagesPath,
libraryNames: libraryNames,
resolver: await CoverageCollector.getResolver(packagesPath));
resolver: await CoverageCollector.getResolver(packagesPath),
);
if (!argResults.options.contains(_kOptionTestDirectory)) {
throwToolExit('Use of --coverage requires setting --test-directory');
}
testDirectory = globals.fs.directory(argResults[_kOptionTestDirectory]);
}
final Map<String, String> tests = <String, String>{};
final List<Map<String, dynamic>> jsonList = List<Map<String, dynamic>>.from(
(json.decode(globals.fs.file(argResults[_kOptionTests]).readAsStringSync()) as List<dynamic>).cast<Map<String, dynamic>>());
(json.decode(globals.fs.file(argResults[_kOptionTests]).readAsStringSync()) as List<dynamic>)
.cast<Map<String, dynamic>>(),
);
for (final Map<String, dynamic> map in jsonList) {
final String source = globals.fs.file(map['source']).resolveSymbolicLinksSync();
final String dill = globals.fs.file(map['dill']).resolveSymbolicLinksSync();
@@ -146,9 +160,7 @@ Future<void> run(List<String> args) async {
'',
treeShakeIcons: false,
packageConfigPath: globals.fs.path.normalize(
globals.fs.path.absolute(
argResults[_kOptionPackages] as String,
),
globals.fs.path.absolute(argResults[_kOptionPackages] as String),
),
),
),
@@ -170,7 +182,10 @@ Future<void> run(List<String> args) async {
} else {
globals.fs.currentDirectory = testDirectory;
}
if (!await collector.collectCoverageData(argResults[_kOptionCoveragePath] as String?, coverageDirectory: coverageDirectory)) {
if (!await collector.collectCoverageData(
argResults[_kOptionCoveragePath] as String?,
coverageDirectory: coverageDirectory,
)) {
throwToolExit('Failed to collect coverage data');
}
}

View File

@@ -18,8 +18,8 @@ Future<void> main(List<String> arguments) async {
final String? extraGenSnapshotOptions = Platform.environment['EXTRA_GEN_SNAPSHOT_OPTIONS'];
final String? flutterEngine = Platform.environment['FLUTTER_ENGINE'];
final String? flutterRoot = Platform.environment['FLUTTER_ROOT'];
final String flutterTarget = Platform.environment['FLUTTER_TARGET']
?? pathJoin(<String>['lib', 'main.dart']);
final String flutterTarget =
Platform.environment['FLUTTER_TARGET'] ?? pathJoin(<String>['lib', 'main.dart']);
final String? codeSizeDirectory = Platform.environment['CODE_SIZE_DIRECTORY'];
final String? localEngine = Platform.environment['LOCAL_ENGINE'];
final String? localEngineHost = Platform.environment['LOCAL_ENGINE_HOST'];
@@ -32,11 +32,15 @@ Future<void> main(List<String> arguments) async {
final bool prefixedErrors = Platform.environment['PREFIXED_ERROR_LOGGING'] == 'true';
if (projectDirectory == null) {
stderr.write('PROJECT_DIR environment variable must be set to the location of Flutter project to be built.');
stderr.write(
'PROJECT_DIR environment variable must be set to the location of Flutter project to be built.',
);
exit(1);
}
if (flutterRoot == null || flutterRoot.isEmpty) {
stderr.write('FLUTTER_ROOT environment variable must be set to the location of the Flutter SDK.');
stderr.write(
'FLUTTER_ROOT environment variable must be set to the location of the Flutter SDK.',
);
exit(1);
}
@@ -71,57 +75,42 @@ or
final String flutterExecutable = pathJoin(<String>[
flutterRoot,
'bin',
if (Platform.isWindows)
'flutter.bat'
else
'flutter',
if (Platform.isWindows) 'flutter.bat' else 'flutter',
]);
final String bundlePlatform = targetPlatform;
final String target = '${buildMode}_bundle_${bundlePlatform}_assets';
final Process assembleProcess = await Process.start(
flutterExecutable,
<String>[
if (verbose)
'--verbose',
if (prefixedErrors)
'--prefixed-errors',
if (flutterEngine != null) '--local-engine-src-path=$flutterEngine',
if (localEngine != null) '--local-engine=$localEngine',
if (localEngineHost != null) '--local-engine-host=$localEngineHost',
'assemble',
'--no-version-check',
'--output=build',
'-dTargetPlatform=$targetPlatform',
'-dTrackWidgetCreation=$trackWidgetCreation',
'-dBuildMode=$buildMode',
'-dTargetFile=$flutterTarget',
'-dTreeShakeIcons="$treeShakeIcons"',
'-dDartObfuscation=$dartObfuscation',
if (bundleSkSLPath != null)
'-dBundleSkSLPath=$bundleSkSLPath',
if (codeSizeDirectory != null)
'-dCodeSizeDirectory=$codeSizeDirectory',
if (splitDebugInfo != null)
'-dSplitDebugInfo=$splitDebugInfo',
if (dartDefines != null)
'--DartDefines=$dartDefines',
if (extraGenSnapshotOptions != null)
'--ExtraGenSnapshotOptions=$extraGenSnapshotOptions',
if (frontendServerStarterPath != null)
'-dFrontendServerStarterPath=$frontendServerStarterPath',
if (extraFrontEndOptions != null)
'--ExtraFrontEndOptions=$extraFrontEndOptions',
target,
],
);
final Process assembleProcess = await Process.start(flutterExecutable, <String>[
if (verbose) '--verbose',
if (prefixedErrors) '--prefixed-errors',
if (flutterEngine != null) '--local-engine-src-path=$flutterEngine',
if (localEngine != null) '--local-engine=$localEngine',
if (localEngineHost != null) '--local-engine-host=$localEngineHost',
'assemble',
'--no-version-check',
'--output=build',
'-dTargetPlatform=$targetPlatform',
'-dTrackWidgetCreation=$trackWidgetCreation',
'-dBuildMode=$buildMode',
'-dTargetFile=$flutterTarget',
'-dTreeShakeIcons="$treeShakeIcons"',
'-dDartObfuscation=$dartObfuscation',
if (bundleSkSLPath != null) '-dBundleSkSLPath=$bundleSkSLPath',
if (codeSizeDirectory != null) '-dCodeSizeDirectory=$codeSizeDirectory',
if (splitDebugInfo != null) '-dSplitDebugInfo=$splitDebugInfo',
if (dartDefines != null) '--DartDefines=$dartDefines',
if (extraGenSnapshotOptions != null) '--ExtraGenSnapshotOptions=$extraGenSnapshotOptions',
if (frontendServerStarterPath != null) '-dFrontendServerStarterPath=$frontendServerStarterPath',
if (extraFrontEndOptions != null) '--ExtraFrontEndOptions=$extraFrontEndOptions',
target,
]);
assembleProcess.stdout
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen(stdout.writeln);
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen(stdout.writeln);
assembleProcess.stderr
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen(stderr.writeln);
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen(stderr.writeln);
if (await assembleProcess.exitCode != 0) {
exit(1);

View File

@@ -22,11 +22,7 @@ void main(List<String> arguments) {
/// All interactions with the platform are broken into individual methods that
/// can be overridden in tests.
class Context {
Context({
required this.arguments,
required this.environment,
File? scriptOutputStreamFile,
}) {
Context({required this.arguments, required this.environment, File? scriptOutputStreamFile}) {
if (scriptOutputStreamFile != null) {
scriptOutputStream = scriptOutputStreamFile.openSync(mode: FileMode.write);
}
@@ -40,8 +36,9 @@ class Context {
if (arguments.isEmpty) {
// Named entry points were introduced in Flutter v0.0.7.
stderr.write(
'error: Your Xcode project is incompatible with this version of Flutter. '
'Run "rm -rf ios/Runner.xcodeproj" and "flutter create ." to regenerate.\n');
'error: Your Xcode project is incompatible with this version of Flutter. '
'Run "rm -rf ios/Runner.xcodeproj" and "flutter create ." to regenerate.\n',
);
exit(-1);
}
@@ -83,11 +80,7 @@ class Context {
if (verbose) {
print('♦ $bin ${args.join(' ')}');
}
final ProcessResult result = Process.runSync(
bin,
args,
workingDirectory: workingDirectory,
);
final ProcessResult result = Process.runSync(bin, args, workingDirectory: workingDirectory);
if (verbose) {
print((result.stdout as String).trim());
}
@@ -102,9 +95,7 @@ class Context {
echoError(errorOutput.toString());
}
if (!allowFail && result.exitCode != 0) {
throw Exception(
'Command "$bin ${args.join(' ')}" exited with code ${result.exitCode}',
);
throw Exception('Command "$bin ${args.join(' ')}" exited with code ${result.exitCode}');
}
return result;
}
@@ -130,9 +121,7 @@ class Context {
String environmentEnsure(String key) {
final String? value = environment[key];
if (value == null) {
throw Exception(
'Expected the environment variable "$key" to exist, but it was not found',
);
throw Exception('Expected the environment variable "$key" to exist, but it was not found');
}
return value;
}
@@ -147,7 +136,8 @@ class Context {
// Use FLUTTER_BUILD_MODE if it's set, otherwise use the Xcode build configuration name
// This means that if someone wants to use an Xcode build config other than Debug/Profile/Release,
// they _must_ set FLUTTER_BUILD_MODE so we know what type of artifact to build.
final String? buildMode = (environment['FLUTTER_BUILD_MODE'] ?? environment['CONFIGURATION'])?.toLowerCase();
final String? buildMode =
(environment['FLUTTER_BUILD_MODE'] ?? environment['CONFIGURATION'])?.toLowerCase();
if (buildMode != null) {
if (buildMode.contains('release')) {
@@ -168,7 +158,9 @@ class Context {
echoError('');
echoError('You can fix this by either adding an appropriately named build');
echoError('configuration, or adding an appropriate value for FLUTTER_BUILD_MODE to the');
echoError('.xcconfig file for the current build configuration (${environment['CONFIGURATION']}).');
echoError(
'.xcconfig file for the current build configuration (${environment['CONFIGURATION']}).',
);
echoError('========================================================================');
exitApp(-1);
}
@@ -184,19 +176,16 @@ class Context {
List<String> extraArgs = const <String>[],
bool delete = false,
}) {
runSync(
'rsync',
<String>[
'-8', // Avoid mangling filenames with encodings that do not match the current locale.
'-av',
if (delete) '--delete',
'--filter',
'- .DS_Store',
...extraArgs,
source,
destination,
],
);
runSync('rsync', <String>[
'-8', // Avoid mangling filenames with encodings that do not match the current locale.
'-av',
if (delete) '--delete',
'--filter',
'- .DS_Store',
...extraArgs,
source,
destination,
]);
}
// Adds the App.framework as an embedded binary and the flutter_assets as
@@ -204,15 +193,9 @@ class Context {
void embedFlutterFrameworks() {
// Embed App.framework from Flutter into the app (after creating the Frameworks directory
// if it doesn't already exist).
final String xcodeFrameworksDir = '${environment['TARGET_BUILD_DIR']}/${environment['FRAMEWORKS_FOLDER_PATH']}';
runSync(
'mkdir',
<String>[
'-p',
'--',
xcodeFrameworksDir,
]
);
final String xcodeFrameworksDir =
'${environment['TARGET_BUILD_DIR']}/${environment['FRAMEWORKS_FOLDER_PATH']}';
runSync('mkdir', <String>['-p', '--', xcodeFrameworksDir]);
runRsync(
delete: true,
'${environment['BUILT_PRODUCTS_DIR']}/App.framework',
@@ -242,12 +225,7 @@ class Context {
print('♦ Copying native assets from $nativeAssetsPath.');
}
runRsync(
extraArgs: <String>[
'--filter',
'- native_assets.yaml',
'--filter',
'- native_assets.json',
],
extraArgs: <String>['--filter', '- native_assets.yaml', '--filter', '- native_assets.json'],
nativeAssetsPath,
xcodeFrameworksDir,
);
@@ -273,7 +251,8 @@ class Context {
return;
}
final String builtProductsPlist = '${environment['BUILT_PRODUCTS_DIR'] ?? ''}/${environment['INFOPLIST_PATH'] ?? ''}';
final String builtProductsPlist =
'${environment['BUILT_PRODUCTS_DIR'] ?? ''}/${environment['INFOPLIST_PATH'] ?? ''}';
if (!existsFile(builtProductsPlist)) {
// Very occasionally Xcode hasn't created an Info.plist when this runs.
@@ -281,47 +260,38 @@ class Context {
echo(
'${environment['INFOPLIST_PATH'] ?? ''} does not exist. Skipping '
'_dartVmService._tcp NSBonjourServices insertion. Try re-building to '
'enable "flutter attach".');
'enable "flutter attach".',
);
return;
}
// If there are already NSBonjourServices specified by the app (uncommon),
// insert the vmService service name to the existing list.
ProcessResult result = runSync(
'plutil',
<String>[
'-extract',
'NSBonjourServices',
'xml1',
'-o',
'-',
builtProductsPlist,
],
allowFail: true,
);
ProcessResult result = runSync('plutil', <String>[
'-extract',
'NSBonjourServices',
'xml1',
'-o',
'-',
builtProductsPlist,
], allowFail: true);
if (result.exitCode == 0) {
runSync(
'plutil',
<String>[
'-insert',
'NSBonjourServices.0',
'-string',
'_dartVmService._tcp',
builtProductsPlist,
],
);
runSync('plutil', <String>[
'-insert',
'NSBonjourServices.0',
'-string',
'_dartVmService._tcp',
builtProductsPlist,
]);
} else {
// Otherwise, add the NSBonjourServices key and vmService service name.
runSync(
'plutil',
<String>[
'-insert',
'NSBonjourServices',
'-json',
'["_dartVmService._tcp"]',
builtProductsPlist,
],
);
runSync('plutil', <String>[
'-insert',
'NSBonjourServices',
'-json',
'["_dartVmService._tcp"]',
builtProductsPlist,
]);
//fi
}
@@ -329,29 +299,22 @@ class Context {
// specified (uncommon). This text will appear below the "Your app would
// like to find and connect to devices on your local network" permissions
// popup.
result = runSync(
'plutil',
<String>[
'-extract',
'NSLocalNetworkUsageDescription',
'xml1',
'-o',
'-',
builtProductsPlist,
],
allowFail: true,
);
result = runSync('plutil', <String>[
'-extract',
'NSLocalNetworkUsageDescription',
'xml1',
'-o',
'-',
builtProductsPlist,
], allowFail: true);
if (result.exitCode != 0) {
runSync(
'plutil',
<String>[
'-insert',
'NSLocalNetworkUsageDescription',
'-string',
'Allow Flutter tools on your computer to connect and debug your application. This prompt will not appear on release builds.',
builtProductsPlist,
],
);
runSync('plutil', <String>[
'-insert',
'NSLocalNetworkUsageDescription',
'-string',
'Allow Flutter tools on your computer to connect and debug your application. This prompt will not appear on release builds.',
builtProductsPlist,
]);
}
}
@@ -367,11 +330,7 @@ class Context {
final String buildMode = parseFlutterBuildMode();
final List<String> flutterArgs = _generateFlutterArgsForAssemble(
'prepare',
buildMode,
verbose,
);
final List<String> flutterArgs = _generateFlutterArgsForAssemble('prepare', buildMode, verbose);
// The "prepare" command only targets the UnpackIOS target, which copies the
// Flutter framework to the BUILT_PRODUCTS_DIR.
@@ -398,11 +357,7 @@ class Context {
final String buildMode = parseFlutterBuildMode();
final List<String> flutterArgs = _generateFlutterArgsForAssemble(
'build',
buildMode,
verbose,
);
final List<String> flutterArgs = _generateFlutterArgsForAssemble('build', buildMode, verbose);
flutterArgs.add('${buildMode}_ios_bundle_flutter_assets');
@@ -425,11 +380,7 @@ class Context {
echo('Project $projectPath built and packaged successfully.');
}
List<String> _generateFlutterArgsForAssemble(
String command,
String buildMode,
bool verbose,
) {
List<String> _generateFlutterArgsForAssemble(String command, String buildMode, bool verbose) {
String targetPath = 'lib/main.dart';
if (environment['FLUTTER_TARGET'] != null) {
targetPath = environment['FLUTTER_TARGET']!;
@@ -510,12 +461,17 @@ class Context {
flutterArgs.add('-dPreBuildAction=PrepareFramework');
}
if (environment['PERFORMANCE_MEASUREMENT_FILE'] != null && environment['PERFORMANCE_MEASUREMENT_FILE']!.isNotEmpty) {
flutterArgs.add('--performance-measurement-file=${environment['PERFORMANCE_MEASUREMENT_FILE']}');
if (environment['PERFORMANCE_MEASUREMENT_FILE'] != null &&
environment['PERFORMANCE_MEASUREMENT_FILE']!.isNotEmpty) {
flutterArgs.add(
'--performance-measurement-file=${environment['PERFORMANCE_MEASUREMENT_FILE']}',
);
}
final String? expandedCodeSignIdentity = environment['EXPANDED_CODE_SIGN_IDENTITY'];
if (expandedCodeSignIdentity != null && expandedCodeSignIdentity.isNotEmpty && environment['CODE_SIGNING_REQUIRED'] != 'NO') {
if (expandedCodeSignIdentity != null &&
expandedCodeSignIdentity.isNotEmpty &&
environment['CODE_SIGNING_REQUIRED'] != 'NO') {
flutterArgs.add('-dCodesignIdentity=$expandedCodeSignIdentity');
}
@@ -523,7 +479,8 @@ class Context {
flutterArgs.add('-dBundleSkSLPath=${environment['BUNDLE_SKSL_PATH']}');
}
if (environment['CODE_SIZE_DIRECTORY'] != null && environment['CODE_SIZE_DIRECTORY']!.isNotEmpty) {
if (environment['CODE_SIZE_DIRECTORY'] != null &&
environment['CODE_SIZE_DIRECTORY']!.isNotEmpty) {
flutterArgs.add('-dCodeSizeDirectory=${environment['CODE_SIZE_DIRECTORY']}');
}