Skip to content

Commit

Permalink
try using the releases of rules_rust
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake committed Sep 3, 2024
1 parent 5a24889 commit fff449c
Show file tree
Hide file tree
Showing 13 changed files with 508 additions and 26 deletions.
17 changes: 17 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,20 @@ envoy_python_dependencies()
load("//bazel:dependency_imports.bzl", "envoy_dependency_imports")

envoy_dependency_imports()

# TODO: move them inside proper macros under bazel/**
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")

crate_universe_dependencies()

load("@rules_rust//crate_universe:defs.bzl", "crates_repository")

crates_repository(
name = "dynamic_modules_rust_sdk_crate_index",
cargo_lockfile = "//source/extensions/dynamic_modules/sdk/rust:Cargo.lock",
manifests = ["//source/extensions/dynamic_modules/sdk/rust:Cargo.toml"],
)

load("@dynamic_modules_rust_sdk_crate_index//:defs.bzl", "crate_repositories")

crate_repositories()
6 changes: 3 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1466,9 +1466,9 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_desc = "Bazel rust rules (used by Wasm)",
project_url = "https://github.com/bazelbuild/rules_rust",
version = "0.35.0",
strip_prefix = "rules_rust-{version}",
sha256 = "3120c7aa3a146dfe6be8d5f23f4cf10af7d0f74a5aed8b94a818f88643bd24c3",
urls = ["https://github.com/bazelbuild/rules_rust/archive/{version}.tar.gz"],
sha256 = "d21c328b21f3c9ecfa4c1e92dd61ace63ff22603234067cf0fe495f75ac251ae",
# Note: rules_rust should point to the releases, not archive to avoid the hassle of bootstrapping in crate_universe.
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/{version}/rules_rust-v{version}.tar.gz"],
use_category = [
"controlplane",
"dataplane_core",
Expand Down
2 changes: 2 additions & 0 deletions source/extensions/dynamic_modules/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

This directory contains the SDKs for the Dynamic Modules feature. Each SDK passes the same set of tests and
is guaranteed to provide the same functionality.

Each SDK has a hard copy of the ABI header file in order for them to be able to compile off-tree. Rust and Go build system cannot handle symlinks.
20 changes: 20 additions & 0 deletions source/extensions/dynamic_modules/sdk/rust/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@dynamic_modules_rust_sdk_crate_index//:defs.bzl", "all_crate_deps")
load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_library")
load(
"//bazel:envoy_build_system.bzl",
Expand All @@ -6,10 +8,28 @@ load(

licenses(["notice"]) # Apache 2

exports_files(["abi.h"])

envoy_extension_package()

cargo_build_script(
name = "build_script",
srcs = ["build.rs"],
data = [
"abi.h",
],
edition = "2021",
deps = all_crate_deps(
build = True,
normal = True,
),
)

rust_library(
name = "envoy_proxy_dynamic_modules_rust_sdk",
srcs = glob(["src/**/*.rs"]),
edition = "2021",
deps = all_crate_deps(
normal = True,
) + [":build_script"],
)
Loading

0 comments on commit fff449c

Please sign in to comment.