bzl gazelle support overwrite resolve

This commit is contained in:
eeelin 2024-08-27 04:23:42 +00:00
parent 5c071b5006
commit 4a79cf5421
7 changed files with 52 additions and 0 deletions

View File

@ -152,6 +152,13 @@ func (*bzlLibraryLang) Resolve(c *config.Config, ix *resolve.RuleIndex, rc *repo
deps := make([]string, 0, len(imports))
for _, imp := range imports {
if l, ok := resolve.FindRuleWithOverride(c, resolve.ImportSpec{Lang: languageName, Imp: imp}, languageName); ok {
depLabel := l.Rel(from.Repo, from.Pkg)
deps = append(deps, depLabel.String())
continue
}
impLabel, err := label.Parse(imp)
if err != nil {
log.Printf("%s: import of %q is invalid: %v", from.String(), imp, err)

View File

@ -0,0 +1,8 @@
# Some comment to be preserved
# gazelle:resolve starlark starlark //internal:defs.bzl //internal:defs_bzl
filegroup(
name = "allfiles",
srcs = glob(["**"]),
)

View File

@ -0,0 +1,17 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
# Some comment to be preserved
# gazelle:resolve starlark starlark //internal:defs.bzl //internal:defs_bzl
filegroup(
name = "allfiles",
srcs = glob(["**"]),
)
bzl_library(
name = "foo",
srcs = ["foo.bzl"],
visibility = ["//visibility:public"],
deps = ["//internal:defs_bzl"],
)

View File

View File

@ -0,0 +1,7 @@
"""
Doc string
"""
load("//internal:defs.bzl", "deps")
deps()

View File

@ -0,0 +1,7 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
bzl_library(
name = "deps_bzl",
srcs = ["deps.bzl"],
visibility = ["//:__subpackages__"],
)

View File

@ -0,0 +1,6 @@
"""
Simple deps
"""
def deps():
pass