Skip to content

Commit

Permalink
support windows and macos
Browse files Browse the repository at this point in the history
  • Loading branch information
chloro-pn committed Jun 5, 2024
1 parent 53e1ae7 commit 2000d22
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
1 change: 0 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
build --cxxopt="-std=c++20"
10 changes: 10 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package(default_visibility = ["//visibility:public"])

load("//bazel/config:copt.bzl", "WAMON_COPTS")

cc_library(
name = "wamon",
hdrs = glob(["include/**/*.h"]),
srcs = glob(["src/*.cc"]),
includes = ["include"],
copts = WAMON_COPTS,
deps = [
"@fmt//:fmt",
]
Expand All @@ -13,6 +16,7 @@ cc_library(
cc_test(
name = "wamon_test",
srcs = glob(["test/*.cc"]),
copts = WAMON_COPTS,
deps = [
":wamon",
"@googletest//:gtest",
Expand All @@ -23,6 +27,7 @@ cc_test(
cc_binary(
name = "hello_world",
srcs = ["example/hello_world.cc"],
copts = WAMON_COPTS,
deps = [
":wamon"
],
Expand All @@ -31,6 +36,7 @@ cc_binary(
cc_binary(
name = "register_cpp_func",
srcs = ["example/register_cpp_function.cc"],
copts = WAMON_COPTS,
deps = [
":wamon"
],
Expand All @@ -39,6 +45,7 @@ cc_binary(
cc_binary(
name = "interpreter_api",
srcs = ["example/interpreter_api.cc"],
copts = WAMON_COPTS,
deps = [
":wamon"
],
Expand All @@ -47,6 +54,7 @@ cc_binary(
cc_binary(
name = "lambda",
srcs = ["example/lambda.cc"],
copts = WAMON_COPTS,
deps = [
":wamon"
],
Expand All @@ -55,6 +63,7 @@ cc_binary(
cc_binary(
name = "struct_trait",
srcs = ["example/struct_trait.cc"],
copts = WAMON_COPTS,
deps = [
":wamon"
],
Expand All @@ -63,6 +72,7 @@ cc_binary(
cc_binary(
name = "merge_sort",
srcs = ["example/merge_sort.cc"],
copts = WAMON_COPTS,
deps = [
":wamon"
],
Expand Down
2 changes: 2 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
workspace(name = "com_github_wamon")

load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository')

git_repository(
Expand Down
6 changes: 6 additions & 0 deletions bazel/config/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config_setting(
name = "msvc_compiler",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "msvc-cl",
},
)
15 changes: 15 additions & 0 deletions bazel/config/copt.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
WAMON_COPTS = select({
"@com_github_wamon//bazel/config:msvc_compiler": [
"/std:c++20",
"/EHa"
],
"//conditions:default": [
"-std=c++20",
"-D_GLIBCXX_USE_CXX11_ABI=1",
"-Wall",
"-Werror",
"-g",
],
}

)
2 changes: 1 addition & 1 deletion include/wamon/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class LambdaExpr : public Expression {
}

static bool IsLambdaName(const std::string& name) {
constexpr int len = strlen("__lambda_");
const int len = strlen("__lambda_");
return name.size() >= len && name.substr(0, len) == "__lambda_";
}

Expand Down

0 comments on commit 2000d22

Please sign in to comment.