From a1d5e4d37250da46a07eecaa17e244e4646ce940 Mon Sep 17 00:00:00 2001 From: Jamy Timmermans Date: Fri, 21 Oct 2022 13:25:41 -0700 Subject: [PATCH 1/2] fix(packages-driver): allow defining additional aspects instead of overwriting the default --- go/tools/gopackagesdriver/bazel_json_builder.go | 4 +++- go/tools/gopackagesdriver/main.go | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/go/tools/gopackagesdriver/bazel_json_builder.go b/go/tools/gopackagesdriver/bazel_json_builder.go index 55b235eeb1..e60e6c7049 100644 --- a/go/tools/gopackagesdriver/bazel_json_builder.go +++ b/go/tools/gopackagesdriver/bazel_json_builder.go @@ -119,11 +119,13 @@ func (b *BazelJSONBuilder) Build(ctx context.Context, mode LoadMode) ([]string, return nil, fmt.Errorf("found no labels matching the requests") } + aspects := append(additionalAspects, rulesGoAspect) + buildArgs := concatStringsArrays([]string{ "--experimental_convenience_symlinks=ignore", "--ui_event_filters=-info,-stderr", "--noshow_progress", - "--aspects=" + customAspect, + "--aspects=" + strings.Join(aspects, ","), "--output_groups=" + b.outputGroupsForMode(mode), "--keep_going", // Build all possible packages }, bazelFlags, bazelBuildFlags, labels) diff --git a/go/tools/gopackagesdriver/main.go b/go/tools/gopackagesdriver/main.go index ff9f9621ad..ace8bc947e 100644 --- a/go/tools/gopackagesdriver/main.go +++ b/go/tools/gopackagesdriver/main.go @@ -52,13 +52,14 @@ var ( // It seems https://github.com/bazelbuild/bazel/issues/3115 isn't fixed when specifying // the aspect from the command line. Use this trick in the mean time. rulesGoRepositoryName = getenvDefault("GOPACKAGESDRIVER_RULES_GO_REPOSITORY_NAME", "@io_bazel_rules_go") + rulesGoAspect = rulesGoRepositoryName + "//go/tools/gopackagesdriver:aspect.bzl%go_pkg_info_aspect" bazelBin = getenvDefault("GOPACKAGESDRIVER_BAZEL", "bazel") bazelFlags = strings.Fields(os.Getenv("GOPACKAGESDRIVER_BAZEL_FLAGS")) bazelQueryFlags = strings.Fields(os.Getenv("GOPACKAGESDRIVER_BAZEL_QUERY_FLAGS")) bazelQueryScope = getenvDefault("GOPACKAGESDRIVER_BAZEL_QUERY_SCOPE", "") bazelBuildFlags = strings.Fields(os.Getenv("GOPACKAGESDRIVER_BAZEL_BUILD_FLAGS")) workspaceRoot = os.Getenv("BUILD_WORKSPACE_DIRECTORY") - customAspect = getenvDefault("GOPACKAGESDRIVER_BAZEL_ASPECT", rulesGoRepositoryName+"//go/tools/gopackagesdriver:aspect.bzl%go_pkg_info_aspect") + additionalAspects = strings.Fields(os.Getenv("GOPACKAGESDRIVER_BAZEL_ADDTL_ASPECTS")) additionalKinds = strings.Fields(os.Getenv("GOPACKAGESDRIVER_BAZEL_KINDS")) emptyResponse = &driverResponse{ NotHandled: false, From 98d593e6245b90da5539679ceca896921507d728 Mon Sep 17 00:00:00 2001 From: Jamy Timmermans Date: Fri, 21 Oct 2022 14:35:09 -0700 Subject: [PATCH 2/2] Update go/tools/gopackagesdriver/main.go Co-authored-by: Zhongpeng Lin --- go/tools/gopackagesdriver/bazel_json_builder.go | 2 +- go/tools/gopackagesdriver/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go/tools/gopackagesdriver/bazel_json_builder.go b/go/tools/gopackagesdriver/bazel_json_builder.go index e60e6c7049..ad6e6dedea 100644 --- a/go/tools/gopackagesdriver/bazel_json_builder.go +++ b/go/tools/gopackagesdriver/bazel_json_builder.go @@ -119,7 +119,7 @@ func (b *BazelJSONBuilder) Build(ctx context.Context, mode LoadMode) ([]string, return nil, fmt.Errorf("found no labels matching the requests") } - aspects := append(additionalAspects, rulesGoAspect) + aspects := append(additionalAspects, goDefaultAspect) buildArgs := concatStringsArrays([]string{ "--experimental_convenience_symlinks=ignore", diff --git a/go/tools/gopackagesdriver/main.go b/go/tools/gopackagesdriver/main.go index ace8bc947e..9d36c8a85a 100644 --- a/go/tools/gopackagesdriver/main.go +++ b/go/tools/gopackagesdriver/main.go @@ -52,7 +52,7 @@ var ( // It seems https://github.com/bazelbuild/bazel/issues/3115 isn't fixed when specifying // the aspect from the command line. Use this trick in the mean time. rulesGoRepositoryName = getenvDefault("GOPACKAGESDRIVER_RULES_GO_REPOSITORY_NAME", "@io_bazel_rules_go") - rulesGoAspect = rulesGoRepositoryName + "//go/tools/gopackagesdriver:aspect.bzl%go_pkg_info_aspect" + goDefaultAspect = rulesGoRepositoryName + "//go/tools/gopackagesdriver:aspect.bzl%go_pkg_info_aspect" bazelBin = getenvDefault("GOPACKAGESDRIVER_BAZEL", "bazel") bazelFlags = strings.Fields(os.Getenv("GOPACKAGESDRIVER_BAZEL_FLAGS")) bazelQueryFlags = strings.Fields(os.Getenv("GOPACKAGESDRIVER_BAZEL_QUERY_FLAGS"))