| #!/bin/bash |
| # Copyright 2024 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. |
| |
| set -eo pipefail |
| |
| _script_dir="${BASH_SOURCE[0]%/*}" |
| if [[ "${_script_dir}" == "${BASH_SOURCE[0]}" ]]; then _script_dir="."; fi |
| readonly _script_dir |
| |
| source "${_script_dir}/../lib/vars.sh" || exit $? |
| fx-config-read |
| |
| if [[ ! -d "${FUCHSIA_BUILD_DIR}" ]]; then |
| fx-error "No Fuchsia build directory, please run $(fx set) or $(fx gen)." |
| fi |
| |
| fx-info "Updating bazel workspace" |
| source "${_script_dir}/../lib/bazel_utils.sh" || exit $? |
| { |
| fx-update-bazel-workspace |
| } |
| |
| fx-info "Refreshing compile_commands.json" |
| |
| # We need to figure out our compilation mode to pass to bazel |
| fx-build-dir-if-present || return 1 |
| optimization=$("${PREBUILT_JQ}" -r '.optimize // "none"' "${FUCHSIA_BUILD_DIR}/args.json") |
| |
| # Use the build API module file to refresh all Bazel targets in the current |
| # build if a specific directory or label is not specified by the user. |
| extra_args=("--bazel-build-action-targets" "${FUCHSIA_BUILD_DIR}/bazel_build_action_targets.json") |
| for arg in "$@"; do |
| case "$arg" in |
| --dir|--dir=*|--label|--label=*) |
| extra_args=() |
| break |
| ;; |
| esac |
| done |
| extra_args+=("$@") |
| |
| BAZEL_EXE="$(fx-get-bazel)" |
| "${PREBUILT_PYTHON3}" \ |
| "${FUCHSIA_DIR}/build/bazel/scripts/refresh-bazel-compdb-bin.py" \ |
| --bazel "${BAZEL_EXE}" \ |
| --build-dir "${FUCHSIA_BUILD_DIR}" \ |
| "${extra_args[@]}" |