rosica | 71bc38f | 2019-02-04 02:39:30 -0800 | [diff] [blame] | 1 | # Copyright 2019 The Bazel Authors. All rights reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | """A Starlark cc_toolchain configuration rule""" |
| 16 | |
| 17 | load( |
| 18 | "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", |
| 19 | "action_config", |
| 20 | "artifact_name_pattern", |
| 21 | "env_entry", |
| 22 | "env_set", |
| 23 | "feature", |
| 24 | "feature_set", |
| 25 | "flag_group", |
| 26 | "flag_set", |
| 27 | "make_variable", |
| 28 | "tool", |
| 29 | "tool_path", |
| 30 | "variable_with_value", |
| 31 | "with_feature_set", |
| 32 | ) |
| 33 | load( |
| 34 | "@bazel_tools//tools/build_defs/cc:action_names.bzl", |
| 35 | _ASSEMBLE_ACTION_NAME = "ASSEMBLE_ACTION_NAME", |
| 36 | _CLIF_MATCH_ACTION_NAME = "CLIF_MATCH_ACTION_NAME", |
| 37 | _CPP_COMPILE_ACTION_NAME = "CPP_COMPILE_ACTION_NAME", |
| 38 | _CPP_HEADER_PARSING_ACTION_NAME = "CPP_HEADER_PARSING_ACTION_NAME", |
| 39 | _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME = "CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME", |
| 40 | _CPP_LINK_EXECUTABLE_ACTION_NAME = "CPP_LINK_EXECUTABLE_ACTION_NAME", |
| 41 | _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME = "CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME", |
| 42 | _CPP_LINK_STATIC_LIBRARY_ACTION_NAME = "CPP_LINK_STATIC_LIBRARY_ACTION_NAME", |
| 43 | _CPP_MODULE_CODEGEN_ACTION_NAME = "CPP_MODULE_CODEGEN_ACTION_NAME", |
| 44 | _CPP_MODULE_COMPILE_ACTION_NAME = "CPP_MODULE_COMPILE_ACTION_NAME", |
| 45 | _C_COMPILE_ACTION_NAME = "C_COMPILE_ACTION_NAME", |
| 46 | _LINKSTAMP_COMPILE_ACTION_NAME = "LINKSTAMP_COMPILE_ACTION_NAME", |
| 47 | _LTO_BACKEND_ACTION_NAME = "LTO_BACKEND_ACTION_NAME", |
| 48 | _LTO_INDEXING_ACTION_NAME = "LTO_INDEXING_ACTION_NAME", |
| 49 | _PREPROCESS_ASSEMBLE_ACTION_NAME = "PREPROCESS_ASSEMBLE_ACTION_NAME", |
| 50 | _STRIP_ACTION_NAME = "STRIP_ACTION_NAME", |
| 51 | ) |
| 52 | |
| 53 | all_compile_actions = [ |
| 54 | _C_COMPILE_ACTION_NAME, |
| 55 | _CPP_COMPILE_ACTION_NAME, |
| 56 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 57 | _ASSEMBLE_ACTION_NAME, |
| 58 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 59 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 60 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 61 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 62 | _CLIF_MATCH_ACTION_NAME, |
| 63 | _LTO_BACKEND_ACTION_NAME, |
| 64 | ] |
| 65 | |
| 66 | all_cpp_compile_actions = [ |
| 67 | _CPP_COMPILE_ACTION_NAME, |
| 68 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 69 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 70 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 71 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 72 | _CLIF_MATCH_ACTION_NAME, |
| 73 | ] |
| 74 | |
| 75 | preprocessor_compile_actions = [ |
| 76 | _C_COMPILE_ACTION_NAME, |
| 77 | _CPP_COMPILE_ACTION_NAME, |
| 78 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 79 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 80 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 81 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 82 | _CLIF_MATCH_ACTION_NAME, |
| 83 | ] |
| 84 | |
| 85 | codegen_compile_actions = [ |
| 86 | _C_COMPILE_ACTION_NAME, |
| 87 | _CPP_COMPILE_ACTION_NAME, |
| 88 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 89 | _ASSEMBLE_ACTION_NAME, |
| 90 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 91 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 92 | _LTO_BACKEND_ACTION_NAME, |
| 93 | ] |
| 94 | |
| 95 | all_link_actions = [ |
| 96 | _CPP_LINK_EXECUTABLE_ACTION_NAME, |
| 97 | _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, |
| 98 | _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, |
| 99 | ] |
| 100 | |
| 101 | def _impl(ctx): |
rosica | c5ebfcf | 2019-06-04 01:47:17 -0700 | [diff] [blame] | 102 | if ctx.attr.disable_static_cc_toolchains: |
| 103 | fail("@bazel_tools//tools/cpp:default-toolchain, as well as the cc_toolchains it points " + |
| 104 | "to have been removed. See https://github.com/bazelbuild/bazel/issues/8546.") |
| 105 | |
rosica | 71bc38f | 2019-02-04 02:39:30 -0800 | [diff] [blame] | 106 | if (ctx.attr.cpu == "darwin"): |
| 107 | toolchain_identifier = "local_darwin" |
| 108 | elif (ctx.attr.cpu == "freebsd"): |
| 109 | toolchain_identifier = "local_freebsd" |
| 110 | elif (ctx.attr.cpu == "local"): |
| 111 | toolchain_identifier = "local_linux" |
| 112 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): |
| 113 | toolchain_identifier = "local_windows_clang" |
| 114 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): |
| 115 | toolchain_identifier = "local_windows_mingw" |
| 116 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): |
| 117 | toolchain_identifier = "local_windows_msys64" |
| 118 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): |
| 119 | toolchain_identifier = "local_windows_msys64_mingw64" |
| 120 | elif (ctx.attr.cpu == "armeabi-v7a"): |
| 121 | toolchain_identifier = "stub_armeabi-v7a" |
| 122 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 123 | toolchain_identifier = "vc_14_0_x64" |
| 124 | else: |
| 125 | fail("Unreachable") |
| 126 | |
| 127 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 128 | host_system_name = "armeabi-v7a" |
| 129 | elif (ctx.attr.cpu == "darwin" or |
| 130 | ctx.attr.cpu == "freebsd" or |
| 131 | ctx.attr.cpu == "local" or |
| 132 | ctx.attr.cpu == "x64_windows" or |
| 133 | ctx.attr.cpu == "x64_windows_msvc"): |
| 134 | host_system_name = "local" |
| 135 | else: |
| 136 | fail("Unreachable") |
| 137 | |
| 138 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 139 | target_system_name = "armeabi-v7a" |
| 140 | elif (ctx.attr.cpu == "darwin" or |
| 141 | ctx.attr.cpu == "freebsd" or |
| 142 | ctx.attr.cpu == "local" or |
| 143 | ctx.attr.cpu == "x64_windows" or |
| 144 | ctx.attr.cpu == "x64_windows_msvc"): |
| 145 | target_system_name = "local" |
| 146 | else: |
| 147 | fail("Unreachable") |
| 148 | |
| 149 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 150 | target_cpu = "armeabi-v7a" |
| 151 | elif (ctx.attr.cpu == "darwin"): |
| 152 | target_cpu = "darwin" |
| 153 | elif (ctx.attr.cpu == "freebsd"): |
| 154 | target_cpu = "freebsd" |
| 155 | elif (ctx.attr.cpu == "local"): |
| 156 | target_cpu = "local" |
| 157 | elif (ctx.attr.cpu == "x64_windows"): |
| 158 | target_cpu = "x64_windows" |
| 159 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 160 | target_cpu = "x64_windows_msvc" |
| 161 | else: |
| 162 | fail("Unreachable") |
| 163 | |
| 164 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 165 | target_libc = "armeabi-v7a" |
| 166 | elif (ctx.attr.cpu == "freebsd" or |
| 167 | ctx.attr.cpu == "local" or |
| 168 | ctx.attr.cpu == "x64_windows"): |
| 169 | target_libc = "local" |
| 170 | elif (ctx.attr.cpu == "darwin"): |
| 171 | target_libc = "macosx" |
| 172 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 173 | target_libc = "msvcrt140" |
| 174 | else: |
| 175 | fail("Unreachable") |
| 176 | |
| 177 | if (ctx.attr.cpu == "x64_windows_msvc"): |
| 178 | compiler = "cl" |
| 179 | elif (ctx.attr.cpu == "armeabi-v7a" or |
| 180 | ctx.attr.cpu == "darwin" or |
| 181 | ctx.attr.cpu == "freebsd" or |
| 182 | ctx.attr.cpu == "local"): |
| 183 | compiler = "compiler" |
| 184 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): |
| 185 | compiler = "windows_clang" |
| 186 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): |
| 187 | compiler = "windows_mingw" |
| 188 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): |
| 189 | compiler = "windows_msys64" |
| 190 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): |
| 191 | compiler = "windows_msys64_mingw64" |
| 192 | else: |
| 193 | fail("Unreachable") |
| 194 | |
| 195 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 196 | abi_version = "armeabi-v7a" |
| 197 | elif (ctx.attr.cpu == "darwin" or |
| 198 | ctx.attr.cpu == "freebsd" or |
| 199 | ctx.attr.cpu == "local" or |
| 200 | ctx.attr.cpu == "x64_windows" or |
| 201 | ctx.attr.cpu == "x64_windows_msvc"): |
| 202 | abi_version = "local" |
| 203 | else: |
| 204 | fail("Unreachable") |
| 205 | |
| 206 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 207 | abi_libc_version = "armeabi-v7a" |
| 208 | elif (ctx.attr.cpu == "darwin" or |
| 209 | ctx.attr.cpu == "freebsd" or |
| 210 | ctx.attr.cpu == "local" or |
| 211 | ctx.attr.cpu == "x64_windows" or |
| 212 | ctx.attr.cpu == "x64_windows_msvc"): |
| 213 | abi_libc_version = "local" |
| 214 | else: |
| 215 | fail("Unreachable") |
| 216 | |
| 217 | cc_target_os = None |
| 218 | |
| 219 | builtin_sysroot = None |
| 220 | |
| 221 | if (ctx.attr.cpu == "darwin" or |
| 222 | ctx.attr.cpu == "freebsd" or |
| 223 | ctx.attr.cpu == "local"): |
| 224 | objcopy_embed_data_action = action_config( |
| 225 | action_name = "objcopy_embed_data", |
| 226 | enabled = True, |
| 227 | tools = [tool(path = "/usr/bin/objcopy")], |
| 228 | ) |
| 229 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): |
| 230 | objcopy_embed_data_action = action_config( |
| 231 | action_name = "objcopy_embed_data", |
| 232 | enabled = True, |
| 233 | tools = [tool(path = "C:/Program Files (x86)/LLVM/bin/objcopy")], |
| 234 | ) |
| 235 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): |
| 236 | objcopy_embed_data_action = action_config( |
| 237 | action_name = "objcopy_embed_data", |
| 238 | enabled = True, |
| 239 | tools = [tool(path = "C:/mingw/bin/objcopy")], |
| 240 | ) |
| 241 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): |
| 242 | objcopy_embed_data_action = action_config( |
| 243 | action_name = "objcopy_embed_data", |
| 244 | enabled = True, |
| 245 | tools = [tool(path = "C:/tools/msys64/mingw64/bin/objcopy")], |
| 246 | ) |
| 247 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): |
| 248 | objcopy_embed_data_action = action_config( |
| 249 | action_name = "objcopy_embed_data", |
| 250 | enabled = True, |
| 251 | tools = [tool(path = "C:/tools/msys64/usr/bin/objcopy")], |
| 252 | ) |
| 253 | |
| 254 | c_compile_action = action_config( |
| 255 | action_name = _C_COMPILE_ACTION_NAME, |
| 256 | implies = [ |
| 257 | "compiler_input_flags", |
| 258 | "compiler_output_flags", |
| 259 | "default_compile_flags", |
| 260 | "user_compile_flags", |
| 261 | "sysroot", |
| 262 | "unfiltered_compile_flags", |
| 263 | ], |
| 264 | tools = [tool(path = "wrapper/bin/msvc_cl.bat")], |
| 265 | ) |
| 266 | |
| 267 | cpp_compile_action = action_config( |
| 268 | action_name = _CPP_COMPILE_ACTION_NAME, |
| 269 | implies = [ |
| 270 | "compiler_input_flags", |
| 271 | "compiler_output_flags", |
| 272 | "default_compile_flags", |
| 273 | "user_compile_flags", |
| 274 | "sysroot", |
| 275 | "unfiltered_compile_flags", |
| 276 | ], |
| 277 | tools = [tool(path = "wrapper/bin/msvc_cl.bat")], |
| 278 | ) |
| 279 | |
| 280 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 281 | action_configs = [] |
| 282 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 283 | action_configs = [c_compile_action, cpp_compile_action] |
| 284 | elif (ctx.attr.cpu == "darwin" or |
| 285 | ctx.attr.cpu == "freebsd" or |
| 286 | ctx.attr.cpu == "local" or |
| 287 | ctx.attr.cpu == "x64_windows"): |
| 288 | action_configs = [objcopy_embed_data_action] |
| 289 | else: |
| 290 | fail("Unreachable") |
| 291 | |
hlopko | 2f17a86 | 2019-02-26 07:56:03 -0800 | [diff] [blame] | 292 | random_seed_feature = feature(name = "random_seed", enabled = True) |
rosica | 71bc38f | 2019-02-04 02:39:30 -0800 | [diff] [blame] | 293 | |
| 294 | compiler_output_flags_feature = feature( |
| 295 | name = "compiler_output_flags", |
| 296 | flag_sets = [ |
| 297 | flag_set( |
| 298 | actions = [_ASSEMBLE_ACTION_NAME], |
| 299 | flag_groups = [ |
| 300 | flag_group( |
| 301 | flags = ["/Fo%{output_file}", "/Zi"], |
| 302 | expand_if_available = "output_file", |
| 303 | expand_if_not_available = "output_assembly_file", |
| 304 | ), |
| 305 | ], |
| 306 | ), |
| 307 | flag_set( |
| 308 | actions = [ |
| 309 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 310 | _C_COMPILE_ACTION_NAME, |
| 311 | _CPP_COMPILE_ACTION_NAME, |
| 312 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 313 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 314 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 315 | ], |
| 316 | flag_groups = [ |
| 317 | flag_group( |
| 318 | flags = ["/Fo%{output_file}"], |
| 319 | expand_if_available = "output_file", |
| 320 | expand_if_not_available = "output_assembly_file", |
| 321 | ), |
| 322 | flag_group( |
| 323 | flags = ["/Fa%{output_file}"], |
| 324 | expand_if_available = "output_file", |
| 325 | ), |
| 326 | flag_group( |
| 327 | flags = ["/P", "/Fi%{output_file}"], |
| 328 | expand_if_available = "output_file", |
| 329 | ), |
| 330 | ], |
| 331 | ), |
| 332 | ], |
| 333 | ) |
| 334 | |
| 335 | if (ctx.attr.cpu == "local"): |
| 336 | default_link_flags_feature = feature( |
| 337 | name = "default_link_flags", |
| 338 | enabled = True, |
| 339 | flag_sets = [ |
| 340 | flag_set( |
| 341 | actions = all_link_actions, |
| 342 | flag_groups = [ |
| 343 | flag_group( |
| 344 | flags = [ |
| 345 | "-lstdc++", |
| 346 | "-Wl,-z,relro,-z,now", |
| 347 | "-no-canonical-prefixes", |
| 348 | "-pass-exit-codes", |
| 349 | ], |
| 350 | ), |
| 351 | ], |
| 352 | ), |
| 353 | flag_set( |
| 354 | actions = all_link_actions, |
| 355 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 356 | with_features = [with_feature_set(features = ["opt"])], |
| 357 | ), |
| 358 | ], |
| 359 | ) |
| 360 | elif (ctx.attr.cpu == "freebsd"): |
| 361 | default_link_flags_feature = feature( |
| 362 | name = "default_link_flags", |
| 363 | enabled = True, |
| 364 | flag_sets = [ |
| 365 | flag_set( |
| 366 | actions = all_link_actions, |
| 367 | flag_groups = [ |
| 368 | flag_group( |
| 369 | flags = [ |
| 370 | "-lstdc++", |
| 371 | "-Wl,-z,relro,-z,now", |
| 372 | "-no-canonical-prefixes", |
| 373 | ], |
| 374 | ), |
| 375 | ], |
| 376 | ), |
| 377 | flag_set( |
| 378 | actions = all_link_actions, |
| 379 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 380 | with_features = [with_feature_set(features = ["opt"])], |
| 381 | ), |
| 382 | ], |
| 383 | ) |
| 384 | elif (ctx.attr.cpu == "darwin"): |
| 385 | default_link_flags_feature = feature( |
| 386 | name = "default_link_flags", |
| 387 | enabled = True, |
| 388 | flag_sets = [ |
| 389 | flag_set( |
| 390 | actions = all_link_actions, |
| 391 | flag_groups = [ |
| 392 | flag_group( |
| 393 | flags = [ |
| 394 | "-lstdc++", |
| 395 | "-undefined", |
| 396 | "dynamic_lookup", |
| 397 | "-headerpad_max_install_names", |
| 398 | "-no-canonical-prefixes", |
| 399 | ], |
| 400 | ), |
| 401 | ], |
| 402 | ), |
| 403 | ], |
| 404 | ) |
| 405 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): |
| 406 | default_link_flags_feature = feature( |
| 407 | name = "default_link_flags", |
| 408 | enabled = True, |
| 409 | flag_sets = [ |
| 410 | flag_set( |
| 411 | actions = all_link_actions, |
| 412 | flag_groups = [flag_group(flags = ["-lstdc++"])], |
| 413 | ), |
| 414 | ], |
| 415 | ) |
| 416 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 417 | default_link_flags_feature = feature( |
| 418 | name = "default_link_flags", |
| 419 | enabled = True, |
| 420 | flag_sets = [ |
| 421 | flag_set( |
| 422 | actions = all_link_actions, |
| 423 | flag_groups = [flag_group(flags = ["-m64"])], |
| 424 | ), |
| 425 | ], |
| 426 | ) |
| 427 | |
| 428 | if (ctx.attr.cpu == "darwin" or |
| 429 | ctx.attr.cpu == "freebsd"): |
| 430 | unfiltered_compile_flags_feature = feature( |
| 431 | name = "unfiltered_compile_flags", |
| 432 | enabled = True, |
| 433 | flag_sets = [ |
| 434 | flag_set( |
| 435 | actions = [ |
| 436 | _ASSEMBLE_ACTION_NAME, |
| 437 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 438 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 439 | _C_COMPILE_ACTION_NAME, |
| 440 | _CPP_COMPILE_ACTION_NAME, |
| 441 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 442 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 443 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 444 | _LTO_BACKEND_ACTION_NAME, |
| 445 | _CLIF_MATCH_ACTION_NAME, |
| 446 | ], |
| 447 | flag_groups = [ |
| 448 | flag_group( |
| 449 | flags = [ |
| 450 | "-no-canonical-prefixes", |
| 451 | "-Wno-builtin-macro-redefined", |
| 452 | "-D__DATE__=\"redacted\"", |
| 453 | "-D__TIMESTAMP__=\"redacted\"", |
| 454 | "-D__TIME__=\"redacted\"", |
| 455 | ], |
| 456 | ), |
| 457 | ], |
| 458 | ), |
| 459 | ], |
| 460 | ) |
| 461 | elif (ctx.attr.cpu == "local"): |
| 462 | unfiltered_compile_flags_feature = feature( |
| 463 | name = "unfiltered_compile_flags", |
| 464 | enabled = True, |
| 465 | flag_sets = [ |
| 466 | flag_set( |
| 467 | actions = [ |
| 468 | _ASSEMBLE_ACTION_NAME, |
| 469 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 470 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 471 | _C_COMPILE_ACTION_NAME, |
| 472 | _CPP_COMPILE_ACTION_NAME, |
| 473 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 474 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 475 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 476 | _LTO_BACKEND_ACTION_NAME, |
| 477 | _CLIF_MATCH_ACTION_NAME, |
| 478 | ], |
| 479 | flag_groups = [ |
| 480 | flag_group( |
| 481 | flags = [ |
| 482 | "-no-canonical-prefixes", |
| 483 | "-fno-canonical-system-headers", |
| 484 | "-Wno-builtin-macro-redefined", |
| 485 | "-D__DATE__=\"redacted\"", |
| 486 | "-D__TIMESTAMP__=\"redacted\"", |
| 487 | "-D__TIME__=\"redacted\"", |
| 488 | ], |
| 489 | ), |
| 490 | ], |
| 491 | ), |
| 492 | ], |
| 493 | ) |
| 494 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 495 | unfiltered_compile_flags_feature = feature( |
| 496 | name = "unfiltered_compile_flags", |
| 497 | flag_sets = [ |
| 498 | flag_set( |
| 499 | actions = [ |
| 500 | _ASSEMBLE_ACTION_NAME, |
| 501 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 502 | _C_COMPILE_ACTION_NAME, |
| 503 | _CPP_COMPILE_ACTION_NAME, |
| 504 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 505 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 506 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 507 | ], |
| 508 | flag_groups = [ |
| 509 | flag_group( |
| 510 | flags = ["%{unfiltered_compile_flags}"], |
| 511 | iterate_over = "unfiltered_compile_flags", |
| 512 | expand_if_available = "unfiltered_compile_flags", |
| 513 | ), |
| 514 | ], |
| 515 | ), |
| 516 | ], |
| 517 | ) |
| 518 | |
| 519 | supports_pic_feature = feature(name = "supports_pic", enabled = True) |
| 520 | |
| 521 | if (ctx.attr.cpu == "darwin"): |
| 522 | default_compile_flags_feature = feature( |
| 523 | name = "default_compile_flags", |
| 524 | enabled = True, |
| 525 | flag_sets = [ |
| 526 | flag_set( |
| 527 | actions = [ |
| 528 | _ASSEMBLE_ACTION_NAME, |
| 529 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 530 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 531 | _C_COMPILE_ACTION_NAME, |
| 532 | _CPP_COMPILE_ACTION_NAME, |
| 533 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 534 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 535 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 536 | _LTO_BACKEND_ACTION_NAME, |
| 537 | _CLIF_MATCH_ACTION_NAME, |
| 538 | ], |
| 539 | flag_groups = [ |
| 540 | flag_group( |
| 541 | flags = [ |
| 542 | "-D_FORTIFY_SOURCE=1", |
| 543 | "-fstack-protector", |
| 544 | "-fcolor-diagnostics", |
| 545 | "-Wall", |
| 546 | "-Wthread-safety", |
| 547 | "-Wself-assign", |
| 548 | "-fno-omit-frame-pointer", |
| 549 | ], |
| 550 | ), |
| 551 | ], |
| 552 | ), |
| 553 | flag_set( |
| 554 | actions = [ |
| 555 | _ASSEMBLE_ACTION_NAME, |
| 556 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 557 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 558 | _C_COMPILE_ACTION_NAME, |
| 559 | _CPP_COMPILE_ACTION_NAME, |
| 560 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 561 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 562 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 563 | _LTO_BACKEND_ACTION_NAME, |
| 564 | _CLIF_MATCH_ACTION_NAME, |
| 565 | ], |
| 566 | flag_groups = [flag_group(flags = ["-g"])], |
| 567 | with_features = [with_feature_set(features = ["dbg"])], |
| 568 | ), |
| 569 | flag_set( |
| 570 | actions = [ |
| 571 | _ASSEMBLE_ACTION_NAME, |
| 572 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 573 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 574 | _C_COMPILE_ACTION_NAME, |
| 575 | _CPP_COMPILE_ACTION_NAME, |
| 576 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 577 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 578 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 579 | _LTO_BACKEND_ACTION_NAME, |
| 580 | _CLIF_MATCH_ACTION_NAME, |
| 581 | ], |
| 582 | flag_groups = [ |
| 583 | flag_group( |
| 584 | flags = [ |
| 585 | "-g0", |
| 586 | "-O2", |
| 587 | "-DNDEBUG", |
| 588 | "-ffunction-sections", |
| 589 | "-fdata-sections", |
| 590 | ], |
| 591 | ), |
| 592 | ], |
| 593 | with_features = [with_feature_set(features = ["opt"])], |
| 594 | ), |
| 595 | flag_set( |
| 596 | actions = [ |
| 597 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 598 | _CPP_COMPILE_ACTION_NAME, |
| 599 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 600 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 601 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 602 | _LTO_BACKEND_ACTION_NAME, |
| 603 | _CLIF_MATCH_ACTION_NAME, |
| 604 | ], |
| 605 | flag_groups = [flag_group(flags = ["-std=c++0x"])], |
| 606 | ), |
| 607 | ], |
| 608 | ) |
| 609 | elif (ctx.attr.cpu == "local"): |
| 610 | default_compile_flags_feature = feature( |
| 611 | name = "default_compile_flags", |
| 612 | enabled = True, |
| 613 | flag_sets = [ |
| 614 | flag_set( |
| 615 | actions = [ |
| 616 | _ASSEMBLE_ACTION_NAME, |
| 617 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 618 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 619 | _C_COMPILE_ACTION_NAME, |
| 620 | _CPP_COMPILE_ACTION_NAME, |
| 621 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 622 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 623 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 624 | _LTO_BACKEND_ACTION_NAME, |
| 625 | _CLIF_MATCH_ACTION_NAME, |
| 626 | ], |
| 627 | flag_groups = [ |
| 628 | flag_group( |
| 629 | flags = [ |
| 630 | "-U_FORTIFY_SOURCE", |
| 631 | "-D_FORTIFY_SOURCE=1", |
| 632 | "-fstack-protector", |
| 633 | "-Wall", |
| 634 | "-Wunused-but-set-parameter", |
| 635 | "-Wno-free-nonheap-object", |
| 636 | "-fno-omit-frame-pointer", |
| 637 | ], |
| 638 | ), |
| 639 | ], |
| 640 | ), |
| 641 | flag_set( |
| 642 | actions = [ |
| 643 | _ASSEMBLE_ACTION_NAME, |
| 644 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 645 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 646 | _C_COMPILE_ACTION_NAME, |
| 647 | _CPP_COMPILE_ACTION_NAME, |
| 648 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 649 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 650 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 651 | _LTO_BACKEND_ACTION_NAME, |
| 652 | _CLIF_MATCH_ACTION_NAME, |
| 653 | ], |
| 654 | flag_groups = [flag_group(flags = ["-g"])], |
| 655 | with_features = [with_feature_set(features = ["dbg"])], |
| 656 | ), |
| 657 | flag_set( |
| 658 | actions = [ |
| 659 | _ASSEMBLE_ACTION_NAME, |
| 660 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 661 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 662 | _C_COMPILE_ACTION_NAME, |
| 663 | _CPP_COMPILE_ACTION_NAME, |
| 664 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 665 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 666 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 667 | _LTO_BACKEND_ACTION_NAME, |
| 668 | _CLIF_MATCH_ACTION_NAME, |
| 669 | ], |
| 670 | flag_groups = [ |
| 671 | flag_group( |
| 672 | flags = [ |
| 673 | "-g0", |
| 674 | "-O2", |
| 675 | "-DNDEBUG", |
| 676 | "-ffunction-sections", |
| 677 | "-fdata-sections", |
| 678 | ], |
| 679 | ), |
| 680 | ], |
| 681 | with_features = [with_feature_set(features = ["opt"])], |
| 682 | ), |
| 683 | flag_set( |
| 684 | actions = [ |
| 685 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 686 | _CPP_COMPILE_ACTION_NAME, |
| 687 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 688 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 689 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 690 | _LTO_BACKEND_ACTION_NAME, |
| 691 | _CLIF_MATCH_ACTION_NAME, |
| 692 | ], |
| 693 | flag_groups = [flag_group(flags = ["-std=c++0x"])], |
| 694 | ), |
| 695 | ], |
| 696 | ) |
| 697 | elif (ctx.attr.cpu == "freebsd"): |
| 698 | default_compile_flags_feature = feature( |
| 699 | name = "default_compile_flags", |
| 700 | enabled = True, |
| 701 | flag_sets = [ |
| 702 | flag_set( |
| 703 | actions = [ |
| 704 | _ASSEMBLE_ACTION_NAME, |
| 705 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 706 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 707 | _C_COMPILE_ACTION_NAME, |
| 708 | _CPP_COMPILE_ACTION_NAME, |
| 709 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 710 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 711 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 712 | _LTO_BACKEND_ACTION_NAME, |
| 713 | _CLIF_MATCH_ACTION_NAME, |
| 714 | ], |
| 715 | flag_groups = [ |
| 716 | flag_group( |
| 717 | flags = [ |
| 718 | "-U_FORTIFY_SOURCE", |
| 719 | "-D_FORTIFY_SOURCE=1", |
| 720 | "-fstack-protector", |
| 721 | "-Wall", |
| 722 | "-fno-omit-frame-pointer", |
| 723 | ], |
| 724 | ), |
| 725 | ], |
| 726 | ), |
| 727 | flag_set( |
| 728 | actions = [ |
| 729 | _ASSEMBLE_ACTION_NAME, |
| 730 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 731 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 732 | _C_COMPILE_ACTION_NAME, |
| 733 | _CPP_COMPILE_ACTION_NAME, |
| 734 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 735 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 736 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 737 | _LTO_BACKEND_ACTION_NAME, |
| 738 | _CLIF_MATCH_ACTION_NAME, |
| 739 | ], |
| 740 | flag_groups = [flag_group(flags = ["-g"])], |
| 741 | with_features = [with_feature_set(features = ["dbg"])], |
| 742 | ), |
| 743 | flag_set( |
| 744 | actions = [ |
| 745 | _ASSEMBLE_ACTION_NAME, |
| 746 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 747 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 748 | _C_COMPILE_ACTION_NAME, |
| 749 | _CPP_COMPILE_ACTION_NAME, |
| 750 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 751 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 752 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 753 | _LTO_BACKEND_ACTION_NAME, |
| 754 | _CLIF_MATCH_ACTION_NAME, |
| 755 | ], |
| 756 | flag_groups = [ |
| 757 | flag_group( |
| 758 | flags = [ |
| 759 | "-g0", |
| 760 | "-O2", |
| 761 | "-DNDEBUG", |
| 762 | "-ffunction-sections", |
| 763 | "-fdata-sections", |
| 764 | ], |
| 765 | ), |
| 766 | ], |
| 767 | with_features = [with_feature_set(features = ["opt"])], |
| 768 | ), |
| 769 | flag_set( |
| 770 | actions = [ |
| 771 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 772 | _CPP_COMPILE_ACTION_NAME, |
| 773 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 774 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 775 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 776 | _LTO_BACKEND_ACTION_NAME, |
| 777 | _CLIF_MATCH_ACTION_NAME, |
| 778 | ], |
| 779 | flag_groups = [flag_group(flags = ["-std=c++0x"])], |
| 780 | ), |
| 781 | ], |
| 782 | ) |
| 783 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 784 | default_compile_flags_feature = feature( |
| 785 | name = "default_compile_flags", |
| 786 | enabled = True, |
| 787 | flag_sets = [ |
| 788 | flag_set( |
| 789 | actions = [ |
| 790 | _ASSEMBLE_ACTION_NAME, |
| 791 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 792 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 793 | _C_COMPILE_ACTION_NAME, |
| 794 | _CPP_COMPILE_ACTION_NAME, |
| 795 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 796 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 797 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 798 | _LTO_BACKEND_ACTION_NAME, |
| 799 | _CLIF_MATCH_ACTION_NAME, |
| 800 | ], |
| 801 | flag_groups = [ |
| 802 | flag_group( |
| 803 | flags = [ |
| 804 | "-m64", |
| 805 | "/D__inline__=__inline", |
| 806 | "/DCOMPILER_MSVC", |
| 807 | "/DNOGDI", |
| 808 | "/DNOMINMAX", |
| 809 | "/DPRAGMA_SUPPORTED", |
| 810 | "/D_WIN32_WINNT=0x0601", |
| 811 | "/D_CRT_SECURE_NO_DEPRECATE", |
| 812 | "/D_CRT_SECURE_NO_WARNINGS", |
| 813 | "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS", |
| 814 | "/D_USE_MATH_DEFINES", |
| 815 | "/nologo", |
| 816 | "/bigobj", |
| 817 | "/Zm500", |
| 818 | "/J", |
| 819 | "/Gy", |
| 820 | "/GF", |
| 821 | "/W3", |
| 822 | "/EHsc", |
| 823 | "/wd4351", |
| 824 | "/wd4291", |
| 825 | "/wd4250", |
| 826 | "/wd4996", |
| 827 | ], |
| 828 | ), |
| 829 | ], |
| 830 | ), |
| 831 | flag_set( |
| 832 | actions = [ |
| 833 | _ASSEMBLE_ACTION_NAME, |
| 834 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 835 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 836 | _C_COMPILE_ACTION_NAME, |
| 837 | _CPP_COMPILE_ACTION_NAME, |
| 838 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 839 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 840 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 841 | _LTO_BACKEND_ACTION_NAME, |
| 842 | _CLIF_MATCH_ACTION_NAME, |
| 843 | ], |
| 844 | flag_groups = [ |
| 845 | flag_group( |
| 846 | flags = ["/DDEBUG=1", "-g", "/Od", "-Xcompilation-mode=dbg"], |
| 847 | ), |
| 848 | ], |
| 849 | with_features = [with_feature_set(features = ["dbg"])], |
| 850 | ), |
| 851 | flag_set( |
| 852 | actions = [ |
| 853 | _ASSEMBLE_ACTION_NAME, |
| 854 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 855 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 856 | _C_COMPILE_ACTION_NAME, |
| 857 | _CPP_COMPILE_ACTION_NAME, |
| 858 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 859 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 860 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 861 | _LTO_BACKEND_ACTION_NAME, |
| 862 | _CLIF_MATCH_ACTION_NAME, |
| 863 | ], |
| 864 | flag_groups = [ |
| 865 | flag_group( |
| 866 | flags = ["/DNDEBUG", "/Od", "-Xcompilation-mode=fastbuild"], |
| 867 | ), |
| 868 | ], |
| 869 | with_features = [with_feature_set(features = ["fastbuild"])], |
| 870 | ), |
| 871 | flag_set( |
| 872 | actions = [ |
| 873 | _ASSEMBLE_ACTION_NAME, |
| 874 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 875 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 876 | _C_COMPILE_ACTION_NAME, |
| 877 | _CPP_COMPILE_ACTION_NAME, |
| 878 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 879 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 880 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 881 | _LTO_BACKEND_ACTION_NAME, |
| 882 | _CLIF_MATCH_ACTION_NAME, |
| 883 | ], |
| 884 | flag_groups = [ |
| 885 | flag_group( |
| 886 | flags = ["/DNDEBUG", "/O2", "-Xcompilation-mode=opt"], |
| 887 | ), |
| 888 | ], |
| 889 | with_features = [with_feature_set(features = ["opt"])], |
| 890 | ), |
| 891 | ], |
| 892 | ) |
| 893 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang" or |
| 894 | ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw" or |
| 895 | ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): |
| 896 | default_compile_flags_feature = feature( |
| 897 | name = "default_compile_flags", |
| 898 | enabled = True, |
| 899 | flag_sets = [ |
| 900 | flag_set( |
| 901 | actions = [ |
| 902 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 903 | _CPP_COMPILE_ACTION_NAME, |
| 904 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 905 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 906 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 907 | _LTO_BACKEND_ACTION_NAME, |
| 908 | _CLIF_MATCH_ACTION_NAME, |
| 909 | ], |
| 910 | flag_groups = [flag_group(flags = ["-std=c++0x"])], |
| 911 | ), |
| 912 | ], |
| 913 | ) |
| 914 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): |
| 915 | default_compile_flags_feature = feature( |
| 916 | name = "default_compile_flags", |
| 917 | enabled = True, |
| 918 | flag_sets = [ |
| 919 | flag_set( |
| 920 | actions = [ |
| 921 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 922 | _CPP_COMPILE_ACTION_NAME, |
| 923 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 924 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 925 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 926 | _LTO_BACKEND_ACTION_NAME, |
| 927 | _CLIF_MATCH_ACTION_NAME, |
| 928 | ], |
| 929 | flag_groups = [flag_group(flags = ["-std=gnu++0x"])], |
| 930 | ), |
| 931 | ], |
| 932 | ) |
| 933 | |
| 934 | opt_feature = feature(name = "opt") |
| 935 | |
| 936 | supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) |
| 937 | |
| 938 | objcopy_embed_flags_feature = feature( |
| 939 | name = "objcopy_embed_flags", |
| 940 | enabled = True, |
| 941 | flag_sets = [ |
| 942 | flag_set( |
| 943 | actions = ["objcopy_embed_data"], |
| 944 | flag_groups = [flag_group(flags = ["-I", "binary"])], |
| 945 | ), |
| 946 | ], |
| 947 | ) |
| 948 | |
| 949 | dbg_feature = feature(name = "dbg") |
| 950 | |
| 951 | if (ctx.attr.cpu == "darwin" or |
| 952 | ctx.attr.cpu == "freebsd" or |
| 953 | ctx.attr.cpu == "local"): |
| 954 | user_compile_flags_feature = feature( |
| 955 | name = "user_compile_flags", |
| 956 | enabled = True, |
| 957 | flag_sets = [ |
| 958 | flag_set( |
| 959 | actions = [ |
| 960 | _ASSEMBLE_ACTION_NAME, |
| 961 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 962 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 963 | _C_COMPILE_ACTION_NAME, |
| 964 | _CPP_COMPILE_ACTION_NAME, |
| 965 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 966 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 967 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 968 | _LTO_BACKEND_ACTION_NAME, |
| 969 | _CLIF_MATCH_ACTION_NAME, |
| 970 | ], |
| 971 | flag_groups = [ |
| 972 | flag_group( |
| 973 | flags = ["%{user_compile_flags}"], |
| 974 | iterate_over = "user_compile_flags", |
| 975 | expand_if_available = "user_compile_flags", |
| 976 | ), |
| 977 | ], |
| 978 | ), |
| 979 | ], |
| 980 | ) |
| 981 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 982 | user_compile_flags_feature = feature( |
| 983 | name = "user_compile_flags", |
| 984 | flag_sets = [ |
| 985 | flag_set( |
| 986 | actions = [ |
| 987 | _ASSEMBLE_ACTION_NAME, |
| 988 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 989 | _C_COMPILE_ACTION_NAME, |
| 990 | _CPP_COMPILE_ACTION_NAME, |
| 991 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 992 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 993 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 994 | ], |
| 995 | flag_groups = [ |
| 996 | flag_group( |
| 997 | flags = ["%{user_compile_flags}"], |
| 998 | iterate_over = "user_compile_flags", |
| 999 | expand_if_available = "user_compile_flags", |
| 1000 | ), |
| 1001 | ], |
| 1002 | ), |
| 1003 | ], |
| 1004 | ) |
| 1005 | |
| 1006 | if (ctx.attr.cpu == "darwin" or |
| 1007 | ctx.attr.cpu == "freebsd" or |
| 1008 | ctx.attr.cpu == "local"): |
| 1009 | sysroot_feature = feature( |
| 1010 | name = "sysroot", |
| 1011 | enabled = True, |
| 1012 | flag_sets = [ |
| 1013 | flag_set( |
| 1014 | actions = [ |
| 1015 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 1016 | _LINKSTAMP_COMPILE_ACTION_NAME, |
| 1017 | _C_COMPILE_ACTION_NAME, |
| 1018 | _CPP_COMPILE_ACTION_NAME, |
| 1019 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 1020 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 1021 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 1022 | _LTO_BACKEND_ACTION_NAME, |
| 1023 | _CLIF_MATCH_ACTION_NAME, |
| 1024 | _CPP_LINK_EXECUTABLE_ACTION_NAME, |
| 1025 | _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, |
| 1026 | _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, |
| 1027 | ], |
| 1028 | flag_groups = [ |
| 1029 | flag_group( |
| 1030 | flags = ["--sysroot=%{sysroot}"], |
| 1031 | expand_if_available = "sysroot", |
| 1032 | ), |
| 1033 | ], |
| 1034 | ), |
| 1035 | ], |
| 1036 | ) |
| 1037 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 1038 | sysroot_feature = feature( |
| 1039 | name = "sysroot", |
| 1040 | flag_sets = [ |
| 1041 | flag_set( |
| 1042 | actions = [ |
| 1043 | _ASSEMBLE_ACTION_NAME, |
| 1044 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 1045 | _C_COMPILE_ACTION_NAME, |
| 1046 | _CPP_COMPILE_ACTION_NAME, |
| 1047 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 1048 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 1049 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 1050 | _CPP_LINK_EXECUTABLE_ACTION_NAME, |
| 1051 | _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, |
| 1052 | _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, |
| 1053 | ], |
| 1054 | flag_groups = [ |
| 1055 | flag_group( |
| 1056 | flags = ["--sysroot=%{sysroot}"], |
| 1057 | iterate_over = "sysroot", |
| 1058 | expand_if_available = "sysroot", |
| 1059 | ), |
| 1060 | ], |
| 1061 | ), |
| 1062 | ], |
| 1063 | ) |
| 1064 | |
| 1065 | include_paths_feature = feature( |
| 1066 | name = "include_paths", |
hlopko | 2f17a86 | 2019-02-26 07:56:03 -0800 | [diff] [blame] | 1067 | enabled = True, |
rosica | 71bc38f | 2019-02-04 02:39:30 -0800 | [diff] [blame] | 1068 | flag_sets = [ |
| 1069 | flag_set( |
| 1070 | actions = [ |
| 1071 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 1072 | _C_COMPILE_ACTION_NAME, |
| 1073 | _CPP_COMPILE_ACTION_NAME, |
| 1074 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 1075 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 1076 | ], |
| 1077 | flag_groups = [ |
| 1078 | flag_group( |
| 1079 | flags = ["/I%{quote_include_paths}"], |
| 1080 | iterate_over = "quote_include_paths", |
| 1081 | ), |
| 1082 | flag_group( |
| 1083 | flags = ["/I%{include_paths}"], |
| 1084 | iterate_over = "include_paths", |
| 1085 | ), |
| 1086 | flag_group( |
| 1087 | flags = ["/I%{system_include_paths}"], |
| 1088 | iterate_over = "system_include_paths", |
| 1089 | ), |
| 1090 | ], |
| 1091 | ), |
| 1092 | ], |
| 1093 | ) |
| 1094 | |
| 1095 | dependency_file_feature = feature( |
| 1096 | name = "dependency_file", |
hlopko | 2f17a86 | 2019-02-26 07:56:03 -0800 | [diff] [blame] | 1097 | enabled = True, |
rosica | 71bc38f | 2019-02-04 02:39:30 -0800 | [diff] [blame] | 1098 | flag_sets = [ |
| 1099 | flag_set( |
| 1100 | actions = [ |
| 1101 | _ASSEMBLE_ACTION_NAME, |
| 1102 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 1103 | _C_COMPILE_ACTION_NAME, |
| 1104 | _CPP_COMPILE_ACTION_NAME, |
| 1105 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 1106 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 1107 | ], |
| 1108 | flag_groups = [ |
| 1109 | flag_group( |
| 1110 | flags = ["/DEPENDENCY_FILE", "%{dependency_file}"], |
| 1111 | expand_if_available = "dependency_file", |
| 1112 | ), |
| 1113 | ], |
| 1114 | ), |
| 1115 | ], |
| 1116 | ) |
| 1117 | |
| 1118 | compiler_input_flags_feature = feature( |
| 1119 | name = "compiler_input_flags", |
| 1120 | flag_sets = [ |
| 1121 | flag_set( |
| 1122 | actions = [ |
| 1123 | _ASSEMBLE_ACTION_NAME, |
| 1124 | _PREPROCESS_ASSEMBLE_ACTION_NAME, |
| 1125 | _C_COMPILE_ACTION_NAME, |
| 1126 | _CPP_COMPILE_ACTION_NAME, |
| 1127 | _CPP_HEADER_PARSING_ACTION_NAME, |
| 1128 | _CPP_MODULE_COMPILE_ACTION_NAME, |
| 1129 | _CPP_MODULE_CODEGEN_ACTION_NAME, |
| 1130 | ], |
| 1131 | flag_groups = [ |
| 1132 | flag_group( |
| 1133 | flags = ["/c", "%{source_file}"], |
| 1134 | expand_if_available = "source_file", |
| 1135 | ), |
| 1136 | ], |
| 1137 | ), |
| 1138 | ], |
| 1139 | ) |
| 1140 | |
| 1141 | fastbuild_feature = feature(name = "fastbuild") |
| 1142 | |
| 1143 | if (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): |
| 1144 | features = [ |
| 1145 | default_compile_flags_feature, |
| 1146 | default_link_flags_feature, |
| 1147 | supports_dynamic_linker_feature, |
| 1148 | objcopy_embed_flags_feature, |
| 1149 | ] |
| 1150 | elif (ctx.attr.cpu == "darwin"): |
| 1151 | features = [ |
| 1152 | default_compile_flags_feature, |
| 1153 | default_link_flags_feature, |
| 1154 | supports_dynamic_linker_feature, |
| 1155 | supports_pic_feature, |
| 1156 | objcopy_embed_flags_feature, |
| 1157 | dbg_feature, |
| 1158 | opt_feature, |
| 1159 | user_compile_flags_feature, |
| 1160 | sysroot_feature, |
| 1161 | unfiltered_compile_flags_feature, |
| 1162 | ] |
| 1163 | elif (ctx.attr.cpu == "freebsd" or |
| 1164 | ctx.attr.cpu == "local"): |
| 1165 | features = [ |
| 1166 | default_compile_flags_feature, |
| 1167 | default_link_flags_feature, |
| 1168 | supports_dynamic_linker_feature, |
| 1169 | supports_pic_feature, |
| 1170 | objcopy_embed_flags_feature, |
| 1171 | opt_feature, |
| 1172 | dbg_feature, |
| 1173 | user_compile_flags_feature, |
| 1174 | sysroot_feature, |
| 1175 | unfiltered_compile_flags_feature, |
| 1176 | ] |
| 1177 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang" or |
| 1178 | ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw" or |
| 1179 | ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): |
| 1180 | features = [ |
| 1181 | default_compile_flags_feature, |
| 1182 | supports_dynamic_linker_feature, |
| 1183 | objcopy_embed_flags_feature, |
| 1184 | ] |
| 1185 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 1186 | features = [ |
| 1187 | default_link_flags_feature, |
| 1188 | random_seed_feature, |
| 1189 | default_compile_flags_feature, |
| 1190 | include_paths_feature, |
| 1191 | dependency_file_feature, |
| 1192 | user_compile_flags_feature, |
| 1193 | sysroot_feature, |
| 1194 | unfiltered_compile_flags_feature, |
| 1195 | compiler_output_flags_feature, |
| 1196 | compiler_input_flags_feature, |
| 1197 | dbg_feature, |
| 1198 | fastbuild_feature, |
| 1199 | opt_feature, |
| 1200 | ] |
| 1201 | elif (ctx.attr.cpu == "armeabi-v7a"): |
| 1202 | features = [supports_dynamic_linker_feature, supports_pic_feature] |
| 1203 | |
| 1204 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 1205 | cxx_builtin_include_directories = [] |
| 1206 | elif (ctx.attr.cpu == "darwin"): |
| 1207 | cxx_builtin_include_directories = ["/"] |
| 1208 | elif (ctx.attr.cpu == "freebsd"): |
| 1209 | cxx_builtin_include_directories = ["/usr/lib/clang", "/usr/local/include", "/usr/include"] |
| 1210 | elif (ctx.attr.cpu == "local" or |
| 1211 | ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): |
| 1212 | cxx_builtin_include_directories = ["/usr/lib/gcc/", "/usr/local/include", "/usr/include"] |
| 1213 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 1214 | cxx_builtin_include_directories = [ |
| 1215 | "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/INCLUDE", |
| 1216 | "C:/Program Files (x86)/Windows Kits/10/include/", |
| 1217 | "C:/Program Files (x86)/Windows Kits/8.1/include/", |
| 1218 | "C:/Program Files (x86)/GnuWin32/include/", |
| 1219 | "C:/python_27_amd64/files/include", |
| 1220 | ] |
| 1221 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): |
| 1222 | cxx_builtin_include_directories = ["C:/mingw/include", "C:/mingw/lib/gcc"] |
| 1223 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): |
| 1224 | cxx_builtin_include_directories = ["C:/tools/msys64/mingw64/x86_64-w64-mingw32/include"] |
| 1225 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): |
| 1226 | cxx_builtin_include_directories = ["C:/tools/msys64/", "/usr/"] |
| 1227 | else: |
| 1228 | fail("Unreachable") |
| 1229 | |
| 1230 | artifact_name_patterns = [] |
| 1231 | |
| 1232 | make_variables = [] |
| 1233 | |
| 1234 | if (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): |
| 1235 | tool_paths = [ |
| 1236 | tool_path( |
| 1237 | name = "ar", |
| 1238 | path = "C:/tools/msys64/mingw64/bin/ar", |
| 1239 | ), |
| 1240 | tool_path( |
| 1241 | name = "compat-ld", |
| 1242 | path = "C:/tools/msys64/mingw64/bin/ld", |
| 1243 | ), |
| 1244 | tool_path( |
| 1245 | name = "cpp", |
| 1246 | path = "C:/tools/msys64/mingw64/bin/cpp", |
| 1247 | ), |
| 1248 | tool_path( |
| 1249 | name = "dwp", |
| 1250 | path = "C:/tools/msys64/mingw64/bin/dwp", |
| 1251 | ), |
| 1252 | tool_path( |
| 1253 | name = "gcc", |
| 1254 | path = "C:/tools/msys64/mingw64/bin/gcc", |
| 1255 | ), |
| 1256 | tool_path( |
| 1257 | name = "gcov", |
| 1258 | path = "C:/tools/msys64/mingw64/bin/gcov", |
| 1259 | ), |
| 1260 | tool_path( |
| 1261 | name = "ld", |
| 1262 | path = "C:/tools/msys64/mingw64/bin/ld", |
| 1263 | ), |
| 1264 | tool_path( |
| 1265 | name = "nm", |
| 1266 | path = "C:/tools/msys64/mingw64/bin/nm", |
| 1267 | ), |
| 1268 | tool_path( |
| 1269 | name = "objcopy", |
| 1270 | path = "C:/tools/msys64/mingw64/bin/objcopy", |
| 1271 | ), |
| 1272 | tool_path( |
| 1273 | name = "objdump", |
| 1274 | path = "C:/tools/msys64/mingw64/bin/objdump", |
| 1275 | ), |
| 1276 | tool_path( |
| 1277 | name = "strip", |
| 1278 | path = "C:/tools/msys64/mingw64/bin/strip", |
| 1279 | ), |
| 1280 | ] |
| 1281 | elif (ctx.attr.cpu == "armeabi-v7a"): |
| 1282 | tool_paths = [ |
| 1283 | tool_path(name = "ar", path = "/bin/false"), |
| 1284 | tool_path(name = "compat-ld", path = "/bin/false"), |
| 1285 | tool_path(name = "cpp", path = "/bin/false"), |
| 1286 | tool_path(name = "dwp", path = "/bin/false"), |
| 1287 | tool_path(name = "gcc", path = "/bin/false"), |
| 1288 | tool_path(name = "gcov", path = "/bin/false"), |
| 1289 | tool_path(name = "ld", path = "/bin/false"), |
| 1290 | tool_path(name = "nm", path = "/bin/false"), |
| 1291 | tool_path(name = "objcopy", path = "/bin/false"), |
| 1292 | tool_path(name = "objdump", path = "/bin/false"), |
| 1293 | tool_path(name = "strip", path = "/bin/false"), |
| 1294 | ] |
| 1295 | elif (ctx.attr.cpu == "freebsd"): |
| 1296 | tool_paths = [ |
| 1297 | tool_path(name = "ar", path = "/usr/bin/ar"), |
| 1298 | tool_path(name = "compat-ld", path = "/usr/bin/ld"), |
| 1299 | tool_path(name = "cpp", path = "/usr/bin/cpp"), |
| 1300 | tool_path(name = "dwp", path = "/usr/bin/dwp"), |
| 1301 | tool_path(name = "gcc", path = "/usr/bin/clang"), |
| 1302 | tool_path(name = "gcov", path = "/usr/bin/gcov"), |
| 1303 | tool_path(name = "ld", path = "/usr/bin/ld"), |
| 1304 | tool_path(name = "nm", path = "/usr/bin/nm"), |
| 1305 | tool_path(name = "objcopy", path = "/usr/bin/objcopy"), |
| 1306 | tool_path(name = "objdump", path = "/usr/bin/objdump"), |
| 1307 | tool_path(name = "strip", path = "/usr/bin/strip"), |
| 1308 | ] |
| 1309 | elif (ctx.attr.cpu == "local"): |
| 1310 | tool_paths = [ |
| 1311 | tool_path(name = "ar", path = "/usr/bin/ar"), |
| 1312 | tool_path(name = "compat-ld", path = "/usr/bin/ld"), |
| 1313 | tool_path(name = "cpp", path = "/usr/bin/cpp"), |
| 1314 | tool_path(name = "dwp", path = "/usr/bin/dwp"), |
| 1315 | tool_path(name = "gcc", path = "/usr/bin/gcc"), |
| 1316 | tool_path(name = "gcov", path = "/usr/bin/gcov"), |
| 1317 | tool_path(name = "ld", path = "/usr/bin/ld"), |
| 1318 | tool_path(name = "nm", path = "/usr/bin/nm"), |
| 1319 | tool_path(name = "objcopy", path = "/usr/bin/objcopy"), |
| 1320 | tool_path(name = "objdump", path = "/usr/bin/objdump"), |
| 1321 | tool_path(name = "strip", path = "/usr/bin/strip"), |
| 1322 | ] |
| 1323 | elif (ctx.attr.cpu == "darwin"): |
| 1324 | tool_paths = [ |
| 1325 | tool_path(name = "ar", path = "/usr/bin/libtool"), |
| 1326 | tool_path(name = "compat-ld", path = "/usr/bin/ld"), |
| 1327 | tool_path(name = "cpp", path = "/usr/bin/cpp"), |
| 1328 | tool_path(name = "dwp", path = "/usr/bin/dwp"), |
| 1329 | tool_path(name = "gcc", path = "osx_cc_wrapper.sh"), |
| 1330 | tool_path(name = "gcov", path = "/usr/bin/gcov"), |
| 1331 | tool_path(name = "ld", path = "/usr/bin/ld"), |
| 1332 | tool_path(name = "nm", path = "/usr/bin/nm"), |
| 1333 | tool_path(name = "objcopy", path = "/usr/bin/objcopy"), |
| 1334 | tool_path(name = "objdump", path = "/usr/bin/objdump"), |
| 1335 | tool_path(name = "strip", path = "/usr/bin/strip"), |
| 1336 | ] |
| 1337 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): |
| 1338 | tool_paths = [ |
| 1339 | tool_path(name = "ar", path = "C:/mingw/bin/ar"), |
| 1340 | tool_path( |
| 1341 | name = "compat-ld", |
| 1342 | path = "C:/Program Files (x86)/LLVM/bin/ld", |
| 1343 | ), |
| 1344 | tool_path( |
| 1345 | name = "cpp", |
| 1346 | path = "C:/Program Files (x86)/LLVM/bin/cpp", |
| 1347 | ), |
| 1348 | tool_path( |
| 1349 | name = "dwp", |
| 1350 | path = "C:/Program Files (x86)/LLVM/bin/dwp", |
| 1351 | ), |
| 1352 | tool_path( |
| 1353 | name = "gcc", |
| 1354 | path = "C:/Program Files (x86)/LLVM/bin/clang", |
| 1355 | ), |
| 1356 | tool_path( |
| 1357 | name = "gcov", |
| 1358 | path = "C:/Program Files (x86)/LLVM/bin/gcov", |
| 1359 | ), |
| 1360 | tool_path( |
| 1361 | name = "ld", |
| 1362 | path = "C:/Program Files (x86)/LLVM/bin/ld", |
| 1363 | ), |
| 1364 | tool_path( |
| 1365 | name = "nm", |
| 1366 | path = "C:/Program Files (x86)/LLVM/bin/nm", |
| 1367 | ), |
| 1368 | tool_path( |
| 1369 | name = "objcopy", |
| 1370 | path = "C:/Program Files (x86)/LLVM/bin/objcopy", |
| 1371 | ), |
| 1372 | tool_path( |
| 1373 | name = "objdump", |
| 1374 | path = "C:/Program Files (x86)/LLVM/bin/objdump", |
| 1375 | ), |
| 1376 | tool_path( |
| 1377 | name = "strip", |
| 1378 | path = "C:/Program Files (x86)/LLVM/bin/strip", |
| 1379 | ), |
| 1380 | ] |
| 1381 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): |
| 1382 | tool_paths = [ |
| 1383 | tool_path(name = "ar", path = "C:/mingw/bin/ar"), |
| 1384 | tool_path(name = "compat-ld", path = "C:/mingw/bin/ld"), |
| 1385 | tool_path(name = "cpp", path = "C:/mingw/bin/cpp"), |
| 1386 | tool_path(name = "dwp", path = "C:/mingw/bin/dwp"), |
| 1387 | tool_path(name = "gcc", path = "C:/mingw/bin/gcc"), |
| 1388 | tool_path(name = "gcov", path = "C:/mingw/bin/gcov"), |
| 1389 | tool_path(name = "ld", path = "C:/mingw/bin/ld"), |
| 1390 | tool_path(name = "nm", path = "C:/mingw/bin/nm"), |
| 1391 | tool_path(name = "objcopy", path = "C:/mingw/bin/objcopy"), |
| 1392 | tool_path(name = "objdump", path = "C:/mingw/bin/objdump"), |
| 1393 | tool_path(name = "strip", path = "C:/mingw/bin/strip"), |
| 1394 | ] |
| 1395 | elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): |
| 1396 | tool_paths = [ |
| 1397 | tool_path(name = "ar", path = "C:/tools/msys64/usr/bin/ar"), |
| 1398 | tool_path( |
| 1399 | name = "compat-ld", |
| 1400 | path = "C:/tools/msys64/usr/bin/ld", |
| 1401 | ), |
| 1402 | tool_path( |
| 1403 | name = "cpp", |
| 1404 | path = "C:/tools/msys64/usr/bin/cpp", |
| 1405 | ), |
| 1406 | tool_path( |
| 1407 | name = "dwp", |
| 1408 | path = "C:/tools/msys64/usr/bin/dwp", |
| 1409 | ), |
| 1410 | tool_path( |
| 1411 | name = "gcc", |
| 1412 | path = "C:/tools/msys64/usr/bin/gcc", |
| 1413 | ), |
| 1414 | tool_path( |
| 1415 | name = "gcov", |
| 1416 | path = "C:/tools/msys64/usr/bin/gcov", |
| 1417 | ), |
| 1418 | tool_path(name = "ld", path = "C:/tools/msys64/usr/bin/ld"), |
| 1419 | tool_path(name = "nm", path = "C:/tools/msys64/usr/bin/nm"), |
| 1420 | tool_path( |
| 1421 | name = "objcopy", |
| 1422 | path = "C:/tools/msys64/usr/bin/objcopy", |
| 1423 | ), |
| 1424 | tool_path( |
| 1425 | name = "objdump", |
| 1426 | path = "C:/tools/msys64/usr/bin/objdump", |
| 1427 | ), |
| 1428 | tool_path( |
| 1429 | name = "strip", |
| 1430 | path = "C:/tools/msys64/usr/bin/strip", |
| 1431 | ), |
| 1432 | ] |
| 1433 | elif (ctx.attr.cpu == "x64_windows_msvc"): |
| 1434 | tool_paths = [ |
| 1435 | tool_path(name = "ar", path = "wrapper/bin/msvc_link.bat"), |
| 1436 | tool_path(name = "cpp", path = "wrapper/bin/msvc_cl.bat"), |
| 1437 | tool_path(name = "gcc", path = "wrapper/bin/msvc_cl.bat"), |
| 1438 | tool_path(name = "gcov", path = "wrapper/bin/msvc_nop.bat"), |
| 1439 | tool_path(name = "ld", path = "wrapper/bin/msvc_link.bat"), |
| 1440 | tool_path(name = "nm", path = "wrapper/bin/msvc_nop.bat"), |
| 1441 | tool_path( |
| 1442 | name = "objcopy", |
| 1443 | path = "wrapper/bin/msvc_nop.bat", |
| 1444 | ), |
| 1445 | tool_path( |
| 1446 | name = "objdump", |
| 1447 | path = "wrapper/bin/msvc_nop.bat", |
| 1448 | ), |
| 1449 | tool_path( |
| 1450 | name = "strip", |
| 1451 | path = "wrapper/bin/msvc_nop.bat", |
| 1452 | ), |
| 1453 | ] |
| 1454 | else: |
| 1455 | fail("Unreachable") |
| 1456 | |
| 1457 | out = ctx.actions.declare_file(ctx.label.name) |
| 1458 | ctx.actions.write(out, "Fake executable") |
| 1459 | return [ |
| 1460 | cc_common.create_cc_toolchain_config_info( |
| 1461 | ctx = ctx, |
| 1462 | features = features, |
| 1463 | action_configs = action_configs, |
| 1464 | artifact_name_patterns = artifact_name_patterns, |
| 1465 | cxx_builtin_include_directories = cxx_builtin_include_directories, |
| 1466 | toolchain_identifier = toolchain_identifier, |
| 1467 | host_system_name = host_system_name, |
| 1468 | target_system_name = target_system_name, |
| 1469 | target_cpu = target_cpu, |
| 1470 | target_libc = target_libc, |
| 1471 | compiler = compiler, |
| 1472 | abi_version = abi_version, |
| 1473 | abi_libc_version = abi_libc_version, |
| 1474 | tool_paths = tool_paths, |
| 1475 | make_variables = make_variables, |
| 1476 | builtin_sysroot = builtin_sysroot, |
| 1477 | cc_target_os = cc_target_os, |
| 1478 | ), |
| 1479 | DefaultInfo( |
| 1480 | executable = out, |
| 1481 | ), |
| 1482 | ] |
| 1483 | |
| 1484 | cc_toolchain_config = rule( |
| 1485 | implementation = _impl, |
| 1486 | attrs = { |
| 1487 | "cpu": attr.string(mandatory = True), |
| 1488 | "compiler": attr.string(), |
rosica | c5ebfcf | 2019-06-04 01:47:17 -0700 | [diff] [blame] | 1489 | "disable_static_cc_toolchains": attr.bool(), |
rosica | 71bc38f | 2019-02-04 02:39:30 -0800 | [diff] [blame] | 1490 | }, |
| 1491 | provides = [CcToolchainConfigInfo], |
| 1492 | executable = True, |
| 1493 | ) |