From 434405afb400795e1ff82d8b89c2a400f5005f59 Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 19 Jul 2022 14:18:53 +0200 Subject: [PATCH] format and lint tasks --- CMakeLists.txt | 4 +++- build.sh | 8 -------- cmake/clang-dev-tools.cmake | 19 +++++++++++++++++++ tools/build.sh | 8 ++++++++ tools/format.sh | 9 +++++++++ tools/lint.sh | 9 +++++++++ 6 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 cmake/clang-dev-tools.cmake create mode 100755 tools/build.sh create mode 100755 tools/format.sh create mode 100755 tools/lint.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d9eea1..2467337 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,4 +68,6 @@ llvm_map_components_to_libnames(llvm_libs support core irreader) # Link against LLVM libraries target_link_libraries(sapphirec ${llvm_libs}) -install(TARGETS sapphirec) \ No newline at end of file +install(TARGETS sapphirec) + +include(cmake/clang-dev-tools.cmake) \ No newline at end of file diff --git a/build.sh b/build.sh index 9db27f2..e69de29 100755 --- a/build.sh +++ b/build.sh @@ -1,8 +0,0 @@ -if [ ! -d build ] -then - mkdir build -fi - -cmake -S . -B build -G Ninja - -cmake --build build \ No newline at end of file diff --git a/cmake/clang-dev-tools.cmake b/cmake/clang-dev-tools.cmake new file mode 100644 index 0000000..5fdfbcf --- /dev/null +++ b/cmake/clang-dev-tools.cmake @@ -0,0 +1,19 @@ +file(GLOB ALL_SOURCE_FILES src/*.cpp src/*.h src/AST/*.cpp src/AST/*.h) + +add_custom_target( + clang-format + COMMAND /usr/bin/clang-format + -style=file + -i + ${ALL_SOURCE_FILES} +) + +add_custom_target( + clang-tidy + COMMAND /usr/bin/clang-tidy + ${ALL_SOURCE_FILES} + -config='' + -- + -std=c++20 + -I${INCLUDE_DIRECTORIES} +) \ No newline at end of file diff --git a/tools/build.sh b/tools/build.sh new file mode 100755 index 0000000..ca8a677 --- /dev/null +++ b/tools/build.sh @@ -0,0 +1,8 @@ +if [ ! -d build ] +then + mkdir build +fi + +cmake -S . -B build -G ${1:-Ninja} + +cmake --build build \ No newline at end of file diff --git a/tools/format.sh b/tools/format.sh new file mode 100755 index 0000000..1b5ded9 --- /dev/null +++ b/tools/format.sh @@ -0,0 +1,9 @@ +if [ ! -d build ] +then + mkdir build + cmake -S . -B build +fi + +cd build + +cmake --build . --target clang-format \ No newline at end of file diff --git a/tools/lint.sh b/tools/lint.sh new file mode 100755 index 0000000..b4fbb14 --- /dev/null +++ b/tools/lint.sh @@ -0,0 +1,9 @@ +if [ ! -d build ] +then + mkdir build + cmake -S . -B build +fi + +cd build + +cmake --build . --target clang-tidy \ No newline at end of file