| #!/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 |
| ### Generates a compile_commands.json file in FUCHSIA_DIR using the current build configuration |
| |
| ## Generates a compile_commands.json file in FUCHSIA_DIR using the current build configuration. |
| ## |
| ## Usage: fx compdb [flags] |
| ## |
| ## --no-gen Do not first run `fx gen` |
| ## --help|-h Print this help |
| |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../lib/vars.sh || exit $? |
| fx-config-read |
| |
| main() { |
| local use_gen=true |
| |
| while [[ $# -gt 0 ]]; do |
| case "$1" in |
| --help | -h) |
| fx-command-help |
| exit 0 |
| ;; |
| --no-gen) |
| use_gen=false |
| ;; |
| *) |
| echo "Invalid argument '$1'" |
| fx-command-help |
| exit 1 |
| ;; |
| esac |
| shift |
| done |
| |
| if [[ "${use_gen}" == true ]]; then |
| fx-gen |
| fi |
| |
| local concat_filename="${FUCHSIA_BUILD_DIR}/compile_commands.zircon-and-build.json" |
| "${FUCHSIA_DIR}/scripts/editors/cat_compile_commands.py" \ |
| "${FUCHSIA_BUILD_DIR}/compile_commands.json" \ |
| >"${concat_filename}" |
| ln -sf "${concat_filename}" "${FUCHSIA_DIR}/compile_commands.json" |
| } |
| |
| main "$@" |