diff --git a/.bazelci/misc.yml b/.bazelci/misc.yml index 836cbc4b2..5d10d9f8a 100644 --- a/.bazelci/misc.yml +++ b/.bazelci/misc.yml @@ -31,13 +31,13 @@ tasks: - "//:tests" third-party-dependencies-linux: name: "Example with third party dependencies" - platform: ubuntu1804 + platform: ubuntu2204 working_directory: ../third-party-dependencies build_targets: - "..." third-party-dependencies-macos: name: "Example with third party dependencies" - platform: macos + platform: macos_arm64 working_directory: ../third-party-dependencies build_targets: - "..." diff --git a/java-maven/.bazelversion b/java-maven/.bazelversion index a3fcc7121..c6b7980b6 100644 --- a/java-maven/.bazelversion +++ b/java-maven/.bazelversion @@ -1 +1 @@ -7.1.0 +8.x diff --git a/java-maven/MODULE.bazel b/java-maven/MODULE.bazel index 20da45c13..98b47093d 100644 --- a/java-maven/MODULE.bazel +++ b/java-maven/MODULE.bazel @@ -1,9 +1,9 @@ "Bazel dependencies" -bazel_dep(name = "aspect_bazel_lib", version = "2.8.1") -bazel_dep(name = "container_structure_test", version = "1.16.0") -bazel_dep(name = "rules_jvm_external", version = "5.3") -bazel_dep(name = "rules_oci", version = "1.4.0") +bazel_dep(name = "aspect_bazel_lib", version = "2.21.2") +bazel_dep(name = "container_structure_test", version = "1.19.1") +bazel_dep(name = "rules_jvm_external", version = "6.8") +bazel_dep(name = "rules_oci", version = "2.2.6") bazel_dep(name = "rules_java", version = "7.11.1") maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") diff --git a/rust-examples/01-hello-world/MODULE.bazel b/rust-examples/01-hello-world/MODULE.bazel index 578152954..53f685cf8 100644 --- a/rust-examples/01-hello-world/MODULE.bazel +++ b/rust-examples/01-hello-world/MODULE.bazel @@ -4,7 +4,7 @@ module( ) # https://github.com/bazelbuild/rules_rust/releases -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") # Rust toolchain RUST_EDITION = "2021" # NOTE: 2024 edition will be released with Rust 1.85.0 diff --git a/rust-examples/02-hello-cross/MODULE.bazel b/rust-examples/02-hello-cross/MODULE.bazel index ae0b93c12..4f746ec2b 100644 --- a/rust-examples/02-hello-cross/MODULE.bazel +++ b/rust-examples/02-hello-cross/MODULE.bazel @@ -6,7 +6,7 @@ module( ############################################################################### # B A Z E L D E P E N D E N C I E S # https://registry.bazel.build/ ############################################################################### -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") bazel_dep(name = "platforms", version = "0.0.11") bazel_dep(name = "toolchains_llvm", version = "1.2.0", dev_dependency = True) diff --git a/rust-examples/03-comp-opt/MODULE.bazel b/rust-examples/03-comp-opt/MODULE.bazel index 7081371b6..bc6f47ec8 100644 --- a/rust-examples/03-comp-opt/MODULE.bazel +++ b/rust-examples/03-comp-opt/MODULE.bazel @@ -4,7 +4,7 @@ module( ) # https://github.com/bazelbuild/rules_rust/releases -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") RUST_EDITION = "2021" # NOTE: 2024 will be released with Rust 1.86.0 diff --git a/rust-examples/04-ffi/MODULE.bazel b/rust-examples/04-ffi/MODULE.bazel index 9b4647ebe..b924e4fcb 100644 --- a/rust-examples/04-ffi/MODULE.bazel +++ b/rust-examples/04-ffi/MODULE.bazel @@ -4,7 +4,7 @@ module( ) # https://github.com/bazelbuild/rules_rust/releases -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") bazel_dep(name = "rules_cc", version = "0.0.9") # Rust toolchain diff --git a/rust-examples/05-deps-cargo/MODULE.bazel b/rust-examples/05-deps-cargo/MODULE.bazel index f1821ec27..c3a2082be 100644 --- a/rust-examples/05-deps-cargo/MODULE.bazel +++ b/rust-examples/05-deps-cargo/MODULE.bazel @@ -4,7 +4,7 @@ module( ) # https://github.com/bazelbuild/rules_rust/releases -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") bazel_dep(name = "bazel_skylib", version = "1.7.1") # Rust toolchain diff --git a/rust-examples/06-deps-direct/MODULE.bazel b/rust-examples/06-deps-direct/MODULE.bazel index 4dd753541..d88dd3bfb 100644 --- a/rust-examples/06-deps-direct/MODULE.bazel +++ b/rust-examples/06-deps-direct/MODULE.bazel @@ -4,7 +4,7 @@ module( ) # https://github.com/bazelbuild/rules_rust/releases -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") # Rust toolchain RUST_EDITION = "2021" diff --git a/rust-examples/07-deps-vendor/MODULE.bazel b/rust-examples/07-deps-vendor/MODULE.bazel index 9f3aca617..b1fabdb80 100644 --- a/rust-examples/07-deps-vendor/MODULE.bazel +++ b/rust-examples/07-deps-vendor/MODULE.bazel @@ -4,7 +4,7 @@ module( ) # https://github.com/bazelbuild/rules_rust/releases -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") # Rust toolchain RUST_EDITION = "2021" # NOTE: 2024 edition will be released with Rust 1.85.0 diff --git a/rust-examples/07-deps-vendor/README.md b/rust-examples/07-deps-vendor/README.md index 7e92879b3..aa6945081 100644 --- a/rust-examples/07-deps-vendor/README.md +++ b/rust-examples/07-deps-vendor/README.md @@ -1,8 +1,8 @@ # Vendored Rust Dependencies -This example shows how to vendor Rust dependencies and use those vendored dependencies -in a binary target. - +This example shows how to vendor Rust dependencies and use those vendored dependencies +in a binary target. + Before you can run the example, you must vendor all dependencies. You can do this as follows: ` @@ -19,8 +19,8 @@ If you ever see an error stating: ```text no such package 'thirdparty/crates': -BUILD file not found in any of the following directories. -``` +BUILD file not found in any of the following directories. +``` Just run: @@ -31,7 +31,7 @@ And then build again; the build will succeed. ## Setup For the setup, you just add rules_rust as usual. Note, you do not declare any dependencies -or crate_universe at this stage. +or crate_universe at this stage. ```starlark module( @@ -40,7 +40,7 @@ module( ) # https://github.com/bazelbuild/rules_rust/releases -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") # Rust toolchain RUST_EDITION = "2021" # NOTE: 2024 edition will be released with Rust 1.85.0 @@ -60,23 +60,23 @@ register_toolchains("@rust_toolchains//:all") ``` -The vendor folder name can be arbitrary, but by convention, its either thirdparty or 3rdparty to indicate vendored dependencies. Also note, you can structure any number of sub-folders in the vendor folder for example. Note, in that case, each sub-folder must have a `BUILD.bazel` file that declares its vendored dependencies. +The vendor folder name can be arbitrary, but by convention, its either thirdparty or 3rdparty to indicate vendored dependencies. Also note, you can structure any number of sub-folders in the vendor folder for example. Note, in that case, each sub-folder must have a `BUILD.bazel` file that declares its vendored dependencies. ```starlark basic thirdparty ├── common │ ├── tokio - │ ├── warp + │ ├── warp ├── sys │ ├── bzip2 ├── macros - │ ├── sys + │ ├── sys ``` - -In this example, the vendor folder is named thirdparty and you add a `BUILD.bazel` to declare your dependencies, for example: + +In this example, the vendor folder is named thirdparty and you add a `BUILD.bazel` to declare your dependencies, for example: ```starlark load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_vendor") @@ -103,13 +103,13 @@ crates_vendor( ) ``` -Then you run `bazel run //thirdparty:crates_vendor` which then downloads all the dependencies and creates the folder `thirdparty/crates`. +Then you run `bazel run //thirdparty:crates_vendor` which then downloads all the dependencies and creates the folder `thirdparty/crates`. **Important:** By default, vendoring does not pin versions defined in crate.spec, which means if you were to declare a Tokio version 1.40 and a newer Tokio version 1.44 is already available, the newer version will be used without notifying you. -You can pin versions by using a `=` prefix in the `version` field, for example: `version = "=1.44.0"`. Only then rules_rust +You can pin versions by using a `=` prefix in the `version` field, for example: `version = "=1.44.0"`. Only then rules_rust will use the exact version you have declared. @@ -117,17 +117,17 @@ At this point, you have the following folder and files: ```starlark basic thirdparty - ├── crates/ + ├── crates/ ├── BUILD.bazel ``` Bazel generated a bunch of files and folder in the crates folder. For the most part, you just run a build and when it completes, you then just check these vendored dependencies into git to ensure -all subsequent and CI build use the exact same dependencies. +all subsequent and CI build use the exact same dependencies. ## Usage -Suppose you have an application in `basic/src` that is defined in `basic/BUILD.bazel` and +Suppose you have an application in `basic/src` that is defined in `basic/BUILD.bazel` and that depends on a vendored dependency. You find a list of all available vendored dependencies in the BUILD file of the generated folder: `basic/3rdparty/crates/BUILD.bazel` You declare a vendored dependency in you target as following: @@ -135,7 +135,7 @@ You declare a vendored dependency in you target as following: **Important:** -The vendor script crates two aliases, one without version number and one with version number. +The vendor script crates two aliases, one without version number and one with version number. It is generally recommended to use the alias without version number unless you have a specific reason to pin a specific crate version. @@ -147,8 +147,8 @@ rust_binary( srcs = ["src/main.rs"], visibility = ["//visibility:public"], deps = [ - "//thirdparty/crates:tokio", # Generally recommended to use the alis without version since mature crates rarely break. - # "//thirdparty/crates:tokio-1.43.0", # Uncomment the the versioned alias if you have to pin the exact crate version. + "//thirdparty/crates:tokio", # Generally recommended to use the alis without version since mature crates rarely break. + # "//thirdparty/crates:tokio-1.43.0", # Uncomment the the versioned alias if you have to pin the exact crate version. ], ) ``` diff --git a/rust-examples/08-grpc-client-server/MODULE.bazel b/rust-examples/08-grpc-client-server/MODULE.bazel index d45c07da2..a081ce419 100644 --- a/rust-examples/08-grpc-client-server/MODULE.bazel +++ b/rust-examples/08-grpc-client-server/MODULE.bazel @@ -8,8 +8,8 @@ module( # https://registry.bazel.build/ ############################################################################### bazel_dep(name = "bazel_skylib", version = "1.7.1") -bazel_dep(name = "rules_rust", version = "0.57.1") -bazel_dep(name = "rules_rust_prost", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") +bazel_dep(name = "rules_rust_prost", version = "0.65.0") bazel_dep(name = "rules_proto", version = "7.1.0") # Toolchains diff --git a/rust-examples/08-grpc-client-server/README.md b/rust-examples/08-grpc-client-server/README.md index 1d469279b..3e382eb35 100644 --- a/rust-examples/08-grpc-client-server/README.md +++ b/rust-examples/08-grpc-client-server/README.md @@ -34,18 +34,18 @@ See the compiler [optimization example](../03-comp-opt) for configuration detail ## Setup -The Prost and Tonic rules do not specify a default toolchain in order to avoid mismatched dependency issues. +The Prost and Tonic rules do not specify a default toolchain in order to avoid mismatched dependency issues. While the Tonic toolchain works out of the box when its dependencies are matched, however, Prost requires a custom toolchain that you have to define. -The setup requires three steps to complete: -1. Configure rules and dependencies +The setup requires three steps to complete: +1. Configure rules and dependencies 2. Configure a custom Prost toolchain 3. Register custom Prost toolchain. -To keep the build hermetic, we use the LLVM Clang compiler to compile all C/C++ dependencies. +To keep the build hermetic, we use the LLVM Clang compiler to compile all C/C++ dependencies. -### 1) Configure rules +### 1) Configure rules ### Rules @@ -55,7 +55,7 @@ In your MODULE.bazel, you add the following: # rules for proto ############################################################################### bazel_dep(name = "bazel_skylib", version = "1.7.1") -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") bazel_dep(name = "rules_rust_prost", version = "0.57.1") bazel_dep(name = "rules_proto", version = "7.1.0") @@ -107,7 +107,7 @@ register_toolchains("@rust_toolchains//:all") # Custom Rust Prost toolchain register_toolchains("@//build/prost_toolchain") -# Rust dependencies. See thirdparty/BUILD.bazel +# Rust dependencies. See thirdparty/BUILD.bazel ``` Pay attention to the path, `build/prost_toolchain` because if your custom prost toolchain @@ -118,7 +118,7 @@ is in a different folder, you have to update this path to make the build work. This example uses [direct dependencies]( https://bazelbuild.github.io/rules_rust/crate_universe_bzlmod.html#direct-dependencies), so you add the following to your MODULE.bazel file: Notice the crate annotations are required for tonic and prost and -are later used in the toolchain setup. +are later used in the toolchain setup. ```starlark crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate") diff --git a/rust-examples/09-oci-container/MODULE.bazel b/rust-examples/09-oci-container/MODULE.bazel index 6a3a31e75..5e1d2fcc9 100644 --- a/rust-examples/09-oci-container/MODULE.bazel +++ b/rust-examples/09-oci-container/MODULE.bazel @@ -7,7 +7,7 @@ module( # Bazel Dependencies # https://registry.bazel.build/ ############################################################################### -bazel_dep(name = "rules_rust", version = "0.57.1") +bazel_dep(name = "rules_rust", version = "0.65.0") bazel_dep(name = "rules_oci", version = "2.2.1") bazel_dep(name = "rules_pkg", version = "1.0.1") diff --git a/third-party-dependencies/.bazelrc b/third-party-dependencies/.bazelrc deleted file mode 100644 index 1c1191021..000000000 --- a/third-party-dependencies/.bazelrc +++ /dev/null @@ -1 +0,0 @@ -common --cxxopt=-std=c++14 \ No newline at end of file diff --git a/third-party-dependencies/.bazelversion b/third-party-dependencies/.bazelversion index f22d756da..35907cd9c 100644 --- a/third-party-dependencies/.bazelversion +++ b/third-party-dependencies/.bazelversion @@ -1 +1 @@ -6.5.0 +7.x diff --git a/third-party-dependencies/MODULE.bazel b/third-party-dependencies/MODULE.bazel index 7ab2a205b..26efe6505 100644 --- a/third-party-dependencies/MODULE.bazel +++ b/third-party-dependencies/MODULE.bazel @@ -2,6 +2,6 @@ bazel_dep(name = "buildifier_prebuilt", version = "6.3.3", dev_dependency = True) -bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "rules_cc", version = "0.2.8") bazel_dep(name = "catch2", version = "3.4.0") -bazel_dep(name = "googletest", version = "1.14.0", repo_name = "gtest") +bazel_dep(name = "googletest", version = "1.17.0", repo_name = "gtest")