Skip to content

Commit

Permalink
Fix minor issues with module_map rule (#2350)
Browse files Browse the repository at this point in the history
Fixes some issues I noticed while I was copying `module_map` to our
internal project.

- Sort `load`
- `break` in loop after finding swift generated header
- Remove duplicate `umbrella_header` being added to output
- Use `:` prefix for umbrella header label
  • Loading branch information
luispadron authored Dec 31, 2023
1 parent 2bef6dd commit 82ade19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions apple/internal/experimental_mixed_language_library.bzl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""experimental_mixed_language_library macro implementation."""

load("@bazel_skylib//lib:paths.bzl", "paths")
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"SwiftInfo",
"swift_library",
)
load("@bazel_skylib//lib:paths.bzl", "paths")

_CPP_FILE_TYPES = [".cc", ".cpp", ".mm", ".cxx", ".C"]

Expand Down Expand Up @@ -109,12 +109,12 @@ def _module_map_impl(ctx):
if hdr.owner == dep.label:
swift_generated_header = hdr
outputs.append(swift_generated_header)
break

# Write the module map content
if swift_generated_header:
umbrella_header_path = ctx.attr.module_name + ".h"
umbrella_header = ctx.actions.declare_file(umbrella_header_path)
outputs.append(umbrella_header)
ctx.actions.write(
content = _umbrella_header_content(hdrs),
output = umbrella_header,
Expand Down Expand Up @@ -322,15 +322,15 @@ target only contains Objective-C files.""")
)

umbrella_module_map = name + ".internal.umbrella"
umbrella_module_map_label = ":" + umbrella_module_map
_module_map(
name = umbrella_module_map,
deps = [":" + swift_library_name],
hdrs = hdrs,
module_name = module_name,
testonly = testonly,
)
objc_deps.append(":" + umbrella_module_map)

objc_deps.append(umbrella_module_map_label)
native.objc_library(
name = name,
copts = objc_copts,
Expand All @@ -339,9 +339,9 @@ target only contains Objective-C files.""")
# These aren't headers but here is the only place to declare these
# files as the inputs because objc_library doesn't have an
# attribute to declare custom inputs.
":" + umbrella_module_map,
umbrella_module_map_label,
],
module_map = umbrella_module_map,
module_map = umbrella_module_map_label,
srcs = objc_srcs,
testonly = testonly,
**kwargs
Expand Down
4 changes: 2 additions & 2 deletions examples/multi_platform/MixedLib/BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("//apple:apple.bzl", "experimental_mixed_language_library")
load("//apple:ios.bzl", "ios_unit_test")
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)
load("//apple:apple.bzl", "experimental_mixed_language_library")
load("//apple:ios.bzl", "ios_unit_test")

experimental_mixed_language_library(
name = "MixedAnswer",
Expand Down

0 comments on commit 82ade19

Please sign in to comment.