Skip to content

Commit 0f88f8c

Browse files
authored
Remove get_nogo from context (#4029)
**What type of PR is this?** Cleanup **What does this PR do? Why is it needed?** It seems odd to hang helpers off the `go` context because they still need to take `go` as a param. It's clearer to just import them. **Which issues(s) does this PR fix?** Fixes # **Other notes for review**
1 parent 3b9a4bc commit 0f88f8c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

go/private/actions/archive.bzl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ load(
1616
"//go/private:common.bzl",
1717
"as_tuple",
1818
)
19+
load(
20+
"//go/private:context.bzl",
21+
"get_nogo",
22+
)
1923
load(
2024
"//go/private:mode.bzl",
2125
"LINKMODE_C_ARCHIVE",
@@ -59,14 +63,16 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
5963
# store export information for compiling dependent packages separately
6064
out_export = go.declare_file(go, name = source.library.name, ext = pre_ext + ".x")
6165
out_cgo_export_h = None # set if cgo used in c-shared or c-archive mode
62-
out_facts = None
63-
out_nogo_log = None
64-
out_nogo_validation = None
65-
nogo = go.get_nogo(go)
66+
67+
nogo = get_nogo(go)
6668
if nogo:
6769
out_facts = go.declare_file(go, name = source.library.name, ext = pre_ext + ".facts")
6870
out_nogo_log = go.declare_file(go, name = source.library.name, ext = pre_ext + ".nogo.log")
6971
out_nogo_validation = go.declare_file(go, name = source.library.name, ext = pre_ext + ".nogo")
72+
else:
73+
out_facts = None
74+
out_nogo_log = None
75+
out_nogo_validation = None
7076

7177
direct = [get_archive(dep) for dep in source.deps]
7278

go/private/context.bzl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ def _matches_scopes(label, scopes):
433433
return True
434434
return False
435435

436-
def _get_nogo(go):
436+
def get_nogo(go):
437437
"""Returns the nogo file for this target, if enabled and in scope."""
438-
label = go._ctx.label
438+
label = go.label
439439
if _matches_scopes(label, NOGO_INCLUDES) and not _matches_scopes(label, NOGO_EXCLUDES):
440440
return go.nogo
441441
else:
@@ -604,7 +604,6 @@ def go_context(ctx, attr = None):
604604
library_to_source = _library_to_source,
605605
declare_file = _declare_file,
606606
declare_directory = _declare_directory,
607-
get_nogo = _get_nogo,
608607

609608
# Private
610609
# TODO: All uses of this should be removed

0 commit comments

Comments
 (0)