Skip to content

Commit

Permalink
Simplify how we emit GoStdLib
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbarsky authored and fmeum committed Aug 10, 2024
1 parent 8c707c8 commit 061ac0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
14 changes: 4 additions & 10 deletions go/private/actions/stdlib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,12 @@ def emit_stdlib(go):
Otherwise, the standard library will be compiled for the target.
Returns:
A list of providers containing GoLibrary and GoSource. GoSource.stdlib
will point to a new GoStdLib.
A list of providers containing GoLibrary, GoSource and GoStdLib.
"""
library = go.new_library(go, resolver = _stdlib_library_to_source)
library = go.new_library(go)
source = go.library_to_source(go, {}, library, False)
return [source, library]

def _stdlib_library_to_source(go, _attr, source, _merge):
if _should_use_sdk_stdlib(go):
source["stdlib"] = _sdk_stdlib(go)
else:
source["stdlib"] = _build_stdlib(go)
stdlib = _sdk_stdlib(go) if _should_use_sdk_stdlib(go) else _build_stdlib(go)
return [source, library, stdlib]

def _should_use_sdk_stdlib(go):
version = parse_version(go.sdk.version)
Expand Down
3 changes: 1 addition & 2 deletions go/private/rules/stdlib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ load(

def _stdlib_impl(ctx):
go = go_context(ctx)
source, library = go.toolchain.actions.stdlib(go)
return [source, library, source.stdlib]
return go.toolchain.actions.stdlib(go)

stdlib = rule(
implementation = _stdlib_impl,
Expand Down

0 comments on commit 061ac0c

Please sign in to comment.