Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
bc316e3d
Commit
bc316e3d
authored
Feb 08, 2019
by
Jeff Grafton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add auto-defined ALL_PLATFORMS field and support for dicts in for_platforms
parent
dfdfc2e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
6 deletions
+37
-6
platforms.bzl
build/platforms.bzl
+33
-3
BUILD.root
build/root/BUILD.root
+4
-3
No files found.
build/platforms.bzl
View file @
bc316e3d
...
@@ -12,6 +12,9 @@
...
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
load("@bazel_skylib//lib:new_sets.bzl", "sets")
load("@bazel_skylib//lib:types.bzl", "types")
# KUBE_SERVER_PLATFORMS in hack/lib/golang.sh
# KUBE_SERVER_PLATFORMS in hack/lib/golang.sh
SERVER_PLATFORMS = {
SERVER_PLATFORMS = {
"linux": [
"linux": [
...
@@ -74,6 +77,20 @@ TEST_PLATFORMS = {
...
@@ -74,6 +77,20 @@ TEST_PLATFORMS = {
],
],
}
}
def _all_platforms():
all_platforms = {}
for platforms in [CLIENT_PLATFORMS, NODE_PLATFORMS, SERVER_PLATFORMS, TEST_PLATFORMS]:
for os, archs in platforms.items():
all_platforms[os] = sets.union(
all_platforms.setdefault(os, sets.make()),
sets.make(archs),
)
for os, archs in all_platforms.items():
all_platforms[os] = sets.to_list(archs)
return all_platforms
ALL_PLATFORMS = _all_platforms()
def go_platform_constraint(os, arch):
def go_platform_constraint(os, arch):
return "@io_bazel_rules_go//go/platform:%s_%s" % (os, arch)
return "@io_bazel_rules_go//go/platform:%s_%s" % (os, arch)
...
@@ -85,20 +102,32 @@ def _update_dict_for_platform_category(d, value, platforms, only_os = None):
...
@@ -85,20 +102,32 @@ def _update_dict_for_platform_category(d, value, platforms, only_os = None):
continue
continue
for arch in arches:
for arch in arches:
constraint = go_platform_constraint(os, arch)
constraint = go_platform_constraint(os, arch)
if type(value) == "list":
fmt_args = {"OS": os, "ARCH": arch}
if types.is_list(value):
# Format all items in the list, and hope there are no duplicates
d.setdefault(constraint, []).extend(
d.setdefault(constraint, []).extend(
[v.format(
OS = os, ARCH = arch
) for v in value],
[v.format(
**fmt_args
) for v in value],
)
)
else:
else:
# Don't overwrite existing value
if constraint in d:
if constraint in d:
fail("duplicate entry for constraint %s", constraint)
fail("duplicate entry for constraint %s", constraint)
d[constraint] = value.format(OS = os, ARCH = arch)
if types.is_dict(value):
# Format dictionary values only
d[constraint] = {
dict_key: dict_value.format(**fmt_args)
for dict_key, dict_value in value.items()
}
else:
# Hopefully this is just a string
d[constraint] = value.format(**fmt_args)
def for_platforms(
def for_platforms(
for_client = None,
for_client = None,
for_node = None,
for_node = None,
for_server = None,
for_server = None,
for_test = None,
for_test = None,
for_all = None,
default = None,
default = None,
only_os = None):
only_os = None):
d = {}
d = {}
...
@@ -108,4 +137,5 @@ def for_platforms(
...
@@ -108,4 +137,5 @@ def for_platforms(
_update_dict_for_platform_category(d, for_node, NODE_PLATFORMS, only_os)
_update_dict_for_platform_category(d, for_node, NODE_PLATFORMS, only_os)
_update_dict_for_platform_category(d, for_server, SERVER_PLATFORMS, only_os)
_update_dict_for_platform_category(d, for_server, SERVER_PLATFORMS, only_os)
_update_dict_for_platform_category(d, for_test, TEST_PLATFORMS, only_os)
_update_dict_for_platform_category(d, for_test, TEST_PLATFORMS, only_os)
_update_dict_for_platform_category(d, for_all, ALL_PLATFORMS, only_os)
return d
return d
build/root/BUILD.root
View file @
bc316e3d
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
package(default_visibility = ["//visibility:public"])
package(default_visibility = ["//visibility:public"])
load("@io_k8s_repo_infra//defs:build.bzl", "gcs_upload")
load("@io_k8s_repo_infra//defs:build.bzl", "gcs_upload")
load("//build:platforms.bzl", "for_platforms")
filegroup(
filegroup(
name = "_binary-artifacts-and-hashes",
name = "_binary-artifacts-and-hashes",
...
@@ -35,11 +36,11 @@ gcs_upload(
...
@@ -35,11 +36,11 @@ gcs_upload(
"//cluster/gce/gci:gcs-release-artifacts-and-hashes",
"//cluster/gce/gci:gcs-release-artifacts-and-hashes",
],
],
tags = ["manual"],
tags = ["manual"],
upload_paths = {
upload_paths = select(for_platforms(for_all = {
"//:_binary-artifacts-and-hashes": "bin/linux/amd64",
"//build/release-tars:release-tars-and-hashes": "",
"//build/release-tars:release-tars-and-hashes": "",
"//cluster/gce/gci:gcs-release-artifacts-and-hashes": "extra/gce",
"//cluster/gce/gci:gcs-release-artifacts-and-hashes": "extra/gce",
},
"//:_binary-artifacts-and-hashes": "bin/{OS}/{ARCH}",
})),
)
)
filegroup(
filegroup(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment