-
Notifications
You must be signed in to change notification settings - Fork 72
build: refactor Bazel configuration towards multiple runtime tests #160
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
Changes from all commits
e8a1e61
10897f3
cf4bb15
5cc55d2
9964456
8bd5f3a
2f4ffe9
7570f7c
2bd8242
72fdbb6
4061ab5
c3c3558
0f3f6b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
build --enable_platform_specific_config | ||
|
||
build:linux --cxxopt=-std=c++17 | ||
# See https://bytecodealliance.github.io/wasmtime/c-api/ | ||
build:linux --linkopt=-lm | ||
build:linux --linkopt=-lpthread | ||
build:linux --linkopt=-ldl | ||
|
||
build:macos --cxxopt=-std=c++17 | ||
|
||
# TODO(mathetake): Windows build is not verified yet. | ||
# build:windows --cxxopt="/std:c++17" | ||
# See https://bytecodealliance.github.io/wasmtime/c-api/ | ||
# build:windows --linkopt="ws2_32.lib advapi32.lib userenv.lib ntdll.lib shell32.lib ole32.lib" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
load("@proxy_wasm_cpp_host//bazel:variables.bzl", "COPTS") | ||
load( | ||
"@proxy_wasm_cpp_host//bazel:select.bzl", | ||
"proxy_wasm_select_runtime_v8", | ||
"proxy_wasm_select_runtime_wamr", | ||
"proxy_wasm_select_runtime_wasmtime", | ||
"proxy_wasm_select_runtime_wavm", | ||
) | ||
|
||
licenses(["notice"]) # Apache 2 | ||
|
||
|
@@ -13,28 +19,87 @@ cc_library( | |
], | ||
) | ||
|
||
# TODO(mathetkae): once other runtimes(WAVM,V8) can be linked in this repos, | ||
# use -define=wasm=v8|wavm|wasmtime and switch | ||
cc_library( | ||
name = "lib", | ||
srcs = glob( | ||
[ | ||
"src/**/*.cc", | ||
"src/**/*.h", | ||
], | ||
exclude = [ | ||
"src/**/v8*", | ||
"src/**/wamr*", | ||
"src/**/wavm*", | ||
], | ||
), | ||
hdrs = glob(["src/**/*.h"]), | ||
copts = COPTS, | ||
name = "common_lib", | ||
srcs = glob([ | ||
"src/*.h", | ||
"src/*.cc", | ||
"src/common/*.h", | ||
"src/common/*.cc", | ||
"src/third_party/*.h", | ||
"src/third_party/*.cc", | ||
"src/null/*.cc", | ||
]), | ||
deps = [ | ||
":include", | ||
"@boringssl//:crypto", | ||
"@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", | ||
]), | ||
deps = [ | ||
":common_lib", | ||
# TODO(@mathetake): Add V8 lib. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, it's probably not worth spending time too much time on getting V8 to build, and we can wait until Bazel is officially supported in V8. |
||
], | ||
) | ||
|
||
cc_library( | ||
name = "wamr_lib", | ||
srcs = glob([ | ||
# TODO(@mathetake): Add WAMR lib. | ||
# "src/wamr/*.h", | ||
# "src/wamr/*.cc", | ||
]), | ||
deps = [ | ||
":common_lib", | ||
# TODO(@mathetake): Add WAMR lib. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any chance you could try to add WAMR here? Or do you prefer to leave it for a separate PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will do in a separate PR. |
||
], | ||
) | ||
|
||
cc_library( | ||
name = "wasmtime_lib", | ||
srcs = glob([ | ||
"src/wasmtime/*.h", | ||
"src/wasmtime/*.cc", | ||
]), | ||
deps = [ | ||
":common_lib", | ||
"@wasm_c_api//:wasmtime_lib", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "wavm_lib", | ||
srcs = glob([ | ||
# TODO(@mathetake): Add WAVM lib. | ||
# "src/wavm/*.h", | ||
# "src/wavm/*.cc", | ||
]), | ||
deps = [ | ||
":common_lib", | ||
# TODO(@mathetake): Add WAVM lib. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any chance you could try to add WAVM here? Or do you prefer to leave it for a separate PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will do in a separate PR. |
||
], | ||
) | ||
|
||
cc_library( | ||
name = "lib", | ||
deps = [ | ||
":common_lib", | ||
] + proxy_wasm_select_runtime_v8( | ||
[":v8_lib"], | ||
) + proxy_wasm_select_runtime_wamr( | ||
[":wamr_lib"], | ||
) + proxy_wasm_select_runtime_wasmtime( | ||
[":wasmtime_lib"], | ||
) + proxy_wasm_select_runtime_wavm( | ||
[":wavm_lib"], | ||
), | ||
mathetake marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
config_setting( | ||
name = "runtime_v8", | ||
values = {"define": "runtime=v8"}, | ||
) | ||
|
||
config_setting( | ||
name = "runtime_wamr", | ||
values = {"define": "runtime=wamr"}, | ||
) | ||
|
||
config_setting( | ||
name = "runtime_wasmtime", | ||
values = {"define": "runtime=wasmtime"}, | ||
) | ||
|
||
config_setting( | ||
name = "runtime_wavm", | ||
values = {"define": "runtime=wavm"}, | ||
) | ||
mathetake marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2021 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
def proxy_wasm_select_runtime_v8(xs): | ||
return select({ | ||
"@proxy_wasm_cpp_host//bazel:runtime_v8": xs, | ||
"//conditions:default": [], | ||
}) | ||
|
||
def proxy_wasm_select_runtime_wamr(xs): | ||
return select({ | ||
"@proxy_wasm_cpp_host//bazel:runtime_wamr": xs, | ||
"//conditions:default": [], | ||
}) | ||
|
||
def proxy_wasm_select_runtime_wasmtime(xs): | ||
return select({ | ||
"@proxy_wasm_cpp_host//bazel:runtime_wasmtime": xs, | ||
"//conditions:default": [], | ||
}) | ||
|
||
def proxy_wasm_select_runtime_wavm(xs): | ||
return select({ | ||
"@proxy_wasm_cpp_host//bazel:runtime_wavm": xs, | ||
"//conditions:default": [], | ||
}) | ||
mathetake marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
.bazelrc
only applies to builds in this workspace.Shouldn't those
linkopts
be a part ofwasmtime_lib
, so that other applications that link against it could pick up them up? But even then, I think the embedding binary would need to specify them as well...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, let's deal with this once it becomes a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, thanks for pointing this out. I will keep that in mind.