-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build) add bazel rules to build ngx-wasm-rs and ngx-rust
- Loading branch information
Showing
19 changed files
with
753 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
build --incompatible_enable_cc_toolchain_resolution | ||
|
||
common --color=yes | ||
common --curses=auto | ||
|
||
build --show_timestamps | ||
build --worker_verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Bazel build | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
# ignore markdown files (CHANGELOG.md, README.md, etc.) | ||
- '**/*.md' | ||
push: | ||
paths-ignore: | ||
# ignore markdown files (CHANGELOG.md, README.md, etc.) | ||
- '**/*.md' | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build | ||
run: bazel build :ngx_rust :ngx_wasm_rs_static :ngx_wasm_rs_shared --verbose_failures | ||
|
||
- name: Display artifacts | ||
run: ls -lh bazel-bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
load("@rules_rust//rust:defs.bzl", "rust_library") | ||
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") | ||
load("@ngx_rust_crate_index//:defs.bzl", ngx_rust_aliases = "aliases", ngx_rust_all_crate_deps = "all_crate_deps") | ||
load("@ngx_wasm_rs_crate_index//:defs.bzl", ngx_wasm_rs_aliases = "aliases", ngx_wasm_rs_all_crate_deps = "all_crate_deps") | ||
load("//build:deps.bzl", "normalize_name") | ||
load("//build:rust-nightly.bzl", "rust_shared_library_nightly", "rust_static_library_nightly") | ||
|
||
# --//:ngx-wasm-rust-feature-wat=false | ||
bool_flag( | ||
name = "ngx-wasm-rust-feature-wat", | ||
build_setting_default = False, | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
config_setting( | ||
name = "ngx-wasm-rust-feature-wat_flag", | ||
flag_values = { | ||
":ngx-wasm-rust-feature-wat": "true", | ||
}, | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
# ngx-rust | ||
|
||
filegroup( | ||
name = "ngx_rust_srcs", | ||
srcs = glob( | ||
include = ["lib/ngx-rust/**"], | ||
exclude = ["*.bazel"], | ||
), | ||
) | ||
|
||
rust_library( | ||
name = "ngx_rust", | ||
srcs = [":ngx_rust_srcs"], | ||
aliases = ngx_rust_aliases(), | ||
proc_macro_deps = ngx_rust_all_crate_deps( | ||
proc_macro = True, | ||
), | ||
visibility = ["//visibility:public"], | ||
deps = ngx_rust_all_crate_deps( | ||
normal = True, | ||
), | ||
) | ||
|
||
# ngx-wasm-rs deps | ||
|
||
# crate: the dependencies of the crate | ||
ngx_wasm_rs_deps = { | ||
"backtrace": ["c-api"], | ||
"c-api": [], | ||
"wat": ["c-api"], | ||
} | ||
|
||
[filegroup( | ||
name = "ngx_wasm_rs_deps_%s_srcs" % normalize_name(dep), | ||
srcs = glob( | ||
include = ["lib/ngx-wasm-rs/lib/%s/**" % dep], | ||
exclude = ["*.bazel"], | ||
), | ||
) for dep in ngx_wasm_rs_deps] | ||
|
||
[rust_library( | ||
name = "ngx_wasm_rs_deps_%s" % normalize_name(dep), | ||
srcs = [":ngx_wasm_rs_deps_%s_srcs" % normalize_name(dep)], | ||
aliases = ngx_wasm_rs_aliases() | { | ||
":ngx_wasm_rs_deps_%s" % normalize_name(d): "ngx_wasm_%s" % normalize_name(d) | ||
for d in ngx_wasm_rs_deps[dep] | ||
}, | ||
proc_macro_deps = ngx_wasm_rs_all_crate_deps( | ||
proc_macro = True, | ||
), | ||
deps = ngx_wasm_rs_all_crate_deps( | ||
normal = True, | ||
) + [":ngx_wasm_rs_deps_%s" % normalize_name(d) for d in ngx_wasm_rs_deps[dep]], | ||
) for dep in ngx_wasm_rs_deps] | ||
|
||
filegroup( | ||
name = "ngx_wasm_rs_srcs", | ||
srcs = glob( | ||
include = ["lib/ngx-wasm-rs/src/**"], | ||
exclude = ["*.bazel"], | ||
), | ||
) | ||
|
||
# ngx-wasm-rs | ||
|
||
rust_library_types = { | ||
"static": rust_static_library_nightly, | ||
"shared": rust_shared_library_nightly, | ||
} | ||
|
||
[rust_library_types[_type]( | ||
name = _type == "static" and "ngx_wasm_rs_" + _type or "ngx_wasm_rs", | ||
srcs = [":ngx_wasm_rs_srcs"], | ||
aliases = ngx_wasm_rs_aliases() | { | ||
":ngx_wasm_rs_deps_backtrace": "ngx_wasm_backtrace", | ||
} | select({ | ||
":ngx-wasm-rust-feature-wat_flag": { | ||
":ngx_wasm_rs_deps_wat": "ngx_wasm_wat", | ||
}, | ||
"//conditions:default": {}, | ||
}), | ||
proc_macro_deps = ngx_wasm_rs_all_crate_deps( | ||
proc_macro = True, | ||
), | ||
visibility = ["//visibility:public"], | ||
deps = ngx_wasm_rs_all_crate_deps( | ||
build = True, | ||
normal = True, | ||
) + [":ngx_wasm_rs_deps_backtrace"] + select({ | ||
":ngx-wasm-rust-feature-wat_flag": [":ngx_wasm_rs_deps_wat"], | ||
"//conditions:default": [], | ||
}), | ||
) for _type in rust_library_types] | ||
|
||
alias( | ||
name = "ngx_wasm_rs_shared", | ||
actual = ":ngx_wasm_rs", | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[workspace] | ||
|
||
members = [ | ||
"lib/ngx-rust", | ||
"t/lib/ngx-rust-tests", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
workspace(name = "ngx_wasm_module") | ||
|
||
load("//build:repos.bzl", "ngx_wasm_module_repositories") | ||
|
||
ngx_wasm_module_repositories() | ||
|
||
load("//build:deps.bzl", "ngx_wasm_module_dependencies") | ||
|
||
ngx_wasm_module_dependencies(cargo_home_isolated = False) # use system `$CARGO_HOME` to speed up builds | ||
|
||
load("//build:crates.bzl", "ngx_wasm_module_crates") | ||
|
||
ngx_wasm_module_crates() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package(default_visibility = ["//visibility:public"]) |
Oops, something went wrong.