Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make wee-alloc an optional feature. #38

Merged
merged 14 commits into from
Nov 4, 2020
20 changes: 20 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,21 @@ jobs:
RUSTFLAGS: -D warnings -C link-args=-S
run: cargo build --release --all-targets --target=wasm32-wasi

- name: Build (wasm32-wasi with wee-alloc)
env:
RUSTFLAGS: -D warnings -C link-args=-S
run: cargo build --release --all-targets --target=wasm32-wasi --features=wee-alloc

- name: Clippy (wasm32-wasi)
env:
RUSTFLAGS: -D warnings -C link-args=-S
run: cargo clippy --release --all-targets --target=wasm32-wasi

- name: Clippy (wasm32-wasi with wee-alloc))
Copy link
Member

Choose a reason for hiding this comment

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

Nit: )) -> )

env:
RUSTFLAGS: -D warnings -C link-args=-S
run: cargo clippy --release --all-targets --target=wasm32-wasi --features=wee-alloc

- name: Format (rustfmt)
run: cargo fmt -- --check

Expand Down Expand Up @@ -151,11 +161,21 @@ jobs:
RUSTFLAGS: -D warnings -C link-args=-S
run: cargo build --release --all-targets --target=wasm32-wasi

- name: Build (wasm32-wasi with wee-alloc)
env:
RUSTFLAGS: -D warnings -C link-args=-S
run: cargo build --release --all-targets --target=wasm32-wasi --features=wee-alloc

- name: Clippy (wasm32-wasi)
env:
RUSTFLAGS: -D warnings -C link-args=-S
run: cargo clippy --release --all-targets --target=wasm32-wasi

- name: Clippy (wasm32-wasi with wee-alloc))
Copy link
Member

Choose a reason for hiding this comment

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

Nit: )) -> )

env:
RUSTFLAGS: -D warnings -C link-args=-S
run: cargo clippy --release --all-targets --target=wasm32-wasi --features=wee-alloc

- name: Format (rustfmt)
run: cargo fmt -- --check

Expand Down
1 change: 0 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ rust_library(
deps = [
"//bazel/cargo:hashbrown",
"//bazel/cargo:log",
"//bazel/cargo:wee_alloc",
],
)
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ license = "Apache-2.0"
repository = "https://github.com/proxy-wasm/proxy-wasm-rust-sdk"
edition = "2018"

[features]
wee-alloc = ["wee_alloc"]

[dependencies]
hashbrown = "0.9"
log = "0.4"
wee_alloc = "0.4"
wee_alloc = { version = "0.4", optional = true }

[dev-dependencies]
chrono = "0.4"
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@

+ [Extending Envoy with WASM and Rust](https://antweiss.com/blog/extending-envoy-with-wasm-and-rust/)
+ [Extending Istio with Rust and WebAssembly](https://blog.red-badger.com/extending-istio-with-rust-and-webassembly)

# Updating dependencies

When updating dependencies, You need to regenerate `BUILD` files to match updated `Cargo.toml`:
Copy link
Member

Choose a reason for hiding this comment

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

Nit: s/You/you/

```
cargo install cargo-raze --version 0.3.8
rm -rf bazel/cargo/
cargo generate-lockfile
cargo raze --output=bazel/cargo
mv Cargo.lock bazel/cargo/
```
5 changes: 0 additions & 5 deletions bazel/cargo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,3 @@ alias(
actual = "@raze__log__0_4_11//:log",
tags = ["cargo-raze"],
)
alias(
name = "wee_alloc",
actual = "@raze__wee_alloc__0_4_5//:wee_alloc",
tags = ["cargo-raze"],
)
18 changes: 0 additions & 18 deletions bazel/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@ def raze_fetch_remote_crates():
build_file = Label("//bazel/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",
sha256 = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3",
strip_prefix = "memory_units-0.4.0",
build_file = Label("//bazel/cargo/remote:memory_units-0.4.0.BUILD"),
)

_new_http_archive(
name = "raze__num_integer__0_1_44",
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/num-integer/num-integer-0.1.44.crate",
Expand Down Expand Up @@ -124,15 +115,6 @@ def raze_fetch_remote_crates():
build_file = Label("//bazel/cargo/remote:wasi-0.10.0+wasi-snapshot-preview1.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",
sha256 = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e",
strip_prefix = "wee_alloc-0.4.5",
build_file = Label("//bazel/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",
Expand Down
43 changes: 0 additions & 43 deletions bazel/cargo/remote/memory_units-0.4.0.BUILD

This file was deleted.

48 changes: 0 additions & 48 deletions bazel/cargo/remote/wee_alloc-0.4.5.BUILD

This file was deleted.

3 changes: 0 additions & 3 deletions bazel/cargo/remote/winapi-0.3.9.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@ rust_library(
version = "0.3.9",
tags = ["cargo-raze"],
crate_features = [
"memoryapi",
"minwinbase",
"minwindef",
"ntdef",
"profileapi",
"std",
"synchapi",
"sysinfoapi",
"timezoneapi",
"winbase",
],
)

1 change: 1 addition & 0 deletions src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "wee-alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

Expand Down