Skip to content

Commit

Permalink
run iwyu during cmake build
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryptkeeper committed Jul 20, 2024
1 parent 39f92ce commit 0e7d738
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
sudo apt-get install -y musl-tools iwyu
- uses: actions/checkout@v4
with:
submodules: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libcjson-dev iwyu valgrind
sudo apt-get install -y valgrind
- uses: actions/checkout@v4
with:
submodules: true
Expand Down
8 changes: 8 additions & 0 deletions .iwyu.imp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{"include": ["<sys/_pthread/_pthread_t.h>", "private", "<pthread.h>", "public"]},
{"include": ["<sys/fcntl.h>", "private", "<fcntl.h>", "public"]},
{"include": ["<_regex.h>", "private", "<regex.h>", "public"]},
{"include": ["<sys/_types/_pid_t.h>", "private", "<sys/types.h>", "public"]},
{"include": ["<sys/_types/_seek_set.h>", "private", "<sys/types.h>", "public"]},
{"include": ["<sys/errno.h>", "private", "<errno.h>", "public"]},
]
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic")

find_program(IWYU_PATH NAMES include-what-you-use iwyu)
if (IWYU_PATH)
# TODO: use --error to fail the build if IWYU fails, but Ubuntu 20.04's IWYU is too old
set(CMAKE_C_INCLUDE_WHAT_YOU_USE ${IWYU_PATH} -Xiwyu --mapping_file=${CMAKE_SOURCE_DIR}/.iwyu.imp)
endif ()

file(GLOB SOURCES "src/*.c")
file(GLOB HEADERS "include/*.h")
add_executable(fsautoproc ${SOURCES} ${HEADERS})
Expand Down
1 change: 1 addition & 0 deletions src/lcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

Expand Down
1 change: 0 additions & 1 deletion src/tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <pthread.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Expand Down

0 comments on commit 0e7d738

Please sign in to comment.