b/toolbase/gotoolchain: fix IntelliJ integration
This adds OutputGroupInfo(go_generated_srcs) to expose the Generated
toolchain source code to the IntelliJ Bazel aspect, removes the
unnecessary GoArchive output (which seems to not be used when embedding
into another go_library) and does a reformat (as per IntelliJ
configuration).
Change-Id: I4bb981d8fa86b5960a7bcceab87607fdff6d1f13
Reviewed-on: https://review.monogon.dev/c/monogon/+/348
Reviewed-by: Mateusz Zalega <mateusz@monogon.tech>
diff --git a/build/toolbase/gotoolchain/def.bzl b/build/toolbase/gotoolchain/def.bzl
index 1722cc4..5c421e6 100644
--- a/build/toolbase/gotoolchain/def.bzl
+++ b/build/toolbase/gotoolchain/def.bzl
@@ -1,4 +1,4 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_context", "GoSource")
+load("@io_bazel_rules_go//go:def.bzl", "GoSource", "go_context")
# This implements the toolchain_library rule, which is used to generate a
# rules_go compatible go_library-style target which contains toolchain.go.in
@@ -17,8 +17,8 @@
template = ctx.file._template,
output = out,
substitutions = {
- 'GOROOT': go.root,
- 'GOTOOL': go.go.path,
+ "GOROOT": go.root,
+ "GOTOOL": go.go.path,
},
)
@@ -37,28 +37,19 @@
source = {
key: getattr(source, key)
for key in dir(source)
- if key not in ['to_json', 'to_proto']
+ if key not in ["to_json", "to_proto"]
}
- source['runfiles'] = runfiles
+ source["runfiles"] = runfiles
source = GoSource(**source)
- archive = go.archive(go, source)
-
return [
library,
source,
- archive,
- DefaultInfo(
- files = depset([archive.data.file]),
- runfiles = runfiles,
- ),
OutputGroupInfo(
- cgo_exports = archive.cgo_exports,
- compilation_outputs = [archive.data.file],
+ go_generated_srcs = depset([out]),
),
]
-
toolchain_library = rule(
implementation = _toolchain_library_impl,
attrs = {