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+ )
2529load ("//swift/internal:features.bzl" , "is_feature_enabled" )
2630load (
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