Skip to content

Commit

Permalink
Address further comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed May 9, 2022
1 parent 3859f9d commit 3ae87c1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions go/private/rules/transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,21 @@ def _non_go_transition_impl(settings, attr):
for key, original_key in _SETTING_KEY_TO_ORIGINAL_SETTING_KEY.items():
original_value = settings[original_key]
if original_value:
# Reset to the original value and clear it.
# Reset to the original value of the setting before go_transition.
new_settings[key] = json.decode(original_value)
new_settings[original_key] = ""
else:
new_settings[key] = settings[key]
new_settings[original_key] = settings[original_key]
# Reset the value of the helper setting to its default for two reasons:
# 1. Performance: This ensures that the Go settings of non-Go
# dependencies have the same values as before the go_transition,
# which can prevent unnecessary rebuilds caused by configuration
# changes.
# 2. Correctness in edge cases: If there is a path in the build graph
# from a go_binary's non-Go dependency to a go_library that does not
# pass through another go_binary (e.g., through a custom rule
# replacement for go_binary), this transition could be applied again
# and cause incorrect Go setting values.
new_settings[original_key] = ""

return new_settings

Expand Down

0 comments on commit 3ae87c1

Please sign in to comment.