Skip to content

Make Bazel rules usable in different workspaces. #171

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

Merged
merged 5 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
127 changes: 89 additions & 38 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,89 +12,140 @@ licenses(["notice"]) # Apache 2
package(default_visibility = ["//visibility:public"])

cc_library(
name = "include",
hdrs = glob(["include/proxy-wasm/**/*.h"]),
name = "wasm_vm_headers",
hdrs = [
"include/proxy-wasm/wasm_vm.h",
"include/proxy-wasm/word.h",
],
deps = [
"@proxy_wasm_cpp_sdk//:common_lib",
],
)

cc_library(
name = "common_lib",
srcs = glob([
"src/*.h",
"src/*.cc",
"src/common/*.h",
"src/null/*.cc",
"src/third_party/*.h",
"src/third_party/*.cc",
]),
name = "headers",
hdrs = [
"include/proxy-wasm/context.h",
"include/proxy-wasm/context_interface.h",
"include/proxy-wasm/exports.h",
"include/proxy-wasm/vm_id_handle.h",
"include/proxy-wasm/wasm.h",
],
deps = [
":wasm_vm_headers",
],
)

cc_library(
name = "base_lib",
srcs = [
"src/bytecode_util.cc",
"src/context.cc",
"src/exports.cc",
"src/shared_data.cc",
"src/shared_data.h",
"src/shared_queue.cc",
"src/shared_queue.h",
"src/signature_util.cc",
"src/third_party/base64.cc",
"src/third_party/base64.h",
"src/third_party/picosha2.h",
"src/vm_id_handle.cc",
"src/wasm.cc",
],
hdrs = [
"include/proxy-wasm/bytecode_util.h",
"include/proxy-wasm/signature_util.h",
],
deps = [
":include",
":headers",
"@boringssl//:crypto",
],
)

cc_library(
name = "null_lib",
srcs = [
"src/null/null.cc",
"src/null/null_plugin.cc",
"src/null/null_vm.cc",
],
hdrs = [
"include/proxy-wasm/null.h",
"include/proxy-wasm/null_plugin.h",
"include/proxy-wasm/null_vm.h",
"include/proxy-wasm/null_vm_plugin.h",
"include/proxy-wasm/wasm_api_impl.h",
],
deps = [
":headers",
"@com_google_protobuf//:protobuf_lite",
"@proxy_wasm_cpp_sdk//:api_lib",
],
)

cc_library(
name = "v8_lib",
srcs = glob([
# TODO(@mathetake): Add V8 lib.
# "src/v8/*.h",
# "src/v8/*.cc",
]),
srcs = [
"src/v8/v8.cc",
],
hdrs = ["include/proxy-wasm/v8.h"],
deps = [
":common_lib",
# TODO(@mathetake): Add V8 lib.
":wasm_vm_headers",
"//external:wee8",
],
)

cc_library(
name = "wamr_lib",
srcs = glob([
"src/wamr/*.h",
"src/wamr/*.cc",
]),
srcs = [
"src/common/types.h",
"src/wamr/types.h",
"src/wamr/wamr.cc",
],
hdrs = ["include/proxy-wasm/wamr.h"],
deps = [
":common_lib",
"@wamr//:wamr_lib",
":wasm_vm_headers",
"//external:wamr",
],
)

cc_library(
name = "wasmtime_lib",
srcs = glob([
"src/wasmtime/*.h",
"src/wasmtime/*.cc",
]),
srcs = [
"src/common/types.h",
"src/wasmtime/types.h",
"src/wasmtime/wasmtime.cc",
],
hdrs = ["include/proxy-wasm/wasmtime.h"],
deps = [
":common_lib",
"@wasm_c_api//:wasmtime_lib",
":wasm_vm_headers",
"//external:wasmtime",
],
)

cc_library(
name = "wavm_lib",
srcs = glob([
"src/wavm/*.h",
"src/wavm/*.cc",
]),
srcs = [
"src/wavm/wavm.cc",
],
hdrs = ["include/proxy-wasm/wavm.h"],
copts = [
'-DWAVM_API=""',
"-Wno-non-virtual-dtor",
"-Wno-old-style-cast",
],
deps = [
":common_lib",
"@wavm//:wavm_lib",
":wasm_vm_headers",
"//external:wavm",
],
)

