Quote arguments to flutter assemble in xcode_backend.sh (#86534)
This commit is contained in:
@@ -22,22 +22,12 @@ BuildApp() {
|
||||
local project_path="${SOURCE_ROOT}/.."
|
||||
RunCommand pushd "${project_path}" > /dev/null
|
||||
|
||||
# Set the verbose flag.
|
||||
local verbose_flag=""
|
||||
if [[ -n "$VERBOSE_SCRIPT_LOGGING" ]]; then
|
||||
verbose_flag="--verbose"
|
||||
fi
|
||||
|
||||
# Set the target file.
|
||||
local target_path="lib/main.dart"
|
||||
if [[ -n "$FLUTTER_TARGET" ]]; then
|
||||
target_path="${FLUTTER_TARGET}"
|
||||
fi
|
||||
|
||||
if [[ -n "$FLUTTER_ENGINE" ]]; then
|
||||
flutter_engine_flag="--local-engine-src-path=${FLUTTER_ENGINE}"
|
||||
fi
|
||||
|
||||
# Set the build mode
|
||||
local build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")"
|
||||
|
||||
@@ -54,7 +44,6 @@ BuildApp() {
|
||||
EchoError "========================================================================"
|
||||
exit -1
|
||||
fi
|
||||
local_engine_flag="--local-engine=${LOCAL_ENGINE}"
|
||||
fi
|
||||
|
||||
# The path where the input/output xcfilelists are stored. These are used by xcode
|
||||
@@ -63,45 +52,50 @@ BuildApp() {
|
||||
local build_inputs_path="${ephemeral_dir}/FlutterInputs.xcfilelist"
|
||||
local build_outputs_path="${ephemeral_dir}/FlutterOutputs.xcfilelist"
|
||||
|
||||
local performance_measurement_option=""
|
||||
# Construct the "flutter assemble" argument array. Arguments should be added
|
||||
# as quoted string elements of the flutter_args array, otherwise an argument
|
||||
# (like a path) with spaces in it might be interpreted as two separate
|
||||
# arguments.
|
||||
local flutter_args=("${FLUTTER_ROOT}/bin/flutter")
|
||||
if [[ -n "$VERBOSE_SCRIPT_LOGGING" ]]; then
|
||||
flutter_args+=('--verbose')
|
||||
fi
|
||||
if [[ -n "$FLUTTER_ENGINE" ]]; then
|
||||
flutter_args+=("--local-engine-src-path=${FLUTTER_ENGINE}")
|
||||
fi
|
||||
if [[ -n "$LOCAL_ENGINE" ]]; then
|
||||
flutter_args+=("--local-engine=${LOCAL_ENGINE}")
|
||||
fi
|
||||
flutter_args+=(
|
||||
"assemble"
|
||||
"--no-version-check"
|
||||
"-dTargetPlatform=darwin"
|
||||
"-dDarwinArchs=x86_64"
|
||||
"-dTargetFile=${target_path}"
|
||||
"-dBuildMode=${build_mode}"
|
||||
"-dTreeShakeIcons=${TREE_SHAKE_ICONS}"
|
||||
"-dDartObfuscation=${DART_OBFUSCATION}"
|
||||
"-dSplitDebugInfo=${SPLIT_DEBUG_INFO}"
|
||||
"-dTrackWidgetCreation=${TRACK_WIDGET_CREATION}"
|
||||
"--DartDefines=${DART_DEFINES}"
|
||||
"--ExtraGenSnapshotOptions=${EXTRA_GEN_SNAPSHOT_OPTIONS}"
|
||||
"--ExtraFrontEndOptions=${EXTRA_FRONT_END_OPTIONS}"
|
||||
"--build-inputs=${build_inputs_path}"
|
||||
"--build-outputs=${build_outputs_path}"
|
||||
"--output=${BUILT_PRODUCTS_DIR}"
|
||||
)
|
||||
if [[ -n "$PERFORMANCE_MEASUREMENT_FILE" ]]; then
|
||||
performance_measurement_option="--performance-measurement-file=${PERFORMANCE_MEASUREMENT_FILE}"
|
||||
flutter_args+=("--performance-measurement-file=${PERFORMANCE_MEASUREMENT_FILE}")
|
||||
fi
|
||||
|
||||
local bundle_sksl_path=""
|
||||
if [[ -n "$BUNDLE_SKSL_PATH" ]]; then
|
||||
bundle_sksl_path="-dBundleSkSLPath=${BUNDLE_SKSL_PATH}"
|
||||
flutter_args+=("-dBundleSkSLPath=${BUNDLE_SKSL_PATH}")
|
||||
fi
|
||||
|
||||
local code_size_directory=""
|
||||
if [[ -n "$CODE_SIZE_DIRECTORY" ]]; then
|
||||
code_size_directory="-dCodeSizeDirectory=${CODE_SIZE_DIRECTORY}"
|
||||
flutter_args+=("-dCodeSizeDirectory=${CODE_SIZE_DIRECTORY}")
|
||||
fi
|
||||
flutter_args+=("${build_mode}_macos_bundle_flutter_assets")
|
||||
|
||||
RunCommand "${FLUTTER_ROOT}/bin/flutter" \
|
||||
${verbose_flag} \
|
||||
${flutter_engine_flag} \
|
||||
${local_engine_flag} \
|
||||
assemble \
|
||||
--no-version-check \
|
||||
${performance_measurement_option} \
|
||||
-dTargetPlatform=darwin \
|
||||
-dDarwinArchs=x86_64 \
|
||||
-dTargetFile="${target_path}" \
|
||||
-dBuildMode="${build_mode}" \
|
||||
-dTreeShakeIcons="${TREE_SHAKE_ICONS}" \
|
||||
-dDartObfuscation="${DART_OBFUSCATION}" \
|
||||
-dSplitDebugInfo="${SPLIT_DEBUG_INFO}" \
|
||||
-dTrackWidgetCreation="${TRACK_WIDGET_CREATION}" \
|
||||
${bundle_sksl_path} \
|
||||
${code_size_directory} \
|
||||
--DartDefines="${DART_DEFINES}" \
|
||||
--ExtraGenSnapshotOptions="${EXTRA_GEN_SNAPSHOT_OPTIONS}" \
|
||||
--ExtraFrontEndOptions="${EXTRA_FRONT_END_OPTIONS}" \
|
||||
--build-inputs="${build_inputs_path}" \
|
||||
--build-outputs="${build_outputs_path}" \
|
||||
--output="${BUILT_PRODUCTS_DIR}" \
|
||||
"${build_mode}_macos_bundle_flutter_assets"
|
||||
RunCommand "${flutter_args[@]}"
|
||||
}
|
||||
|
||||
# Adds the App.framework as an embedded binary and the flutter_assets as
|
||||
|
||||
@@ -80,11 +80,6 @@ BuildApp() {
|
||||
derived_dir="${project_path}/.ios/Flutter"
|
||||
fi
|
||||
|
||||
local bundle_sksl_path=""
|
||||
if [[ -n "$BUNDLE_SKSL_PATH" ]]; then
|
||||
bundle_sksl_path="-dBundleSkSLPath=${BUNDLE_SKSL_PATH}"
|
||||
fi
|
||||
|
||||
# Default value of assets_path is flutter_assets
|
||||
local assets_path="flutter_assets"
|
||||
# The value of assets_path can set by add FLTAssetsPath to
|
||||
@@ -113,14 +108,8 @@ is set to release or run \"flutter build ios --release\", then re-run Archive fr
|
||||
fi
|
||||
|
||||
local framework_path="${FLUTTER_ROOT}/bin/cache/artifacts/engine/${artifact_variant}"
|
||||
local flutter_engine_flag=""
|
||||
local local_engine_flag=""
|
||||
local flutter_framework="${framework_path}/Flutter.xcframework"
|
||||
|
||||
if [[ -n "$FLUTTER_ENGINE" ]]; then
|
||||
flutter_engine_flag="--local-engine-src-path=${FLUTTER_ENGINE}"
|
||||
fi
|
||||
|
||||
if [[ -n "$LOCAL_ENGINE" ]]; then
|
||||
if [[ $(echo "$LOCAL_ENGINE" | tr "[:upper:]" "[:lower:]") != *"$build_mode"* ]]; then
|
||||
EchoError "========================================================================"
|
||||
@@ -134,7 +123,6 @@ is set to release or run \"flutter build ios --release\", then re-run Archive fr
|
||||
EchoError "========================================================================"
|
||||
exit -1
|
||||
fi
|
||||
local_engine_flag="--local-engine=${LOCAL_ENGINE}"
|
||||
flutter_framework="${FLUTTER_ENGINE}/out/${LOCAL_ENGINE}/Flutter.xcframework"
|
||||
fi
|
||||
local bitcode_flag=""
|
||||
@@ -149,51 +137,53 @@ is set to release or run \"flutter build ios --release\", then re-run Archive fr
|
||||
|
||||
RunCommand pushd "${project_path}" > /dev/null
|
||||
|
||||
local verbose_flag=""
|
||||
# Construct the "flutter assemble" argument array. Arguments should be added
|
||||
# as quoted string elements of the flutter_args array, otherwise an argument
|
||||
# (like a path) with spaces in it might be interpreted as two separate
|
||||
# arguments.
|
||||
local flutter_args=("${FLUTTER_ROOT}/bin/flutter")
|
||||
if [[ -n "$VERBOSE_SCRIPT_LOGGING" ]]; then
|
||||
verbose_flag="--verbose"
|
||||
flutter_args+=('--verbose')
|
||||
fi
|
||||
|
||||
local performance_measurement_option=""
|
||||
if [[ -n "$FLUTTER_ENGINE" ]]; then
|
||||
flutter_args+=("--local-engine-src-path=${FLUTTER_ENGINE}")
|
||||
fi
|
||||
if [[ -n "$LOCAL_ENGINE" ]]; then
|
||||
flutter_args+=("--local-engine=${LOCAL_ENGINE}")
|
||||
fi
|
||||
flutter_args+=(
|
||||
"assemble"
|
||||
"--no-version-check"
|
||||
"--output=${BUILT_PRODUCTS_DIR}/"
|
||||
"-dTargetPlatform=ios"
|
||||
"-dTargetFile=${target_path}"
|
||||
"-dBuildMode=${build_mode}"
|
||||
"-dIosArchs=${ARCHS}"
|
||||
"-dSdkRoot=${SDKROOT}"
|
||||
"-dSplitDebugInfo=${SPLIT_DEBUG_INFO}"
|
||||
"-dTreeShakeIcons=${TREE_SHAKE_ICONS}"
|
||||
"-dTrackWidgetCreation=${TRACK_WIDGET_CREATION}"
|
||||
"-dDartObfuscation=${DART_OBFUSCATION}"
|
||||
"-dEnableBitcode=${bitcode_flag}"
|
||||
"--ExtraGenSnapshotOptions=${EXTRA_GEN_SNAPSHOT_OPTIONS}"
|
||||
"--DartDefines=${DART_DEFINES}"
|
||||
"--ExtraFrontEndOptions=${EXTRA_FRONT_END_OPTIONS}"
|
||||
)
|
||||
if [[ -n "$PERFORMANCE_MEASUREMENT_FILE" ]]; then
|
||||
performance_measurement_option="--performance-measurement-file=${PERFORMANCE_MEASUREMENT_FILE}"
|
||||
flutter_args+=("--performance-measurement-file=${PERFORMANCE_MEASUREMENT_FILE}")
|
||||
fi
|
||||
|
||||
local code_size_directory=""
|
||||
if [[ -n "$CODE_SIZE_DIRECTORY" ]]; then
|
||||
code_size_directory="-dCodeSizeDirectory=${CODE_SIZE_DIRECTORY}"
|
||||
fi
|
||||
|
||||
local codesign_identity_flag=""
|
||||
if [[ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" && "${CODE_SIGNING_REQUIRED:-}" != "NO" ]]; then
|
||||
codesign_identity_flag="-dCodesignIdentity=${EXPANDED_CODE_SIGN_IDENTITY}"
|
||||
flutter_args+=("-dCodesignIdentity=${EXPANDED_CODE_SIGN_IDENTITY}")
|
||||
fi
|
||||
if [[ -n "$BUNDLE_SKSL_PATH" ]]; then
|
||||
flutter_args+=("-dBundleSkSLPath=${BUNDLE_SKSL_PATH}")
|
||||
fi
|
||||
if [[ -n "$CODE_SIZE_DIRECTORY" ]]; then
|
||||
flutter_args+=("-dCodeSizeDirectory=${CODE_SIZE_DIRECTORY}")
|
||||
fi
|
||||
flutter_args+=("${build_mode}_ios_bundle_flutter_assets")
|
||||
|
||||
RunCommand "${FLUTTER_ROOT}/bin/flutter" \
|
||||
${verbose_flag} \
|
||||
${flutter_engine_flag} \
|
||||
${local_engine_flag} \
|
||||
assemble \
|
||||
--no-version-check \
|
||||
--output="${BUILT_PRODUCTS_DIR}/" \
|
||||
${performance_measurement_option} \
|
||||
-dTargetPlatform=ios \
|
||||
-dTargetFile="${target_path}" \
|
||||
-dBuildMode=${build_mode} \
|
||||
-dIosArchs="${ARCHS}" \
|
||||
-dSdkRoot="${SDKROOT}" \
|
||||
-dSplitDebugInfo="${SPLIT_DEBUG_INFO}" \
|
||||
-dTreeShakeIcons="${TREE_SHAKE_ICONS}" \
|
||||
-dTrackWidgetCreation="${TRACK_WIDGET_CREATION}" \
|
||||
-dDartObfuscation="${DART_OBFUSCATION}" \
|
||||
-dEnableBitcode="${bitcode_flag}" \
|
||||
${codesign_identity_flag} \
|
||||
${bundle_sksl_path} \
|
||||
${code_size_directory} \
|
||||
--ExtraGenSnapshotOptions="${EXTRA_GEN_SNAPSHOT_OPTIONS}" \
|
||||
--DartDefines="${DART_DEFINES}" \
|
||||
--ExtraFrontEndOptions="${EXTRA_FRONT_END_OPTIONS}" \
|
||||
"${build_mode}_ios_bundle_flutter_assets"
|
||||
RunCommand "${flutter_args[@]}"
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
EchoError "Failed to package ${project_path}."
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'test_utils.dart';
|
||||
|
||||
const String apkDebugMessage = 'A summary of your APK analysis can be found at: ';
|
||||
const String iosDebugMessage = 'A summary of your iOS bundle analysis can be found at: ';
|
||||
const String macOSDebugMessage = 'A summary of your macOS bundle analysis can be found at: ';
|
||||
const String runDevToolsMessage = 'flutter pub global activate devtools; flutter pub global run devtools ';
|
||||
|
||||
void main() {
|
||||
@@ -55,11 +56,14 @@ void main() {
|
||||
testWithoutContext('--analyze-size flag produces expected output on hello_world for iOS', () async {
|
||||
final String workingDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
|
||||
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_size_test.');
|
||||
final Directory codeSizeDir = tempDir.childDirectory('code size dir')..createSync();
|
||||
final ProcessResult result = await processManager.run(<String>[
|
||||
flutterBin,
|
||||
'build',
|
||||
'ios',
|
||||
'--analyze-size',
|
||||
'--code-size-directory=${codeSizeDir.path}',
|
||||
'--no-codesign',
|
||||
], workingDirectory: workingDirectory);
|
||||
|
||||
@@ -79,10 +83,58 @@ void main() {
|
||||
.firstWhere((String line) => line.contains(runDevToolsMessage));
|
||||
final String commandArguments = devToolsCommand.split(runDevToolsMessage).last.trim();
|
||||
final String relativeAppSizePath = outputFilePath.split('.flutter-devtools/').last.trim();
|
||||
expect(commandArguments.contains('--appSizeBase=$relativeAppSizePath'), isTrue);
|
||||
|
||||
expect(commandArguments.contains('--appSizeBase=$relativeAppSizePath'), isTrue);
|
||||
expect(codeSizeDir.existsSync(), true);
|
||||
expect(result.exitCode, 0);
|
||||
}, skip: true); // Extremely flaky due to https://github.com/flutter/flutter/issues/68144
|
||||
tempDir.deleteSync(recursive: true);
|
||||
}, skip: !platform.isMacOS);
|
||||
|
||||
testWithoutContext('--analyze-size flag produces expected output on hello_world for macOS', () async {
|
||||
final String workingDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
|
||||
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_size_test.');
|
||||
final Directory codeSizeDir = tempDir.childDirectory('code size dir')..createSync();
|
||||
|
||||
final ProcessResult configResult = await processManager.run(<String>[
|
||||
flutterBin,
|
||||
'config',
|
||||
'--enable-macos-desktop',
|
||||
], workingDirectory: workingDirectory);
|
||||
|
||||
print(configResult.stdout);
|
||||
print(configResult.stderr);
|
||||
|
||||
final ProcessResult result = await processManager.run(<String>[
|
||||
flutterBin,
|
||||
'build',
|
||||
'macos',
|
||||
'--analyze-size',
|
||||
'--code-size-directory=${codeSizeDir.path}',
|
||||
], workingDirectory: workingDirectory);
|
||||
|
||||
print(result.stdout);
|
||||
print(result.stderr);
|
||||
expect(result.stdout.toString(), contains('Dart AOT symbols accounted decompressed size'));
|
||||
|
||||
final String line = result.stdout.toString()
|
||||
.split('\n')
|
||||
.firstWhere((String line) => line.contains(macOSDebugMessage));
|
||||
|
||||
final String outputFilePath = line.split(macOSDebugMessage).last.trim();
|
||||
expect(fileSystem.file(fileSystem.path.join(workingDirectory, outputFilePath)), exists);
|
||||
|
||||
final String devToolsCommand = result.stdout.toString()
|
||||
.split('\n')
|
||||
.firstWhere((String line) => line.contains(runDevToolsMessage));
|
||||
final String commandArguments = devToolsCommand.split(runDevToolsMessage).last.trim();
|
||||
final String relativeAppSizePath = outputFilePath.split('.flutter-devtools/').last.trim();
|
||||
|
||||
expect(commandArguments.contains('--appSizeBase=$relativeAppSizePath'), isTrue);
|
||||
expect(codeSizeDir.existsSync(), true);
|
||||
expect(result.exitCode, 0);
|
||||
tempDir.deleteSync(recursive: true);
|
||||
}, skip: !platform.isMacOS);
|
||||
|
||||
testWithoutContext('--analyze-size is only supported in release mode', () async {
|
||||
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||
|
||||
@@ -66,7 +66,7 @@ void main() {
|
||||
'--no-codesign',
|
||||
'--${buildMode.name}',
|
||||
'--obfuscate',
|
||||
'--split-debug-info=foo/',
|
||||
'--split-debug-info=foo debug info/',
|
||||
], workingDirectory: projectRoot);
|
||||
|
||||
buildPath = fileSystem.directory(fileSystem.path.join(
|
||||
|
||||
Reference in New Issue
Block a user