Skip to content

Commit 84883d1

Browse files
authored
Merge pull request #6813 from adityasharad/docs/database-create-bazel
CLI docs: Add example for creating a database using a Bazel build command
2 parents 5d0e727 + 2ed5720 commit 84883d1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,26 @@ 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+
# Before building, remove cached objects
229+
# and stop all running Bazel server processes.
230+
bazel clean --expunge
231+
232+
# Build using the following Bazel flags, to help CodeQL detect the build:
233+
# `--spawn_strategy=local`: build locally, instead of using a distributed build
234+
# `--nouse_action_cache`: turn off build caching, which might prevent recompilation of source code
235+
# `--noremote_accept_cached`, `--noremote_upload_local_results`: avoid using a remote cache
236+
codeql database create new-database --language=<language> \
237+
--command='bazel build --spawn_strategy=local --nouse_action_cache --noremote_accept_cached --noremote_upload_local_results //path/to/package:target'
238+
239+
# After building, stop all running Bazel server processes.
240+
# This ensures future build commands start in a clean Bazel server process
241+
# without CodeQL attached.
242+
bazel shutdown
243+
224244
- Project built using a custom build script::
225245

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

0 commit comments

Comments
 (0)