Skip to content

Commit

Permalink
Correctly add .swiftmodule directories to the search path.
Browse files Browse the repository at this point in the history
If a propagated `.swiftmodule` is ever in a directory-based layout (`Name.swiftmodule/$TARGET.swiftmodule`), then we need to add the path to the directory containing the top-level module directory, not the path to the `.swiftmodule` directory itself.

PiperOrigin-RevId: 456263364
(cherry picked from commit 21580ea)
  • Loading branch information
allevato authored and brentleyjones committed Jun 21, 2024
1 parent ca9bfae commit 31ca061
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion swift/toolchains/config/compile_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,14 @@ def _swift_module_search_path_map_fn(module):
The dirname of the module's `.swiftmodule` file.
"""
if module.swift:
return module.swift.swiftmodule.dirname
search_path = module.swift.swiftmodule.dirname

# If the dirname also ends in .swiftmodule, remove it as well so that
# the compiler finds the module *directory*.
if search_path.endswith(".swiftmodule"):
search_path = paths.dirname(search_path)

return search_path
else:
return None

Expand Down

0 comments on commit 31ca061

Please sign in to comment.