|
24 | 24 | "run_toolchain_action",
|
25 | 25 | "swift_action_names",
|
26 | 26 | )
|
| 27 | +load(":explicit_module_map_file.bzl", "write_explicit_swift_module_map_file") |
27 | 28 | load(":derived_files.bzl", "derived_files")
|
28 | 29 | load(
|
29 | 30 | ":feature_names.bzl",
|
|
62 | 63 | "SWIFT_FEATURE_SUPPORTS_SYSTEM_MODULE_FLAG",
|
63 | 64 | "SWIFT_FEATURE_SYSTEM_MODULE",
|
64 | 65 | "SWIFT_FEATURE_USE_C_MODULES",
|
| 66 | + "SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP", |
65 | 67 | "SWIFT_FEATURE_USE_GLOBAL_INDEX_STORE",
|
66 | 68 | "SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE",
|
67 | 69 | "SWIFT_FEATURE_USE_OLD_DRIVER",
|
@@ -890,6 +892,29 @@ def compile_action_configs(
|
890 | 892 | ),
|
891 | 893 | ])
|
892 | 894 |
|
| 895 | + action_configs.extend([ |
| 896 | + swift_toolchain_config.action_config( |
| 897 | + actions = [ |
| 898 | + swift_action_names.COMPILE, |
| 899 | + swift_action_names.DERIVE_FILES, |
| 900 | + swift_action_names.DUMP_AST, |
| 901 | + ], |
| 902 | + configurators = [_dependencies_swiftmodules_configurator], |
| 903 | + not_features = [SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP], |
| 904 | + ), |
| 905 | + swift_toolchain_config.action_config( |
| 906 | + actions = [ |
| 907 | + swift_action_names.COMPILE, |
| 908 | + swift_action_names.DERIVE_FILES, |
| 909 | + swift_action_names.DUMP_AST, |
| 910 | + ], |
| 911 | + configurators = [ |
| 912 | + _explicit_swift_module_map_configurator, |
| 913 | + ], |
| 914 | + features = [SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP], |
| 915 | + ), |
| 916 | + ]) |
| 917 | + |
893 | 918 | #### Search paths for framework dependencies
|
894 | 919 | action_configs.extend([
|
895 | 920 | swift_toolchain_config.action_config(
|
@@ -1620,6 +1645,21 @@ def _dependencies_swiftmodules_vfsoverlay_configurator(prerequisites, args):
|
1620 | 1645 | inputs = swiftmodules + [prerequisites.vfsoverlay_file],
|
1621 | 1646 | )
|
1622 | 1647 |
|
| 1648 | +def _explicit_swift_module_map_configurator(prerequisites, args): |
| 1649 | + """Adds the explicit Swift module map file to the command line.""" |
| 1650 | + args.add_all( |
| 1651 | + [ |
| 1652 | + "-explicit-swift-module-map-file", |
| 1653 | + prerequisites.explicit_swift_module_map_file, |
| 1654 | + ], |
| 1655 | + before_each = "-Xfrontend", |
| 1656 | + ) |
| 1657 | + return swift_toolchain_config.config_result( |
| 1658 | + inputs = prerequisites.transitive_swiftmodules + [ |
| 1659 | + prerequisites.explicit_swift_module_map_file, |
| 1660 | + ], |
| 1661 | + ) |
| 1662 | + |
1623 | 1663 | def _module_name_configurator(prerequisites, args):
|
1624 | 1664 | """Adds the module name flag to the command line."""
|
1625 | 1665 | args.add("-module-name", prerequisites.module_name)
|
@@ -2081,11 +2121,32 @@ def compile(
|
2081 | 2121 | else:
|
2082 | 2122 | vfsoverlay_file = None
|
2083 | 2123 |
|
| 2124 | + if is_feature_enabled( |
| 2125 | + feature_configuration = feature_configuration, |
| 2126 | + feature_name = SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP, |
| 2127 | + ): |
| 2128 | + if vfsoverlay_file: |
| 2129 | + fail("Cannot use both `swift.vfsoverlay` and `swift.use_explicit_swift_module_map` features at the same time.") |
| 2130 | + |
| 2131 | + # Generate the JSON file that contains the manifest of Swift |
| 2132 | + # dependencies. |
| 2133 | + explicit_swift_module_map_file = actions.declare_file( |
| 2134 | + "{}.swift-explicit-module-map.json".format(target_name), |
| 2135 | + ) |
| 2136 | + write_explicit_swift_module_map_file( |
| 2137 | + actions = actions, |
| 2138 | + explicit_swift_module_map_file = explicit_swift_module_map_file, |
| 2139 | + module_contexts = transitive_modules, |
| 2140 | + ) |
| 2141 | + else: |
| 2142 | + explicit_swift_module_map_file = None |
| 2143 | + |
2084 | 2144 | prerequisites = struct(
|
2085 | 2145 | additional_inputs = additional_inputs,
|
2086 | 2146 | bin_dir = feature_configuration._bin_dir,
|
2087 | 2147 | cc_compilation_context = merged_providers.cc_info.compilation_context,
|
2088 | 2148 | defines = sets.to_list(defines_set),
|
| 2149 | + explicit_swift_module_map_file = explicit_swift_module_map_file, |
2089 | 2150 | developer_dirs = swift_toolchain.developer_dirs,
|
2090 | 2151 | genfiles_dir = feature_configuration._genfiles_dir,
|
2091 | 2152 | is_swift = True,
|
|
0 commit comments