Skip to content

Commit 51f9e34

Browse files
authored
Merge pull request kubernetes#89430 from mikedanese/bazel2
Update bazel to 2.2.0
2 parents 5d4553a + 59e2a09 commit 51f9e34

File tree

6 files changed

+54
-73
lines changed

6 files changed

+54
-73
lines changed

build/code_generation.bzl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
load("//build:kazel_generated.bzl", "go_prefix", "tags_values_pkgs")
1616
load("//build:openapi.bzl", "openapi_vendor_prefix")
1717
load("@io_k8s_repo_infra//defs:go.bzl", "go_genrule")
18+
load("@bazel_skylib//lib:paths.bzl", "paths")
1819

1920
def bazel_go_library(pkg):
2021
"""Returns the Bazel label for the Go library for the provided package.
@@ -41,8 +42,10 @@ def go_pkg(pkg):
4142
...
4243
)
4344
"""
44-
count = 1
45-
return go_prefix + "/" + pkg.replace("staging/src/", "vendor/", count)
45+
for prefix in ["staging/src", "vendor"]:
46+
if pkg.startswith(prefix):
47+
return paths.relativize(pkg, prefix)
48+
return paths.join(go_prefix, pkg)
4649

4750
def openapi_deps():
4851
deps = [
@@ -73,18 +76,18 @@ def gen_openapi(outs, output_pkg, include_pkgs = [], exclude_pkgs = []):
7376
# the generator must run from the repo root inside the generated GOPATH.
7477
# All of bazel's $(location)s are relative to the original working directory, however.
7578
cmd = " ".join([
76-
"cd $$GOPATH/src/" + go_prefix + ";",
77-
"$$GO_GENRULE_EXECROOT/$(location //vendor/k8s.io/kube-openapi/cmd/openapi-gen)",
79+
"$(location //vendor/k8s.io/kube-openapi/cmd/openapi-gen)",
7880
"--v 1",
7981
"--logtostderr",
80-
"--go-header-file $$GO_GENRULE_EXECROOT/$(location //" + openapi_vendor_prefix + "hack/boilerplate:boilerplate.generatego.txt)",
82+
"--go-header-file $(location //" + openapi_vendor_prefix + "hack/boilerplate:boilerplate.generatego.txt)",
8183
"--output-file-base zz_generated.openapi",
8284
"--output-package " + output_pkg,
8385
"--report-filename tmp_api_violations.report",
8486
"--input-dirs " + ",".join([go_pkg(pkg) for pkg in tags_values_pkgs["openapi-gen"]["true"] if applies(pkg, include_pkgs, True) and not applies(pkg, exclude_pkgs, False)]),
85-
"&& cp $$GOPATH/src/" + output_pkg + "/zz_generated.openapi.go $$GO_GENRULE_EXECROOT/$(location :zz_generated.openapi.go)",
87+
"&& cp $$GOPATH/src/" + output_pkg + "/zz_generated.openapi.go $(location :zz_generated.openapi.go)",
8688
"&& rm tmp_api_violations.report",
8789
]),
8890
go_deps = openapi_deps(),
8991
tools = ["//vendor/k8s.io/kube-openapi/cmd/openapi-gen"],
92+
message = "GenOpenAPI",
9093
)

build/code_generation_test.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ def _bazel_go_library_test_impl(ctx):
2424
]
2525
for input, expected in test_cases:
2626
asserts.equals(env, expected, bazel_go_library(input))
27-
unittest.end(env)
27+
return unittest.end(env)
2828

2929
bazel_go_library_test = unittest.make(_bazel_go_library_test_impl)
3030

3131
def _go_pkg_test_impl(ctx):
3232
env = unittest.begin(ctx)
3333
test_cases = [
3434
("pkg/kubectl/util", "k8s.io/kubernetes/pkg/kubectl/util"),
35-
("vendor/some/third/party", "k8s.io/kubernetes/vendor/some/third/party"),
36-
("staging/src/k8s.io/apimachinery/api", "k8s.io/kubernetes/vendor/k8s.io/apimachinery/api"),
35+
("vendor/some/third/party", "some/third/party"),
36+
("staging/src/k8s.io/apimachinery/api", "k8s.io/apimachinery/api"),
3737
]
3838
for input, expected in test_cases:
3939
asserts.equals(env, expected, go_pkg(input))
40-
unittest.end(env)
40+
return unittest.end(env)
4141

4242
go_pkg_test = unittest.make(_go_pkg_test_impl)
4343

build/root/.bazelrc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,18 @@ build:cross:darwin_amd64 --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd
4040
build:cross:windows_386 --platforms=@io_bazel_rules_go//go/toolchain:windows_386
4141
build:cross:windows_amd64 --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64
4242

