(self)
| 110 | ] |
| 111 | |
| 112 | def run(self): |
| 113 | logging.info("CMake Config Task Start...") |
| 114 | |
| 115 | cmake_cfg_path = self.config.get("cmake_cfg_path", "build") |
| 116 | self.CMAKE_COMMAND.extend( |
| 117 | [ |
| 118 | "-G", |
| 119 | "Ninja", |
| 120 | "-B", |
| 121 | os.path.join(PROJECT_ROOT_PATH, cmake_cfg_path), |
| 122 | ] |
| 123 | ) |
| 124 | |
| 125 | cmake_build_type = self.config.get("cmake_build_type", "Release") |
| 126 | self.CMAKE_COMMAND.extend(["-DCMAKE_BUILD_TYPE=" + cmake_build_type]) |
| 127 | |
| 128 | cmake_toolchain_file = self.config.get("cmake_toolchain_file", None) |
| 129 | if cmake_toolchain_file: |
| 130 | self.CMAKE_COMMAND.extend( |
| 131 | [ |
| 132 | "-DCMAKE_TOOLCHAIN_FILE=" + cmake_toolchain_file, |
| 133 | ] |
| 134 | ) |
| 135 | |
| 136 | cmake_extra_args = self.config.get("cmake_extra_args", None) |
| 137 | if cmake_extra_args: |
| 138 | self.CMAKE_COMMAND.extend(cmake_extra_args) |
| 139 | |
| 140 | commands = self.make_command_str(self.CMAKE_COMMAND) |
| 141 | logging.info(f"{commands}") |
| 142 | throw_error_if_failed(os.system(commands)) |
| 143 | |
| 144 | logging.warning( |
| 145 | f'If you are using vscode to develop. Pls set `"clangd.arguments": ["--compile-commands-dir={os.path.join(PROJECT_ROOT_PATH, cmake_cfg_path)}"]`' |
| 146 | ) |
| 147 | |
| 148 | show_ninja_targets = self.config.get("show_ninja_targets", False) |
| 149 | if show_ninja_targets: |
| 150 | logging.info("Finding targets in Ninja Builder:") |
| 151 | throw_error_if_failed( |
| 152 | os.system( |
| 153 | self.make_command_str( |
| 154 | [ |
| 155 | "ninja", |
| 156 | "-C", |
| 157 | os.path.join(PROJECT_ROOT_PATH, cmake_cfg_path), |
| 158 | "-t", |
| 159 | "targets", |
| 160 | ] |
| 161 | ) |
| 162 | ) |
| 163 | ) |
| 164 | |
| 165 | |
| 166 | class CMakeFormatTask(Task): |
nothing calls this directly
no test coverage detected