cc_library(
name = "lib",
deps = [
":common_lib",
":base_lib",
":null_lib",
] + proxy_wasm_select_runtime_v8(
[":v8_lib"],
) + proxy_wasm_select_runtime_wamr(
Expand Down
2 changes: 1 addition & 1 deletion bazel/external/wasm-c-api.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ cc_library(
defines = ["WASM_WASMTIME"],
include_prefix = "wasmtime",
deps = [
"@wasmtime//:rust_c_api",
"@com_github_bytecodealliance_wasmtime//:rust_c_api",
],
)
23 changes: 19 additions & 4 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,39 @@ def proxy_wasm_cpp_host_repositories():
)

http_archive(
name = "wamr",
name = "com_github_bytecodealliance_wasm_micro_runtime",
build_file = "@proxy_wasm_cpp_host//bazel/external:wamr.BUILD",
sha256 = "46ad365a1c0668797e69cb868574fd526cd8e26a503213caf782c39061e6d2e1",
strip_prefix = "wasm-micro-runtime-17a216748574499bd3a5130e7e6a20b84fe76798",
url = "https://github.com/bytecodealliance/wasm-micro-runtime/archive/17a216748574499bd3a5130e7e6a20b84fe76798.tar.gz",
)

native.bind(
name = "wamr",
actual = "@com_github_bytecodealliance_wasm_micro_runtime//:wamr_lib",
)

http_archive(
name = "wasmtime",
name = "com_github_bytecodealliance_wasmtime",
build_file = "@proxy_wasm_cpp_host//bazel/external:wasmtime.BUILD",
sha256 = "e95d274822ac72bf06355bdfbeddcacae60d7e98fec8ee4b2e21740636fb5c2c",
strip_prefix = "wasmtime-0.26.0",
url = "https://github.com/bytecodealliance/wasmtime/archive/v0.26.0.tar.gz",
)

http_archive(
name = "wasm_c_api",
name = "com_github_webassembly_wasm_c_api",
build_file = "@proxy_wasm_cpp_host//bazel/external:wasm-c-api.BUILD",
sha256 = "c774044f51431429e878bd1b9e2a4e38932f861f9211df72f75e9427eb6b8d32",
strip_prefix = "wasm-c-api-c9d31284651b975f05ac27cee0bab1377560b87e",
url = "https://github.com/WebAssembly/wasm-c-api/archive/c9d31284651b975f05ac27cee0bab1377560b87e.tar.gz",
)

native.bind(
name = "wasmtime",
actual = "@com_github_webassembly_wasm_c_api//:wasmtime_lib",
)

http_archive(
name = "rules_rust",
sha256 = "db182e96b5ed62b044142cdae096742fcfd1aa4febfe3af8afa3c0ee438a52a4",
Expand Down Expand Up @@ -90,9 +100,14 @@ def proxy_wasm_cpp_host_repositories():
)

http_archive(
name = "wavm",
name = "com_github_wavm_wavm",
build_file = "@proxy_wasm_cpp_host//bazel/external:wavm.BUILD",
sha256 = "fa9a8dece0f1a51f8789c07f7f0c1f817ceee54c57d85f22ab958e43cde648d3",
strip_prefix = "WAVM-93c3ad73e2938f19c8bb26d4f456b39d6bc4ca01",
url = "https://github.com/WAVM/WAVM/archive/93c3ad73e2938f19c8bb26d4f456b39d6bc4ca01.tar.gz",
)

native.bind(
name = "wavm",
actual = "@com_github_wavm_wavm//:wavm_lib",
)
2 changes: 0 additions & 2 deletions src/wamr/wamr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#include <utility>
#include <vector>

#include "include/proxy-wasm/bytecode_util.h"

#include "src/wamr/types.h"
#include "wasm_c_api.h"

Expand Down