From e4a1913e013d588db5b77ced65493f2739c79053 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Tue, 23 Apr 2019 17:20:22 -0700 Subject: [PATCH] Support local engine and asset sync for macOS (#31515) --- .../bin/macos_build_flutter_assets.sh | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/bin/macos_build_flutter_assets.sh b/packages/flutter_tools/bin/macos_build_flutter_assets.sh index 528a4195f3..f83cb238c5 100755 --- a/packages/flutter_tools/bin/macos_build_flutter_assets.sh +++ b/packages/flutter_tools/bin/macos_build_flutter_assets.sh @@ -5,7 +5,6 @@ # TODO(jonahwilliams): refactor this and xcode_backend.sh into one script # once macOS supports the same configuration as iOS. - RunCommand() { if [[ -n "$VERBOSE_SCRIPT_LOGGING" ]]; then echo "♦ $*" @@ -40,6 +39,37 @@ if [[ -n "$TRACK_WIDGET_CREATION" ]]; then track_widget_creation_flag="--track-widget-creation" fi +# Copy the framework and handle local engine builds. +framework_name = "FlutterMacOS.framework" +derived_dir="${SOURCE_ROOT}/../build/macos/Build/Products/flutter_framework" +framework_path="${FLUTTER_ROOT}/bin/cache/artifacts/engine/darwin-x64" +flutter_framework="${framework_path}/${framework_name}" + +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 "========================================================================" + EchoError "ERROR: Requested build with Flutter local engine at '${LOCAL_ENGINE}'" + EchoError "This engine is not compatible with FLUTTER_BUILD_MODE: '${build_mode}'." + EchoError "You can fix this by updating the LOCAL_ENGINE environment variable, or" + EchoError "by running:" + EchoError " flutter build macos --local-engine=host_${build_mode}" + EchoError "or" + EchoError " flutter build macos --local-engine=host_${build_mode}_unopt" + EchoError "========================================================================" + exit -1 + fi + local_engine_flag="--local-engine=${LOCAL_ENGINE}" + flutter_framework="${FLUTTER_ENGINE}/out/${LOCAL_ENGINE}/${framework_name}" +fi + +RunCommand mkdir -p -- "$derived_dir" +RunCommand rm -rf -- "${derived_dir}/${framework_name}" +RunCommand cp -Rp -- "${flutter_framework}" "${derived_dir}" + # Set the build mode build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")" @@ -49,4 +79,6 @@ RunCommand "${FLUTTER_ROOT}/bin/flutter" --suppress-analytics \ --target-platform=darwin-x64 \ --target="${target_path}" \ --${build_mode} \ - ${track_widget_creation_flag} + ${track_widget_creation_flag} \ + ${flutter_engine_flag} \ + ${local_engine_flag}