forked from Consti10/wifibroadcast
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from OpenHD/consti-dev
No functional changes. add clang-format
- Loading branch information
Showing
132 changed files
with
5,133 additions
and
4,525 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Run clang-tidy | ||
name: Clang-tidy | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
|
||
validate_codestyle_clang_format: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout repository and submodules | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Dependencies | ||
run: | | ||
sudo apt install clang-format | ||
- name: Validate | ||
run: | | ||
./run_clang_format.sh |
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,24 +1,43 @@ | ||
#!/bin/bash | ||
|
||
# From https://stackoverflow.com/a/65988393 | ||
# OpenHD clang-format checking. | ||
# Step1: Generate list of all .cpp / .h / .hpp files of this project | ||
# (excluding subdirectories) | ||
# Step 2: Run clang-format | ||
|
||
|
||
function append_all_sources_headers() { | ||
# We use .h, .cpp and .hpp in OpenHD | ||
TMP_FILE_LIST="$(find "$1" | grep -E ".*(\.cpp|\.h|\.hpp)$")" | ||
#TMP_FILE_LIST+='\n' | ||
FILE_LIST+=$'\n' | ||
FILE_LIST+=$TMP_FILE_LIST | ||
} | ||
|
||
THIS_PATH="$(realpath "$0")" | ||
THIS_DIR="$(dirname "$THIS_PATH")" | ||
|
||
EXCLUDED_DIRECTORIES="external" | ||
append_all_sources_headers "$THIS_DIR/wifibroadcast/src" | ||
append_all_sources_headers "$THIS_DIR/wifibroadcast/executables" | ||
|
||
echo "Files found to format = \n\"\"\"\n$FILE_LIST\n\"\"\"" | ||
|
||
# Find all files in THIS_DIR which end in .ino, .cpp, etc., as specified | ||
# in the regular expression just below | ||
FILE_LIST="$(find "$THIS_DIR/src" -not -path "$THIS_DIR/src/external/*" | grep -E ".*(\.ino|\.cpp|\.c|\.h|\.hpp|\.hh)$")" | ||
# Checks for clang-format issues and returns error if they exist | ||
function check_warning(){ | ||
clang-format --dry-run --Werror --verbose -i --style=file $FILE_LIST | ||
|
||
echo -e "Files found to format = \n\"\"\"\n$FILE_LIST\n\"\"\"" | ||
if [ "$?" -eq "0" ]; then | ||
echo "Everything formatted correctly" | ||
else | ||
echo "There are formatting errors ! Please fix first." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Format each file. | ||
# - NB: do NOT put quotes around `$FILE_LIST` below or else the `clang-format` command will | ||
# mistakenly see the entire blob of newline-separated file names as a SINGLE file name instead | ||
# of as a new-line separated list of *many* file names! | ||
#clang-format --verbose -i --style=file $FILE_LIST | ||
# fixes any issues (re-formats everything) | ||
function fix_warnings() { | ||
clang-format --verbose -i --style=file $FILE_LIST | ||
} | ||
|
||
# Create a directory where we can build with ninja & generate the list of files for clang tidy | ||
cmake -G Ninja -S . -B build_clang_format -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | ||
#clang-tidy -format-style=file -p build_clang_format $FILE_LIST | ||
#fix_warnings | ||
check_warning |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.