-
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.
Merge pull request #34 from tritonuas/chore/clang-tidy-linter
clang tidy linter
- Loading branch information
Showing
6 changed files
with
92 additions
and
29 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,15 @@ | ||
--- | ||
Checks: > | ||
*, | ||
-altera-struct-pack-align, | ||
-fuchsia-*, | ||
-google-*, | ||
-zircon-*, | ||
-abseil-*, | ||
-modernize-use-trailing-return-type, | ||
-llvm-*, | ||
-llvmlibc-*, | ||
CheckOptions: [{ key: misc-non-private-member-variables-in-classes, value: IgnoreClassesWithAllMemberVariablesBeingPublic }] | ||
WarningsAsErrors: '*' | ||
HeaderFilterRegex: '' | ||
FormatStyle: none |
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,34 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: clang-tidy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Install CMake | ||
run: sudo apt install cmake | ||
|
||
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
token: ${{ secrets.SSH_TOKEN }} | ||
|
||
- name: Create build dir | ||
run: mkdir build | ||
|
||
- name: Set up Cmake | ||
run: cd build && cmake .. | ||
|
||
- name: Run clang-tidy | ||
run: cd build && make lint | ||
|
||
|
||
|
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,48 +1,57 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
set(CMAKE_CXX_COMPILER g++) | ||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_C_COMPILER gcc) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ./bin) | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
|
||
project(obcpp VERSION 1.0) | ||
|
||
# ============================= | ||
# Libraries | ||
add_library(core_library SHARED | ||
src/core/states.cpp | ||
) | ||
add_library(core::library ALIAS core_library) | ||
target_include_directories(core_library | ||
PUBLIC | ||
${PROJECT_SOURCE_DIR}/include | ||
) | ||
|
||
add_subdirectory(deps/json) | ||
# ============================= | ||
file(GLOB_RECURSE SOURCES "src/*.cpp") | ||
file(GLOB_RECURSE HEADERS "include/*.hpp") | ||
|
||
# ============================= | ||
# Executable | ||
set(INCLUDE_DIRECTORY ${PROJECT_SOURCE_DIR}/include) | ||
include_directories(${INCLUDE_DIRECTORY}) | ||
add_executable(${PROJECT_NAME} ${SOURCES}) | ||
# ============================= | ||
|
||
add_executable(obcpp | ||
src/main.cpp | ||
) | ||
|
||
target_link_libraries(obcpp | ||
# ============================= | ||
# Libraries | ||
# NOTE: add each library's include directory to clang-tidy in the Linting section | ||
add_subdirectory(deps/json) | ||
target_link_libraries(${PROJECT_NAME} | ||
PRIVATE | ||
core::library | ||
nlohmann_json::nlohmann_json | ||
nlohmann_json::nlohmann_json | ||
) | ||
|
||
# ============================= | ||
|
||
|
||
# ============================= | ||
# Unit tests | ||
|
||
add_subdirectory(tests) | ||
add_subdirectory(deps/google-test) | ||
# ============================= | ||
|
||
# ============================= | ||
# Json Library | ||
# Linting | ||
# Adding lint target if clang-tidy executable is found | ||
find_program(CLANG_TIDY "clang-tidy") | ||
if(CLANG_TIDY) | ||
# define lint target | ||
add_custom_target(lint | ||
COMMAND ${CLANG_TIDY} | ||
${SOURCES} | ||
${HEADERS} | ||
-- | ||
-std=c++${CMAKE_CXX_STANDARD} | ||
-I${INCLUDE_DIRECTORY} | ||
# NOTE: need to add include directory for every library | ||
-I./_deps/json-src/include/ | ||
) | ||
else() | ||
message(FATAL_ERROR "clang-tidy executable not found. Check the README for steps to install it on your system") | ||
endif() | ||
# ============================= |
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 |
---|---|---|
|
@@ -4,4 +4,5 @@ RUN apt-get update \ | |
&& apt-get install -y build-essential \ | ||
gdb \ | ||
git \ | ||
cmake | ||
cmake \ | ||
clang-tidy |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ pkgs.mkShell { | |
buildInputs = [ | ||
pkgs.gcc | ||
pkgs.cmake | ||
pkgs.libclang | ||
]; | ||
} | ||
|