diff --git a/engine/src/flutter/tools/fuchsia/all_packages.list b/engine/src/flutter/tools/fuchsia/all_packages.list new file mode 100644 index 0000000000..5342cc5e88 --- /dev/null +++ b/engine/src/flutter/tools/fuchsia/all_packages.list @@ -0,0 +1,90 @@ +out/fuchsia_debug_x64/dart_aot_runner_package_manifest.json +out/fuchsia_debug_x64/dart_jit_runner_package_manifest.json +out/fuchsia_debug_x64/embedder_tests_package_manifest.json +out/fuchsia_debug_x64/flow_tests_package_manifest.json +out/fuchsia_debug_x64/flutter_aot_runner_package_manifest.json +out/fuchsia_debug_x64/flutter_jit_runner_package_manifest.json +out/fuchsia_debug_x64/flutter_runner_scenic_tests_package_manifest.json +out/fuchsia_debug_x64/flutter_runner_tests_package_manifest.json +out/fuchsia_debug_x64/flutter_runner_tzdata_tests_package_manifest.json +out/fuchsia_debug_x64/fml_tests_package_manifest.json +out/fuchsia_debug_x64/runtime_tests_package_manifest.json +out/fuchsia_debug_x64/shell_tests_package_manifest.json +out/fuchsia_debug_x64/testing_tests_package_manifest.json +out/fuchsia_debug_x64/txt_tests_package_manifest.json +out/fuchsia_debug_x64/ui_tests_package_manifest.json +out/fuchsia_release_x64/dart_aot_runner_package_manifest.json +out/fuchsia_release_x64/dart_jit_runner_package_manifest.json +out/fuchsia_release_x64/embedder_tests_package_manifest.json +out/fuchsia_release_x64/flow_tests_package_manifest.json +out/fuchsia_release_x64/flutter_aot_runner_package_manifest.json +out/fuchsia_release_x64/flutter_jit_runner_package_manifest.json +out/fuchsia_release_x64/flutter_runner_scenic_tests_package_manifest.json +out/fuchsia_release_x64/flutter_runner_tests_package_manifest.json +out/fuchsia_release_x64/flutter_runner_tzdata_tests_package_manifest.json +out/fuchsia_release_x64/fml_tests_package_manifest.json +out/fuchsia_release_x64/runtime_tests_package_manifest.json +out/fuchsia_release_x64/shell_tests_package_manifest.json +out/fuchsia_release_x64/testing_tests_package_manifest.json +out/fuchsia_release_x64/txt_tests_package_manifest.json +out/fuchsia_release_x64/ui_tests_package_manifest.json +out/fuchsia_profile_x64/dart_aot_runner_package_manifest.json +out/fuchsia_profile_x64/dart_jit_runner_package_manifest.json +out/fuchsia_profile_x64/embedder_tests_package_manifest.json +out/fuchsia_profile_x64/flow_tests_package_manifest.json +out/fuchsia_profile_x64/flutter_aot_runner_package_manifest.json +out/fuchsia_profile_x64/flutter_jit_runner_package_manifest.json +out/fuchsia_profile_x64/flutter_runner_scenic_tests_package_manifest.json +out/fuchsia_profile_x64/flutter_runner_tests_package_manifest.json +out/fuchsia_profile_x64/flutter_runner_tzdata_tests_package_manifest.json +out/fuchsia_profile_x64/fml_tests_package_manifest.json +out/fuchsia_profile_x64/runtime_tests_package_manifest.json +out/fuchsia_profile_x64/shell_tests_package_manifest.json +out/fuchsia_profile_x64/testing_tests_package_manifest.json +out/fuchsia_profile_x64/txt_tests_package_manifest.json +out/fuchsia_profile_x64/ui_tests_package_manifest.json +out/fuchsia_debug_arm64/dart_aot_runner_package_manifest.json +out/fuchsia_debug_arm64/dart_jit_runner_package_manifest.json +out/fuchsia_debug_arm64/embedder_tests_package_manifest.json +out/fuchsia_debug_arm64/flow_tests_package_manifest.json +out/fuchsia_debug_arm64/flutter_aot_runner_package_manifest.json +out/fuchsia_debug_arm64/flutter_jit_runner_package_manifest.json +out/fuchsia_debug_arm64/flutter_runner_scenic_tests_package_manifest.json +out/fuchsia_debug_arm64/flutter_runner_tests_package_manifest.json +out/fuchsia_debug_arm64/flutter_runner_tzdata_tests_package_manifest.json +out/fuchsia_debug_arm64/fml_tests_package_manifest.json +out/fuchsia_debug_arm64/runtime_tests_package_manifest.json +out/fuchsia_debug_arm64/shell_tests_package_manifest.json +out/fuchsia_debug_arm64/testing_tests_package_manifest.json +out/fuchsia_debug_arm64/txt_tests_package_manifest.json +out/fuchsia_debug_arm64/ui_tests_package_manifest.json +out/fuchsia_release_arm64/dart_aot_runner_package_manifest.json +out/fuchsia_release_arm64/dart_jit_runner_package_manifest.json +out/fuchsia_release_arm64/embedder_tests_package_manifest.json +out/fuchsia_release_arm64/flow_tests_package_manifest.json +out/fuchsia_release_arm64/flutter_aot_runner_package_manifest.json +out/fuchsia_release_arm64/flutter_jit_runner_package_manifest.json +out/fuchsia_release_arm64/flutter_runner_scenic_tests_package_manifest.json +out/fuchsia_release_arm64/flutter_runner_tests_package_manifest.json +out/fuchsia_release_arm64/flutter_runner_tzdata_tests_package_manifest.json +out/fuchsia_release_arm64/fml_tests_package_manifest.json +out/fuchsia_release_arm64/runtime_tests_package_manifest.json +out/fuchsia_release_arm64/shell_tests_package_manifest.json +out/fuchsia_release_arm64/testing_tests_package_manifest.json +out/fuchsia_release_arm64/txt_tests_package_manifest.json +out/fuchsia_release_arm64/ui_tests_package_manifest.json +out/fuchsia_profile_arm64/dart_aot_runner_package_manifest.json +out/fuchsia_profile_arm64/dart_jit_runner_package_manifest.json +out/fuchsia_profile_arm64/embedder_tests_package_manifest.json +out/fuchsia_profile_arm64/flow_tests_package_manifest.json +out/fuchsia_profile_arm64/flutter_aot_runner_package_manifest.json +out/fuchsia_profile_arm64/flutter_jit_runner_package_manifest.json +out/fuchsia_profile_arm64/flutter_runner_scenic_tests_package_manifest.json +out/fuchsia_profile_arm64/flutter_runner_tests_package_manifest.json +out/fuchsia_profile_arm64/flutter_runner_tzdata_tests_package_manifest.json +out/fuchsia_profile_arm64/fml_tests_package_manifest.json +out/fuchsia_profile_arm64/runtime_tests_package_manifest.json +out/fuchsia_profile_arm64/shell_tests_package_manifest.json +out/fuchsia_profile_arm64/testing_tests_package_manifest.json +out/fuchsia_profile_arm64/txt_tests_package_manifest.json +out/fuchsia_profile_arm64/ui_tests_package_manifest.json diff --git a/engine/src/flutter/tools/fuchsia/devshell/lib/vars.sh b/engine/src/flutter/tools/fuchsia/devshell/lib/vars.sh new file mode 100644 index 0000000000..0839363559 --- /dev/null +++ b/engine/src/flutter/tools/fuchsia/devshell/lib/vars.sh @@ -0,0 +1,48 @@ +#!/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. + + +if [[ -n "${ZSH_VERSION:-}" ]]; then + devshell_lib_dir=${${(%):-%x}:a:h} +else + devshell_lib_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +fi + +# Note: if this file location changes this path needs to change +FLUTTER_ENGINE_SRC_DIR="$(dirname "$(dirname "$(dirname "$(dirname "$(dirname "${devshell_lib_dir}")")")")")" +export FLUTTER_ENGINE_SRC_DIR +export FLUTTER_ENGINE_OUT_DIR="${FLUTTER_ENGINE_OUT_DIR:-${FLUTTER_ENGINE_SRC_DIR}/out}" +unset devshell_lib_dir + +# Find the fuchsia sdk location +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + export FLUTTER_ENGINE_FUCHSIA_SDK_DIR="${FLUTTER_ENGINE_SRC_DIR}/fuchsia/sdk/linux" +elif [[ "$OSTYPE" == "darwin"* ]]; then + export FLUTTER_ENGINE_FUCHSIA_SDK_DIR="${FLUTTER_ENGINE_SRC_DIR}/fuchsia/sdk/mac" +else + echo "We only support linux/mac" + exit 1 +fi + +function engine-is-stderr-tty { + [[ -t 2 ]] +} + +# engine-error prints a line to stderr with a red ERROR: prefix. +function engine-error { + if engine-is-stderr-tty; then + echo -e >&2 "\033[1;31mERROR:\033[0m $*" + else + echo -e >&2 "ERROR: $*" + fi +} + +function ensure_fuchsia_dir() { + if [[ -z "${FUCHSIA_DIR}" ]]; then + engine-error "A valid fuchsia.git checkout is required." \ + "Make sure you have a valid FUCHSIA_DIR." + exit 1 + fi +} diff --git a/engine/src/flutter/tools/fuchsia/devshell/serve.sh b/engine/src/flutter/tools/fuchsia/devshell/serve.sh new file mode 100755 index 0000000000..7adae92520 --- /dev/null +++ b/engine/src/flutter/tools/fuchsia/devshell/serve.sh @@ -0,0 +1,219 @@ +#!/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. + + +### Serves the out directory +## usage: +## -p port for "pm serve" to listen on +## -d device_name to use for connecting +## -r If you are running a remote workflow +## --only-serve-runners If set will only serve the flutter and dart runners +## --out the out directory (ex: fuchsia_debug_x64) + +#TODO: Take an out directory and use that to find the list of packages to publish + +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? + +# We need to use the fuchsia checkout still, make sure it is there +ensure_fuchsia_dir + +remote=false +device_name="" +port="8084" +only_serve_runners=false +while (($#)); do + case "$1" in + -p) + port="$2" + shift + ;; + -d) + device_name="$2" + shift + ;; + -r) + remote=true + ;; + --only-serve-runners) + only_serve_runners=true + ;; + *) + echo 2>&1 "Unknown argument: \"${1}\" ignored" + ;; + esac + shift +done + +# Start our package server +# TODO: Need to ask for the out directory to find the package list +# TODO: Generate the all_packages.list file +cd "${FLUTTER_ENGINE_SRC_DIR}" || exit +"${FLUTTER_ENGINE_FUCHSIA_SDK_DIR}/tools/pm" serve -vt \ + -repo "${FLUTTER_ENGINE_OUT_DIR}/tuf" \ + -l ":${port}" \ + -p "${FLUTTER_ENGINE_SRC_DIR}/flutter/tools/fuchsia/all_packages.list"& +serve_pid=$! + +# TODO: Set up the debug symbol server + +# Start our server and loop to check if our device is up give some slack time +# to ensure that pm has started +sleep 1 + +ffx="${FLUTTER_ENGINE_FUCHSIA_SDK_DIR}/tools/x64/ffx" + +serve_updates_target_addr="" +resolve_local_target() { + if [[ -z "${device_name}" ]]; then + engine-error "Must specify a device name with -d if using a local workflow" + exit 1 + fi + result=$("${ffx}" target list "${device_name}" --format a 2> /dev/null) + + if [[ $? == 0 ]]; then + serve_updates_target_addr=$result + fi +} + +resolve_target() { + if [[ $remote == true ]]; then + serve_updates_target_addr="-p 8022 ::1" + else + resolve_local_target + fi +} + +clear_target_addr() { + serve_updates_target_addr="" +} + +kill_child_processes() { + child_pids=$(jobs -p) + if [[ -n "${child_pids}" ]]; then + # Note: child_pids must be expanded to args here. + kill ${child_pids} 2> /dev/null + wait 2> /dev/null + fi +} +trap kill_child_processes EXIT + +run_ssh_command() { + # Enusre we have a target to ssh to + if [[ -z $serve_updates_target_addr ]]; then + return 1 + fi + + build_dir="$(<"${FUCHSIA_DIR}/.fx-build-dir")" + ssh_config="${FUCHSIA_DIR}/${build_dir}/ssh-keys/ssh_config" + if [[ ! -e $ssh_config ]]; then + engine-error "No valid ssh_config at $ssh_config" + fi + + if [[ $remote == true ]]; then + ssh -F "${ssh_config}" -p 8022 ::1 "$@" + else + ssh -F "${ssh_config}" "$serve_updates_target_addr" "$@" + fi +} + +# State is used to prevent too much output +state="discover" +while true; do + sleep 1 + if ! kill -0 "${serve_pid}" 2> /dev/null; then + echo "Server died, exiting" + serve_pid= + exit 1 + fi + + if [[ "$state" == "discover" ]]; then + # While we're still trying to connect to the device, clear the target + # address state so we re-resolve. + clear_target_addr + resolve_target + run_ssh_command exit 2>/dev/null + ping_result=$? + else + run_ssh_command -O check > /dev/null 2>&1 + ping_result=$? + fi + + if [[ "$state" == "discover" && "$ping_result" == 0 ]]; then + echo "Device up" + state="config" + fi + + if [[ "$state" == "config" ]]; then + echo "Registering engine as update source" + + # Get our ssh host address + addr=$(run_ssh_command 'echo $SSH_CONNECTION' | cut -d ' ' -f 1) + if [[ $? -ne 0 || -z "${addr}" ]]; then + engine-error "unable to determine host address as seen from the target. Is the target up?" + exit 1 + fi + + addr="$(echo "${addr}" | sed 's/%/%25/g')" + if [[ "${addr}" =~ : ]]; then + addr="[${addr}]" + fi + + config_url="http://${addr}:${port}/config.json" + run_ssh_command amberctl add_src \ + -n "engine" \ + -f "${config_url}" + err=$? + + if [[ $err -ne 0 ]]; then + engine-error "Failed to add update source" + exit 1 + fi + + if [[ $only_serve_runners == true ]]; then + run_ssh_command "pkgctl rule replace json ' + { + \"version\": \"1\", + \"content\": [ + { + \"host_match\": \"fuchsia.com\", \"host_replacement\": \"engine\", + \"path_prefix_match\": \"/flutter_jit_runner/\", \"path_prefix_replacement\": \"/flutter_jit_runner/\" + }, + { + \"host_match\": \"fuchsia.com\", \"host_replacement\": \"engine\", + \"path_prefix_match\": \"/flutter_jit_runner\", \"path_prefix_replacement\": \"/flutter_jit_runner\" + }, + { + \"host_match\": \"fuchsia.com\", \"host_replacement\": \"engine\", + \"path_prefix_match\": \"/flutter_aot_runner/\", \"path_prefix_replacement\": \"/flutter_aot_runner/\" + }, + { + \"host_match\": \"fuchsia.com\", \"host_replacement\": \"engine\", + \"path_prefix_match\": \"/flutter_aot_runner\", \"path_prefix_replacement\": \"/flutter_aot_runner\" + }, + { + \"host_match\": \"fuchsia.com\", \"host_replacement\": \"devhost\", + \"path_prefix_match\": \"/\", \"path_prefix_replacement\": \"/\" + }] + }'" + err=$? + if [[ $err -ne 0 ]]; then + engine-error "Failed to add runner rewrite rules" + exit 1 + fi + fi + + state="ready" + fi + + if [[ "$state" == "ready" ]]; then + if [[ "$ping_result" != 0 ]]; then + echo "Device lost" + state="discover" + else + sleep 1 + fi + fi +done + diff --git a/engine/src/flutter/tools/fuchsia/fuchsia_archive.gni b/engine/src/flutter/tools/fuchsia/fuchsia_archive.gni index 72ed98df69..fb0f0e74f9 100644 --- a/engine/src/flutter/tools/fuchsia/fuchsia_archive.gni +++ b/engine/src/flutter/tools/fuchsia/fuchsia_archive.gni @@ -113,8 +113,6 @@ template("fuchsia_archive") { rebase_path("//fuchsia/sdk/$host_os/tools/pm"), "--package-dir", rebase_path(far_base_dir), - "--signing-key", - rebase_path("//flutter/tools/fuchsia/development.key"), "--far-name", target_name, "--manifest-json-file", diff --git a/engine/src/flutter/tools/fuchsia/gen_package.py b/engine/src/flutter/tools/fuchsia/gen_package.py index a5623b17e6..873356f7c6 100755 --- a/engine/src/flutter/tools/fuchsia/gen_package.py +++ b/engine/src/flutter/tools/fuchsia/gen_package.py @@ -3,7 +3,7 @@ # 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. -""" Generate a Fuchsia FAR Archive from an asset manifest and a signing key. +""" Generate a Fuchsia FAR Archive from an asset manifest. """ import argparse @@ -15,7 +15,6 @@ import sys from gather_flutter_runner_artifacts import CreateMetaPackage - # Generates the manifest and returns the file. def GenerateManifest(package_dir): full_paths = [] @@ -26,6 +25,7 @@ def GenerateManifest(package_dir): from_package = os.path.abspath(os.path.join(package_dir, rel_path)) assert from_package, 'Failed to create from_package for %s' % os.path.join(root, f) full_paths.append('%s=%s' % (rel_path, from_package)) + parent_dir = os.path.abspath(os.path.join(package_dir, os.pardir)) manifest_file_name = os.path.basename(package_dir) + '.manifest' manifest_path = os.path.join(parent_dir, manifest_file_name) @@ -57,8 +57,6 @@ def main(): parser.add_argument('--pm-bin', dest='pm_bin', action='store', required=True) parser.add_argument( '--package-dir', dest='package_dir', action='store', required=True) - parser.add_argument( - '--signing-key', dest='signing_key', action='store', required=True) parser.add_argument( '--manifest-file', dest='manifest_file', action='store', required=False) parser.add_argument( @@ -70,7 +68,6 @@ def main(): assert os.path.exists(args.pm_bin) assert os.path.exists(args.package_dir) - assert os.path.exists(args.signing_key) pkg_dir = args.package_dir if not os.path.exists(os.path.join(pkg_dir, 'meta', 'package')): @@ -93,8 +90,6 @@ def main(): output_dir, '-n', args.far_name, - '-k', - args.signing_key, '-m', manifest_file, ]