blob: bc7ab556f84421348f302a92784925526580b133 [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.
#### CATEGORY=Build
### 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 file"
echo "Concatenates the Fuchsia and Zircon compile_commands.json into one"
echo "Usage: fx compdb"
echo
exit
fi
fx-gen
local concat_filename="${FUCHSIA_BUILD_DIR}/compile_commands.zircon-and-build.json"
"${FUCHSIA_DIR}/scripts/editors/cat_compile_commands.py" \
"${ZIRCON_BUILDROOT}/compile_commands.json" \
"${FUCHSIA_BUILD_DIR}/compile_commands.json" \
> "${concat_filename}"
ln -sf "${concat_filename}" "${FUCHSIA_DIR}/compile_commands.json"
}
main "$@"