Skip to content

wasmtime: split "prefixed_wasmtime" into a separate target. #262

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 1 commit into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
45 changes: 26 additions & 19 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ cc_library(
],
)

cc_library(
name = "wasmtime_lib",
srcs = [
"src/common/types.h",
"src/wasmtime/types.h",
"src/wasmtime/wasmtime.cc",
],
hdrs = ["include/proxy-wasm/wasmtime.h"],
defines = [
"PROXY_WASM_HAS_RUNTIME_WASMTIME",
"PROXY_WASM_HOST_ENGINE_WASMTIME",
],
deps = [
":wasm_vm_headers",
"//external:wasmtime",
],
)

genrule(
name = "prefixed_wasmtime_sources",
srcs = [
Expand All @@ -141,41 +159,29 @@ genrule(
cmd = """
for file in $(SRCS); do
sed -e 's/wasm_/wasmtime_wasm_/g' \
-e 's/include\\/wasm.h/include\\/prefixed_wasm.h/g' \
-e 's/wasmtime\\/types.h/wasmtime\\/prefixed_types.h/g' \
$$file >$(@D)/$$(dirname $$file)/prefixed_$$(basename $$file)
done
""",
)

cc_library(
name = "wasmtime_lib",
name = "prefixed_wasmtime_lib",
srcs = [
"src/common/types.h",
] + select({
"@proxy_wasm_cpp_host//bazel:multiengine": [
"src/wasmtime/prefixed_types.h",
"src/wasmtime/prefixed_wasmtime.cc",
],
"//conditions:default": [
"src/wasmtime/types.h",
"src/wasmtime/wasmtime.cc",
],
}),
"src/wasmtime/prefixed_types.h",
"src/wasmtime/prefixed_wasmtime.cc",
],
hdrs = ["include/proxy-wasm/wasmtime.h"],
defines = [
"PROXY_WASM_HAS_RUNTIME_WASMTIME",
"PROXY_WASM_HOST_ENGINE_WASMTIME",
],
deps = [
":wasm_vm_headers",
] + select({
"@proxy_wasm_cpp_host//bazel:multiengine": [
"//external:prefixed_wasmtime",
],
"//conditions:default": [
"//external:wasmtime",
],
}),
"//external:prefixed_wasmtime",
],
)

cc_library(
Expand Down Expand Up @@ -211,6 +217,7 @@ cc_library(
[":wamr_lib"],
) + proxy_wasm_select_engine_wasmtime(
[":wasmtime_lib"],
[":prefixed_wasmtime_lib"],
) + proxy_wasm_select_engine_wavm(
[":wavm_lib"],
),
Expand Down
3 changes: 1 addition & 2 deletions bazel/external/wasm-c-api.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ cc_library(
hdrs = [
"include/wasm.h",
],
include_prefix = "wasmtime",
deps = [
"@com_github_bytecodealliance_wasmtime//:rust_c_api",
],
Expand All @@ -21,7 +20,7 @@ genrule(
"include/wasm.h",
],
outs = [
"wasmtime/include/wasm.h",
"include/prefixed_wasm.h",
],
cmd = """
sed -e 's/\\ wasm_/\\ wasmtime_wasm_/g' \
Expand Down
4 changes: 2 additions & 2 deletions bazel/select.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def proxy_wasm_select_engine_wamr(xs):
"//conditions:default": [],
})

def proxy_wasm_select_engine_wasmtime(xs):
def proxy_wasm_select_engine_wasmtime(xs, xp):
return select({
"@proxy_wasm_cpp_host//bazel:engine_wasmtime": xs,
"@proxy_wasm_cpp_host//bazel:multiengine": xs,
"@proxy_wasm_cpp_host//bazel:multiengine": xp,
"//conditions:default": [],
})

Expand Down
2 changes: 1 addition & 1 deletion src/wasmtime/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

#include "src/common/types.h"
#include "wasmtime/include/wasm.h"
#include "include/wasm.h"

namespace proxy_wasm {
namespace wasmtime {
Expand Down
2 changes: 1 addition & 1 deletion src/wasmtime/wasmtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "src/wasmtime/types.h"

#include "wasmtime/include/wasm.h"
#include "include/wasm.h"

namespace proxy_wasm {
namespace wasmtime {
Expand Down