diff --git a/ci/README.md b/ci/README.md index 2e356ddc0f29a..d42aaaa0df757 100644 --- a/ci/README.md +++ b/ci/README.md @@ -85,6 +85,15 @@ To force the Envoy build image to be refreshed by Docker you can set `ENVOY_DOCK ENVOY_DOCKER_PULL=true ./ci/run_envoy_docker.sh ``` + +# Generating compile commands + +The `./ci/do_ci.sh` script provides a CI target that generates compile commands for clangd or other tools. + +```bash +ENVOY_GEN_COMPDB_OPTIONS="--vscode --exclude_contrib" ./ci/do_ci.sh refresh_compdb +``` + ## On Linux An example basic invocation to build a developer version of the Envoy static binary (using the Bazel `fastbuild` type) is: diff --git a/ci/do_ci.sh b/ci/do_ci.sh index cc042c2279b15..2341bd0f9b40c 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -1041,7 +1041,18 @@ case $CI_TARGET in ;; refresh_compdb) - "${CURRENT_SCRIPT_DIR}/../tools/vscode/refresh_compdb.sh" + if [[ -z "${SKIP_PROTO_FORMAT}" ]]; then + "${CURRENT_SCRIPT_DIR}/../tools/proto_format/proto_format.sh" fix + fi + + read -ra ENVOY_GEN_COMPDB_OPTIONS <<< "${ENVOY_GEN_COMPDB_OPTIONS:-}" + + # Setting TEST_TMPDIR here so the compdb headers won't be overwritten by another bazel run. + TEST_TMPDIR="${BUILD_DIR}/envoy-compdb" \ + "${CURRENT_SCRIPT_DIR}/../tools/gen_compilation_database.py" \ + "${ENVOY_GEN_COMPDB_OPTIONS[@]}" + # Kill clangd to reload the compilation database + pkill clangd || : ;; *) diff --git a/ci/run_envoy_docker.sh b/ci/run_envoy_docker.sh index 8c65e97372698..72251f96e2626 100755 --- a/ci/run_envoy_docker.sh +++ b/ci/run_envoy_docker.sh @@ -158,6 +158,7 @@ docker run --rm \ -e ENVOY_PUBLISH_DRY_RUN \ -e ENVOY_REPO \ -e ENVOY_TARBALL_DIR \ + -e ENVOY_GEN_COMPDB_OPTIONS \ -e SYSTEM_PULLREQUEST_PULLREQUESTNUMBER \ -e GCS_ARTIFACT_BUCKET \ -e GITHUB_REF_NAME \