aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2024-01-17 18:08:22 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-01-17 18:08:22 +0000
commite352aabd0131f3ac3f340282a43ba85ffc3fe8fa (patch)
treeec8305e2de409593ea17fba364a67cd8c1af4d58
parent9ea54df557a62fb1f5397dc802a5a291144f6c11 (diff)
parentc240f2aa4ef096cd46d76f5758e120cc150510e7 (diff)
downloadbazelbuild-platforms-e352aabd0131f3ac3f340282a43ba85ffc3fe8fa.tar.gz
Upgrade platforms to 0.0.8 am: c240f2aa4eHEADmastermain
Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-platforms/+/2913504 Change-Id: Ieff9ad338e61d3f8066551696ba08a10acbcfb56 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--.bazelci/presubmit.yml59
-rw-r--r--BUILD34
-rw-r--r--MODULE.bazel7
-rw-r--r--README.md11
-rw-r--r--WORKSPACE11
-rw-r--r--WORKSPACE.bzlmod4
-rw-r--r--cpu/BUILD112
-rw-r--r--distro/README.md47
-rwxr-xr-xdistro/makerel.sh67
-rw-r--r--os/BUILD38
-rw-r--r--tests/BUILD21
-rw-r--r--version.bzl16
12 files changed, 398 insertions, 29 deletions
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index d529df1..b24af0f 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -1,19 +1,46 @@
---
+#
+# Bazel releases
+#
+lts: &lts
+ bazel: latest
+
+rolling: &rolling
+ bazel: rolling
+
+
+targets: &targets
+ build_targets:
+ - "//..."
+
+
tasks:
- ubuntu1604:
- build_targets:
- - "..."
- ubuntu1804:
- build_targets:
- - "..."
- ubuntu1804_nojava:
+ ubuntu_lts:
+ name: ubuntu_lts
+ platform: ubuntu2004
+ <<: *lts
+ <<: *targets
+ ubuntu_rolling:
+ name: ubuntu_rolling
+ platform: ubuntu2004
+ <<: *rolling
+ <<: *targets
+ macos_lts:
+ name: macos_lts
+ platform: macos
+ <<: *lts
+ <<: *targets
+ windows_lts:
+ name: windows_lts
+ platform: windows
+ <<: *lts
+ <<: *targets
+ check_bzlmod:
+ name: check_bzlmod
+ # No need to check bzlmod on every platform. This repository only holds
+ # constants and has no per-platform behavior.
+ platform: ubuntu2004
+ <<: *rolling
+ <<: *targets
build_flags:
- - "--javabase=@openjdk11_linux_archive//:runtime"
- build_targets:
- - "..."
- macos:
- build_targets:
- - "..."
- windows:
- build_targets:
- - "..."
+ - "--enable_bzlmod"
diff --git a/BUILD b/BUILD
index d73ff92..4ab75c5 100644
--- a/BUILD
+++ b/BUILD
@@ -1,8 +1,22 @@
-package(default_visibility = ["//visibility:public"])
+load("@rules_license//rules:license.bzl", "license")
-licenses(["notice"])
+package(
+ default_applicable_licenses = [":license"],
+ default_visibility = ["//visibility:public"],
+)
+
+license(
+ name = "license",
+ license_kinds = [
+ "@rules_license//licenses/spdx:Apache-2.0",
+ ],
+ license_text = "LICENSE",
+)
-exports_files(["LICENSE"])
+exports_files([
+ "LICENSE",
+ "MODULE.bazel",
+])
filegroup(
name = "srcs",
@@ -13,3 +27,17 @@ filegroup(
"//os:srcs",
],
)
+
+# For use in Incompatible Target Skipping:
+# https://docs.bazel.build/versions/main/platforms.html#skipping-incompatible-targets
+#
+# Specifically this lets targets declare incompatibility with some set of
+# platforms. See
+# https://docs.bazel.build/versions/main/platforms.html#more-expressive-constraints
+# for some more details.
+constraint_setting(name = "incompatible_setting")
+
+constraint_value(
+ name = "incompatible",
+ constraint_setting = ":incompatible_setting",
+)
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 0000000..617a84a
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,7 @@
+module(
+ name = "platforms",
+ version = "0.0.8", # keep in sync with version.bzl
+ compatibility_level = 1,
+)
+
+bazel_dep(name = "rules_license", version = "0.0.7")
diff --git a/README.md b/README.md
index a2c00d3..99fc7a9 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
# [Bazel Platforms](https://bazel.build)
This repository houses all canonical
-[constraint_setting()](https://docs.bazel.build/versions/master/be/platform.html#constraint_setting)s,
-[constraint_value()](https://docs.bazel.build/versions/master/be/platform.html#constraint_value)s
+[constraint_setting()](https://bazel.build/reference/be/platforms-and-toolchains#constraint_setting)s,
+[constraint_value()](https://bazel.build/reference/be/platforms-and-toolchains#constraint_value)s
and
-[platform()](https://docs.bazel.build/versions/master/be/platform.html#platform)s
+[platform()](https://bazel.build/reference/be/platforms-and-toolchains#platform)s
that are universally useful across languages and Bazel projects.
For questions or concerns please email
@@ -80,6 +80,5 @@ If you need custom constaint_settings, just declare them in your own repo. They
are, by definition, not global.
If you really need a permanent global change and it isn't design-approved for
-this repo, contact
-[bazel-dev@googlegroups.com](mailto://bazel-dev@googlegroups.com) to discuss
-options.
+this repo, start a thread on
+[GitHub](https://github.com/bazelbuild/bazel/discussions) to discuss options.
diff --git a/WORKSPACE b/WORKSPACE
index f1874ea..172bccc 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1 +1,12 @@
workspace(name = "platforms")
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
+ name = "rules_license",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
+ "https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
+ ],
+ sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
+)
diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod
new file mode 100644
index 0000000..59c0af4
--- /dev/null
+++ b/WORKSPACE.bzlmod
@@ -0,0 +1,4 @@
+# Include dependencies which are only needed for development here.
+#
+# Even if this is empty, you need it with bzlmod enable to prevent
+# bzlmod from bringing in WORKSPACE too.
diff --git a/cpu/BUILD b/cpu/BUILD
index e06de69..6497452 100644
--- a/cpu/BUILD
+++ b/cpu/BUILD
@@ -13,25 +13,94 @@ filegroup(
# To add a new constraint_value see https://github.com/bazelbuild/platforms.
constraint_setting(name = "cpu")
-# TODO(b/136237408): Remove this generic CPU name and replace with a specific one.
+# New cpu values should refer to specific, highly available CPU implementations,
+# not broad architectures. It should be possible to select the right compiler
+# options by just by knowing the cpu. This can be a difficult evaluation for
+# ARM variations, where there are many possibilities for customization within
+# an architecture.
+#
+# 1. No private names are be allowed. If you build your own custom ARM chips,
+# then define them locally within your organization.
+# 2. All CPU values must be clear that they are for a 32 or a 64 bit
+# implementation. For example, cortex-r52 is a 32 bit processor, and
+# cortex-r82 is a 64 bit processor, but both are armv8-r architecture.
+# We use the specific processor names because armv8-r is insufficient to
+# select proper compiler options.
+#
+# Many of the name here are legacy values and probably violate these conditions.
+# We'll try to clean those up over time.
+
+# Special case: Architecture-independent outputs only
+#
+# Some builds are expected to only produce architecture-independent data files,
+# such as configuration files, database seed data, composited images, or even
+# some kinds of interpreted scripts (Shell, Python, Perl, etc).
+#
+# When such a build is being performed, this constraint value may be used to
+# ensure that architecture-dependent builds cannot be performed (except by way
+# of another transition).
+#
+# As a final example, consider building a package of NIC firmware images for
+# many different NIC models. The package overall is architecture-independent,
+# and should be built with `//cpu:all`, then each individual image rule has a
+# transition to the suitable architecture for that specific NIC model.
constraint_value(
- name = "aarch64",
+ name = "all",
constraint_setting = ":cpu",
)
-# TODO(b/136237408): Remove this generic CPU name and replace with a specific one.
constraint_value(
+ name = "aarch32",
+ constraint_setting = ":cpu",
+)
+
+constraint_value(
+ name = "aarch64",
+ constraint_setting = ":cpu",
+)
+
+alias(
name = "arm",
+ actual = ":aarch32",
+)
+
+# Cortex-M0, Cortex-M0+, Cortex-M1
+constraint_value(
+ name = "armv6-m", # Commonly known as thumbv6
constraint_setting = ":cpu",
)
+# Cortex-M3
constraint_value(
- name = "arm64_32",
+ name = "armv7-m",
+ constraint_setting = ":cpu",
+)
+
+# Cortex-M4, Cortex-M7
+constraint_value(
+ name = "armv7e-m",
+ constraint_setting = ":cpu",
+)
+
+# Cortex-M4, Cortex-M7 with fpu
+constraint_value(
+ name = "armv7e-mf", # armv7e-m with fpu
constraint_setting = ":cpu",
)
+# Cortex-M23, Cortex-M33, Cortex-M35P
constraint_value(
+ name = "armv8-m",
+ constraint_setting = ":cpu",
+)
+
+alias(
name = "arm64",
+ actual = ":aarch64",
+)
+
+constraint_value(
+ name = "arm64_32",
constraint_setting = ":cpu",
)
@@ -51,6 +120,16 @@ constraint_value(
)
constraint_value(
+ name = "cortex-r52",
+ constraint_setting = ":cpu",
+)
+
+constraint_value(
+ name = "cortex-r82",
+ constraint_setting = ":cpu",
+)
+
+constraint_value(
name = "i386",
constraint_setting = ":cpu",
)
@@ -61,6 +140,16 @@ constraint_value(
)
constraint_value(
+ name = "ppc32",
+ constraint_setting = ":cpu",
+)
+
+constraint_value(
+ name = "ppc64le",
+ constraint_setting = ":cpu",
+)
+
+constraint_value(
name = "s390x",
constraint_setting = ":cpu",
)
@@ -84,3 +173,18 @@ constraint_value(
name = "wasm64",
constraint_setting = ":cpu",
)
+
+constraint_value(
+ name = "mips64",
+ constraint_setting = ":cpu",
+)
+
+constraint_value(
+ name = "riscv32",
+ constraint_setting = ":cpu",
+)
+
+constraint_value(
+ name = "riscv64",
+ constraint_setting = ":cpu",
+)
diff --git a/distro/README.md b/distro/README.md
new file mode 100644
index 0000000..77fffd6
--- /dev/null
+++ b/distro/README.md
@@ -0,0 +1,47 @@
+# Updating bazelbuild/platforms
+
+WARNING: These are what worked last time. Reality might be different.
+
+## Step 1: Make the release
+
+- Pick a new version number
+- Update version.bzl
+- Run distro/makerel.sh
+- Go to the [Releases](https://github.com/bazelbuild/platforms/releases) page
+- Draft a new release
+ - Name the release with a version number
+ - Use the version number as the title
+ - Copy the description that makerel.sh produced to the description field.
+ - upload the generated tar file
+
+- use https://github.com/bazelbuild/continuous-integration/blob/HEAD/mirror/mirror.sh to mirror the file
+
+## Step 2: Update Bazel
+
+- Edit `distdir_deps.bzl`
+- Merge the PR
+
+Sample diff:
+
+```
+diff --git a/distdir_deps.bzl b/distdir_deps.bzl
+index ed49a563bc..1739a25c2a 100644
+--- a/distdir_deps.bzl
++++ b/distdir_deps.bzl
+@@ -20,11 +20,11 @@ DIST_DEPS = {
+ #
+ ########################################
+ "platforms": {
+- "archive": "platforms-0.0.2.tar.gz",
+- "sha256": "48a2d8d343863989c232843e01afc8a986eb8738766bfd8611420a7db8f6f0c3",
++ "archive": "platforms-0.0.3.tar.gz",
++ "sha256": "460caee0fa583b908c622913334ec3c1b842572b9c23cf0d3da0c2543a1a157d",
+ "urls": [
+- "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.2/platforms-0.0.2.tar.gz",
+- "https://github.com/bazelbuild/platforms/releases/download/0.0.2/platforms-0.0.2.tar.gz",
++ "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.3/platforms-0.0.3.tar.gz",
++ "https://github.com/bazelbuild/platforms/releases/download/0.0.3/platforms-0.0.3.tar.gz",
+ ],
+ "used_in": [
+ "additional_distfiles",
+```
diff --git a/distro/makerel.sh b/distro/makerel.sh
new file mode 100755
index 0000000..20c2f0b
--- /dev/null
+++ b/distro/makerel.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+if [[ ! -f WORKSPACE ]] ; then
+ echo 'You must run this command from the top of the workspace.'
+ exit 1
+fi
+
+if [[ ! -f version.bzl ]] ; then
+ version.bzl is missing.
+ exit 1
+fi
+version=$(sed -n -e 's/^version *= *"\(.*\)".*$/\1/p' version.bzl)
+
+# tar on macos builds a file with different checksums each time.
+if [[ $(uname) != 'Linux' ]] ; then
+ echo 'You must run this command from a linux machine.'
+ exit 1
+fi
+
+
+dist_file="/tmp/platforms-${version}.tar.gz"
+tar czf "$dist_file" BUILD LICENSE MODULE.bazel WORKSPACE WORKSPACE.bzlmod version.bzl cpu os
+sha256=$(shasum -a256 "$dist_file" | cut -d' ' -f1)
+
+path="github.com/bazelbuild/platforms/releases/download/$version/platforms-$version.tar.gz"
+cat <<INP
+
+
+1. Create a new release using the tag $version
+2. Copy/paste the text below into the release description field.
+3. Upload $dist_file as an artifact.
+4. Copy $dist_file to the mirror site.
+5. Create the release.
+6. Update Bazel distdir_deps.bzl to point to this new release. See the readme.
+
+=============== CUT HERE ===============
+**WORKSPACE setup**
+
+\`\`\`
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+http_archive(
+ name = "platforms",
+ urls = [
+ "https://mirror.bazel.build/${path}",
+ "https://${path}",
+ ],
+ sha256 = "$sha256",
+)
+\`\`\`
+=============== CUT HERE ===============
+
+Use this to update Bazel's distdir_deps.bzl
+
+
+ "archive": "platforms-$version.tar.gz",
+ "sha256": "$sha256",
+ "urls": [
+ "https://mirror.bazel.build/${path}",
+ "https://${path}",
+ ],
+
+Copy/paste this to mirror the file.
+
+ gsutil cp /tmp/platforms-$version.tar.gz "gs://bazel-mirror/${path}"
+ gsutil setmeta -h "Cache-Control: public, max-age=31536000" "gs://bazel-mirror/${path}"
+
+INP
diff --git a/os/BUILD b/os/BUILD
index 16525d3..ae6e8b0 100644
--- a/os/BUILD
+++ b/os/BUILD
@@ -19,11 +19,21 @@ constraint_value(
)
constraint_value(
+ name = "netbsd",
+ constraint_setting = ":os",
+)
+
+constraint_value(
name = "openbsd",
constraint_setting = ":os",
)
constraint_value(
+ name = "haiku",
+ constraint_setting = ":os",
+)
+
+constraint_value(
name = "android",
constraint_setting = ":os",
)
@@ -38,6 +48,12 @@ constraint_value(
constraint_setting = ":os",
)
+# For the VXworks OS, usefull for embedded systems
+constraint_value(
+ name = "vxworks",
+ constraint_setting = ":os",
+)
+
# For platforms with no OS, like microcontrollers.
constraint_value(
name = "none",
@@ -73,6 +89,11 @@ constraint_value(
)
constraint_value(
+ name = "visionos",
+ constraint_setting = ":os",
+)
+
+constraint_value(
name = "qnx",
constraint_setting = ":os",
)
@@ -84,3 +105,20 @@ constraint_value(
name = "nixos",
constraint_setting = ":os",
)
+
+# WASI (WebAssembly System Interface)
+# https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-overview.md
+constraint_value(
+ name = "wasi",
+ constraint_setting = ":os",
+)
+
+constraint_value(
+ name = "fuchsia",
+ constraint_setting = ":os",
+)
+
+constraint_value(
+ name = "chromiumos",
+ constraint_setting = ":os",
+)
diff --git a/tests/BUILD b/tests/BUILD
new file mode 100644
index 0000000..e0c7526
--- /dev/null
+++ b/tests/BUILD
@@ -0,0 +1,21 @@
+load("//:version.bzl", "version")
+
+package(default_visibility = ["//visibility:private"])
+
+# This is a quick hack to make sure that version.bzl agrees with MODULE.bazel
+# It only works from Linux, but that is sufficient, becuase we do a presubmit
+# run linux, so we will still catch a mismatch.
+genrule(
+ name = "versions_match",
+ outs = ["found_it"],
+ cmd = ";\n".join([
+ """echo version: %s""" % version,
+ """grep 'version = "%s",' $(location //:MODULE.bazel) >$(location :found_it)""" % version,
+ ]),
+ target_compatible_with = [
+ "//os:linux",
+ ],
+ tools = [
+ "//:MODULE.bazel",
+ ],
+)
diff --git a/version.bzl b/version.bzl
new file mode 100644
index 0000000..2068e00
--- /dev/null
+++ b/version.bzl
@@ -0,0 +1,16 @@
+# Copyright 2022 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""The version of bazelbuild/platforms."""
+
+version = "0.0.8"