diff options
author | Manuel Bentele | 2021-03-04 08:47:43 +0100 |
---|---|---|
committer | Manuel Bentele | 2021-03-04 08:47:43 +0100 |
commit | 2b5631eaa444023043a18ff3985f5a0e7a11436a (patch) | |
tree | 4f27eaf01b80eea60d5f9b65023c8db2635ec8b5 | |
parent | [BUILD] Add build support for Github actions (diff) | |
download | dnbd3-2b5631eaa444023043a18ff3985f5a0e7a11436a.tar.gz dnbd3-2b5631eaa444023043a18ff3985f5a0e7a11436a.tar.xz dnbd3-2b5631eaa444023043a18ff3985f5a0e7a11436a.zip |
[BUILD] Add support in CMake to validate (lint) the source code
-rw-r--r-- | .clang-format | 118 | ||||
-rw-r--r-- | .github/workflows/build.yml | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 23 | ||||
-rw-r--r-- | README.md | 21 | ||||
-rw-r--r-- | cmake/FindClangFormat.cmake | 21 | ||||
-rw-r--r-- | cmake/Lint.cmake | 49 | ||||
-rw-r--r-- | inc/dnbd3/shared/serialize.h | 3 | ||||
-rw-r--r-- | src/bench/CMakeLists.txt | 13 | ||||
-rw-r--r-- | src/client/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/fuse/CMakeLists.txt | 13 | ||||
-rw-r--r-- | src/kernel/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/server/CMakeLists.txt | 57 | ||||
-rw-r--r-- | src/shared/CMakeLists.txt | 20 |
13 files changed, 321 insertions, 33 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..2abc64d --- /dev/null +++ b/.clang-format @@ -0,0 +1,118 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# clang-format configuration file. Intended for clang-format >= 4. +# +# For more information, see: +# +# Documentation/process/clang-format.rst +# https://clang.llvm.org/docs/ClangFormat.html +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +# +--- +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +#AlignEscapedNewlines: Left # Unknown to clang-format-4.0 +AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + #AfterExternBlock: false # Unknown to clang-format-5.0 + BeforeCatch: false + BeforeElse: false + IndentBraces: false + #SplitEmptyFunction: true # Unknown to clang-format-4.0 + #SplitEmptyRecord: true # Unknown to clang-format-4.0 + #SplitEmptyNamespace: true # Unknown to clang-format-4.0 +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0 +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false +#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0 +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: false +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +#CompactNamespaces: false # Unknown to clang-format-4.0 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +#FixNamespaceComments: false # Unknown to clang-format-4.0 + +#IncludeBlocks: Preserve # Unknown to clang-format-5.0 +IncludeCategories: + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +#IndentPPDirectives: None # Unknown to clang-format-5.0 +IndentWidth: 8 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0 +ObjCBlockIndentWidth: 8 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true + +# Taken from git's rules +#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0 +PenaltyBreakBeforeFirstCallParameter: 30 +PenaltyBreakComment: 10 +PenaltyBreakFirstLessLess: 0 +PenaltyBreakString: 10 +PenaltyExcessCharacter: 100 +PenaltyReturnTypeOnItsOwnLine: 60 + +PointerAlignment: Right +ReflowComments: false +SortIncludes: false +#SortUsingDeclarations: false # Unknown to clang-format-4.0 +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0 +#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0 +SpaceBeforeParens: ControlStatements +#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0 +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp03 +TabWidth: 8 +UseTab: Always +... diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7c61fb3..8eff91a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,6 +45,7 @@ jobs: run: | sudo apt-get update -y -qq sudo apt-get install -y -qq make \ + clang-format \ linux-headers-generic \ libfuse-dev \ libjansson-dev \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c104a9..fb4d5d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ find_package(Threads REQUIRED) # include project version and build type related macros include(Version) include(Build) +include(Lint) # check for system and enable or disable built of Linux kernel module if(DNBD3_KERNEL_MODULE AND UNIX AND CMAKE_SYSTEM_NAME MATCHES "Linux") @@ -59,6 +60,25 @@ set(PROJECT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/${PROJECT_INCLUDE_DIR_PREFIX}) set(PROJECT_INCLUDE_GEN_DIR ${PROJECT_GEN_DIR}/${PROJECT_INCLUDE_DIR_PREFIX}) include_directories(${PROJECT_INCLUDE_DIR}) +# get all global header files for the linter +set(DNBD3_HEADER_FILES ${PROJECT_INCLUDE_DIR}/dnbd3/build.h.in + ${PROJECT_INCLUDE_DIR}/dnbd3/config/client.h + ${PROJECT_INCLUDE_DIR}/dnbd3/config.h + ${PROJECT_INCLUDE_DIR}/dnbd3/config/server.h + ${PROJECT_INCLUDE_DIR}/dnbd3/shared/crc32.h + ${PROJECT_INCLUDE_DIR}/dnbd3/shared/fdsignal.h + ${PROJECT_INCLUDE_DIR}/dnbd3/shared/log.h + ${PROJECT_INCLUDE_DIR}/dnbd3/shared/protocol.h + ${PROJECT_INCLUDE_DIR}/dnbd3/shared/serialize.h + ${PROJECT_INCLUDE_DIR}/dnbd3/shared/sockhelper.h + ${PROJECT_INCLUDE_DIR}/dnbd3/shared/timing.h + ${PROJECT_INCLUDE_DIR}/dnbd3/types.h + ${PROJECT_INCLUDE_DIR}/dnbd3/version.h.in) + +# add linter for header files +add_linter(dnbd3-headers-lint "${DNBD3_HEADER_FILES}") +add_linter_fix(dnbd3-headers-lint-fix "${DNBD3_HEADER_FILES}") + # generate project version C header file from template # exposes dnbd3-generate-version and dnbd3-version target set(INCLUDE_VERSION_HEADER ${PROJECT_INCLUDE_DIR}/dnbd3/version.h) @@ -119,7 +139,7 @@ if(CMAKE_BUILD_TYPE MATCHES Release) set(CPACK_PACKAGE_SECTION admin) set(CPACK_PACKAGE_VENDOR "University of Freiburg") set(CPACK_PACKAGE_CONTACT "Christian Rößler <christian.roessler@rz.uni-freiburg.de>") - set(CPACK_PACKAGE_HOMEPAGE_URL "https://git.openslx.org/dnbd3.git/") + set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/bwLehrpool/dnbd3") set(CPACK_PACKAGE_CHECKSUM SHA256) set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${REPOSITORY_VERSION_FULL}_${CMAKE_SYSTEM_PROCESSOR}) set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_source) @@ -164,6 +184,7 @@ if(CMAKE_BUILD_TYPE MATCHES Release) "${PROJECT_GEN_DIR}" "/") set(CPACK_SOURCE_IGNORE_FILES "/build/" "/.git/" + "/.github/" ".gitignore" "version.h.in") @@ -31,6 +31,7 @@ pacman -S git \ make \ cmake \ gcc \ + clang \ linux-headers \ # or linux-lts-headers fuse2 \ jansson \ @@ -45,6 +46,7 @@ apt-get install git \ make \ cmake \ gcc \ + clang-format \ raspberrypi-kernel-headers \ libfuse-dev \ libjansson-dev \ @@ -58,6 +60,7 @@ apt-get install git \ make \ cmake \ gcc \ + clang-format \ linux-headers-generic \ libfuse-dev \ libjansson-dev \ @@ -72,6 +75,7 @@ apt-get install git \ make \ cmake \ gcc \ + clang-format \ linux-headers-generic \ libfuse-dev \ libjansson-dev \ @@ -85,6 +89,7 @@ yum install git \ make \ cmake \ gcc \ + clang-tools-extra \ kernel-devel \ elfutils-libelf-devel \ fuse-devel \ @@ -100,6 +105,7 @@ yum install git \ make \ cmake \ gcc \ + clang-tools-extra \ kernel-devel \ elfutils-libelf-devel \ fuse-devel \ @@ -116,6 +122,7 @@ Note that `afl` is not available on AlmaLinux 8 and should be built from the [or pkg install git \ cmake \ gcc \ + clang-devel \ pkgconf \ fusefs-libs \ jansson \ @@ -318,6 +325,20 @@ More information regarding the Linux kernel's dynamic debug feature can be found ## Development notes +### Code style of source code files +The code style fo all source code files can be checked by calling the make target `lint`: + +```shell +make lint +``` + +If some source code files do not meet the project's code style, they can be fixed automatically by calling the make target `lint-fix`: + +```shell +make lint-fix +``` + + ### Resource locking in dnbd3 The order of aquiring multiple locks is very important, as you'll produce a possible deadlock if you do it in the wrong order. Take very good care of locking order if you have lots of functions that call each other. You might lose track of what's going on. diff --git a/cmake/FindClangFormat.cmake b/cmake/FindClangFormat.cmake new file mode 100644 index 0000000..9abf943 --- /dev/null +++ b/cmake/FindClangFormat.cmake @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2021 Manuel Bentele <development@manuel-bentele.de> +# + +find_program(ClangFormat_EXECUTABLE NAMES clang-format) + +if(ClangFormat_EXECUTABLE) + execute_process(COMMAND clang-format --version + OUTPUT_VARIABLE ClangFormat_VERBOSE_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" ClangFormat_VERSION ${ClangFormat_VERBOSE_VERSION}) +endif(ClangFormat_EXECUTABLE) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ClangFormat + FOUND_VAR ClangFormat_FOUND + REQUIRED_VARS ClangFormat_EXECUTABLE + VERSION_VAR ClangFormat_VERSION + FAIL_MESSAGE "clang-format is not available! Please install clang-format to format the source code!") + diff --git a/cmake/Lint.cmake b/cmake/Lint.cmake new file mode 100644 index 0000000..73b4795 --- /dev/null +++ b/cmake/Lint.cmake @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# CMake macros to check style of source code files +# Copyright (C) 2021 Manuel Bentele <development@manuel-bentele.de> +# + +find_package(ClangFormat REQUIRED) + +# add target to trigger all linter targets +add_custom_target(lint) + +# macro to define lint targets +macro(add_linter LINT_NAME LINT_SOURCE_FILES) + add_custom_target(${LINT_NAME} + COMMAND clang-format --Werror --dry-run ${LINT_SOURCE_FILES} ${ARGN} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS ${LINT_SOURCE_FILES} ${ARGN}) + add_dependencies(lint ${LINT_NAME}) +endmacro(add_linter) + +# macro to define lint targets for kernel source code files +macro(add_kernel_linter LINT_NAME KERNEL_BUILD_DIR LINT_SOURCE_FILES LINT_HEADER_FILES) + add_custom_target(${LINT_NAME} + COMMAND ${KERNEL_BUILD_DIR}/scripts/checkpatch.pl --no-tree -f ${LINT_SOURCE_FILES} ${LINT_HEADER_FILES} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS ${LINT_SOURCE_FILES} ${LINT_HEADER_FILES}) + add_dependencies(lint ${LINT_NAME}) +endmacro(add_kernel_linter) + +# add target to trigger all formatter targets +add_custom_target(lint-fix) + +# macro to define formatter targets +macro(add_linter_fix LINT_FIX_NAME LINT_FIX_SOURCE_FILES) + add_custom_target(${LINT_FIX_NAME} + COMMAND clang-format --Werror -i ${LINT_FIX_SOURCE_FILES} ${ARGN} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS ${LINT_FIX_SOURCE_FILES} ${ARGN}) + add_dependencies(lint-fix ${LINT_FIX_NAME}) +endmacro(add_linter_fix) + +# macro to define formatter targets for kernel source code files +macro(add_kernel_linter_fix LINT_FIX_NAME KERNEL_BUILD_DIR LINT_FIX_SOURCE_FILES LINT_FIX_HEADER_FILES) + add_custom_target(${LINT_FIX_NAME} + COMMAND ${KERNEL_BUILD_DIR}/scripts/checkpatch.pl --no-tree --fix-inplace -f ${LINT_FIX_SOURCE_FILES} ${LINT_FIX_HEADER_FILES} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS ${LINT_FIX_SOURCE_FILES} ${LINT_FIX_HEADER_FILES}) + add_dependencies(lint-fix ${LINT_FIX_NAME}) +endmacro(add_kernel_linter_fix) diff --git a/inc/dnbd3/shared/serialize.h b/inc/dnbd3/shared/serialize.h index a7a1ced..b808fd0 100644 --- a/inc/dnbd3/shared/serialize.h +++ b/inc/dnbd3/shared/serialize.h @@ -4,8 +4,7 @@ #include <dnbd3/config.h> #include <dnbd3/types.h> -typedef struct -{ +typedef struct { char buffer[MAX_PAYLOAD]; // This MUST be the first member or send_reply() will blow up char *buffer_end; char *buffer_pointer; diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt index 4e2becf..24542a7 100644 --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -7,9 +7,16 @@ project(dnbd3-bench # add compile option to enable enhanced POSIX pthread features add_definitions(-D_GNU_SOURCE) -add_executable(dnbd3-bench ${CMAKE_CURRENT_SOURCE_DIR}/connection.c - ${CMAKE_CURRENT_SOURCE_DIR}/helper.c - ${CMAKE_CURRENT_SOURCE_DIR}/main.c) +set(DNBD3_BENCH_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/connection.c + ${CMAKE_CURRENT_SOURCE_DIR}/helper.c + ${CMAKE_CURRENT_SOURCE_DIR}/main.c) +set(DNBD3_BENCH_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/connection.h + ${CMAKE_CURRENT_SOURCE_DIR}/helper.h) + +add_executable(dnbd3-bench ${DNBD3_BENCH_SOURCE_FILES}) target_link_libraries(dnbd3-bench dnbd3-version dnbd3-shared ${CMAKE_THREAD_LIBS_INIT}) install(TARGETS dnbd3-bench RUNTIME DESTINATION bin COMPONENT bench) + +add_linter(dnbd3-bench-lint "${DNBD3_BENCH_SOURCE_FILES}" "${DNBD3_BENCH_HEADER_FILES}") +add_linter_fix(dnbd3-bench-lint-fix "${DNBD3_BENCH_SOURCE_FILES}" "${DNBD3_BENCH_HEADER_FILES}") diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 29dcdb4..41f182e 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -7,7 +7,12 @@ project(dnbd3-client # add compile option to enable enhanced BSD netdb features add_definitions(-D_GNU_SOURCE) -add_executable(dnbd3-client ${CMAKE_CURRENT_SOURCE_DIR}/client.c) +set(DNBD3_CLIENT_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/client.c) + +add_executable(dnbd3-client ${DNBD3_CLIENT_SOURCE_FILES}) target_link_libraries(dnbd3-client dnbd3-version dnbd3-build dnbd3-shared) install(TARGETS dnbd3-client RUNTIME DESTINATION bin COMPONENT kernel) + +add_linter(dnbd3-client-lint "${DNBD3_CLIENT_SOURCE_FILES}") +add_linter_fix(dnbd3-client-lint-fix "${DNBD3_CLIENT_SOURCE_FILES}") diff --git a/src/fuse/CMakeLists.txt b/src/fuse/CMakeLists.txt index fba0ed1..e4c8de9 100644 --- a/src/fuse/CMakeLists.txt +++ b/src/fuse/CMakeLists.txt @@ -9,10 +9,17 @@ find_package(Fuse REQUIRED) # add compile option to enable enhanced POSIX pthread features add_definitions(-D_GNU_SOURCE) -add_executable(dnbd3-fuse ${CMAKE_CURRENT_SOURCE_DIR}/connection.c - ${CMAKE_CURRENT_SOURCE_DIR}/helper.c - ${CMAKE_CURRENT_SOURCE_DIR}/main.c) +set(DNBD3_FUSE_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/connection.c + ${CMAKE_CURRENT_SOURCE_DIR}/helper.c + ${CMAKE_CURRENT_SOURCE_DIR}/main.c) +set(DNBD3_FUSE_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/connection.h + ${CMAKE_CURRENT_SOURCE_DIR}/helper.h) + +add_executable(dnbd3-fuse ${DNBD3_FUSE_SOURCE_FILES}) target_include_directories(dnbd3-fuse PRIVATE ${FUSE_INCLUDE_DIRS}) target_link_libraries(dnbd3-fuse dnbd3-build dnbd3-version dnbd3-shared ${FUSE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) install(TARGETS dnbd3-fuse RUNTIME DESTINATION bin COMPONENT fuse) + +add_linter(dnbd3-fuse-lint "${DNBD3_FUSE_SOURCE_FILES}" "${DNBD3_FUSE_HEADER_FILES}") +add_linter_fix(dnbd3-fuse-lint-fix "${DNBD3_FUSE_SOURCE_FILES}" "${DNBD3_FUSE_HEADER_FILES}") diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 0f5a4bd..47efdd2 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -37,6 +37,7 @@ set(KERNEL_MODULE_DNBD3_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/blk.h ${CMAKE_CURRENT_SOURCE_DIR}/net.h ${CMAKE_CURRENT_SOURCE_DIR}/sysfs.h ${CMAKE_CURRENT_SOURCE_DIR}/utils.h) + add_kernel_module(dnbd3 "${KERNEL_BUILD_DIR}" "${KERNEL_INSTALL_DIR}" "CONFIG_BLK_DEV_DNBD3=m" @@ -46,3 +47,10 @@ add_kernel_module(dnbd3 "${KERNEL_BUILD_DIR}" # add dependency to generate project version header before dnbd3.ko is built add_dependencies(dnbd3 dnbd3-generate-version) + +add_kernel_linter(dnbd3-lint "${KERNEL_BUILD_DIR}" + "${KERNEL_MODULE_DNBD3_SOURCE_FILES}" + "${KERNEL_MODULE_DNBD3_HEADER_FILES}") +add_kernel_linter_fix(dnbd3-lint-fix "${KERNEL_BUILD_DIR}" + "${KERNEL_MODULE_DNBD3_SOURCE_FILES}" + "${KERNEL_MODULE_DNBD3_HEADER_FILES}") diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index a5bd660..915da74 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -40,23 +40,43 @@ if(DNBD3_SERVER_AFL) endif(AFL_C_COMPILER) endif(DNBD3_SERVER_AFL) -add_executable(dnbd3-server ${CMAKE_CURRENT_SOURCE_DIR}/altservers.c - ${CMAKE_CURRENT_SOURCE_DIR}/fileutil.c - ${CMAKE_CURRENT_SOURCE_DIR}/fuse.c - ${CMAKE_CURRENT_SOURCE_DIR}/globals.c - ${CMAKE_CURRENT_SOURCE_DIR}/helper.c - ${CMAKE_CURRENT_SOURCE_DIR}/image.c - ${CMAKE_CURRENT_SOURCE_DIR}/ini.c - ${CMAKE_CURRENT_SOURCE_DIR}/integrity.c - ${CMAKE_CURRENT_SOURCE_DIR}/locks.c - ${CMAKE_CURRENT_SOURCE_DIR}/net.c - ${CMAKE_CURRENT_SOURCE_DIR}/picohttpparser/picohttpparser.c - ${CMAKE_CURRENT_SOURCE_DIR}/reference.c - ${CMAKE_CURRENT_SOURCE_DIR}/rpc.c - ${CMAKE_CURRENT_SOURCE_DIR}/server.c - ${CMAKE_CURRENT_SOURCE_DIR}/threadpool.c - ${CMAKE_CURRENT_SOURCE_DIR}/uplink.c - ${CMAKE_CURRENT_SOURCE_DIR}/urldecode.c) +set(DNBD3_SERVER_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/altservers.c + ${CMAKE_CURRENT_SOURCE_DIR}/fileutil.c + ${CMAKE_CURRENT_SOURCE_DIR}/fuse.c + ${CMAKE_CURRENT_SOURCE_DIR}/globals.c + ${CMAKE_CURRENT_SOURCE_DIR}/helper.c + ${CMAKE_CURRENT_SOURCE_DIR}/image.c + ${CMAKE_CURRENT_SOURCE_DIR}/ini.c + ${CMAKE_CURRENT_SOURCE_DIR}/integrity.c + ${CMAKE_CURRENT_SOURCE_DIR}/locks.c + ${CMAKE_CURRENT_SOURCE_DIR}/net.c + ${CMAKE_CURRENT_SOURCE_DIR}/picohttpparser/picohttpparser.c + ${CMAKE_CURRENT_SOURCE_DIR}/reference.c + ${CMAKE_CURRENT_SOURCE_DIR}/rpc.c + ${CMAKE_CURRENT_SOURCE_DIR}/server.c + ${CMAKE_CURRENT_SOURCE_DIR}/threadpool.c + ${CMAKE_CURRENT_SOURCE_DIR}/uplink.c + ${CMAKE_CURRENT_SOURCE_DIR}/urldecode.c) +set(DNBD3_SERVER_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/altservers.h + ${CMAKE_CURRENT_SOURCE_DIR}/fileutil.h + ${CMAKE_CURRENT_SOURCE_DIR}/fuse.h + ${CMAKE_CURRENT_SOURCE_DIR}/globals.h + ${CMAKE_CURRENT_SOURCE_DIR}/helper.h + ${CMAKE_CURRENT_SOURCE_DIR}/image.h + ${CMAKE_CURRENT_SOURCE_DIR}/ini.h + ${CMAKE_CURRENT_SOURCE_DIR}/integrity.h + ${CMAKE_CURRENT_SOURCE_DIR}/locks.h + ${CMAKE_CURRENT_SOURCE_DIR}/net.h + ${CMAKE_CURRENT_SOURCE_DIR}/picohttpparser/picohttpparser.h + ${CMAKE_CURRENT_SOURCE_DIR}/reference.h + ${CMAKE_CURRENT_SOURCE_DIR}/reftypes.h + ${CMAKE_CURRENT_SOURCE_DIR}/rpc.h + ${CMAKE_CURRENT_SOURCE_DIR}/server.h + ${CMAKE_CURRENT_SOURCE_DIR}/threadpool.h + ${CMAKE_CURRENT_SOURCE_DIR}/uplink.h + ${CMAKE_CURRENT_SOURCE_DIR}/urldecode.h) + +add_executable(dnbd3-server ${DNBD3_SERVER_SOURCE_FILES}) target_include_directories(dnbd3-server PRIVATE ${JANSSON_INCLUDE_DIR}) target_link_libraries(dnbd3-server dnbd3-version dnbd3-build dnbd3-shared Libatomic::Libatomic ${CMAKE_THREAD_LIBS_INIT} ${JANSSON_LIBRARIES}) @@ -85,3 +105,6 @@ endif(DNBD3_SERVER_DEBUG_THREADS) install(TARGETS dnbd3-server RUNTIME DESTINATION bin COMPONENT server) + +add_linter(dnbd3-server-lint "${DNBD3_SERVER_SOURCE_FILES}" "${DNBD3_SERVER_HEADER_FILES}") +add_linter_fix(dnbd3-server-lint-fix "${DNBD3_SERVER_SOURCE_FILES}" "${DNBD3_SERVER_HEADER_FILES}") diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt index 6356399..b280b77 100644 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -7,10 +7,18 @@ project(dnbd3-shared # add compile option to get POLLRDHUP support for signals add_definitions(-D_GNU_SOURCE) -add_library(dnbd3-shared STATIC ${CMAKE_CURRENT_SOURCE_DIR}/crc32.c - ${CMAKE_CURRENT_SOURCE_DIR}/fdsignal.c - ${CMAKE_CURRENT_SOURCE_DIR}/log.c - ${CMAKE_CURRENT_SOURCE_DIR}/serialize.c - ${CMAKE_CURRENT_SOURCE_DIR}/sockhelper.c - ${CMAKE_CURRENT_SOURCE_DIR}/timing.c) +set(DNBD3_SHARED_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/crc32.c + ${CMAKE_CURRENT_SOURCE_DIR}/fdsignal.c + ${CMAKE_CURRENT_SOURCE_DIR}/log.c + ${CMAKE_CURRENT_SOURCE_DIR}/serialize.c + ${CMAKE_CURRENT_SOURCE_DIR}/sockhelper.c + ${CMAKE_CURRENT_SOURCE_DIR}/timing.c) +set(DNBD3_SHARED_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/fdsignal.inc/eventfd.c + ${CMAKE_CURRENT_SOURCE_DIR}/fdsignal.inc/pipe64.c + ${CMAKE_CURRENT_SOURCE_DIR}/fdsignal.inc/pipe_malloc.c) + +add_library(dnbd3-shared STATIC ${DNBD3_SHARED_SOURCE_FILES}) target_include_directories(dnbd3-shared PUBLIC ${PROJECT_INCLUDE_DIR}) + +add_linter(dnbd3-shared-lint "${DNBD3_SHARED_SOURCE_FILES}" "${DNBD3_SHARED_HEADER_FILES}") +add_linter_fix(dnbd3-shared-lint-fix "${DNBD3_SHARED_SOURCE_FILES}" "${DNBD3_SHARED_HEADER_FILES}") |