43-
# We enable cgo cross-compilation for Linux, but need to use our custom crosstool.
44-
build:repo_infra_crosstool --crosstool_top=@io_k8s_repo_infra//tools:toolchain --compiler=gcc
45-
build:cross:linux_386 --config=repo_infra_crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_386
46-
build:cross:linux_amd64 --config=repo_infra_crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 --cpu=amd64
47-
build:cross:linux_arm --config=repo_infra_crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_arm --cpu=arm
48-
build:cross:linux_arm64 --config=repo_infra_crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 --cpu=arm64
49-
build:cross:linux_ppc64le --config=repo_infra_crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le --cpu=ppc64le
50-
build:cross:linux_s390x --config=repo_infra_crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_s390x --cpu=s390x
43+
# These cross-compilation targets are most likely non-functional.
44+
build:crosstool --compiler=gcc
45+
build:cross:linux_386 --config=crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_386
46+
build:cross:linux_amd64 --config=crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 --cpu=amd64
47+
build:cross:linux_arm --config=crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_arm --cpu=arm
48+
build:cross:linux_arm64 --config=crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 --cpu=arm64
49+
build:cross:linux_ppc64le --config=crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le --cpu=ppc64le
50+
build:cross:linux_s390x --config=crosstool --platforms=@io_bazel_rules_go//go/toolchain:linux_s390x --cpu=s390x
5151

5252
# --config=remote-cache enables a remote bazel cache
5353
# Note needs a --remote_instance_name=projects/PROJ/instances/default_instance flag
5454
build:remote-cache --remote_cache=remotebuildexecution.googleapis.com
55-
build:remote-cache --tls_enabled=true
5655
build:remote-cache --remote_timeout=3600
5756
build:remote-cache --auth_enabled=true
5857

build/root/.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.23.2
1+
2.2.0

build/root/WORKSPACE

Lines changed: 31 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,53 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file"
44
load("//build:workspace_mirror.bzl", "mirror")
55

66
http_archive(
7-
name = "bazel_toolchains",
8-
sha256 = "3a6ffe6dd91ee975f5d5bc5c50b34f58e3881dfac59a7b7aba3323bd8f8571a8",
9-
strip_prefix = "bazel-toolchains-92dd8a7",
10-
urls = [
11-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/92dd8a7.tar.gz",
12-
"https://github.com/bazelbuild/bazel-toolchains/archive/92dd8a7.tar.gz",
13-
],
7+
name = "io_bazel_rules_go",
8+
sha256 = "142dd33e38b563605f0d20e89d9ef9eda0fc3cb539a14be1bdb1350de2eda659",
9+
urls = mirror("https://github.com/bazelbuild/rules_go/releases/download/v0.22.2/rules_go-v0.22.2.tar.gz"),
1410
)
1511

16-
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
12+
load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchains", "go_rules_dependencies")
1713

