blob: 779e3944dd1ad77dd4ec90f3449b2af92e75ae59 [file] [log] [blame]
#!/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.
_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
bazel_sdk_dir=$(${FUCHSIA_DIR}/build/api/client print bazel_sdk_info |
fx-command-run jq -r ".[0] | .location")
if [[ ! -d "${FUCHSIA_BUILD_DIR}/${bazel_sdk_dir}" ]]; then
fx-error "No bazel sdk in build directory, please run $(fx build generate_fuchsia_sdk_repository)"
fi
source "${_script_dir}/../lib/bazel_utils.sh" || exit $?
fx-update-bazel-workspace
# We need to figure out our compilation mode to pass to bazel
fx-build-dir-if-present || return 1
optimization=$(fx-command-run gn args ${FUCHSIA_BUILD_DIR} --list=optimize --json | fx-command-run jq ".[0] | if .current then .current else .default end | .value")
BAZEL_EXE="$(fx-get-bazel)"
"${_script_dir}/refresh-bazel-compdb-bin.py" \
--bazel $BAZEL_EXE \
--optimization "${optimization}" \
--build-dir "${FUCHSIA_BUILD_DIR}" \
"$@"