From e8a1e61afd6e82130f6d84bb54435db0634eeb82 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Thu, 29 Apr 2021 20:49:59 +0900 Subject: [PATCH 01/12] Add bazelrc, and delete variables.bzl. Signed-off-by: Takeshi Yoneda --- .bazelrc | 11 +++++++++++ BUILD | 2 -- bazel/variables.bzl | 42 ------------------------------------------ test/BUILD | 11 ----------- test/common/BUILD | 2 -- 5 files changed, 11 insertions(+), 57 deletions(-) create mode 100644 .bazelrc delete mode 100644 bazel/variables.bzl diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 000000000..7ca29b15e --- /dev/null +++ b/.bazelrc @@ -0,0 +1,11 @@ +build --enable_platform_specific_config + +# COPTS +build:linux --cxxopt=-std=c++17 +build:macos --cxxopt=-std=c++17 +build:windows --cxxopt="/std:c++17" + +# LINKOPTS +# See https://bytecodealliance.github.io/wasmtime/c-api/ +build:linux --action_env=BAZEL_LINKOPTS=-lm:-lpthread:-ldl +build:windows --action_env=BAZEL_LINKOPTS=ws2_32.lib:advapi32.lib:userenv.lib:ntdll.lib:shell32.lib:ole32.lib diff --git a/BUILD b/BUILD index 840ccd3a2..7ff6efcd0 100644 --- a/BUILD +++ b/BUILD @@ -1,5 +1,4 @@ load("@rules_cc//cc:defs.bzl", "cc_library") -load("@proxy_wasm_cpp_host//bazel:variables.bzl", "COPTS") licenses(["notice"]) # Apache 2 @@ -28,7 +27,6 @@ cc_library( ], ), hdrs = glob(["src/**/*.h"]), - copts = COPTS, deps = [ ":include", "@boringssl//:crypto", diff --git a/bazel/variables.bzl b/bazel/variables.bzl deleted file mode 100644 index 1d28c04ae..000000000 --- a/bazel/variables.bzl +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2020 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. - -COPTS = select({ - "@bazel_tools//src/conditions:windows": [ - "/std:c++17", - ], - "//conditions:default": [ - "-std=c++17", - ], -}) - -# https://bytecodealliance.github.io/wasmtime/c-api/ -LINKOPTS = select({ - "@bazel_tools//src/conditions:windows": [ - "-", - "ws2_32.lib", - "advapi32.lib", - "userenv.lib", - "ntdll.lib", - "shell32.lib", - "ole32.lib", - ], - "@bazel_tools//src/conditions:darwin": [], - "//conditions:default": [ - # required for linux - "-lpthread", - "-ldl", - "-lm", - ], -}) diff --git a/test/BUILD b/test/BUILD index 0fad5ceb6..15df65282 100644 --- a/test/BUILD +++ b/test/BUILD @@ -1,12 +1,10 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") -load("@proxy_wasm_cpp_host//bazel:variables.bzl", "COPTS", "LINKOPTS") package(default_visibility = ["//visibility:public"]) cc_test( name = "null_vm_test", srcs = ["null_vm_test.cc"], - copts = COPTS, deps = [ "//:lib", "@com_google_googletest//:gtest", @@ -17,13 +15,11 @@ cc_test( cc_test( name = "runtime_test", srcs = ["runtime_test.cc"], - copts = COPTS, data = [ "//test/test_data:abi_export.wasm", "//test/test_data:callback.wasm", "//test/test_data:trap.wasm", ], - linkopts = LINKOPTS, deps = [ ":utility_lib", "//:lib", @@ -35,11 +31,9 @@ cc_test( cc_test( name = "exports_test", srcs = ["exports_test.cc"], - copts = COPTS, data = [ "//test/test_data:env.wasm", ], - linkopts = LINKOPTS, deps = [ ":utility_lib", "//:lib", @@ -51,7 +45,6 @@ cc_test( cc_test( name = "context_test", srcs = ["context_test.cc"], - copts = COPTS, deps = [ "//:lib", "@com_google_googletest//:gtest", @@ -62,7 +55,6 @@ cc_test( cc_test( name = "shared_data", srcs = ["shared_data_test.cc"], - copts = COPTS, deps = [ "//:lib", "@com_google_googletest//:gtest", @@ -73,7 +65,6 @@ cc_test( cc_test( name = "shared_queue", srcs = ["shared_queue_test.cc"], - copts = COPTS, deps = [ "//:lib", "@com_google_googletest//:gtest", @@ -84,7 +75,6 @@ cc_test( cc_test( name = "vm_id_handle", srcs = ["vm_id_handle_test.cc"], - copts = COPTS, deps = [ "//:lib", "@com_google_googletest//:gtest", @@ -99,7 +89,6 @@ cc_library( "utility.h", ], hdrs = ["utility.h"], - copts = COPTS, deps = [ "//:lib", "@com_google_googletest//:gtest", diff --git a/test/common/BUILD b/test/common/BUILD index c76fc5e48..23e21ba71 100644 --- a/test/common/BUILD +++ b/test/common/BUILD @@ -1,10 +1,8 @@ load("@rules_cc//cc:defs.bzl", "cc_test") -load("@proxy_wasm_cpp_host//bazel:variables.bzl", "COPTS") cc_test( name = "bytecode_util_test", srcs = ["bytecode_util_test.cc"], - copts = COPTS, data = [ "//test/test_data:abi_export.wasm", ], From 10897f346fad00816d40c6d4868de07112f297bc Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Thu, 29 Apr 2021 20:59:10 +0900 Subject: [PATCH 02/12] Add select config on Wasm runtimes. Signed-off-by: Takeshi Yoneda --- bazel/BUILD | 14 ++++++++++++++ bazel/select.bzl | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 bazel/select.bzl diff --git a/bazel/BUILD b/bazel/BUILD index e69de29bb..5b17c5ed8 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -0,0 +1,14 @@ +config_setting( + name = "wasm_runtime_wavm", + values = {"define": "wasm_runtime=wavm"}, +) + +config_setting( + name = "wasm_runtime_v8", + values = {"define": "wasm_runtime=v8"}, +) + +config_setting( + name = "wasm_runtime_wasmtime", + values = {"define": "wasm_runtime=wasmtime"}, +) diff --git a/bazel/select.bzl b/bazel/select.bzl new file mode 100644 index 000000000..2d0fb9d4f --- /dev/null +++ b/bazel/select.bzl @@ -0,0 +1,22 @@ +# Selects the given values depending on the Wasm runtimes enabled in the current build. +def envoy_select_wasm_v8(xs): + return select({ + # TODO(@mathetake): enable V8 build. + # "@proxy_wasm_cpp_host//bazel:wasm_runtime_v8": xs, + "//conditions:default": [], + }) + +# Selects the given values depending on the Wasm runtimes enabled in the current build. +def envoy_select_wasm_wavm(xs): + return select({ + # TODO(@mathetake): enable WAVM build. + # "@envoy//bazel:wasm_runtime_wavm": xs, + "//conditions:default": [], + }) + +# Selects the given values depending on the Wasm runtimes enabled in the current build. +def envoy_select_wasm_wasmtime(xs): + return select({ + "@proxy_wasm_cpp_host//bazel:wasm_runtime_wasmtime": xs, + "//conditions:default": [], + }) From cf4bb158537d56dc212b5eaca9cc291fd14ba476 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Thu, 29 Apr 2021 21:17:37 +0900 Subject: [PATCH 03/12] Add libs. Signed-off-by: Takeshi Yoneda --- .bazelrc | 6 ++-- BUILD | 78 +++++++++++++++++++++++++++++++++++++++--------- bazel/select.bzl | 9 ++---- 3 files changed, 71 insertions(+), 22 deletions(-) diff --git a/.bazelrc b/.bazelrc index 7ca29b15e..529964d58 100644 --- a/.bazelrc +++ b/.bazelrc @@ -3,9 +3,11 @@ build --enable_platform_specific_config # COPTS build:linux --cxxopt=-std=c++17 build:macos --cxxopt=-std=c++17 -build:windows --cxxopt="/std:c++17" +# TODO(mathetake): Windows build is not verified yet. +# build:windows --cxxopt="/std:c++17" # LINKOPTS # See https://bytecodealliance.github.io/wasmtime/c-api/ build:linux --action_env=BAZEL_LINKOPTS=-lm:-lpthread:-ldl -build:windows --action_env=BAZEL_LINKOPTS=ws2_32.lib:advapi32.lib:userenv.lib:ntdll.lib:shell32.lib:ole32.lib +# TODO(mathetake): Windows build is not verified yet. +# build:windows --action_env=BAZEL_LINKOPTS=ws2_32.lib:advapi32.lib:userenv.lib:ntdll.lib:shell32.lib:ole32.lib diff --git a/BUILD b/BUILD index 7ff6efcd0..134a98898 100644 --- a/BUILD +++ b/BUILD @@ -1,4 +1,10 @@ load("@rules_cc//cc:defs.bzl", "cc_library") +load( + "@proxy_wasm_cpp_host//bazel:select.bzl", + "proxy_wasm_select_wasm_runtime_v8", + "proxy_wasm_select_wasm_runtime_wasmtime", + "proxy_wasm_select_wasm_runtime_wavm", +) licenses(["notice"]) # Apache 2 @@ -12,26 +18,70 @@ 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/**/wavm*", - "src/**/v8*", - ], - ), - hdrs = glob(["src/**/*.h"]), + 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 = "wasmtime_lib", + srcs = glob([ + "src/wasmtime/*.h", + "src/wasmtime/*.cc", + ]), + deps = [ + ":common_lib", "@wasm_c_api//:wasmtime_lib", ], ) + +cc_library( + name = "v8_lib", + srcs = glob([ + "src/v8/*.h", + "src/v8/*.cc", + ]), + deps = [ + ":common_lib", + # TODO(@mathetake): Add V8 lib. + ], +) + +cc_library( + name = "wavm_lib", + srcs = glob([ + "src/wavm/*.h", + "src/wavm/*.cc", + ]), + deps = [ + ":common_lib", + # TODO(@mathetake): Add WAVM lib. + ], +) + +cc_library( + name = "lib", + deps = [ + ":common_lib", + ] + proxy_wasm_select_wasm_runtime_wasmtime( + ["wasmtime_lib"], + ) + proxy_wasm_select_wasm_runtime_v8([ + ["v8_lib"], + ]) + proxy_wasm_select_wasm_runtime_wavm([ + ["wavm_lib"], + ]), +) diff --git a/bazel/select.bzl b/bazel/select.bzl index 2d0fb9d4f..8866ff799 100644 --- a/bazel/select.bzl +++ b/bazel/select.bzl @@ -1,21 +1,18 @@ -# Selects the given values depending on the Wasm runtimes enabled in the current build. -def envoy_select_wasm_v8(xs): +def proxy_wasm_select_wasm_runtime_v8(xs): return select({ # TODO(@mathetake): enable V8 build. # "@proxy_wasm_cpp_host//bazel:wasm_runtime_v8": xs, "//conditions:default": [], }) -# Selects the given values depending on the Wasm runtimes enabled in the current build. -def envoy_select_wasm_wavm(xs): +def proxy_wasm_select_wasm_runtime_wavm(xs): return select({ # TODO(@mathetake): enable WAVM build. # "@envoy//bazel:wasm_runtime_wavm": xs, "//conditions:default": [], }) -# Selects the given values depending on the Wasm runtimes enabled in the current build. -def envoy_select_wasm_wasmtime(xs): +def proxy_wasm_select_wasm_runtime_wasmtime(xs): return select({ "@proxy_wasm_cpp_host//bazel:wasm_runtime_wasmtime": xs, "//conditions:default": [], From 5cc55d2d0deadb731a18089bbfea05eea7713608 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Thu, 29 Apr 2021 21:21:17 +0900 Subject: [PATCH 04/12] Make the build job matrixed on runtimes. Signed-off-by: Takeshi Yoneda --- .github/workflows/cpp.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index d509c7842..358d94be1 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -56,7 +56,10 @@ jobs: build: runs-on: ubuntu-latest - + strategy: + matrix: + # TODO(mathetake): Add other runtimes. + wasm_runtime: [ "wasmtime" ] steps: - uses: actions/checkout@v2 @@ -64,9 +67,9 @@ jobs: uses: actions/cache@v1 with: path: "/home/runner/.cache/bazel" - key: bazel + key: bazel-${{ matrix.wasm_runtime }} - name: Test run: | - bazel test //... + bazel test -define wasm_runtime=${{ matrix.wasm_runtime }} //... From 9964456d64ee77412513df5aebc10ab3dbe0bb41 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Thu, 29 Apr 2021 21:25:21 +0900 Subject: [PATCH 05/12] Fix bazel define flag. Signed-off-by: Takeshi Yoneda --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 358d94be1..38d7d8e25 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -71,5 +71,5 @@ jobs: - name: Test run: | - bazel test -define wasm_runtime=${{ matrix.wasm_runtime }} //... + bazel test --define wasm_runtime=${{ matrix.wasm_runtime }} //... From 8bd5f3afa3531f0a526f576cb13a4cd3295f49e0 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Thu, 29 Apr 2021 21:27:06 +0900 Subject: [PATCH 06/12] Add license header in select.bzl. Signed-off-by: Takeshi Yoneda --- bazel/select.bzl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bazel/select.bzl b/bazel/select.bzl index 8866ff799..b897674f8 100644 --- a/bazel/select.bzl +++ b/bazel/select.bzl @@ -1,3 +1,17 @@ +# 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_wasm_runtime_v8(xs): return select({ # TODO(@mathetake): enable V8 build. From 2f4ffe9c416db516d283bafdf56b2f0ce093eac3 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Thu, 29 Apr 2021 21:43:09 +0900 Subject: [PATCH 07/12] Fix build. Signed-off-by: Takeshi Yoneda --- BUILD | 28 +++++++++++++++------------- bazel/select.bzl | 6 ++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/BUILD b/BUILD index 134a98898..26871a5c4 100644 --- a/BUILD +++ b/BUILD @@ -38,34 +38,36 @@ cc_library( ) cc_library( - name = "wasmtime_lib", + name = "v8_lib", srcs = glob([ - "src/wasmtime/*.h", - "src/wasmtime/*.cc", + # TODO(@mathetake): Add V8 lib. + # "src/v8/*.h", + # "src/v8/*.cc", ]), deps = [ ":common_lib", - "@wasm_c_api//:wasmtime_lib", + # TODO(@mathetake): Add V8 lib. ], ) cc_library( - name = "v8_lib", + name = "wasmtime_lib", srcs = glob([ - "src/v8/*.h", - "src/v8/*.cc", + "src/wasmtime/*.h", + "src/wasmtime/*.cc", ]), deps = [ ":common_lib", - # TODO(@mathetake): Add V8 lib. + "@wasm_c_api//:wasmtime_lib", ], ) cc_library( name = "wavm_lib", srcs = glob([ - "src/wavm/*.h", - "src/wavm/*.cc", + # TODO(@mathetake): Add WAVM lib. + # "src/wavm/*.h", + # "src/wavm/*.cc", ]), deps = [ ":common_lib", @@ -79,9 +81,9 @@ cc_library( ":common_lib", ] + proxy_wasm_select_wasm_runtime_wasmtime( ["wasmtime_lib"], - ) + proxy_wasm_select_wasm_runtime_v8([ + ) + proxy_wasm_select_wasm_runtime_v8( ["v8_lib"], - ]) + proxy_wasm_select_wasm_runtime_wavm([ + ) + proxy_wasm_select_wasm_runtime_wavm( ["wavm_lib"], - ]), + ), ) diff --git a/bazel/select.bzl b/bazel/select.bzl index b897674f8..eb3d2cc8d 100644 --- a/bazel/select.bzl +++ b/bazel/select.bzl @@ -14,15 +14,13 @@ def proxy_wasm_select_wasm_runtime_v8(xs): return select({ - # TODO(@mathetake): enable V8 build. - # "@proxy_wasm_cpp_host//bazel:wasm_runtime_v8": xs, + "@proxy_wasm_cpp_host//bazel:wasm_runtime_v8": xs, "//conditions:default": [], }) def proxy_wasm_select_wasm_runtime_wavm(xs): return select({ - # TODO(@mathetake): enable WAVM build. - # "@envoy//bazel:wasm_runtime_wavm": xs, + "@proxy_wasm_cpp_host//bazel:wasm_runtime_wavm": xs, "//conditions:default": [], }) From 2bd8242810079fd022d33c3b006b0cde7bda1417 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Fri, 7 May 2021 15:31:31 +0900 Subject: [PATCH 08/12] Fix style and add wamr_lib. Signed-off-by: Takeshi Yoneda --- .github/workflows/cpp.yml | 6 ++++-- BUILD | 34 +++++++++++++++++++++++++--------- bazel/BUILD | 17 +++++++++++------ bazel/select.bzl | 18 ++++++++++++------ 4 files changed, 52 insertions(+), 23 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 38d7d8e25..b74a9c03c 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -56,10 +56,12 @@ jobs: build: runs-on: ubuntu-latest + strategy: matrix: # TODO(mathetake): Add other runtimes. - wasm_runtime: [ "wasmtime" ] + runtime: [ "wasmtime" ] + steps: - uses: actions/checkout@v2 @@ -71,5 +73,5 @@ jobs: - name: Test run: | - bazel test --define wasm_runtime=${{ matrix.wasm_runtime }} //... + bazel test --define runtime=${{ matrix.wasm_runtime }} //... diff --git a/BUILD b/BUILD index 26871a5c4..2f760f841 100644 --- a/BUILD +++ b/BUILD @@ -1,9 +1,10 @@ load("@rules_cc//cc:defs.bzl", "cc_library") load( "@proxy_wasm_cpp_host//bazel:select.bzl", - "proxy_wasm_select_wasm_runtime_v8", - "proxy_wasm_select_wasm_runtime_wasmtime", - "proxy_wasm_select_wasm_runtime_wavm", + "proxy_wasm_select_runtime_v8", + "proxy_wasm_select_runtime_wamr", + "proxy_wasm_select_runtime_wasmtime", + "proxy_wasm_select_runtime_wavm", ) licenses(["notice"]) # Apache 2 @@ -50,6 +51,19 @@ cc_library( ], ) +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. + ], +) + cc_library( name = "wasmtime_lib", srcs = glob([ @@ -79,11 +93,13 @@ cc_library( name = "lib", deps = [ ":common_lib", - ] + proxy_wasm_select_wasm_runtime_wasmtime( - ["wasmtime_lib"], - ) + proxy_wasm_select_wasm_runtime_v8( - ["v8_lib"], - ) + proxy_wasm_select_wasm_runtime_wavm( - ["wavm_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"], ), ) diff --git a/bazel/BUILD b/bazel/BUILD index 5b17c5ed8..b6eb774cd 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -1,14 +1,19 @@ config_setting( - name = "wasm_runtime_wavm", - values = {"define": "wasm_runtime=wavm"}, + name = "runtime_v8", + values = {"define": "runtime=v8"}, ) config_setting( - name = "wasm_runtime_v8", - values = {"define": "wasm_runtime=v8"}, + name = "runtime_wamr", + values = {"define": "runtime=wamr"}, ) config_setting( - name = "wasm_runtime_wasmtime", - values = {"define": "wasm_runtime=wasmtime"}, + name = "runtime_wasmtime", + values = {"define": "runtime=wasmtime"}, +) + +config_setting( + name = "runtime_wavm", + values = {"define": "runtime=wavm"}, ) diff --git a/bazel/select.bzl b/bazel/select.bzl index eb3d2cc8d..7d4a305a3 100644 --- a/bazel/select.bzl +++ b/bazel/select.bzl @@ -12,20 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -def proxy_wasm_select_wasm_runtime_v8(xs): +def proxy_wasm_select_runtime_v8(xs): return select({ - "@proxy_wasm_cpp_host//bazel:wasm_runtime_v8": xs, + "@proxy_wasm_cpp_host//bazel:runtime_v8": xs, "//conditions:default": [], }) -def proxy_wasm_select_wasm_runtime_wavm(xs): +def proxy_wasm_select_runtime_wamr(xs): return select({ - "@proxy_wasm_cpp_host//bazel:wasm_runtime_wavm": xs, + "@proxy_wasm_cpp_host//bazel:runtime_wamr": xs, "//conditions:default": [], }) -def proxy_wasm_select_wasm_runtime_wasmtime(xs): +def proxy_wasm_select_runtime_wasmtime(xs): return select({ - "@proxy_wasm_cpp_host//bazel:wasm_runtime_wasmtime": xs, + "@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": [], }) From 72fdbb672c92fb9fbd4d5f174c82551769e6f748 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Fri, 7 May 2021 15:35:25 +0900 Subject: [PATCH 09/12] Fix bazelrc style Signed-off-by: Takeshi Yoneda --- .bazelrc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.bazelrc b/.bazelrc index 529964d58..b87e8b849 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,13 +1,15 @@ build --enable_platform_specific_config -# COPTS +# linux build:linux --cxxopt=-std=c++17 +# See https://bytecodealliance.github.io/wasmtime/c-api/ +build:linux --action_env=BAZEL_LINKOPTS=-lm:-lpthread:-ldl + +# macos build:macos --cxxopt=-std=c++17 + +# windows # TODO(mathetake): Windows build is not verified yet. # build:windows --cxxopt="/std:c++17" - -# LINKOPTS # See https://bytecodealliance.github.io/wasmtime/c-api/ -build:linux --action_env=BAZEL_LINKOPTS=-lm:-lpthread:-ldl -# TODO(mathetake): Windows build is not verified yet. # build:windows --action_env=BAZEL_LINKOPTS=ws2_32.lib:advapi32.lib:userenv.lib:ntdll.lib:shell32.lib:ole32.lib From 4061ab5bc3fa21d0b4911aea0d00faf2301a418a Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Fri, 7 May 2021 15:44:53 +0900 Subject: [PATCH 10/12] Fix matrix key. Signed-off-by: Takeshi Yoneda --- .github/workflows/cpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index b74a9c03c..ab27b2797 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -69,9 +69,9 @@ jobs: uses: actions/cache@v1 with: path: "/home/runner/.cache/bazel" - key: bazel-${{ matrix.wasm_runtime }} + key: bazel-${{ matrix.runtime }} - name: Test run: | - bazel test --define runtime=${{ matrix.wasm_runtime }} //... + bazel test --define runtime=${{ matrix.runtime }} //... From c3c35581cfba1760b98c4506c1f794c0a08c278e Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Fri, 7 May 2021 15:58:58 +0900 Subject: [PATCH 11/12] Use linkopt instead of action env. Signed-off-by: Takeshi Yoneda --- .bazelrc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.bazelrc b/.bazelrc index b87e8b849..674ec5735 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,15 +1,12 @@ build --enable_platform_specific_config -# linux build:linux --cxxopt=-std=c++17 # See https://bytecodealliance.github.io/wasmtime/c-api/ -build:linux --action_env=BAZEL_LINKOPTS=-lm:-lpthread:-ldl +build:linux --linkopt="-lm -lpthread -ldl" -# macos build:macos --cxxopt=-std=c++17 -# windows # TODO(mathetake): Windows build is not verified yet. # build:windows --cxxopt="/std:c++17" # See https://bytecodealliance.github.io/wasmtime/c-api/ -# build:windows --action_env=BAZEL_LINKOPTS=ws2_32.lib:advapi32.lib:userenv.lib:ntdll.lib:shell32.lib:ole32.lib +# build:windows --linkopt="ws2_32.lib advapi32.lib userenv.lib ntdll.lib shell32.lib ole32.lib" From 0f3f6b1c6f140c31cac1150f6573ee9fb0bb72b1 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Fri, 7 May 2021 16:18:37 +0900 Subject: [PATCH 12/12] Have separate lines for linkopts. Signed-off-by: Takeshi Yoneda --- .bazelrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 674ec5735..d63c7058a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,7 +2,9 @@ build --enable_platform_specific_config build:linux --cxxopt=-std=c++17 # See https://bytecodealliance.github.io/wasmtime/c-api/ -build:linux --linkopt="-lm -lpthread -ldl" +build:linux --linkopt=-lm +build:linux --linkopt=-lpthread +build:linux --linkopt=-ldl build:macos --cxxopt=-std=c++17