aboutsummaryrefslogtreecommitdiff
path: root/backend/cmake/modules/RCCBackendDeveloperTools.cmake
blob: 0313fe691b98f579a59364f9cc603d4a5625f65c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# SPDX-License-Identifier: GPL-3.0-or-later

function(rcc_backend_add_developer_targets)
  get_property(FormatFiles GLOBAL PROPERTY RCC_BACKEND_FORMAT_FILES)
  get_property(TidyFiles GLOBAL PROPERTY RCC_BACKEND_TIDY_FILES)

  if(FormatFiles)
    list(REMOVE_DUPLICATES FormatFiles)

    add_custom_target(
      rcc-backend-format
      COMMAND "${RCC_BACKEND_CLANG_FORMAT}" -i ${FormatFiles}
      COMMAND_EXPAND_LISTS
      COMMENT "Formatting RCC Backend C++ sources"
      VERBATIM
    )

    add_custom_target(
      rcc-backend-format-check
      COMMAND "${RCC_BACKEND_CLANG_FORMAT}" --dry-run --Werror ${FormatFiles}
      COMMAND_EXPAND_LISTS
      COMMENT "Checking RCC Backend C++ formatting"
      VERBATIM
    )
  endif()

  if(TidyFiles)
    list(REMOVE_DUPLICATES TidyFiles)

    # LLVM's repository runs clang-tidy-diff.py for changed lines. Keep the
    # backend's explicit full audit deterministic by invoking clang-tidy once
    # with the registered translation units instead of using a process pool.
    add_custom_target(
      rcc-backend-tidy
      COMMAND
        "${RCC_BACKEND_CLANG_TIDY}"
        "--quiet"
        "-p=${CMAKE_BINARY_DIR}"
        "--warnings-as-errors=*"
        ${TidyFiles}
      COMMAND_EXPAND_LISTS
      COMMENT "Running clang-tidy on RCC Backend"
      USES_TERMINAL
      VERBATIM
    )

    add_custom_target(
      rcc-backend-analyze
      COMMAND
        "${RCC_BACKEND_CLANG_TIDY}"
        "--quiet"
        "-p=${CMAKE_BINARY_DIR}"
        "-checks=-*,clang-analyzer-*"
        "--warnings-as-errors=*"
        ${TidyFiles}
      COMMAND_EXPAND_LISTS
      COMMENT "Running Clang Static Analyzer checks on RCC Backend"
      USES_TERMINAL
      VERBATIM
    )
  endif()
endfunction()