Skip to content

Commit

Permalink
Add CI support for building wasm targets by declaring target_compatib…
Browse files Browse the repository at this point in the history
…le_with.

- More precise settings to specify one of our 3 target platforms: x86_64 on linux, x86_64 on bare metal, wasm32 on bare metal.
- Added wasm query and building to `just bazel-ci` command

BUG: 349778041
Change-Id: I1b97e40f81d6a9c09fa29b76e2874ae840fa6f11
  • Loading branch information
ernoc committed Jul 5, 2024
1 parent 07be522 commit b905b06
Show file tree
Hide file tree
Showing 23 changed files with 578 additions and 223 deletions.
31 changes: 31 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# loaded by `rules_docker`:
# https://github.com/bazelbuild/bazel-gazelle/issues/609

load("@bazel_skylib//lib:selects.bzl", "selects")

package(
default_visibility = ["//visibility:public"],
licenses = ["notice"],
Expand Down Expand Up @@ -66,6 +68,35 @@ platform(
],
)

# To mark targets to build for x86_64 on bare metal, use this setting.
# This way you can exclude your target from being built for
# wasm on bare metal or for x86_64 on Linux.
selects.config_setting_group(
name = "x86_64-none-setting",
match_all = [
"@platforms//cpu:x86_64",
"@platforms//os:none",
],
)

# Same as previous setting, but for wasm on bare metal.
selects.config_setting_group(
name = "wasm32-none-setting",
match_all = [
"@platforms//cpu:wasm32",
"@platforms//os:none",
],
)

# Same as previous setting, but for x86_64 on Linux.
selects.config_setting_group(
name = "x86_64-linux-setting",
match_all = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
)

filegroup(
name = "clang_tidy_config",
srcs = [".clang-tidy"],
Expand Down
8 changes: 4 additions & 4 deletions bazel/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ def either_platform(platform_list):
Example:
```
target_compatible_with = either_platform([
"@platforms//os:linux",
"@platforms//os:none"
"//:x86_64-linux-setting",
"//:x86_64-none-setting"
]),
```
is equivalent to:
```
target_compatible_with = select({
"@platforms//os:linux": ["@platforms//os:linux"],
"@platforms//os:none": ["@platforms//os:none"],
"//:x86_64-linux-setting": ["//:x86_64-linux-setting"],
"//:x86_64-none-setting": ["//:x86_64-none-setting"],
"//conditions:default": ["@platforms//:incompatible"],
}),
```
Expand Down
118 changes: 84 additions & 34 deletions bazel/test_workspace/Cargo-test.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"

[[package]]
name = "cfg_aliases"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"

[[package]]
name = "chacha20"
version = "0.9.1"
Expand Down Expand Up @@ -826,6 +820,15 @@ dependencies = [
"itertools 0.10.5",
]

[[package]]
name = "crossbeam-channel"
version = "0.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2"
dependencies = [
"crossbeam-utils",
]

[[package]]
name = "crossbeam-deque"
version = "0.8.5"
Expand Down Expand Up @@ -1093,13 +1096,13 @@ dependencies = [
"lock_api",
"log",
"maplit",
"nix 0.29.0",
"nix 0.27.1",
"oci-spec",
"once_cell",
"opentelemetry",
"opentelemetry 0.22.0",
"opentelemetry-otlp",
"opentelemetry-proto",
"opentelemetry_sdk",
"opentelemetry-proto 0.6.0",
"opentelemetry_sdk 0.22.1",
"ouroboros",
"p256",
"p384",
Expand Down Expand Up @@ -2311,23 +2314,11 @@ checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
dependencies = [
"bitflags 2.5.0",
"cfg-if",
"cfg_aliases 0.1.1",
"cfg_aliases",
"libc",
"memoffset",
]

[[package]]
name = "nix"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
"bitflags 2.5.0",
"cfg-if",
"cfg_aliases 0.2.1",
"libc",
]

[[package]]
name = "num-bigint-dig"
version = "0.8.4"
Expand Down Expand Up @@ -2463,6 +2454,21 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"

[[package]]
name = "opentelemetry"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900d57987be3f2aeb70d385fff9b27fb74c5723cc9a52d904d4f9c807a0667bf"
dependencies = [
"futures-core",
"futures-sink",
"js-sys",
"once_cell",
"pin-project-lite",
"thiserror",
"urlencoding",
]

[[package]]
name = "opentelemetry"
version = "0.23.0"
Expand All @@ -2479,48 +2485,67 @@ dependencies = [

[[package]]
name = "opentelemetry-otlp"
version = "0.16.0"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a94c69209c05319cdf7460c6d4c055ed102be242a0a6245835d7bc42c6ec7f54"
checksum = "1a016b8d9495c639af2145ac22387dcb88e44118e45320d9238fbf4e7889abcb"
dependencies = [
"async-trait",
"futures-core",
"http 0.2.12",
"opentelemetry",
"opentelemetry-proto",
"opentelemetry_sdk",
"opentelemetry 0.22.0",
"opentelemetry-proto 0.5.0",
"opentelemetry-semantic-conventions",
"opentelemetry_sdk 0.22.1",
"prost",
"thiserror",
"tokio",
"tonic",
]

[[package]]
name = "opentelemetry-proto"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a8fddc9b68f5b80dae9d6f510b88e02396f006ad48cac349411fbecc80caae4"
dependencies = [
"opentelemetry 0.22.0",
"opentelemetry_sdk 0.22.1",
"prost",
"tonic",
]

[[package]]
name = "opentelemetry-proto"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "984806e6cf27f2b49282e2a05e288f30594f3dbc74eb7a6e99422bc48ed78162"
dependencies = [
"opentelemetry",
"opentelemetry_sdk",
"opentelemetry 0.23.0",
"opentelemetry_sdk 0.23.0",
"prost",
"tonic",
]

[[package]]
name = "opentelemetry-semantic-conventions"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9ab5bd6c42fb9349dcf28af2ba9a0667f697f9bdcca045d39f2cec5543e2910"

[[package]]
name = "opentelemetry_sdk"
version = "0.23.0"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd"
checksum = "9e90c7113be649e31e9a0f8b5ee24ed7a16923b322c3c5ab6367469c049d6b7e"
dependencies = [
"async-trait",
"crossbeam-channel",
"futures-channel",
"futures-executor",
"futures-util",
"glob",
"lazy_static",
"once_cell",
"opentelemetry",
"opentelemetry 0.22.0",
"ordered-float",
"percent-encoding",
"rand",
Expand All @@ -2530,6 +2555,25 @@ dependencies = [
"tokio-stream",
]

[[package]]
name = "opentelemetry_sdk"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd"
dependencies = [
"async-trait",
"futures-channel",
"futures-executor",
"futures-util",
"glob",
"lazy_static",
"once_cell",
"opentelemetry 0.23.0",
"ordered-float",
"serde_json",
"thiserror",
]

[[package]]
name = "ordered-float"
version = "4.2.0"
Expand Down Expand Up @@ -4184,6 +4228,12 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"

[[package]]
name = "urlencoding"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"

[[package]]
name = "utf8parse"
version = "0.2.1"
Expand Down
Loading

0 comments on commit b905b06

Please sign in to comment.