Skip to content

Commit 82ade19

Browse files
authored
Fix minor issues with module_map rule (#2350)
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
1 parent 2bef6dd commit 82ade19

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

apple/internal/experimental_mixed_language_library.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""experimental_mixed_language_library macro implementation."""
22

3+
load("@bazel_skylib//lib:paths.bzl", "paths")
34
load(
45
"@build_bazel_rules_swift//swift:swift.bzl",
56
"SwiftInfo",
67
"swift_library",
78
)
8-
load("@bazel_skylib//lib:paths.bzl", "paths")
99

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

@@ -109,12 +109,12 @@ def _module_map_impl(ctx):
109109
if hdr.owner == dep.label:
110110
swift_generated_header = hdr
111111
outputs.append(swift_generated_header)
112+
break
112113

113114
# Write the module map content
114115
if swift_generated_header:
115116
umbrella_header_path = ctx.attr.module_name + ".h"
116117
umbrella_header = ctx.actions.declare_file(umbrella_header_path)
117-
outputs.append(umbrella_header)
118118
ctx.actions.write(
119119
content = _umbrella_header_content(hdrs),
120120
output = umbrella_header,
@@ -322,15 +322,15 @@ target only contains Objective-C files.""")
322322
)
323323

324324
umbrella_module_map = name + ".internal.umbrella"
325+
umbrella_module_map_label = ":" + umbrella_module_map
325326
_module_map(
326327
name = umbrella_module_map,
327328
deps = [":" + swift_library_name],
328329
hdrs = hdrs,
329330
module_name = module_name,
330331
testonly = testonly,
331332
)
332-
objc_deps.append(":" + umbrella_module_map)
333-
333+
objc_deps.append(umbrella_module_map_label)
334334
native.objc_library(
335335
name = name,
336336
copts = objc_copts,
@@ -339,9 +339,9 @@ target only contains Objective-C files.""")
339339
# These aren't headers but here is the only place to declare these
340340
# files as the inputs because objc_library doesn't have an
341341
# attribute to declare custom inputs.
342-
":" + umbrella_module_map,
342+
umbrella_module_map_label,
343343
],
344-
module_map = umbrella_module_map,
344+
module_map = umbrella_module_map_label,
345345
srcs = objc_srcs,
346346
testonly = testonly,
347347
**kwargs

examples/multi_platform/MixedLib/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
load("//apple:apple.bzl", "experimental_mixed_language_library")
2-
load("//apple:ios.bzl", "ios_unit_test")
31
load(
42
"@build_bazel_rules_swift//swift:swift.bzl",
53
"swift_library",
64
)
5+
load("//apple:apple.bzl", "experimental_mixed_language_library")
6+
load("//apple:ios.bzl", "ios_unit_test")
77

88
experimental_mixed_language_library(
99
name = "MixedAnswer",

0 commit comments

Comments
 (0)