-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMODULE.bazel
More file actions
52 lines (43 loc) · 2.43 KB
/
MODULE.bazel
File metadata and controls
52 lines (43 loc) · 2.43 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
# The MODULE.bazel file appears in the root directory of each Bazel module.
# Its main purpose is to list the other Bazel modules that this module depends
# on. MODULE.bazel may also contain non-module dependencies declared with
# repository rules or module extensions. It may have other declarations too
# like toolchain registrations.
# The string below is this module's documentation string. It may be shown
# on the Bazel Central Registry and other places.
"""
rules_go_simple is a simple set of Bazel rules for building Go code. It
is intended to be a simple, clean, minimal example of how to write Bazel
rules for new languages.
"""
# The module declaration sets this module's name. You can use this name to
# refer to targets within this module. Other modules can depend on this module
# using this name.
module(name = "rules_go_simple")
# bazel_dep declarations register dependencies on other modules.
# Bazel recursively fetches their MODULE.bazel files and other metadata
# from the Bazel Central Registry (or whatever registry you're using)
# and selects a version of each module to use, which may be higher than the
# version listed here if another module requires a higher version.
# bazel_skylib is a common library for writing and testing Bazel rules.
bazel_dep(name = "bazel_skylib", version = "1.7.1")
# platforms contains constraints matching various operating systems and
# CPU architectures, used for toolchain selection.
bazel_dep(name = "platforms", version = "1.0.0")
# go is a module extension. It lets us download things that aren't Bazel
# modules. We use the go extension to download the Go toolchain, generate
# a BUILD file, and register toolchains with Bazel.
go = use_extension("//:go.bzl", "go")
# This statement declares a download tag. After all MODULE.bazel files are
# loaded, the go module extension considers all tags declared in any module.
# It picks the highest version and lazily downloads archives for all supported
# platforms.
go.download(version = "1.25.0")
# The go extension generates a "go_toolchains" repo that contains toolchain
# definitions for all supported platforms. This use_repo statement declares
# that repo so we can refer to it here.
use_repo(go, "go_toolchains")
# Finally, we register the declared toolchains with Bazel. Bazel automatically
# selects a toolchain based on the execution and target platforms, then
# downloads and builds the toolchain files when needed.
register_toolchains("@go_toolchains//:all")