18-
rbe_autoconfig(
19-
name = "rbe_default",
20-
base_container_digest = "sha256:677c1317f14c6fd5eba2fd8ec645bfdc5119f64b3e5e944e13c89e0525cc8ad1",
21-
digest = "sha256:b7c2e7a18968b9df2db43eda722c5ae592aafbf774ba2766074a9c96926743d8",
22-
registry = "gcr.io",
23-
repository = "k8s-testimages/bazel-krte",
24-
# tag = "latest",
14+
go_rules_dependencies()
15+
16+
go_register_toolchains(
17+
go_version = "1.13.9",
2518
)
2619

2720
http_archive(
28-
name = "bazel_skylib",
29-
sha256 = "eb5c57e4c12e68c0c20bc774bfbc60a568e800d025557bc4ea022c6479acc867",
30-
strip_prefix = "bazel-skylib-0.6.0",
31-
urls = mirror("https://github.com/bazelbuild/bazel-skylib/archive/0.6.0.tar.gz"),
21+
name = "io_k8s_repo_infra",
22+
sha256 = "a6ca952e365600a17f56f0fc8e41016e1d13cfb2b74c0c29bad6bdba3e3d8a4d",
23+
strip_prefix = "repo-infra-0.0.3",
24+
urls = mirror("https://github.com/kubernetes/repo-infra/archive/v0.0.3.tar.gz"),
3225
)
3326

34-
load("@bazel_skylib//lib:versions.bzl", "versions")
27+
load("@io_k8s_repo_infra//:load.bzl", repo_infra_repositories = "repositories")
3528

36-
versions.check(minimum_bazel_version = "0.23.0")
29+
repo_infra_repositories()
3730

38-
http_archive(
39-
name = "io_k8s_repo_infra",
40-
sha256 = "f6d65480241ec0fd7a0d01f432938b97d7395aeb8eefbe859bb877c9b4eafa56",
41-
strip_prefix = "repo-infra-9f4571ad7242bf3ec4b47365062498c2528f9a5f",
42-
urls = mirror("https://github.com/kubernetes/repo-infra/archive/9f4571ad7242bf3ec4b47365062498c2528f9a5f.tar.gz"),
43-
)
31+
load("@io_k8s_repo_infra//:repos.bzl", repo_infra_go_repositories = "go_repositories", repo_infra_configure = "configure")
4432

45-
http_archive(
46-
name = "io_bazel_rules_go",
47-
sha256 = "62bedd372f125fe62c16c0cc2ad9d7a2b6a1171d639933a5651a729fdce497fc",
48-
urls = mirror("https://github.com/bazelbuild/rules_go/releases/download/v0.20.7/rules_go-v0.20.7.tar.gz"),
33+
repo_infra_configure(
34+
minimum_bazel_version = "2.2.0",
35+
rbe_name = None,
4936
)
5037

51-
load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchains", "go_rules_dependencies")
38+
repo_infra_go_repositories()
5239

53-
go_rules_dependencies()
40+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
5441

55-
# The version of rules_go we're using here is no longer supported, so
56-
# we must manually download a newer version of the go sdk.
57-
go_download_sdk(
58-
name = "go_sdk",
59-
sdks = {
60-
"darwin_amd64": ("go1.13.9.darwin-amd64.tar.gz", "450e59538ed5d3f2b165ba5107530afce6e8e89c6cc5c90a0cbf0a58846ef3b1"),
61-
"freebsd_386": ("go1.13.9.freebsd-386.tar.gz", "6b75a5a46ebbdf06aa5023f2bd0ad7e9e37389125468243368d5795e1c15c9cd"),
62-
"freebsd_amd64": ("go1.13.9.freebsd-amd64.tar.gz", "87716246da52c193226df44031aaf45e45ebfc23e01bdc845311c1b560e76e2b"),
63-
"linux_386": ("go1.13.9.linux-386.tar.gz", "a2744aa2ddc68d888e9f65c2cbe4c8b527b139688ce232ead90dc2961f8d51a8"),
64-
"linux_amd64": ("go1.13.9.linux-amd64.tar.gz", "f4ad8180dd0aaf7d7cda7e2b0a2bf27e84131320896d376549a7d849ecf237d7"),
65-
"linux_arm64": ("go1.13.9.linux-arm64.tar.gz", "b53cb466d7986e5e17a3d4c196bc95df08a35968eced5efd7e128387a246c46e"),
66-
"linux_arm": ("go1.13.9.linux-armv6l.tar.gz", "a3c2941a1fde8692514ece7e2180a0e3ca70609f52756a66bc0ab68c63572361"),
67-
"linux_ppc64le": ("go1.13.9.linux-ppc64le.tar.gz", "90beb01962202f332be0a7c8dad2db3d30242759ba863db3f36c45d241940efc"),
68-
"linux_s390x": ("go1.13.9.linux-s390x.tar.gz", "a40949aaf55912b06df8fda511c33fde3e52d377706bdc095332652c1ad225e3"),
69-
"windows_386": ("go1.13.9.windows-386.zip", "e22406377448f1aea2dd1517327e5ae452d826c0c7624b3511d5af510c57b69a"),
70-
"windows_amd64": ("go1.13.9.windows-amd64.zip", "cf066aabdf4d83c251aaace14b57a35aafffd1fa67d54d907f27fb31e470a135"),
71-
},
72-
)
42+
bazel_skylib_workspace()
7343

74-
go_register_toolchains()
44+
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
45+
46+
rbe_autoconfig(
47+
name = "rbe_default",
48+
base_container_digest = "sha256:b4dad0bfc4951d619229ab15343a311f2415a16ef83bcaa55b44f4e2bf1cf635",
49+
digest = "sha256:b28ddaf98c6e0bb840c5fded3c0a899a7db45bb44f69859f16c37be092bfcb4e",
50+
registry = "marketplace.gcr.io",
51+
repository = "google/bazel",
52+
# tag = "2.2.0",
53+
)
7554

7655
http_archive(
7756
name = "io_bazel_rules_docker",

staging/src/k8s.io/apimachinery/pkg/util/sets/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ go_genrule(
3838
],
3939
cmd = """
4040
$(location //vendor/k8s.io/code-generator/cmd/set-gen) \
41-
--input-dirs k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/sets/types \
41+
--input-dirs k8s.io/apimachinery/pkg/util/sets/types \
4242
--output-base $$(dirname $$(dirname $(location :byte.go))) \
4343
--go-header-file $(location //hack/boilerplate:boilerplate.generatego.txt) \
4444
--output-package sets

0 commit comments

Comments
 (0)