Skip to content

Commit

Permalink
feat: add build support
Browse files Browse the repository at this point in the history
  • Loading branch information
longfar-ncy committed Nov 23, 2023
1 parent bba8f25 commit a98db47
Show file tree
Hide file tree
Showing 8 changed files with 7,328 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ tests/tmp
bin

compile_commands.json

# build support
build_support/__pycache__
42 changes: 42 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ SET(INSTALL_INCLUDEDIR ${STAGED_INSTALL_PREFIX}/include)
SET(INSTALL_LIBDIR ${STAGED_INSTALL_PREFIX}/lib)
SET(INSTALL_LIBDIR_64 ${STAGED_INSTALL_PREFIX}/lib64)
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${STAGED_INSTALL_PREFIX})
SET(BUILD_SUPPORT_DIR ${PROJECT_SOURCE_DIR}/build_support)

MESSAGE(STATUS "${PROJECT_NAME} staged install: ${STAGED_INSTALL_PREFIX}")
MESSAGE(STATUS "Current platform: ${OS_VERSION} ")
Expand All @@ -114,3 +115,44 @@ ADD_SUBDIRECTORY(src/pstd)
ADD_SUBDIRECTORY(src/net)
ADD_SUBDIRECTORY(src)

#############################################################################
### custom target
#############################################################################
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

STRING(CONCAT FORMAT_DIRS "${PROJECT_SOURCE_DIR}/src,")
ADD_CUSTOM_TARGET(format
COMMAND ${BUILD_SUPPORT_DIR}/run_clang_format.py
/usr/bin/clang-format
${BUILD_SUPPORT_DIR}/clang_format_exclusions.txt
--source_dirs ${FORMAT_DIRS}
--quiet
--fix
)

ADD_CUSTOM_TARGET(clang-tidy
COMMAND ${BUILD_SUPPORT_DIR}/run_clang_tidy.py
-clang-tidy-binary /usr/bin/clang-tidy
-p ${CMAKE_BINARY_DIR}
-extra-arg=-std=c++17
)

ADD_CUSTOM_TARGET(clang-tidy-fix
COMMAND ${BUILD_SUPPORT_DIR}/run_clang_tidy.py
-clang-tidy-binary /usr/bin/clang-tidy
-p ${CMAKE_BINARY_DIR}
-extra-arg=-std=c++17
-fix
)

FILE(GLOB_RECURSE LINT_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
)
ADD_CUSTOM_TARGET(cpplint echo '${LINT_FILES}' | xargs -n12 -P8
${CPPLINT_BIN}
--verbose=2 --quiet
--linelength=120
--filter=-legal/copyright,-build/header_guard,-runtime/references
)

Empty file.
Loading

0 comments on commit a98db47

Please sign in to comment.