Skip to content

Commit 9913221

Browse files
committed
CLI docs: Add example for creating a database using a Bazel build command
We have internal material on this subject, so it makes sense to have a reference example. Bazel builds could be in any compiled language, so follow the pattern of the generic build script example. Include the build flags that we recommend to customers, which turn off Bazel's caching and distributed behaviour so that CodeQL can observe the entire build.
1 parent f230a37 commit 9913221

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/codeql/codeql-cli/creating-codeql-databases.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,23 @@ commands that you can specify for compiled languages.
221221

222222
codeql database create java-database --language=java --command='ant -f build.xml'
223223

224+
- Project built using Bazel::
225+
226+
# Navigate to the Bazel workspace.
227+
228+
# Stop all running Bazel server processes.
229+
bazel shutdown
230+
231+
# Remove cached objects before building.
232+
bazel clean --expunge
233+
234+
# Build using the following Bazel flags, to help CodeQL detect the build:
235+
# `--spawn_strategy=local`: build locally, instead of using a distributed build
236+
# `--nouse_action_cache`: turn off build caching, which might prevent recompilation of source code
237+
# `--noremote_accept_cached`, `--noremote_upload_local_results`: avoid using a remote cache
238+
codeql database create new-database --language=<language> \
239+
--command='bazel build --spawn_strategy=local --nouse_action_cache --noremote_accept_cached --noremote_upload_local_results //path/to/package:target'
240+
224241
- Project built using a custom build script::
225242

226243
codeql database create new-database --language=<language> --command='./scripts/build.sh'

0 commit comments

Comments
 (0)