|
30 | 30 | artifact_category = "artifact_category_names", |
31 | 31 | ) |
32 | 32 | load("//cc/common:semantics.bzl", _starlark_cc_semantics = "semantics") |
33 | | -load("//cc/private:cc_info.bzl", "create_compilation_context_with_extra_header_tokens", "create_separate_module_map") |
| 33 | +load( |
| 34 | + "//cc/private:cc_info.bzl", |
| 35 | + "create_cc_compilation_context_with_cpp20_modules", |
| 36 | + "create_compilation_context_with_extra_header_tokens", |
| 37 | + "create_separate_module_map", |
| 38 | +) |
34 | 39 | load("//cc/private:cc_internal.bzl", _cc_internal = "cc_internal") |
35 | 40 | load("//cc/private/compile:cc_compilation_helper.bzl", "cc_compilation_helper", "dotd_files_enabled", "serialized_diagnostics_file_enabled") |
36 | 41 | load("//cc/private/compile:cc_compilation_outputs.bzl", "create_compilation_outputs_internal") |
|
43 | 48 | "setup_common_compile_build_variables", |
44 | 49 | ) |
45 | 50 | load("//cc/private/compile:lto_compilation_context.bzl", "create_lto_compilation_context") |
46 | | -load("//cc/private/rules_impl:native.bzl", _cc_common_internal = "native_cc_common") |
47 | 51 |
|
48 | 52 | _VALID_CPP_SOURCE_TYPES = set([CPP_SOURCE_TYPE_SOURCE, CPP_SOURCE_TYPE_HEADER, CPP_SOURCE_TYPE_CLIF_INPUT_PROTO]) |
49 | 53 |
|
@@ -390,7 +394,7 @@ def compile( |
390 | 394 | ) |
391 | 395 | compilation_outputs = create_compilation_outputs_internal(**compilation_outputs_dict) |
392 | 396 | if feature_configuration.is_enabled("cpp_modules"): |
393 | | - public_compilation_context = _cc_internal.create_cc_compilation_context_with_cpp20_modules( |
| 397 | + public_compilation_context = create_cc_compilation_context_with_cpp20_modules( |
394 | 398 | cc_compilation_context = public_compilation_context, |
395 | 399 | cpp_module_files = compilation_outputs.cpp_module_files, |
396 | 400 | pic_cpp_module_files = compilation_outputs.pic_cpp_module_files, |
@@ -520,15 +524,14 @@ def _create_scan_deps_action( |
520 | 524 | label, |
521 | 525 | common_toolchain_variables, |
522 | 526 | language, |
523 | | - native_cc_semantics, |
524 | 527 | source_artifact, |
525 | 528 | source_label, |
526 | 529 | use_pic, |
527 | 530 | ddi_file, |
528 | 531 | ddi_output_name): |
529 | 532 | dotd_file = None |
530 | 533 | if ( |
531 | | - dotd_files_enabled(native_cc_semantics, configuration, feature_configuration) and |
| 534 | + dotd_files_enabled(language, cpp_configuration, feature_configuration) and |
532 | 535 | _use_dotd_file(feature_configuration, source_artifact) |
533 | 536 | ): |
534 | 537 | dotd_file = _get_compile_output_file( |
@@ -563,20 +566,20 @@ def _create_scan_deps_action( |
563 | 566 | common_toolchain_variables, |
564 | 567 | specific_compile_build_variables, |
565 | 568 | ) |
566 | | - _cc_internal.create_cpp_compile_action( |
| 569 | + _cc_internal.create_cc_compile_action( |
567 | 570 | action_construction_context = action_construction_context, |
568 | 571 | cc_compilation_context = cc_compilation_context, |
569 | 572 | cc_toolchain = cc_toolchain, |
570 | 573 | configuration = configuration, |
571 | 574 | copts_filter = copts_filter, |
572 | 575 | feature_configuration = feature_configuration, |
573 | | - cpp_semantics = native_cc_semantics, |
574 | | - source_artifact = source_artifact, |
| 576 | + source = source_artifact, |
575 | 577 | additional_compilation_inputs = additional_compilation_inputs, |
576 | 578 | output_file = ddi_file, |
577 | 579 | dotd_file = dotd_file, |
578 | 580 | compile_build_variables = compile_variables, |
579 | 581 | action_name = ACTION_NAMES.cpp_module_deps_scanning, |
| 582 | + toolchain_type = _starlark_cc_semantics.toolchain, |
580 | 583 | ) |
581 | 584 |
|
582 | 585 | def _create_aggregate_ddi_action( |
@@ -683,7 +686,6 @@ def _create_cc_compile_actions_with_cpp20_module_helper( |
683 | 686 | else: |
684 | 687 | outputs["cpp_modules_info_file"] = modules_info_file |
685 | 688 |
|
686 | | - native_cc_semantics = _cc_common_internal.get_cpp_semantics(language = language) |
687 | 689 | for cpp_source in module_interfaces_sources.values(): |
688 | 690 | source_artifact = cpp_source.file |
689 | 691 | output_name = output_name_map[source_artifact] |
@@ -741,7 +743,6 @@ def _create_cc_compile_actions_with_cpp20_module_helper( |
741 | 743 | label = label, |
742 | 744 | common_toolchain_variables = common_compile_build_variables, |
743 | 745 | language = language, |
744 | | - native_cc_semantics = native_cc_semantics, |
745 | 746 | source_artifact = source_artifact, |
746 | 747 | source_label = source_label, |
747 | 748 | use_pic = use_pic, |
@@ -825,7 +826,6 @@ def _create_cc_compile_actions_with_cpp20_module_helper( |
825 | 826 | feature_configuration = feature_configuration, |
826 | 827 | configuration = configuration, |
827 | 828 | cpp_configuration = cpp_configuration, |
828 | | - cpp_semantics = native_cc_semantics, |
829 | 829 | language = language, |
830 | 830 | conlyopts = conlyopts, |
831 | 831 | copts = copts, |
@@ -925,7 +925,6 @@ def _create_cc_compile_actions_with_cpp20_module_helper( |
925 | 925 | label = label, |
926 | 926 | common_toolchain_variables = common_compile_build_variables, |
927 | 927 | language = language, |
928 | | - native_cc_semantics = native_cc_semantics, |
929 | 928 | source_artifact = source_artifact, |
930 | 929 | source_label = source_label, |
931 | 930 | use_pic = use_pic, |
@@ -974,7 +973,6 @@ def _create_cc_compile_actions_with_cpp20_module_helper( |
974 | 973 | feature_configuration = feature_configuration, |
975 | 974 | configuration = configuration, |
976 | 975 | cpp_configuration = cpp_configuration, |
977 | | - cpp_semantics = native_cc_semantics, |
978 | 976 | language = language, |
979 | 977 | conlyopts = conlyopts, |
980 | 978 | copts = copts, |
@@ -1541,25 +1539,8 @@ def _create_compile_source_action( |
1541 | 1539 | category = artifact_category.PIC_FILE, |
1542 | 1540 | output_name = output_name, |
1543 | 1541 | ) |
1544 | | - cpp20_module_compile_enabled = False |
1545 | | - if not action_name: |
1546 | | - if output_category == artifact_category.CPP_MODULE: |
1547 | | - action_name = "c++-module-compile" |
1548 | | - cpp20_module_compile_enabled = True |
1549 | | - else: |
1550 | | - ext = "." + source_artifact.extension |
1551 | | - if ext in extensions.C_SOURCE: |
1552 | | - action_name = "c-compile" |
1553 | | - elif ext in extensions.OBJC_SOURCE: |
1554 | | - action_name = "objc-compile" |
1555 | | - elif ext in extensions.OBJCPP_SOURCE: |
1556 | | - action_name = "objc++-compile" |
1557 | | - elif ext in extensions.ASSESMBLER_WITH_C_PREPROCESSOR: |
1558 | | - action_name = "preprocess-assemble" |
1559 | | - elif ext in extensions.ASSEMBLER: |
1560 | | - action_name = "assemble" |
1561 | | - else: |
1562 | | - action_name = "c++-compile" |
| 1542 | + if not action_name and output_category == artifact_category.CPP_MODULE: |
| 1543 | + action_name = "c++-module-compile" |
1563 | 1544 |
|
1564 | 1545 | object_file = _get_compile_output_file( |
1565 | 1546 | ctx = action_construction_context, |
@@ -1685,8 +1666,8 @@ def _create_compile_source_action( |
1685 | 1666 | if add_object and fdo_context_has_artifacts: |
1686 | 1667 | additional_inputs = additional_compilation_inputs + auxiliary_fdo_inputs.to_list() |
1687 | 1668 |
|
1688 | | - # Until a new enough Bazel supports C++20 Modules, these argument names are invalid. |
1689 | | - if cpp20_module_compile_enabled: |
| 1669 | + # Provide these args conditionally as they require a recent version of Bazel. |
| 1670 | + if modmap_file: |
1690 | 1671 | module_args = { |
1691 | 1672 | "additional_outputs": additional_outputs, |
1692 | 1673 | "module_files": module_files, |
|
0 commit comments