Go: add vendor update to //go:gen

This commit is contained in:
Paolo Tranquilli
2024-04-26 16:31:04 +02:00
parent d98ccdfa06
commit 0f387eeac2
3 changed files with 12 additions and 5 deletions

View File

@@ -1,15 +1,17 @@
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
load("@gazelle//:def.bzl", "gazelle")
load("@rules_pkg//pkg:install.bzl", "pkg_install")
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files")
load("//:defs.bzl", "codeql_platform")
gazelle(
name = "_gazelle",
name = "gazelle",
extra_args = ["go/extractor"],
)
_gen_binaries = [
":_gazelle",
"@rules_go//go",
":gazelle",
"//go/extractor/cli/go-gen-dbscheme",
]
@@ -62,6 +64,7 @@ pkg_files(
"//go/extractor/cli/go-gen-dbscheme",
"//go/extractor/cli/go-tokenizer",
],
attributes = pkg_attributes(mode = "0755"),
prefix = "tools/" + codeql_platform,
visibility = ["//visibility:public"],
)

View File

@@ -1,3 +1,4 @@
## workspace
# golang.org/x/mod v0.15.0
## explicit; go 1.18
golang.org/x/mod/internal/lazyregexp

View File

@@ -7,14 +7,17 @@ this = pathlib.Path(__file__).resolve()
go_extractor_dir = this.parent / "extractor"
go_dbscheme = this.parent / "ql" / "lib" / "go.dbscheme"
r = runfiles.Create()
gazelle, go_gen_dbscheme = map(r.Rlocation, sys.argv[1:])
go, gazelle, go_gen_dbscheme = map(r.Rlocation, sys.argv[1:])
print("updating vendor")
subprocess.check_call([go, "-C", go_extractor_dir, "work", "vendor"])
print("clearing generated BUILD files")
for build_file in go_extractor_dir.glob("*/**/BUILD.bazel"):
build_file.unlink()
print("running gazelle")
subprocess.check_call([gazelle, "go/extractor"])
subprocess.check_call([gazelle])
print("adding header to generated BUILD files")
for build_file in go_extractor_dir.glob("*/**/BUILD.bazel"):