blob: 79b991990c2e04c1a0cd606dbdf6adb28cc54d82 [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]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $?
fx-config-read
main () {
if [ $# -gt 0 ]; then
echo "Script to generate compile_commands.json files"
echo "Automatically generates compile_commands.json for Zircon and Fuchsia"
echo "and concatenates the two compile_commands.json"
echo "Usage: fx compdb"
echo
exit
fi
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $?
fx-config-read
cd ${FUCHSIA_DIR}/zircon
"${FUCHSIA_DIR}/buildtools/gn" gen "${ZIRCON_BUILDROOT}" --export-compile-commands
cd ..
"${FUCHSIA_DIR}/buildtools/gn" gen "${FUCHSIA_BUILD_DIR}" --export-compile-commands
#concatenate the two files together by making a tmp file and then removing it when done
rm -f "${FUCHSIA_DIR}/compile_commands.json"
${FUCHSIA_DIR}/scripts/editors/cat_compile_commands.py ${ZIRCON_BUILDROOT}/compile_commands.json \
${FUCHSIA_BUILD_DIR}/compile_commands.json > ${FUCHSIA_DIR}/compile_commands.json
}
main "$@"