Skip to content

Commit c83d21e

Browse files
michaeleiselMichael Eiselkeith
authored
Allow generated headers with path separators (bazelbuild#439)
Co-authored-by: Michael Eisel <[email protected]> Co-authored-by: Keith Smiley <[email protected]>
1 parent 29dc8c3 commit c83d21e

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

swift/internal/compiling.bzl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,7 @@ def _declare_multiple_outputs_and_write_output_file_map(
15881588
def _declare_validated_generated_header(actions, generated_header_name):
15891589
"""Validates and declares the explicitly named generated header.
15901590
1591-
If the file does not have a `.h` extension or conatins path separators, the
1592-
build will fail.
1591+
If the file does not have a `.h` extension, the build will fail.
15931592
15941593
Args:
15951594
actions: The context's `actions` object.
@@ -1598,12 +1597,6 @@ def _declare_validated_generated_header(actions, generated_header_name):
15981597
Returns:
15991598
A `File` that should be used as the output for the generated header.
16001599
"""
1601-
if "/" in generated_header_name:
1602-
fail(
1603-
"The generated header for a Swift module may not contain " +
1604-
"directory components (got '{}').".format(generated_header_name),
1605-
)
1606-
16071600
extension = paths.split_extension(generated_header_name)[1]
16081601
if extension != ".h":
16091602
fail(

test/fixtures/generated_header/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ swift_library(
2828
)
2929

3030
swift_library(
31-
name = "invalid_path_separator",
31+
name = "valid_path_separator",
3232
srcs = ["Empty.swift"],
33-
generated_header_name = "Invalid/Separator.h",
33+
generated_header_name = "Valid/Separator.h",
3434
tags = FIXTURE_TAGS,
3535
)

test/generated_header_tests.bzl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,17 @@ def generated_header_test_suite(name = "generated_header"):
121121
target_under_test = "@build_bazel_rules_swift//test/fixtures/generated_header:invalid_extension",
122122
)
123123

124-
# Verify that the build fails to analyze if a path separator is used.
125-
generate_header_and_module_map_failure_test(
126-
name = "{}_invalid_path_separator".format(name),
127-
expected_message = "The generated header for a Swift module may not contain directory components",
124+
# Verify that the build analyzes if a path separator is used.
125+
generate_header_and_module_map_provider_test(
126+
name = "{}_valid_path_separator".format(name),
127+
expected_files = [
128+
"test/fixtures/generated_header/Valid/Separator.h",
129+
"*",
130+
],
131+
field = "files",
132+
provider = "DefaultInfo",
128133
tags = [name],
129-
target_under_test = "@build_bazel_rules_swift//test/fixtures/generated_header:invalid_path_separator",
134+
target_under_test = "@build_bazel_rules_swift//test/fixtures/generated_header:valid_path_separator",
130135
)
131136

132137
# Verify that the header is not generated if the feature

0 commit comments

Comments
 (0)