blob: 8295131659770adefeb7258094e49587b8d012d0 [file] [log] [blame]
#!/bin/bash
# Copyright 2018 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.
### generate a compilation database for the current build configuration
## usage: fx compdb
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/lib/vars.sh
fx-config-read
# TODO(BLD-165): This is a temporary workaround, as it uses the specific rule names
# generated by GN for each arch's shared directory. A better solution is to
# teach GN itself to output the compdb.
"${FUCHSIA_DIR}/buildtools/ninja" -C "${FUCHSIA_BUILD_DIR}" -t compdb cc cxx ${FUCHSIA_ARCH}-shared_cc ${FUCHSIA_ARCH}-shared_cxx > "${FUCHSIA_BUILD_DIR}/compile_commands.json"
ln -sf "${FUCHSIA_BUILD_DIR}/compile_commands.json" "${FUCHSIA_DIR}/compile_commands.json"
echo "Note: The compile_commands may be incomplete if you are building with variants other than arch."