blob: 35052a4231370e7731782a043a8cae6c60385628 [file]
#!/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=Build
### Collect Ninja trace information for analysis in chrome://tracing
## Usage: fx ninjatrace2json
##
## Use this after a build to write "ninjatrace.json" in the build directory.
##
## See //build/scripts/ninjatrace2json.py for more usage information.
set -e
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"/lib/vars.sh || exit $?
fx-config-read
# Collect any system profiles from `fx build-profile`.
# See implementation in tools/devshell/lib/vars.sh inside fx-run-ninja().
readonly BUILD_LOG_DIR="$(fx-get-last-build-log-dir)"
readonly BUILD_PROFILE_DIR="${BUILD_LOG_DIR}/build_profile"
command=("${PREBUILT_PYTHON3}"
"$FUCHSIA_DIR/build/scripts/ninjatrace2json.py"
"--fuchsia-build-dir" "$FUCHSIA_BUILD_DIR"
"--ninja-path" "$PREBUILT_NINJA"
"--ninjatrace-path" "$PREBUILT_NINJATRACE"
"--subbuilds-in-place" )
# If there exists a consolidated system profile, merge it.
readonly recent_system_profile="${BUILD_PROFILE_DIR}/system_profile.json"
if [[ -f "${recent_system_profile}" ]]; then
command+=("--system-profile" "${recent_system_profile}")
fi
exec "${command[@]}" "$@"