Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b88f7a5

Browse files
authored
Add script to serve fuchsia packages (#26380)
1 parent beb712f commit b88f7a5

File tree

5 files changed

+359
-9
lines changed

5 files changed

+359
-9
lines changed

tools/fuchsia/all_packages.list

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
out/fuchsia_debug_x64/dart_aot_runner_package_manifest.json
2+
out/fuchsia_debug_x64/dart_jit_runner_package_manifest.json
3+
out/fuchsia_debug_x64/embedder_tests_package_manifest.json
4+
out/fuchsia_debug_x64/flow_tests_package_manifest.json
5+
out/fuchsia_debug_x64/flutter_aot_runner_package_manifest.json
6+
out/fuchsia_debug_x64/flutter_jit_runner_package_manifest.json
7+
out/fuchsia_debug_x64/flutter_runner_scenic_tests_package_manifest.json
8+
out/fuchsia_debug_x64/flutter_runner_tests_package_manifest.json
9+
out/fuchsia_debug_x64/flutter_runner_tzdata_tests_package_manifest.json
10+
out/fuchsia_debug_x64/fml_tests_package_manifest.json
11+
out/fuchsia_debug_x64/runtime_tests_package_manifest.json
12+
out/fuchsia_debug_x64/shell_tests_package_manifest.json
13+
out/fuchsia_debug_x64/testing_tests_package_manifest.json
14+
out/fuchsia_debug_x64/txt_tests_package_manifest.json
15+
out/fuchsia_debug_x64/ui_tests_package_manifest.json
16+
out/fuchsia_release_x64/dart_aot_runner_package_manifest.json
17+
out/fuchsia_release_x64/dart_jit_runner_package_manifest.json
18+
out/fuchsia_release_x64/embedder_tests_package_manifest.json
19+
out/fuchsia_release_x64/flow_tests_package_manifest.json
20+
out/fuchsia_release_x64/flutter_aot_runner_package_manifest.json
21+
out/fuchsia_release_x64/flutter_jit_runner_package_manifest.json
22+
out/fuchsia_release_x64/flutter_runner_scenic_tests_package_manifest.json
23+
out/fuchsia_release_x64/flutter_runner_tests_package_manifest.json
24+
out/fuchsia_release_x64/flutter_runner_tzdata_tests_package_manifest.json
25+
out/fuchsia_release_x64/fml_tests_package_manifest.json
26+
out/fuchsia_release_x64/runtime_tests_package_manifest.json
27+
out/fuchsia_release_x64/shell_tests_package_manifest.json
28+
out/fuchsia_release_x64/testing_tests_package_manifest.json
29+
out/fuchsia_release_x64/txt_tests_package_manifest.json
30+
out/fuchsia_release_x64/ui_tests_package_manifest.json
31+
out/fuchsia_profile_x64/dart_aot_runner_package_manifest.json
32+
out/fuchsia_profile_x64/dart_jit_runner_package_manifest.json
33+
out/fuchsia_profile_x64/embedder_tests_package_manifest.json
34+
out/fuchsia_profile_x64/flow_tests_package_manifest.json
35+
out/fuchsia_profile_x64/flutter_aot_runner_package_manifest.json
36+
out/fuchsia_profile_x64/flutter_jit_runner_package_manifest.json
37+
out/fuchsia_profile_x64/flutter_runner_scenic_tests_package_manifest.json
38+
out/fuchsia_profile_x64/flutter_runner_tests_package_manifest.json
39+
out/fuchsia_profile_x64/flutter_runner_tzdata_tests_package_manifest.json
40+
out/fuchsia_profile_x64/fml_tests_package_manifest.json
41+
out/fuchsia_profile_x64/runtime_tests_package_manifest.json
42+
out/fuchsia_profile_x64/shell_tests_package_manifest.json
43+
out/fuchsia_profile_x64/testing_tests_package_manifest.json
44+
out/fuchsia_profile_x64/txt_tests_package_manifest.json
45+
out/fuchsia_profile_x64/ui_tests_package_manifest.json
46+
out/fuchsia_debug_arm64/dart_aot_runner_package_manifest.json
47+
out/fuchsia_debug_arm64/dart_jit_runner_package_manifest.json
48+
out/fuchsia_debug_arm64/embedder_tests_package_manifest.json
49+
out/fuchsia_debug_arm64/flow_tests_package_manifest.json
50+
out/fuchsia_debug_arm64/flutter_aot_runner_package_manifest.json
51+
out/fuchsia_debug_arm64/flutter_jit_runner_package_manifest.json
52+
out/fuchsia_debug_arm64/flutter_runner_scenic_tests_package_manifest.json
53+
out/fuchsia_debug_arm64/flutter_runner_tests_package_manifest.json
54+
out/fuchsia_debug_arm64/flutter_runner_tzdata_tests_package_manifest.json
55+
out/fuchsia_debug_arm64/fml_tests_package_manifest.json
56+
out/fuchsia_debug_arm64/runtime_tests_package_manifest.json
57+
out/fuchsia_debug_arm64/shell_tests_package_manifest.json
58+
out/fuchsia_debug_arm64/testing_tests_package_manifest.json
59+
out/fuchsia_debug_arm64/txt_tests_package_manifest.json
60+
out/fuchsia_debug_arm64/ui_tests_package_manifest.json
61+
out/fuchsia_release_arm64/dart_aot_runner_package_manifest.json
62+
out/fuchsia_release_arm64/dart_jit_runner_package_manifest.json
63+
out/fuchsia_release_arm64/embedder_tests_package_manifest.json
64+
out/fuchsia_release_arm64/flow_tests_package_manifest.json
65+
out/fuchsia_release_arm64/flutter_aot_runner_package_manifest.json
66+
out/fuchsia_release_arm64/flutter_jit_runner_package_manifest.json
67+
out/fuchsia_release_arm64/flutter_runner_scenic_tests_package_manifest.json
68+
out/fuchsia_release_arm64/flutter_runner_tests_package_manifest.json
69+
out/fuchsia_release_arm64/flutter_runner_tzdata_tests_package_manifest.json
70+
out/fuchsia_release_arm64/fml_tests_package_manifest.json
71+
out/fuchsia_release_arm64/runtime_tests_package_manifest.json
72+
out/fuchsia_release_arm64/shell_tests_package_manifest.json
73+
out/fuchsia_release_arm64/testing_tests_package_manifest.json
74+
out/fuchsia_release_arm64/txt_tests_package_manifest.json
75+
out/fuchsia_release_arm64/ui_tests_package_manifest.json
76+
out/fuchsia_profile_arm64/dart_aot_runner_package_manifest.json
77+
out/fuchsia_profile_arm64/dart_jit_runner_package_manifest.json
78+
out/fuchsia_profile_arm64/embedder_tests_package_manifest.json
79+
out/fuchsia_profile_arm64/flow_tests_package_manifest.json
80+
out/fuchsia_profile_arm64/flutter_aot_runner_package_manifest.json
81+
out/fuchsia_profile_arm64/flutter_jit_runner_package_manifest.json
82+
out/fuchsia_profile_arm64/flutter_runner_scenic_tests_package_manifest.json
83+
out/fuchsia_profile_arm64/flutter_runner_tests_package_manifest.json
84+
out/fuchsia_profile_arm64/flutter_runner_tzdata_tests_package_manifest.json
85+
out/fuchsia_profile_arm64/fml_tests_package_manifest.json
86+
out/fuchsia_profile_arm64/runtime_tests_package_manifest.json
87+
out/fuchsia_profile_arm64/shell_tests_package_manifest.json
88+
out/fuchsia_profile_arm64/testing_tests_package_manifest.json
89+
out/fuchsia_profile_arm64/txt_tests_package_manifest.json
90+
out/fuchsia_profile_arm64/ui_tests_package_manifest.json

tools/fuchsia/devshell/lib/vars.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# Copyright 2013 The Flutter Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
7+
if [[ -n "${ZSH_VERSION:-}" ]]; then
8+
devshell_lib_dir=${${(%):-%x}:a:h}
9+
else
10+
devshell_lib_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
11+
fi
12+
13+
# Note: if this file location changes this path needs to change
14+
FLUTTER_ENGINE_SRC_DIR="$(dirname "$(dirname "$(dirname "$(dirname "$(dirname "${devshell_lib_dir}")")")")")"
15+
export FLUTTER_ENGINE_SRC_DIR
16+
export FLUTTER_ENGINE_OUT_DIR="${FLUTTER_ENGINE_OUT_DIR:-${FLUTTER_ENGINE_SRC_DIR}/out}"
17+
unset devshell_lib_dir
18+
19+
# Find the fuchsia sdk location
20+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
21+
export FLUTTER_ENGINE_FUCHSIA_SDK_DIR="${FLUTTER_ENGINE_SRC_DIR}/fuchsia/sdk/linux"
22+
elif [[ "$OSTYPE" == "darwin"* ]]; then
23+
export FLUTTER_ENGINE_FUCHSIA_SDK_DIR="${FLUTTER_ENGINE_SRC_DIR}/fuchsia/sdk/mac"
24+
else
25+
echo "We only support linux/mac"
26+
exit 1
27+
fi
28+
29+
function engine-is-stderr-tty {
30+
[[ -t 2 ]]
31+
}
32+
33+
# engine-error prints a line to stderr with a red ERROR: prefix.
34+
function engine-error {
35+
if engine-is-stderr-tty; then
36+
echo -e >&2 "\033[1;31mERROR:\033[0m $*"
37+
else
38+
echo -e >&2 "ERROR: $*"
39+
fi
40+
}
41+
42+
function ensure_fuchsia_dir() {
43+
if [[ -z "${FUCHSIA_DIR}" ]]; then
44+
engine-error "A valid fuchsia.git checkout is required." \
45+
"Make sure you have a valid FUCHSIA_DIR."
46+
exit 1
47+
fi
48+
}

tools/fuchsia/devshell/serve.sh

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
#!/bin/bash
2+
# Copyright 2013 The Flutter Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
7+
### Serves the out directory
8+
## usage:
9+
## -p port for "pm serve" to listen on
10+
## -d device_name to use for connecting
11+
## -r If you are running a remote workflow
12+
## --only-serve-runners If set will only serve the flutter and dart runners
13+
## --out the out directory (ex: fuchsia_debug_x64)
14+
15+
#TODO: Take an out directory and use that to find the list of packages to publish
16+
17+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $?
18+
19+
# We need to use the fuchsia checkout still, make sure it is there
20+
ensure_fuchsia_dir
21+
22+
remote=false
23+
device_name=""
24+
port="8084"
25+
only_serve_runners=false
26+
while (($#)); do
27+
case "$1" in
28+
-p)
29+
port="$2"
30+
shift
31+
;;
32+
-d)
33+
device_name="$2"
34+
shift
35+
;;
36+
-r)
37+
remote=true
38+
;;
39+
--only-serve-runners)
40+
only_serve_runners=true
41+
;;
42+
*)
43+
echo 2>&1 "Unknown argument: \"${1}\" ignored"
44+
;;
45+
esac
46+
shift
47+
done
48+
49+
# Start our package server
50+
# TODO: Need to ask for the out directory to find the package list
51+
# TODO: Generate the all_packages.list file
52+
cd "${FLUTTER_ENGINE_SRC_DIR}" || exit
53+
"${FLUTTER_ENGINE_FUCHSIA_SDK_DIR}/tools/pm" serve -vt \
54+
-repo "${FLUTTER_ENGINE_OUT_DIR}/tuf" \
55+
-l ":${port}" \
56+
-p "${FLUTTER_ENGINE_SRC_DIR}/flutter/tools/fuchsia/all_packages.list"&
57+
serve_pid=$!
58+
59+
# TODO: Set up the debug symbol server
60+
61+
# Start our server and loop to check if our device is up give some slack time
62+
# to ensure that pm has started
63+
sleep 1
64+
65+
ffx="${FLUTTER_ENGINE_FUCHSIA_SDK_DIR}/tools/x64/ffx"
66+
67+
serve_updates_target_addr=""
68+
resolve_local_target() {
69+
if [[ -z "${device_name}" ]]; then
70+
engine-error "Must specify a device name with -d if using a local workflow"
71+
exit 1
72+
fi
73+
result=$("${ffx}" target list "${device_name}" --format a 2> /dev/null)
74+
75+
if [[ $? == 0 ]]; then
76+
serve_updates_target_addr=$result
77+
fi
78+
}
79+
80+
resolve_target() {
81+
if [[ $remote == true ]]; then
82+
serve_updates_target_addr="-p 8022 ::1"
83+
else
84+
resolve_local_target
85+
fi
86+
}
87+
88+
clear_target_addr() {
89+
serve_updates_target_addr=""
90+
}
91+
92+
kill_child_processes() {
93+
child_pids=$(jobs -p)
94+
if [[ -n "${child_pids}" ]]; then
95+
# Note: child_pids must be expanded to args here.
96+
kill ${child_pids} 2> /dev/null
97+
wait 2> /dev/null
98+
fi
99+
}
100+
trap kill_child_processes EXIT
101+
102+
run_ssh_command() {
103+
# Enusre we have a target to ssh to
104+
if [[ -z $serve_updates_target_addr ]]; then
105+
return 1
106+
fi
107+
108+
build_dir="$(<"${FUCHSIA_DIR}/.fx-build-dir")"
109+
ssh_config="${FUCHSIA_DIR}/${build_dir}/ssh-keys/ssh_config"
110+
if [[ ! -e $ssh_config ]]; then
111+
engine-error "No valid ssh_config at $ssh_config"
112+
fi
113+
114+
if [[ $remote == true ]]; then
115+
ssh -F "${ssh_config}" -p 8022 ::1 "$@"
116+
else
117+
ssh -F "${ssh_config}" "$serve_updates_target_addr" "$@"
118+
fi
119+
}
120+
121+
# State is used to prevent too much output
122+
state="discover"
123+
while true; do
124+
sleep 1
125+
if ! kill -0 "${serve_pid}" 2> /dev/null; then
126+
echo "Server died, exiting"
127+
serve_pid=
128+
exit 1
129+
fi
130+
131+
if [[ "$state" == "discover" ]]; then
132+
# While we're still trying to connect to the device, clear the target
133+
# address state so we re-resolve.
134+
clear_target_addr
135+
resolve_target
136+
run_ssh_command exit 2>/dev/null
137+
ping_result=$?
138+
else
139+
run_ssh_command -O check > /dev/null 2>&1
140+
ping_result=$?
141+
fi
142+
143+
if [[ "$state" == "discover" && "$ping_result" == 0 ]]; then
144+
echo "Device up"
145+
state="config"
146+
fi
147+
148+
if [[ "$state" == "config" ]]; then
149+
echo "Registering engine as update source"
150+
151+
# Get our ssh host address
152+
addr=$(run_ssh_command 'echo $SSH_CONNECTION' | cut -d ' ' -f 1)
153+
if [[ $? -ne 0 || -z "${addr}" ]]; then
154+
engine-error "unable to determine host address as seen from the target. Is the target up?"
155+
exit 1
156+
fi
157+
158+
addr="$(echo "${addr}" | sed 's/%/%25/g')"
159+
if [[ "${addr}" =~ : ]]; then
160+
addr="[${addr}]"
161+
fi
162+
163+
config_url="http://${addr}:${port}/config.json"
164+
run_ssh_command amberctl add_src \
165+
-n "engine" \
166+
-f "${config_url}"
167+
err=$?
168+
169+
if [[ $err -ne 0 ]]; then
170+
engine-error "Failed to add update source"
171+
exit 1
172+
fi
173+
174+
if [[ $only_serve_runners == true ]]; then
175+
run_ssh_command "pkgctl rule replace json '
176+
{
177+
\"version\": \"1\",
178+
\"content\": [
179+
{
180+
\"host_match\": \"fuchsia.com\", \"host_replacement\": \"engine\",
181+
\"path_prefix_match\": \"/flutter_jit_runner/\", \"path_prefix_replacement\": \"/flutter_jit_runner/\"
182+
},
183+
{
184+
\"host_match\": \"fuchsia.com\", \"host_replacement\": \"engine\",
185+
\"path_prefix_match\": \"/flutter_jit_runner\", \"path_prefix_replacement\": \"/flutter_jit_runner\"
186+
},
187+
{
188+
\"host_match\": \"fuchsia.com\", \"host_replacement\": \"engine\",
189+
\"path_prefix_match\": \"/flutter_aot_runner/\", \"path_prefix_replacement\": \"/flutter_aot_runner/\"
190+
},
191+
{
192+
\"host_match\": \"fuchsia.com\", \"host_replacement\": \"engine\",
193+
\"path_prefix_match\": \"/flutter_aot_runner\", \"path_prefix_replacement\": \"/flutter_aot_runner\"
194+
},
195+
{
196+
\"host_match\": \"fuchsia.com\", \"host_replacement\": \"devhost\",
197+
\"path_prefix_match\": \"/\", \"path_prefix_replacement\": \"/\"
198+
}]
199+
}'"
200+
err=$?
201+
if [[ $err -ne 0 ]]; then
202+
engine-error "Failed to add runner rewrite rules"
203+
exit 1
204+
fi
205+
fi
206+
207+
state="ready"
208+
fi
209+
210+
if [[ "$state" == "ready" ]]; then
211+
if [[ "$ping_result" != 0 ]]; then
212+
echo "Device lost"
213+
state="discover"
214+
else
215+
sleep 1
216+
fi
217+
fi
218+
done
219+

tools/fuchsia/fuchsia_archive.gni

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ template("fuchsia_archive") {
113113
rebase_path("//fuchsia/sdk/$host_os/tools/pm"),
114114
"--package-dir",
115115
rebase_path(far_base_dir),
116-
"--signing-key",
117-
rebase_path("//flutter/tools/fuchsia/development.key"),
118116
"--far-name",
119117
target_name,
120118
"--manifest-json-file",

0 commit comments

Comments
 (0)