Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying default patches for go_deps and add patch for go-tree-sitter #1985

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/bzlmod/default_gazelle_overrides.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,9 @@ DEFAULT_BUILD_EXTRA_ARGS_BY_PATH = {
"-exclude=arith_s390x_test.go",
],
}

DEFAULT_PATCHES_BY_PATH = {
"github.com/smacker/go-tree-sitter": [
"//third_party:com_github_smacker_go_tree_sitter/build.patch",
],
}
3 changes: 2 additions & 1 deletion internal/bzlmod/go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ load(
"DEFAULT_BUILD_EXTRA_ARGS_BY_PATH",
"DEFAULT_BUILD_FILE_GENERATION_BY_PATH",
"DEFAULT_DIRECTIVES_BY_PATH",
"DEFAULT_PATCHES_BY_PATH",
)
load(":go_mod.bzl", "deps_from_go_mod", "go_work_from_label", "sums_from_go_mod", "sums_from_go_work")
load(":semver.bzl", "COMPARES_HIGHEST_SENTINEL", "semver")
Expand Down Expand Up @@ -157,7 +158,7 @@ def _get_build_extra_args(path, gazelle_overrides, gazelle_default_attributes):
return _get_override_or_default(gazelle_overrides, gazelle_default_attributes, DEFAULT_BUILD_EXTRA_ARGS_BY_PATH, path, [], "build_extra_args")

def _get_patches(path, module_overrides):
return _get_override_or_default(module_overrides, struct(), {}, path, [], "patches")
return _get_override_or_default(module_overrides, struct(), DEFAULT_PATCHES_BY_PATH, path, [], "patches")

def _get_patch_args(path, module_overrides):
override = _get_override_or_default(module_overrides, struct(), {}, path, None, "patch_strip")
Expand Down
1 change: 1 addition & 0 deletions internal/go_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def _go_repository_impl(ctx):
print("%s gazelle.stderr: %s" % (ctx.name, result.stderr))

# Apply patches if necessary.
print("bazel_gazelle/go_repository: applying patches. name=%s, patches=%s" % (ctx.attr.name, ctx.attr.patches))
patch(ctx)

if generate:
Expand Down
26 changes: 26 additions & 0 deletions third_party/com_github_smacker_go_tree_sitter/build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git BUILD.bazel BUILD.bazel
index 6aa29a3..155129f 100644
--- BUILD.bazel
+++ BUILD.bazel
@@ -3,3 +3,9 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+filegroup(
+ name = "common",
+ srcs = ["alloc.h", "api.h", "array.h"],
+ visibility = [":__subpackages__"],
+)
+
go_library(
name = "go-tree-sitter",
srcs = [
diff --git python/BUILD.bazel python/BUILD.bazel
index 04c7312..b184ac8 100644
--- python/BUILD.bazel
+++ python/BUILD.bazel
@@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "python",
srcs = [
+ "//:common",
"binding.go",
"parser.c",
"parser.h",