-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clang-tidy.sh more auto detects inlcude dirs
- Loading branch information
Benedikt Moritz Maurer
committed
Oct 5, 2024
1 parent
64401bf
commit b398d3a
Showing
12 changed files
with
84 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,4 @@ | |
# FORCE) | ||
|
||
find_package(HDF5 REQUIRED COMPONENTS C CXX) | ||
|
||
include_directories(${HDF5_INCLUDE_DIRS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Get the list of include directories (e.g., target_include_directories or include_directories) | ||
get_property(INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) | ||
|
||
# Specify the output file | ||
set(OUTPUT_FILE "${CMAKE_BINARY_DIR}/include_paths.txt") | ||
|
||
# Open the file for writing | ||
file(WRITE ${OUTPUT_FILE} "") | ||
|
||
# Iterate over the list of include directories and write each to the file | ||
foreach(INCLUDE_DIR ${INCLUDE_DIRS}) | ||
file(APPEND ${OUTPUT_FILE} "${INCLUDE_DIR}\n") | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
# types | ||
add_subdirectory(types) | ||
|
||
# constants | ||
add_subdirectory(constants) | ||
|
||
# config | ||
add_subdirectory(data_processing) | ||
|
||
# electrons | ||
add_subdirectory(electrons) | ||
|
||
add_subdirectory(types) | ||
add_subdirectory(constants) | ||
add_subdirectory(data_processing) | ||
add_subdirectory(electrons) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,50 @@ | ||
#!/bin/bash | ||
|
||
PROJECT_DIR=$1 | ||
COMPILE_COMMANDS=$2 | ||
|
||
|
||
BUILD_DIR=$1 | ||
SRC_DIR=$2 | ||
CONFIG_FILE=$3 | ||
SRC_DIR=$4 | ||
CPP_STD=$5 | ||
NUMBER_OF_ARGUMENTS=5 | ||
CPP_STD=$4 | ||
|
||
# Check if enough arguments are passed | ||
NUMBER_OF_ARGUMENTS=5 | ||
if [ "$#" -ne ${NUMBER_OF_ARGUMENTS} ]; then | ||
echo "Usage: $0 <project_dir> <compile_commands> <config_file> <src> <cpp_std>" | ||
echo "Usage: $0 <BUILD_DIR> <SRC_DIR> <CONFIG_FILE> <CPP_STD> <INCLUDE_LIBS_EXT>" | ||
exit 1 | ||
fi | ||
|
||
# Check if compile_commands.json exists | ||
if [ ! -f ${COMPILE_COMMANDS} ]; then | ||
echo "${COMPILE_COMMANDS} not found!" | ||
exit 1 | ||
fi | ||
# Find compile_commands.json in build dir | ||
COMPILE_COMMANDS_FILE="compile_commands.json" | ||
INCLUDE_PATHS_EXT_FILE="include_paths.txt" | ||
BUILDS=$(find "${BUILD_DIR}" -maxdepth 1 -type d) | ||
COMPILE_COMMANDS="" | ||
INCLUDE_PATHS_EXT=() | ||
for BUILD in ${BUILDS}; do | ||
if [ -d "${BUILD}" ]; then | ||
COMPILE_COMMANDS="${BUILD}/${COMPILE_COMMANDS_FILE}" | ||
mapfile -t INCLUDE_PATHS_EXT < "${BUILD}/${INCLUDE_PATHS_EXT_FILE}" | ||
echo "Running clang-tidy with ${COMPILE_COMMANDS}..." | ||
fi | ||
done | ||
if [ -z ${COMPILE_COMMANDS} ]; then\ | ||
echo "Could not find ${COMPILE_COMMANDS_FILE}. Exit..." | ||
exit | ||
fi | ||
|
||
|
||
# Find all directories named "include" and generate the include string | ||
INCLUDE_PATHS=$(find "$PROJECT_DIR" -type d -name "include" -print | awk '{printf "-I%s ", $0}') | ||
INCLUDE_PATHS_INT=$(find "$SRC_DIR" -type d -name "include" -print) | ||
INCLUDE_PATHS_LIST=("${INCLUDE_PATHS_EXT[@]}" "${INCLUDE_PATHS_INT[@]}") | ||
INCLUDE_PATHS="" | ||
for LIB in ${INCLUDE_PATHS_LIST[@]}; do | ||
INCLUDE_PATHS+="-I${LIB} " | ||
done | ||
|
||
|
||
# Run clang-tidy for all cpp files | ||
for file in $(find ${SRC_DIR} -name '*.cpp'); do | ||
echo "Running clang-tidy on $file " | ||
clang-tidy ${file} --config-file=${CONFIG_FILE} -- -std=${CPP_STD} ${INCLUDE_PATHS} "-I/usr/include/eigen3" "-I/usr/include/catch2" | ||
clang-tidy ${file} --config-file=${CONFIG_FILE} -- -std=${CPP_STD} ${INCLUDE_PATHS} | ||
|
||
done |