Skip to content

Commit

Permalink
Use the idiomatic target_compatible_with attribute to select what pla…
Browse files Browse the repository at this point in the history
…tform to build for.

- Avoid building for Linux things that are not needed for Linux
- Remove bespoke tag ["ci-build-for-x86_64-unknown-none"]

BUG: 349778041
Change-Id: Ib66be7d7ab294d167582d0f99dcdc58005a8ef40
  • Loading branch information
ernoc committed Jul 3, 2024
1 parent d594cb5 commit cfb5a13
Show file tree
Hide file tree
Showing 22 changed files with 7,826 additions and 170 deletions.
33 changes: 33 additions & 0 deletions bazel/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,36 @@ RUST_VERSIONS = [
]

RUST_EDITION = "2021"

def either_platform(platform_list):
"""Helper to mark either platform from platform_list as compatible.
Generates a `select` expression to use with `target_compatible_with`
meaning that any of the platforms given is compatible.
Example:
```
target_compatible_with = either_platform([
"@platforms//os:linux",
"@platforms//os:none"
]),
```
is equivalent to:
```
target_compatible_with = select({
"@platforms//os:linux": ["@platforms//os:linux"],
"@platforms//os:none": ["@platforms//os:none"],
"//conditions:default": ["@platforms//:incompatible"],
}),
```
This is the idiomatic way to select one of several possible compatible
platforms as pointed out in
https://bazel.build/extending/platforms#expressive-constraints,
except we return the same OS string in the values (instead of `[]`), as
that is required for our cquery in just bazel-ci to work properly. If we
return `[]`, that query will include false positives, as all targets that
don't specify any value for `target_compatible_with` will default to `[]`.
"""
select_dict = {platform: [platform] for platform in platform_list}
select_dict["//conditions:default"] = ["@platforms//:incompatible"]
return select(select_dict)
97 changes: 85 additions & 12 deletions bazel/test_workspace/Cargo-test.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,17 @@ version = "7.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c24e9d990669fbd16806bff449e4ac644fd9b1fca014760087732fe4102f131"

[[package]]
name = "async-recursion"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
]

[[package]]
name = "async-stream"
version = "0.3.5"
Expand Down Expand Up @@ -524,31 +535,40 @@ dependencies = [

[[package]]
name = "clap"
version = "4.5.4"
version = "4.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0"
checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d"
dependencies = [
"clap_builder",
"clap_derive",
]

[[package]]
name = "clap_builder"
version = "4.5.2"
version = "4.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4"
checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]

[[package]]
name = "clap_complete"
version = "4.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d598e88f6874d4b888ed40c71efbcbf4076f1dfbae128a08a8c9e45f710605d"
dependencies = [
"clap",
]

[[package]]
name = "clap_derive"
version = "4.5.4"
version = "4.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64"
checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085"
dependencies = [
"heck 0.5.0",
"proc-macro2",
Expand Down Expand Up @@ -1004,6 +1024,12 @@ dependencies = [
"syn 2.0.66",
]

[[package]]
name = "diff"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"

[[package]]
name = "digest"
version = "0.10.7"
Expand All @@ -1027,6 +1053,7 @@ dependencies = [
"anyhow",
"arrayvec",
"assertables",
"async-recursion",
"async-stream",
"async-trait",
"atomic_refcell",
Expand All @@ -1035,8 +1062,10 @@ dependencies = [
"bitvec",
"bmrng",
"bytes",
"chrono",
"ciborium",
"clap",
"clap_complete",
"colored",
"command-fds",
"coset",
Expand All @@ -1056,6 +1085,7 @@ dependencies = [
"http 1.1.0",
"hyper",
"ignore",
"itertools 0.12.1",
"lazy_static",
"libloading",
"libm",
Expand All @@ -1076,7 +1106,9 @@ dependencies = [
"parking_lot",
"pkcs8",
"port_check",
"portpicker",
"pprof",
"pretty_assertions",
"primeorder",
"procfs",
"prost",
Expand Down Expand Up @@ -1105,6 +1137,7 @@ dependencies = [
"static_assertions",
"stderrlog",
"strum",
"strum_macros 0.25.3",
"subprocess",
"syn 2.0.66",
"syslog",
Expand All @@ -1116,6 +1149,7 @@ dependencies = [
"tokio-stream",
"tokio-util",
"tokio-vsock",
"toml",
"tonic",
"tonic-build",
"tonic-web",
Expand Down Expand Up @@ -2746,6 +2780,15 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2110609fb863cdb367d4e69d6c43c81ba6a8c7d18e80082fe9f3ef16b23afeed"

[[package]]
name = "portpicker"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be97d76faf1bfab666e1375477b23fde79eccf0276e9b63b92a39d676a889ba9"
dependencies = [
"rand",
]

[[package]]
name = "postcard"
version = "1.0.8"
Expand Down Expand Up @@ -2793,6 +2836,16 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"

[[package]]
name = "pretty_assertions"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66"
dependencies = [
"diff",
"yansi 0.5.1",
]

[[package]]
name = "prettyplease"
version = "0.2.20"
Expand Down Expand Up @@ -2855,7 +2908,7 @@ dependencies = [
"quote",
"syn 2.0.66",
"version_check",
"yansi",
"yansi 1.0.1",
]

[[package]]
Expand Down Expand Up @@ -3535,18 +3588,31 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"

[[package]]
name = "strum"
version = "0.26.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29"
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
dependencies = [
"strum_macros",
"strum_macros 0.24.3",
]

[[package]]
name = "strum_macros"
version = "0.26.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946"
checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
dependencies = [
"heck 0.4.1",
"proc-macro2",
"quote",
"rustversion",
"syn 1.0.109",
]

[[package]]
name = "strum_macros"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
dependencies = [
"heck 0.4.1",
"proc-macro2",
Expand Down Expand Up @@ -3796,6 +3862,7 @@ dependencies = [
"libc",
"mio",
"num_cpus",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
Expand Down Expand Up @@ -4920,6 +4987,12 @@ dependencies = [
"lzma-sys",
]

[[package]]
name = "yansi"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"

[[package]]
name = "yansi"
version = "1.0.1"
Expand Down
Loading

0 comments on commit cfb5a13

Please sign in to comment.