Skip to content

Commit 7f2ca09

Browse files
authored
feat: set CMAKE_EXPORT_COMPILE_COMMANDS to On (#312)
* feat: set CMAKE_EXPORT_COMPILE_COMMANDS to On This PR enables default generation of a compilation database (compile_commands.json) that can be used by tools like clangd, clang-tidy and include-what-you-use to provide diagnostics. * chore: remove potential vulnerable package bats-file
1 parent b34b954 commit 7f2ca09

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

.devcontainer/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ COPY .devcontainer/requirements.txt /tmp/requirements.txt
3131
RUN python3 -m pip install --require-hashes --no-cache-dir -r /tmp/requirements.txt \
3232
&& rm -rf /tmp/requirements.txt
3333

34-
# Set default generator for CMake to Ninja
34+
# Set default environment options for CMake
3535
ENV CMAKE_GENERATOR="Ninja"
36+
ENV CMAKE_EXPORT_COMPILE_COMMANDS="On"
3637

3738
# Install clang toolchain
3839
COPY .devcontainer/apt-requirements-clang.json /tmp/apt-requirements-clang.json

test/testsuite.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ teardown() {
6767
assert_success
6868
}
6969

70+
# bats test_tags=tc:20
71+
@test "compilation database should be generated on CMake configure" {
72+
run cmake --preset gcc
73+
[ -e build/gcc/compile_commands.json ]
74+
75+
run cmake --preset gcc-arm-none-eabi
76+
[ -e build/gcc-arm-none-eabi/compile_commands.json ]
77+
}
78+
7079
# bats test_tags=tc:4
7180
@test "invalid code input should result in failing build" {
7281
run cmake --preset gcc

0 commit comments

Comments
 (0)