Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Porting to build Rust wasm test datas with Bazel #613

Merged
merged 22 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions bazel/crates.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
"""
cargo-raze crate workspace functions

DO NOT EDIT! Replaced on runs of cargo-raze
"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")

def _new_http_archive(name, **kwargs):
if not native.existing_rule(name):
http_archive(name = name, **kwargs)

def _new_git_repository(name, **kwargs):
if not native.existing_rule(name):
new_git_repository(name = name, **kwargs)

def raze_fetch_remote_crates():
_new_http_archive(
name = "raze__ahash__0_3_8",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/ahash/ahash-0.3.8.crate",
type = "tar.gz",
strip_prefix = "ahash-0.3.8",
build_file = Label("//bazel/external/cargo/remote:ahash-0.3.8.BUILD"),
)

_new_http_archive(
name = "raze__autocfg__1_0_0",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/autocfg/autocfg-1.0.0.crate",
type = "tar.gz",
strip_prefix = "autocfg-1.0.0",
build_file = Label("//bazel/external/cargo/remote:autocfg-1.0.0.BUILD"),
)

_new_http_archive(
name = "raze__cfg_if__0_1_10",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/cfg-if/cfg-if-0.1.10.crate",
type = "tar.gz",
strip_prefix = "cfg-if-0.1.10",
build_file = Label("//bazel/external/cargo/remote:cfg-if-0.1.10.BUILD"),
)

_new_http_archive(
name = "raze__hashbrown__0_7_2",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/hashbrown/hashbrown-0.7.2.crate",
type = "tar.gz",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all very similar, can you create a _rust_crate(..) macro that factors out all the boilerplate? it should be possible to have just _rust_crate(name="hashbrown", version="0.7.2") and it can fill the rest I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are all automatically generated by cargo raze tool, using macros here would turn this into manual work.

strip_prefix = "hashbrown-0.7.2",
build_file = Label("//bazel/external/cargo/remote:hashbrown-0.7.2.BUILD"),
)

_new_http_archive(
name = "raze__libc__0_2_74",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/libc/libc-0.2.74.crate",
type = "tar.gz",
strip_prefix = "libc-0.2.74",
build_file = Label("//bazel/external/cargo/remote:libc-0.2.74.BUILD"),
)

_new_http_archive(
name = "raze__log__0_4_11",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/log/log-0.4.11.crate",
type = "tar.gz",
strip_prefix = "log-0.4.11",
build_file = Label("//bazel/external/cargo/remote:log-0.4.11.BUILD"),
)

_new_http_archive(
name = "raze__memory_units__0_4_0",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/memory_units/memory_units-0.4.0.crate",
type = "tar.gz",
strip_prefix = "memory_units-0.4.0",
build_file = Label("//bazel/external/cargo/remote:memory_units-0.4.0.BUILD"),
)

_new_http_archive(
name = "raze__proxy_wasm__0_1_2",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/proxy-wasm/proxy-wasm-0.1.2.crate",
type = "tar.gz",
strip_prefix = "proxy-wasm-0.1.2",
build_file = Label("//bazel/external/cargo/remote:proxy-wasm-0.1.2.BUILD"),
)

_new_http_archive(
name = "raze__wee_alloc__0_4_5",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/wee_alloc/wee_alloc-0.4.5.crate",
type = "tar.gz",
strip_prefix = "wee_alloc-0.4.5",
build_file = Label("//bazel/external/cargo/remote:wee_alloc-0.4.5.BUILD"),
)

_new_http_archive(
name = "raze__winapi__0_3_9",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/winapi/winapi-0.3.9.crate",
type = "tar.gz",
strip_prefix = "winapi-0.3.9",
build_file = Label("//bazel/external/cargo/remote:winapi-0.3.9.BUILD"),
)

_new_http_archive(
name = "raze__winapi_i686_pc_windows_gnu__0_4_0",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/winapi-i686-pc-windows-gnu/winapi-i686-pc-windows-gnu-0.4.0.crate",
type = "tar.gz",
strip_prefix = "winapi-i686-pc-windows-gnu-0.4.0",
build_file = Label("//bazel/external/cargo/remote:winapi-i686-pc-windows-gnu-0.4.0.BUILD"),
)

_new_http_archive(
name = "raze__winapi_x86_64_pc_windows_gnu__0_4_0",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/winapi-x86_64-pc-windows-gnu/winapi-x86_64-pc-windows-gnu-0.4.0.crate",
type = "tar.gz",
strip_prefix = "winapi-x86_64-pc-windows-gnu-0.4.0",
build_file = Label("//bazel/external/cargo/remote:winapi-x86_64-pc-windows-gnu-0.4.0.BUILD"),
)
23 changes: 23 additions & 0 deletions bazel/external/cargo/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
cargo-raze workspace build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

package(default_visibility = ["//visibility:public"])

licenses([
"notice", # See individual crates for specific licenses
])

alias(
name = "log",
actual = "@raze__log__0_4_11//:log",
tags = ["cargo-raze"],
)

alias(
name = "proxy_wasm",
actual = "@raze__proxy_wasm__0_1_2//:proxy_wasm",
tags = ["cargo-raze"],
)
Empty file.
46 changes: 46 additions & 0 deletions bazel/external/cargo/remote/ahash-0.3.8.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the plan to check all of this into the main Envoy repo? Seems kind of terrifying from a maintenance perspective, even if automatically generated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. But maintaining these automatically generated is not inevitable. I think that we should force to use this. And warn to use this script by DO NOT EDIT comment by inserting that "We must use tools/cargo-raze.sh".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, automatically generate with cargo-raze.sh from pre-push script by checking the Cargo.toml had staged or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meanwhile, yes, eventually I think it can made into rules_rust to generate WORKSPACE rule, just like rules_python's pip3_import.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely want a tracking issue for this one, since this is a lot of boilerplate that we should be able to minimize. But I'd be willing to take it as MVP.

cargo-raze crate build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

load(
"@io_bazel_rules_rust//rust:rust.bzl",
"rust_library",
)

package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//bazel/external/cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])

licenses([
"notice", # MIT from expression "MIT OR Apache-2.0"
])

# Unsupported target "ahash" with type "bench" omitted

rust_library(
name = "ahash",
srcs = glob(["**/*.rs"]),
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "lib",
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
tags = ["cargo-raze"],
version = "0.3.8",
deps = [
],
)

# Unsupported target "bench" with type "test" omitted
# Unsupported target "map" with type "bench" omitted
# Unsupported target "map_tests" with type "test" omitted
# Unsupported target "nopanic" with type "test" omitted
45 changes: 45 additions & 0 deletions bazel/external/cargo/remote/autocfg-1.0.0.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
cargo-raze crate build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

load(
"@io_bazel_rules_rust//rust:rust.bzl",
"rust_library",
)

package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//bazel/external/cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])

licenses([
"notice", # Apache-2.0 from expression "Apache-2.0 OR MIT"
])

rust_library(
name = "autocfg",
srcs = glob(["**/*.rs"]),
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "lib",
edition = "2015",
rustc_flags = [
"--cap-lints=allow",
],
tags = ["cargo-raze"],
version = "1.0.0",
deps = [
],
)

# Unsupported target "integers" with type "example" omitted
# Unsupported target "paths" with type "example" omitted
# Unsupported target "rustflags" with type "test" omitted
# Unsupported target "traits" with type "example" omitted
# Unsupported target "versions" with type "example" omitted
41 changes: 41 additions & 0 deletions bazel/external/cargo/remote/cfg-if-0.1.10.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
cargo-raze crate build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

load(
"@io_bazel_rules_rust//rust:rust.bzl",
"rust_library",
)

package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//bazel/external/cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])

licenses([
"notice", # MIT from expression "MIT OR Apache-2.0"
])

rust_library(
name = "cfg_if",
srcs = glob(["**/*.rs"]),
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "lib",
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
tags = ["cargo-raze"],
version = "0.1.10",
deps = [
],
)

# Unsupported target "xcrate" with type "test" omitted
50 changes: 50 additions & 0 deletions bazel/external/cargo/remote/hashbrown-0.7.2.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
cargo-raze crate build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

load(
"@io_bazel_rules_rust//rust:rust.bzl",
"rust_library",
)

package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//bazel/external/cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])

licenses([
"notice", # Apache-2.0 from expression "Apache-2.0 OR MIT"
])

# Unsupported target "bench" with type "bench" omitted
# Unsupported target "build-script-build" with type "custom-build" omitted

rust_library(
name = "hashbrown",
srcs = glob(["**/*.rs"]),
crate_features = [
"ahash",
"inline-more",
],
crate_root = "src/lib.rs",
crate_type = "lib",
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
tags = ["cargo-raze"],
version = "0.7.2",
deps = [
"@raze__ahash__0_3_8//:ahash",
],
)

# Unsupported target "hasher" with type "test" omitted
# Unsupported target "rayon" with type "test" omitted
# Unsupported target "serde" with type "test" omitted
# Unsupported target "set" with type "test" omitted
42 changes: 42 additions & 0 deletions bazel/external/cargo/remote/libc-0.2.74.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
cargo-raze crate build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

load(
"@io_bazel_rules_rust//rust:rust.bzl",
"rust_library",
)

package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//bazel/external/cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])

licenses([
"notice", # MIT from expression "MIT OR Apache-2.0"
])

# Unsupported target "build-script-build" with type "custom-build" omitted
# Unsupported target "const_fn" with type "test" omitted

rust_library(
name = "libc",
srcs = glob(["**/*.rs"]),
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "lib",
edition = "2015",
rustc_flags = [
"--cap-lints=allow",
],
tags = ["cargo-raze"],
version = "0.2.74",
deps = [
],
)
Loading