| #!/bin/bash |
| # Copyright 2023 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 |
| ### Manage build log directories |
| |
| ## usage: fx build-logs <subcommand> |
| ## |
| ## subcommands: |
| ## last: prints the path to the most recent build log directory. |
| ## (The value returned depends on the current output directory of 'fx use', |
| ## which is also seen in .fx-build-dir.) |
| ## clean: removes all build log directories. |
| |
| # shellcheck source=/dev/null |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? |
| |
| set -e |
| |
| function usage() { |
| cat <<EOF |
| usage: fx build-logs <subcommand> |
| |
| subcommands: |
| last: prints the path to the most recent build log directory. |
| (The value returned depends on the current output directory of 'fx use', |
| which is also seen in .fx-build-dir.) |
| clean: removes all build log directories. |
| EOF |
| } |
| |
| if [[ $# -ne 1 ]]; then |
| usage |
| exit 1 |
| fi |
| |
| subcommand="$1" |
| case "$subcommand" in |
| last) |
| fx-get-last-build-log-dir |
| ;; |
| clean) |
| local -r logs_dir="${FUCHSIA_DIR}/out/.build_logs" |
| if [[ -d "$logs_dir" ]]; then |
| echo "Removing $logs_dir" |
| rm -rf "$logs_dir" |
| fi |
| ;; |
| *) |
| usage |
| exit 1 |
| ;; |
| esac |