Skip to content

Commit 66e5842

Browse files
Adding target name to output path for plugin executable (#1294)
1 parent c253a4f commit 66e5842

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

swift/swift_compiler_plugin.bzl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ load(
2121
"@build_bazel_apple_support//lib:transitions.bzl",
2222
"macos_universal_transition",
2323
)
24-
load("//swift/internal:feature_names.bzl", "SWIFT_FEATURE__SUPPORTS_MACROS")
24+
load(
25+
"@build_bazel_rules_swift//swift/internal:feature_names.bzl",
26+
"SWIFT_FEATURE_ADD_TARGET_NAME_TO_OUTPUT",
27+
"SWIFT_FEATURE__SUPPORTS_MACROS",
28+
)
2529
load("//swift/internal:features.bzl", "is_feature_enabled")
2630
load(
2731
"//swift/internal:linking.bzl",
@@ -111,6 +115,15 @@ def _swift_compiler_plugin_impl(ctx):
111115
compilation_outputs = compile_result.compilation_outputs
112116
supplemental_outputs = compile_result.supplemental_outputs
113117

118+
if is_feature_enabled(
119+
feature_configuration = feature_configuration,
120+
feature_name = SWIFT_FEATURE_ADD_TARGET_NAME_TO_OUTPUT,
121+
):
122+
# Making executable in a folder to avoid naming collisions
123+
name = "{}/{}".format(ctx.label.name, ctx.label.name)
124+
else:
125+
name = ctx.label.name
126+
114127
binary_linking_outputs = register_link_binary_action(
115128
actions = ctx.actions,
116129
additional_inputs = ctx.files.swiftc_inputs,
@@ -119,7 +132,7 @@ def _swift_compiler_plugin_impl(ctx):
119132
deps = deps,
120133
feature_configuration = feature_configuration,
121134
module_contexts = module_contexts,
122-
name = ctx.label.name,
135+
name = name,
123136
output_type = "executable",
124137
owner = ctx.label,
125138
stamp = ctx.attr.stamp,

0 commit comments

Comments
 (0)