Skip to content

Commit

Permalink
Add swift.experimental_rules_swift_package_manager flag
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Schear <jonathanschear@gmail.com>
  • Loading branch information
2 people authored and gyfelton committed Sep 18, 2024
1 parent e74047f commit d704f72
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rules/features.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ feature_names = struct(

# When set disable passing the `-import-underlying-module` copt to `swift_library` targets
swift_disable_import_underlying_module = "swift.swift_disable_import_underlying_module",

# Allows consumers to depend on targets from https://github.com/cgrindel/rules_swift_package_manager.
#
# Note: This is a work in progress, and the flag will remain experimental until full support is ready.
experimental_rules_swift_package_manager = "swift.experimental_rules_swift_package_manager",
)
20 changes: 20 additions & 0 deletions rules/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,27 @@ def _get_virtual_framework_info(ctx, framework_files, compilation_context_fields

# We need to map all the deps here - for both swift headers and others
fw_dep_vfsoverlays = []

# Whether or not to collect SwiftInfo providers from rules_swift_package_manager targets
enable_rules_swift_package_manager = feature_names.experimental_rules_swift_package_manager in ctx.features

for dep in transitive_deps + deps:
if enable_rules_swift_package_manager and SwiftInfo in dep:
if dep.label.workspace_name.startswith("swiftpkg"):
for spm_dep in dep[SwiftInfo].transitive_modules.to_list():
if spm_dep.swift:
spm_dep_vfs = make_vfsoverlay(
ctx,
hdrs = [],
module_map = [],
swiftmodules = [spm_dep.swift.swiftmodule, spm_dep.swift.swiftdoc],
private_hdrs = [],
has_swift = True,
merge_vfsoverlays = [],
framework_name = spm_dep.name,
)
fw_dep_vfsoverlays.append(spm_dep_vfs.vfs_info)

# Collect transitive headers. For now, this needs to include all of the
# transitive headers
if CcInfo in dep:
Expand Down

0 comments on commit d704f72

Please sign in to comment.