blob: 08993981dcfcd250d1c832e271f47a7a1e4596d8 [file] [log] [blame] [edit]
#!/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
} &> /dev/null
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=$(jq -r '.optimize // "none"' "${FUCHSIA_BUILD_DIR}/args.json")
BAZEL_EXE="$(fx-get-bazel)"
"${PREBUILT_PYTHON3}" \
"${FUCHSIA_DIR}/build/bazel/scripts/refresh-bazel-compdb-bin.py" \
--bazel $BAZEL_EXE \
--optimization "${optimization}" \
--build-dir "${FUCHSIA_BUILD_DIR}" \
--target-cpu "${FUCHSIA_ARCH}" \
"$@"