-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUILD.bazel
More file actions
79 lines (71 loc) · 2.61 KB
/
BUILD.bazel
File metadata and controls
79 lines (71 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@pip//:requirements.bzl", "all_whl_requirements")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest")
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
compile_pip_requirements(
name = "requirements",
src = "requirements.in",
requirements_txt = "requirements_lock.txt",
requirements_windows = "requirements_windows.txt",
)
# This repository rule fetches the metadata for python packages we
# depend on. That data is required for the gazelle_python_manifest
# rule to update our manifest file.
# To see what this rule does, try `bazel run @modules_map//:print`
modules_mapping(
name = "modules_map",
exclude_patterns = [
"^_|(\\._)+", # This is the default.
"(\\.tests)+", # Add a custom one to get rid of the psutil tests.
],
wheels = all_whl_requirements,
)
# Gazelle python extension needs a manifest file mapping from
# an import to the installed package that provides it.
# This macro produces two targets:
# - //:gazelle_python_manifest.update can be used with `bazel run`
# to recalculate the manifest
# - //:gazelle_python_manifest.test is a test target ensuring that
# the manifest doesn't need to be updated
gazelle_python_manifest(
name = "gazelle_python_manifest",
modules_mapping = ":modules_map",
pip_repository_name = "pip",
# NOTE: We can pass a list just like in `bzlmod_build_file_generation` example
# but we keep a single target here for regression testing.
requirements = "//:requirements_lock.txt",
)
gazelle_binary(
name = "gazelle_bin",
languages = [
"@rules_python_gazelle_plugin//python:python",
"@bazel_gazelle//language/go", # Built-in rule from gazelle for Golang.
],
visibility = ["//visibility:public"],
)
gazelle(
name = "gazelle",
gazelle = ":gazelle_bin",
)
gazelle(
name = "gazelle-update-repos",
args = [
"-from_file=go.mod",
"-to_macro=DEPS.bzl%go_dependencies",
"-prune",
],
command = "update-repos",
)
# Gazelle needs the following resolve hints.
#
# gazelle:resolve go github.com/google/cel-go/cel @com_github_google_cel_go//cel:go_default_library
# gazelle:resolve go github.com/google/cel-go/common/types/ref @com_github_google_cel_go//common/types/ref:go_default_library
# gazelle:python_library_naming_convention $package_name$_lib
# gazelle:python_binary_naming_convention $package_name$
exports_files([
"DEPS.bzl",
"WORKSPACE",
"go.mod",
"go.sum",
])