@@ -37,43 +37,23 @@ load(
3737 "platform_from_crosstool" ,
3838)
3939
40- def filter_transition_label (label ):
41- """Transforms transition labels for the current workspace.
42-
43- This works around bazelbuild/bazel#10499 by automatically using the correct
44- way to refer to this repository (@io_bazel_rules_go from another workspace,
45- but only repo-relative labels if this repository is the main workspace).
46- """
47- if label .startswith ("//command_line_option:" ):
48- # This is a special prefix that allows transitions to access the values
49- # of native command-line flags. It is not a valid package, but just a
50- # syntactic prefix that is consumed by the transition logic, and thus
51- # must not be passed through the Label constructor.
52- # https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/analysis/config/StarlarkDefinedConfigTransition.java;l=62;drc=463e8c80cd11d36777ddf80543aea7c53293f298
53- return label
54- else :
55- return str (Label (label ))
56-
5740# A list of rules_go settings that are possibly set by go_transition.
5841# Keep their package name in sync with the implementation of
5942# _original_setting_key.
6043TRANSITIONED_GO_SETTING_KEYS = [
61- filter_transition_label (key )
62- for key in [
63- "//go/config:static" ,
64- "//go/config:msan" ,
65- "//go/config:race" ,
66- "//go/config:pure" ,
67- "//go/config:linkmode" ,
68- "//go/config:tags" ,
69- ]
44+ "//go/config:static" ,
45+ "//go/config:msan" ,
46+ "//go/config:race" ,
47+ "//go/config:pure" ,
48+ "//go/config:linkmode" ,
49+ "//go/config:tags" ,
7050]
7151
7252def _original_setting_key (key ):
7353 if not "//go/config:" in key :
7454 fail ("_original_setting_key currently assumes that all Go settings live under //go/config, got: " + key )
7555 name = key .split (":" )[1 ]
76- return filter_transition_label ( "//go/private/rules:original_" + name )
56+ return "//go/private/rules:original_" + name
7757
7858_SETTING_KEY_TO_ORIGINAL_SETTING_KEY = {
7959 setting : _original_setting_key (setting )
@@ -100,17 +80,17 @@ def _go_transition_impl(settings, attr):
10080 if pure == "on" :
10181 fail ('race = "on" cannot be set when pure = "on" is set. race requires cgo.' )
10282 pure = "off"
103- settings [filter_transition_label ( "@io_bazel_rules_go //go/config:pure") ] = False
83+ settings [" //go/config:pure" ] = False
10484 if msan == "on" :
10585 if pure == "on" :
10686 fail ('msan = "on" cannot be set when msan = "on" is set. msan requires cgo.' )
10787 pure = "off"
108- settings [filter_transition_label ( "@io_bazel_rules_go //go/config:pure") ] = False
88+ settings [" //go/config:pure" ] = False
10989 if pure == "on" :
11090 race = "off"
111- settings [filter_transition_label ( "@io_bazel_rules_go //go/config:race") ] = False
91+ settings [" //go/config:race" ] = False
11292 msan = "off"
113- settings [filter_transition_label ( "@io_bazel_rules_go //go/config:msan") ] = False
93+ settings [" //go/config:msan" ] = False
11494 cgo = pure == "off"
11595
11696 goos = getattr (attr , "goos" , "auto" )
@@ -137,14 +117,14 @@ def _go_transition_impl(settings, attr):
137117
138118 tags = getattr (attr , "gotags" , [])
139119 if tags :
140- tags_label = filter_transition_label ( "@io_bazel_rules_go //go/config:tags")
120+ tags_label = " //go/config:tags"
141121 settings [tags_label ] = tags
142122
143123 linkmode = getattr (attr , "linkmode" , "auto" )
144124 if linkmode != "auto" :
145125 if linkmode not in LINKMODES :
146126 fail ("linkmode: invalid mode {}; want one of {}" .format (linkmode , ", " .join (LINKMODES )))
147- linkmode_label = filter_transition_label ( "@io_bazel_rules_go //go/config:linkmode")
127+ linkmode_label = " //go/config:linkmode"
148128 settings [linkmode_label ] = linkmode
149129
150130 for key , original_key in _SETTING_KEY_TO_ORIGINAL_SETTING_KEY .items ():
@@ -179,52 +159,50 @@ def _request_nogo_transition(settings, _attr):
179159 request_nogo to be true to provide the project configured nogo.
180160 """
181161 settings = dict (settings )
182- settings [filter_transition_label ( "@io_bazel_rules_go //go/private:request_nogo") ] = True
162+ settings [" //go/private:request_nogo" ] = True
183163 return settings
184164
185165request_nogo_transition = transition (
186166 implementation = _request_nogo_transition ,
187167 inputs = [],
188- outputs = [filter_transition_label (label ) for label in [
189- "@io_bazel_rules_go//go/private:request_nogo" ,
190- ]],
168+ outputs = ["//go/private:request_nogo" ],
191169)
192170
193171go_transition = transition (
194172 implementation = _go_transition_impl ,
195- inputs = [filter_transition_label ( label ) for label in [
173+ inputs = [
196174 "//command_line_option:cpu" ,
197175 "//command_line_option:crosstool_top" ,
198176 "//command_line_option:platforms" ,
199- ] + TRANSITIONED_GO_SETTING_KEYS ] ,
200- outputs = [filter_transition_label ( label ) for label in [
177+ ] + TRANSITIONED_GO_SETTING_KEYS ,
178+ outputs = [
201179 "//command_line_option:platforms" ,
202- ] + TRANSITIONED_GO_SETTING_KEYS + _SETTING_KEY_TO_ORIGINAL_SETTING_KEY .values ()] ,
180+ ] + TRANSITIONED_GO_SETTING_KEYS + _SETTING_KEY_TO_ORIGINAL_SETTING_KEY .values (),
203181)
204182
205183_common_reset_transition_dict = dict ({
206- "@io_bazel_rules_go //go/private:request_nogo" : False ,
207- "@io_bazel_rules_go //go/config:static" : False ,
208- "@io_bazel_rules_go //go/config:msan" : False ,
209- "@io_bazel_rules_go //go/config:race" : False ,
210- "@io_bazel_rules_go //go/config:pure" : False ,
211- "@io_bazel_rules_go //go/config:strip" : False ,
212- "@io_bazel_rules_go //go/config:debug" : False ,
213- "@io_bazel_rules_go //go/config:linkmode" : LINKMODE_NORMAL ,
214- "@io_bazel_rules_go //go/config:tags" : [],
184+ "//go/private:request_nogo" : False ,
185+ "//go/config:static" : False ,
186+ "//go/config:msan" : False ,
187+ "//go/config:race" : False ,
188+ "//go/config:pure" : False ,
189+ "//go/config:strip" : False ,
190+ "//go/config:debug" : False ,
191+ "//go/config:linkmode" : LINKMODE_NORMAL ,
192+ "//go/config:tags" : [],
215193}, ** {setting : "" for setting in _SETTING_KEY_TO_ORIGINAL_SETTING_KEY .values ()})
216194
217195_reset_transition_dict = dict (_common_reset_transition_dict , ** {
218- "@io_bazel_rules_go //go/private:bootstrap_nogo" : True ,
196+ "//go/private:bootstrap_nogo" : True ,
219197})
220198
221- _reset_transition_keys = sorted ([ filter_transition_label ( label ) for label in _reset_transition_dict .keys ()] )
199+ _reset_transition_keys = sorted (_reset_transition_dict .keys ())
222200
223201_stdlib_keep_keys = sorted ([
224- "@io_bazel_rules_go //go/config:msan" ,
225- "@io_bazel_rules_go //go/config:race" ,
226- "@io_bazel_rules_go //go/config:pure" ,
227- "@io_bazel_rules_go //go/config:linkmode" ,
202+ "//go/config:msan" ,
203+ "//go/config:race" ,
204+ "//go/config:pure" ,
205+ "//go/config:linkmode" ,
228206])
229207
230208def _go_tool_transition_impl (settings , _attr ):
@@ -239,10 +217,7 @@ def _go_tool_transition_impl(settings, _attr):
239217 have `cfg = "exec"` so tool binaries should be built for the execution
240218 platform.
241219 """
242- settings = dict (settings )
243- for label , value in _reset_transition_dict .items ():
244- settings [filter_transition_label (label )] = value
245- return settings
220+ return dict (settings , ** _reset_transition_dict )
246221
247222go_tool_transition = transition (
248223 implementation = _go_tool_transition_impl ,
@@ -262,10 +237,8 @@ def _non_go_tool_transition_impl(settings, _attr):
262237 Examples: This transition is applied to attributes referencing proto_library
263238 targets or protoc directly.
264239 """
265- settings = dict (settings )
266- for label , value in _reset_transition_dict .items ():
267- settings [filter_transition_label (label )] = value
268- settings [filter_transition_label ("@io_bazel_rules_go//go/private:bootstrap_nogo" )] = False
240+ settings = dict (settings , ** _reset_transition_dict )
241+ settings ["//go/private:bootstrap_nogo" ] = False
269242 return settings
270243
271244non_go_tool_transition = transition (
@@ -285,8 +258,8 @@ def _go_stdlib_transition_impl(settings, _attr):
285258 settings = dict (settings )
286259 for label , value in _reset_transition_dict .items ():
287260 if label not in _stdlib_keep_keys :
288- settings [filter_transition_label ( label ) ] = value
289- settings [filter_transition_label ( "@io_bazel_rules_go //go/private:bootstrap_nogo") ] = False
261+ settings [label ] = value
262+ settings [" //go/private:bootstrap_nogo" ] = False
290263 return settings
291264
292265go_stdlib_transition = transition (
@@ -426,11 +399,11 @@ def _set_ternary(settings, attr, name):
426399 value = getattr (attr , name , "auto" )
427400 _check_ternary (name , value )
428401 if value != "auto" :
429- label = filter_transition_label ( "@io_bazel_rules_go //go/config:{}" .format (name ) )
402+ label = " //go/config:{}" .format (name )
430403 settings [label ] = value == "on"
431404 return value
432405
433- _SDK_VERSION_BUILD_SETTING = filter_transition_label ( "@io_bazel_rules_go //go/toolchain:sdk_version")
406+ _SDK_VERSION_BUILD_SETTING = " //go/toolchain:sdk_version"
434407TRANSITIONED_GO_CROSS_SETTING_KEYS = [
435408 _SDK_VERSION_BUILD_SETTING ,
436409 "//command_line_option:platforms" ,
0 commit comments