Skip to content

Commit

Permalink
TMP: Debug diff
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Dec 30, 2024
1 parent ac4921b commit 5c8c4a5
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -501,21 +501,26 @@ def go_context(
stdlib = go_context_data[GoStdLib]
go_context_info = go_context_data[GoContextInfo]

if goos == "auto" and goarch == "auto" and cgo_context_info:
# Fast-path to reuse the GoConfigInfo as-is
mode = go_config_info
else:
if go_config_info == None:
go_config_info = default_go_config_info
mode_kwargs = structs.to_dict(go_config_info)
mode_kwargs["goos"] = toolchain.default_goos if goos == "auto" else goos
mode_kwargs["goarch"] = toolchain.default_goarch if goarch == "auto" else goarch
if not cgo_context_info:
if getattr(ctx.attr, "pure", None) == "off":
fail("{} has pure explicitly set to off, but no C++ toolchain could be found for its platform".format(ctx.label))
mode_kwargs["pure"] = True
mode = GoConfigInfo(**mode_kwargs)
validate_mode(mode)
# Fast-path to reuse the GoConfigInfo as-is
first_mode = go_config_info

# else:
if go_config_info == None:
go_config_info = default_go_config_info
mode_kwargs = structs.to_dict(go_config_info)
mode_kwargs["goos"] = toolchain.default_goos if goos == "auto" else goos
mode_kwargs["goarch"] = toolchain.default_goarch if goarch == "auto" else goarch
if not cgo_context_info:
if getattr(ctx.attr, "pure", None) == "off":
fail("{} has pure explicitly set to off, but no C++ toolchain could be found for its platform".format(ctx.label))
mode_kwargs["pure"] = True
second_mode = GoConfigInfo(**mode_kwargs)
validate_mode(second_mode)

if goos == "auto" and goarch == "auto" and cgo_context_info and go_config_info:
if first_mode != second_mode:
fail("Inconsistent GoConfigInfo: {} != {}".format(first_mode, second_mode))
mode = second_mode

if stdlib:
goroot = stdlib.root_file.dirname
Expand Down

0 comments on commit 5c8c4a5

Please sign in to comment.