Skip to content

Review of WasmVM. #1

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
Mar 9, 2020
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
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --cxxopt="-std=c++17"
16 changes: 16 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
Language: Cpp
ColumnLimit: 100
AccessModifierOffset: -2
DerivePointerAlignment: false
PointerAlignment: Right
SortIncludes: false
...

---
Language: Proto
ColumnLimit: 100
AllowShortFunctionsOnASingleLine: false
ReflowComments: false
SpacesInContainerLiterals: false
...
57 changes: 57 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
licenses(["notice"]) # Apache 2

package(default_visibility = ["//visibility:public"])

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

# TODO: remove when dependent projects have been upgraded.
cc_library(
name = "include14",
hdrs = [
"include/proxy-wasm/compat.h",
"include/proxy-wasm/wasm_vm.h",
"include/proxy-wasm/word.h",
],
copts = ["-std=c++14"],
deps = [
"@proxy_wasm_cpp_sdk//:common_lib",
],
)

cc_test(
name = "wasm_vm_test",
srcs = ["wasm_vm_test.cc"],
deps = [
":include",
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings:strings",
"@com_google_absl//absl/types:optional",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)

# TODO: remove when dependent projects have been upgraded.
cc_test(
name = "wasm_vm_14_test",
srcs = ["wasm_vm_test.cc"],
copts = ["-std=c++14"],
deps = [
":include14",
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings:strings",
"@com_google_absl//absl/types:optional",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)
24 changes: 24 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
workspace(name = "proxy_wasm_cpp_host")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "proxy_wasm_cpp_sdk",
sha256 = "14f66f67e8f37ec81d28d7f5307be4407d206ac5f0daaf6d22fa5536797bcac1",
strip_prefix = "proxy-wasm-cpp-sdk-31f1fc5b7e09f231fa532d2d296e479a113c3e10",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/31f1fc5b7e09f231fa532d2d296e479a113c3e10.tar.gz"],
)

http_archive(
name = "com_google_absl",
sha256 = "19391fb4882601a65cb648d638c11aa301ce5f525ef02da1a9eafd22f72d7c59",
strip_prefix = "abseil-cpp-37dd2562ec830d547a1524bb306be313ac3f2556",
# 2020-01-29
urls = ["https://github.com/abseil/abseil-cpp/archive/37dd2562ec830d547a1524bb306be313ac3f2556.tar.gz"],
)

http_archive(
name = "com_google_googletest",
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
strip_prefix = "googletest-release-1.10.0",
urls = ["https://github.com/google/googletest/archive/release-1.10.0.tar.gz"],
)
50 changes: 50 additions & 0 deletions include/proxy-wasm/compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 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.

#pragma once

// Provide compatibiliby for projects which have not yet moved to C++17.
// TODO: remove this when all dependent projects have upgraded.

#ifndef __cpp_lib_optional
#include "absl/types/optional.h"
#else
#include <optional>
#endif

#ifndef __cpp_lib_string_view
#include "absl/strings/string_view.h"
#else
#include <string_view>
#endif

namespace proxy_wasm {
#ifndef __cpp_lib_optional
template <typename T> using optional = absl::optional<T>;
// Only available in C++17
// inline constexpr absl::nullopt_t nullopt = absl::nullopt;
#define PROXY_WASM_NULLOPT absl::nullopt
#else
template <typename T> using optional = std::optional<T>;
// Only available in C++17
// inline constexpr std::nullopt_t nullopt = std::nullopt;
#define PROXY_WASM_NULLOPT std::nullopt
#endif

#ifndef __cpp_lib_string_view
using string_view = absl::string_view;
#else
using string_view = std::string_view;
#endif
} // namespace proxy_wasm
Loading