Skip to content

Commit

Permalink
Add Bazel support. (yskopets#18)
Browse files Browse the repository at this point in the history
Signed-off-by: Shikugawa <Shikugawa@gmail.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
  • Loading branch information
PiotrSikora authored Aug 4, 2020
1 parent d0b574b commit fbea6e1
Show file tree
Hide file tree
Showing 27 changed files with 1,169 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Force Bazel to use --target=wasm32-unknown-unknown.
build --platforms=@io_bazel_rules_rust//rust/platform:wasm
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.4.1
39 changes: 39 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,42 @@ jobs:

- name: Package (publish)
run: cargo +nightly publish --dry-run --target=wasm32-unknown-unknown

bazel:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cache/bazel
~/.cache/bazelisk
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry
key: ${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'cargo/Cargo.lock') }}

- name: Build
run: |
bazelisk build //...
- name: Format (buildifier)
run: |
GO111MODULE=on go get -u github.com/bazelbuild/buildtools/buildifier@3.4.0
export PATH=$PATH:$(go env GOPATH)/bin
buildifier -mode=check WORKSPACE
buildifier -mode=check BUILD
buildifier -mode=check examples/BUILD
- name: Format (cargo raze)
run: |
cargo install cargo-raze --version 0.3.8
cp -p cargo/Cargo.lock .
rm -rf cargo/
cargo raze --output=cargo
mv Cargo.lock cargo/
git diff --exit-code
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/bazel-*
/target
Cargo.lock
/Cargo.lock
13 changes: 13 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library")

rust_library(
name = "proxy_wasm",
srcs = glob(["src/*.rs"]),
edition = "2018",
visibility = ["//visibility:public"],
deps = [
"//cargo:hashbrown",
"//cargo:log",
"//cargo:wee_alloc",
],
)
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ lto = true
opt-level = 3
panic = "abort"

[raze]
workspace_path = "//cargo"
target = "wasm32-unknown-unknown"
genmode = "Remote"

[raze.crates.log.'0.4.11']
additional_flags = ["--cfg=atomic_cas"]

[[example]]
name = "hello_world"
path = "examples/hello_world.rs"
Expand Down
37 changes: 37 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
workspace(name = "proxy_wasm_rust_sdk")

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

http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

http_archive(
name = "io_bazel_rules_rust",
sha256 = "484a2b2b67cd2d1fa1054876de7f8d291c4b203fd256bc8cbea14d749bb864ce",
# Last commit where "out_binary = True" works.
# See: https://github.com/bazelbuild/rules_rust/issues/386
strip_prefix = "rules_rust-fda9a1ce6482973adfda022cadbfa6b300e269c3",
url = "https://github.com/bazelbuild/rules_rust/archive/fda9a1ce6482973adfda022cadbfa6b300e269c3.tar.gz",
)

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

rust_repositories()

load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version")

bazel_version(name = "bazel_version")

load("//cargo:crates.bzl", "raze_fetch_remote_crates")

raze_fetch_remote_crates()
30 changes: 30 additions & 0 deletions cargo/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
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 = "chrono",
actual = "@raze__chrono__0_4_13//:chrono",
tags = ["cargo-raze"],
)
alias(
name = "hashbrown",
actual = "@raze__hashbrown__0_7_2//:hashbrown",
tags = ["cargo-raze"],
)
alias(
name = "log",
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"],
)
134 changes: 134 additions & 0 deletions cargo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fbea6e1

Please sign in to comment.