blob: bc91f9fd33550c419cc3f43ab3fc51fb29c18b53 [file] [log] [blame]
#!/bin/bash
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#### CATEGORY=Run, inspect and debug
### run fuchsia devtools
## usage: fx fdt [VERSION]
## VERSION Download (if necessary) and run a specific version of
## Fuchsia devtools. If not specified, the current version
## in //prebuilt will be used.
## VERSION is either a CIPD hash or "latest".
if [[ $# == 0 ]]; then
# Use prebuilt version.
system_monitor="$FUCHSIA_DIR/prebuilt/gui_tools/system_monitor/linux/system_monitor"
if [[ ! -x "$system_monitor" ]]; then
cat << end
To use fdt, JIRI should download it. Please run the following commands:
jiri init -fetch-optional=fuchsia_devtools && jiri fetch-packages --local-manifest=true
end
exit 1;
fi
# Maybe add ` > /dev/null 2>&1 &` in the future.
exec "$system_monitor"
fi
# If a specific version of FDT is requested, it can be downloaded directly.
# Check that the fuchsia_devtools are downloaded and then run it.
# If the version is already downloaded, it will not be re-downloaded.
# Using "latest" or a CIPD hash.
version="$1"
shift
# The "XXXXXX" will be replaced with a unique value.
temp_file=$(mktemp /tmp/fuchsia_devtools_cipd_XXXXXX.ensure)
cat << end > "$temp_file"
\$ServiceURL https://chrome-infra-packages.appspot.com/
fuchsia_internal/gui_tools/fuchsia_devtools/\${platform} $version
end
if [[ -z "$FUCHSIA_DIR" ]]; then
echo "Please define a FUCHSIA_DIR."
exit 1
fi
dev_tools="$FUCHSIA_DIR/prebuilt/gui_tools/test_fuchsia_devtools"
cipd ensure -ensure-file "$temp_file" -root "$dev_tools"
if ! `cipd ensure -ensure-file "$temp_file" -root "$dev_tools"`; then
rm "$temp_file"
echo "Failed to download $version."
exit 1
fi
rm "$temp_file"
"$dev_tools/system_monitor/linux/system_monitor" $@
# In the future, we should add the following to eliminate the terminal spam:
# > /dev/null 2>&1 &
# For the near term, using this for debug output is important.