Skip to content

Commit

Permalink
feat: set CMAKE_EXPORT_COMPILE_COMMANDS to On (#312)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rjaegers authored Feb 16, 2024
1 parent b34b954 commit 7f2ca09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ COPY .devcontainer/requirements.txt /tmp/requirements.txt
RUN python3 -m pip install --require-hashes --no-cache-dir -r /tmp/requirements.txt \
&& rm -rf /tmp/requirements.txt

# Set default generator for CMake to Ninja
# Set default environment options for CMake
ENV CMAKE_GENERATOR="Ninja"
ENV CMAKE_EXPORT_COMPILE_COMMANDS="On"

# Install clang toolchain
COPY .devcontainer/apt-requirements-clang.json /tmp/apt-requirements-clang.json
Expand Down
9 changes: 9 additions & 0 deletions test/testsuite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ teardown() {
assert_success
}

# bats test_tags=tc:20
@test "compilation database should be generated on CMake configure" {
run cmake --preset gcc
[ -e build/gcc/compile_commands.json ]

run cmake --preset gcc-arm-none-eabi
[ -e build/gcc-arm-none-eabi/compile_commands.json ]
}

# bats test_tags=tc:4
@test "invalid code input should result in failing build" {
run cmake --preset gcc
Expand Down

0 comments on commit 7f2ca09

Please sign in to comment.