This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[fuchsia] Workflow scripts. #35822
Merged
Merged
[fuchsia] Workflow scripts. #35822
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| #!/bin/bash | ||
| # Copyright 2013 The Flutter Authors. All rights reserved. | ||
| # Use of this source code is governed by a BSD-style license that can be | ||
| # found in the LICENSE file. | ||
| # | ||
| ### Builds and copies the Flutter and Dart runners for the Fuchsia platform. | ||
| ### | ||
| ### Arguments: | ||
| ### --runtime-mode: The runtime mode to build Flutter in. | ||
| ### Valid values: [debug, profile, release] | ||
| ### Default value: debug | ||
| ### --fuchsia-cpu: The architecture of the Fuchsia device to target. | ||
| ### Valid values: [x64, arm64] | ||
| ### Default value: x64 | ||
| ### --unoptimized: Disables C++ compiler optimizations. | ||
| ### --goma: Speeds up builds for Googlers. sorry. :( | ||
| ### | ||
| ### Any additional arguments are forwarded directly to GN. | ||
|
|
||
| set -e # Fail on any error. | ||
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? | ||
|
|
||
| ensure_fuchsia_dir | ||
| ensure_engine_dir | ||
| ensure_ninja | ||
|
|
||
| # Parse arguments. | ||
| runtime_mode="debug" | ||
| compilation_mode="jit" | ||
| fuchsia_cpu="x64" | ||
| goma=0 | ||
| goma_flags="" | ||
| ninja_cmd="ninja" | ||
| unoptimized_flags="" | ||
| unoptimized_suffix="" | ||
| extra_gn_args=() | ||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| --runtime-mode) | ||
| shift # past argument | ||
| runtime_mode="$1" | ||
| shift # past value | ||
|
|
||
| if [[ "${runtime_mode}" == debug ]] | ||
| then | ||
| compilation_mode="jit" | ||
| elif [[ "${runtime_mode}" == profile || "${runtime_mode}" == release ]] | ||
| then | ||
| compilation_mode="aot" | ||
| else | ||
| engine-error "Invalid value for --runtime_mode: ${runtime_mode}" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| --fuchsia-cpu) | ||
| shift # past argument | ||
| fuchsia_cpu="$1" | ||
| shift # past value | ||
|
|
||
| if [[ "${fuchsia_cpu}" != x64 && "${fuchsia_cpu}" != arm64 ]] | ||
| then | ||
| engine-error "Invalid value for --fuchsia-cpu: ${fuchsia_cpu}" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| --goma) | ||
| goma=1 | ||
| goma_flags="--goma" | ||
| ninja_cmd="autoninja" | ||
| shift # past argument | ||
| ;; | ||
| --unopt|--unoptimized) | ||
| unoptimized_flags="--unoptimized" | ||
| unoptimized_suffix="_unopt" | ||
| shift # past argument | ||
| ;; | ||
| *) | ||
| extra_gn_args+=("$1") # forward argument | ||
| shift # past argument | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| fuchsia_flutter_git_revision="$(cat $FUCHSIA_DIR/integration/jiri.lock | grep -A 1 "\"package\": \"flutter/fuchsia\"" | grep "git_revision" | tr ":" "\n" | sed -n 3p | tr "\"" "\n" | sed -n 1p)" | ||
| current_flutter_git_revision="$(git -C $ENGINE_DIR/flutter rev-parse HEAD)" | ||
| if [[ $fuchsia_flutter_git_revision != $current_flutter_git_revision ]] | ||
| then | ||
| engine-warning "Your current Flutter Engine commit ($current_flutter_git_revision) is not Fuchsia's Flutter Engine commit ($fuchsia_flutter_git_revision)." | ||
| engine-warning "You should checkout Fuchsia's Flutter Engine commit. This avoids crashing on app startup from using a different version of the Dart SDK. See https://github.com/flutter/flutter/wiki/Compiling-the-engine#important-dart-version-synchronization-on-fuchsia for more details." | ||
| engine-warning "You can checkout Fuchsia's Flutter Engine commit by running:" | ||
| engine-warning '$ENGINE_DIR/flutter/tools/fuchsia/devshell/checkout_fuchsia_revision.sh' | ||
| engine-warning "If you have already checked out Fuchsia's Flutter Engine commit and then committed some additional changes, please ignore the above warning." | ||
| fi | ||
|
|
||
| all_gn_args="--fuchsia --no-lto --fuchsia-cpu="${fuchsia_cpu}" --runtime-mode="${runtime_mode}" ${goma_flags} ${unoptimized_flags} ${extra_gn_args[@]}" | ||
| engine-info "GN args: ${all_gn_args}" | ||
|
|
||
| "$ENGINE_DIR"/flutter/tools/gn ${all_gn_args} | ||
|
|
||
| fuchsia_out_dir_name=fuchsia_${runtime_mode}${unoptimized_suffix}_${fuchsia_cpu} | ||
| fuchsia_out_dir="$ENGINE_DIR"/out/"${fuchsia_out_dir_name}" | ||
| engine-info "Building ${fuchsia_out_dir_name}..." | ||
| ${ninja_cmd} -C "${fuchsia_out_dir}" flutter/shell/platform/fuchsia | ||
|
|
||
| engine-info "Making Fuchsia's Flutter prebuilts writable..." | ||
| chmod -R +w "$FUCHSIA_DIR"/prebuilt/third_party/flutter | ||
|
|
||
| engine-info "Copying the patched SDK (dart:ui, dart:zircon, dart:fuchsia) to Fuchsia..." | ||
| cp -ra "${fuchsia_out_dir}"/flutter_runner_patched_sdk/* "$FUCHSIA_DIR"/prebuilt/third_party/flutter/"${fuchsia_cpu}"/release/aot/flutter_runner_patched_sdk/ | ||
|
|
||
| engine-info "Registering debug symbols..." | ||
| "$ENGINE_DIR"/fuchsia/sdk/linux/tools/x64/symbol-index add "${fuchsia_out_dir}"/.build-id "${fuchsia_out_dir}" | ||
|
|
||
| if [[ "${runtime_mode}" == release ]] | ||
| then | ||
| flutter_runner_pkg="flutter_jit_product_runner-0.far" | ||
| engine-info "Copying the Flutter JIT product runner (${flutter_runner_pkg}) to Fuchsia..." | ||
| cp "${fuchsia_out_dir}"/"${flutter_runner_pkg}" "$FUCHSIA_DIR"/prebuilt/third_party/flutter/"${fuchsia_cpu}"/"${runtime_mode}"/jit/"${flutter_runner_pkg}" | ||
|
|
||
| flutter_runner_pkg="flutter_aot_product_runner-0.far" | ||
| engine-info "Copying the Flutter AOT product runner (${flutter_runner_pkg}) to Fuchsia..." | ||
| cp "${fuchsia_out_dir}"/"${flutter_runner_pkg}" "$FUCHSIA_DIR"/prebuilt/third_party/flutter/"${fuchsia_cpu}"/"${runtime_mode}"/aot/"${flutter_runner_pkg}" | ||
|
|
||
| dart_runner_pkg="dart_jit_product_runner-0.far" | ||
| engine-info "Copying the Dart JIT product runner (${dart_runner_pkg}) to Fuchsia..." | ||
| cp "${fuchsia_out_dir}"/"${dart_runner_pkg}" "$FUCHSIA_DIR"/prebuilt/third_party/flutter/"${fuchsia_cpu}"/"${runtime_mode}"/jit/"${dart_runner_pkg}" | ||
|
|
||
| dart_runner_pkg="dart_aot_product_runner-0.far" | ||
| engine-info "Copying the Dart AOT product runner (${dart_runner_pkg}) to Fuchsia..." | ||
| cp "${fuchsia_out_dir}"/"${dart_runner_pkg}" "$FUCHSIA_DIR"/prebuilt/third_party/flutter/"${fuchsia_cpu}"/"${runtime_mode}"/aot/"${dart_runner_pkg}" | ||
| else | ||
| flutter_runner_pkg="flutter_${compilation_mode}_runner-0.far" | ||
| engine-info "Copying the Flutter runner (${flutter_runner_pkg}) to Fuchsia..." | ||
| cp "${fuchsia_out_dir}"/"${flutter_runner_pkg}" "$FUCHSIA_DIR"/prebuilt/third_party/flutter/"${fuchsia_cpu}"/"${runtime_mode}"/"${compilation_mode}"/"${flutter_runner_pkg}" | ||
|
|
||
| dart_runner_pkg="dart_${compilation_mode}_runner-0.far" | ||
| engine-info "Copying the Dart runner (${dart_runner_pkg}) to Fuchsia..." | ||
| cp "${fuchsia_out_dir}"/"${dart_runner_pkg}" "$FUCHSIA_DIR"/prebuilt/third_party/flutter/"${fuchsia_cpu}"/"${runtime_mode}"/"${compilation_mode}"/"${dart_runner_pkg}" | ||
| fi | ||
|
|
||
| # TODO(akbiggs): Warn the developer when their current | ||
| # Fuchsia configuration (`fx set`) is mismatched with the runner | ||
| # they just deployed. | ||
|
|
||
| # TODO(akbiggs): Copy the tests over. I couldn't figure out a glob that grabs all of them. | ||
|
|
||
| echo "Done. You can now build Fuchsia with your Flutter Engine changes by running:" | ||
| echo ' cd $FUCHSIA_DIR' | ||
| # TODO(akbiggs): I'm not sure what example to give for arm64. | ||
| if [[ "${fuchsia_cpu}" == x64 ]] | ||
| then | ||
| if [[ "${runtime_mode}" == debug ]] | ||
| then | ||
| echo " fx set workstation_eng.x64" | ||
| else | ||
| echo " fx set workstation_eng.x64 --release" | ||
| fi | ||
| fi | ||
| echo ' fx build' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tools/fuchsia/devshell/test/test_build_and_copy_to_fuchsia.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/bin/bash | ||
| # Copyright 2013 The Flutter Authors. All rights reserved. | ||
| # Use of this source code is governed by a BSD-style license that can be | ||
| # found in the LICENSE file. | ||
| # | ||
| ### Tests build_and_copy_to_fuchsia.sh by running it with various arguments. | ||
| ### This script doesn't assert the results but just checks that the script runs | ||
| ### successfully every time. | ||
| ### | ||
| ### This script doesn't run on CQ, it's only used for local testing. | ||
|
|
||
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../lib/vars.sh || exit $? | ||
|
|
||
| ensure_fuchsia_dir | ||
| ensure_engine_dir | ||
|
|
||
| set -e # Fail on any error. | ||
|
|
||
| # TODO(akbiggs): Remove prebuilts before each build to check that the right set of | ||
| # prebuilts is being deployed. I tried this initially but gave up because | ||
| # build_and_copy_to_fuchsia.sh would fail when the prebuilt directories were missing. | ||
|
|
||
| engine-info "Testing build_and_copy_to_fuchsia.sh with no args..." | ||
| "$ENGINE_DIR"/flutter/tools/fuchsia/devshell/build_and_copy_to_fuchsia.sh | ||
|
|
||
| engine-info "Testing build_and_copy_to_fuchsia.sh --unoptimized..." | ||
| $ENGINE_DIR/flutter/tools/fuchsia/devshell/build_and_copy_to_fuchsia.sh --unoptimized | ||
|
|
||
| engine-info "Testing build_and_copy_to_fuchsia.sh --runtime-mode profile..." | ||
| $ENGINE_DIR/flutter/tools/fuchsia/devshell/build_and_copy_to_fuchsia.sh --runtime-mode profile | ||
|
|
||
| engine-info "Testing build_and_copy_to_fuchsia.sh --runtime-mode release..." | ||
| $ENGINE_DIR/flutter/tools/fuchsia/devshell/build_and_copy_to_fuchsia.sh --runtime-mode release | ||
|
|
||
| engine-info "Testing build_and_copy_to_fuchsia.sh --fuchsia-cpu arm64..." | ||
| $ENGINE_DIR/flutter/tools/fuchsia/devshell/build_and_copy_to_fuchsia.sh --fuchsia-cpu arm64 | ||
|
|
||
| engine-info "Testing build_and_copy_to_fuchsia.sh --goma..." | ||
| $ENGINE_DIR/flutter/tools/fuchsia/devshell/build_and_copy_to_fuchsia.sh --goma | ||
|
|
||
| engine-info "Testing build_and_copy_to_fuchsia.sh --no-prebuilt-dart-sdk..." | ||
| $ENGINE_DIR/flutter/tools/fuchsia/devshell/build_and_copy_to_fuchsia.sh --no-prebuilt-dart-sdk |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone use
workstation_eng.arm64?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be broken for me, opened fxb/108361.