diff --git a/.bazelrc b/.bazelrc index 3ec7a19..e69de29 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1 +0,0 @@ -build --cxxopt="-std=c++20" \ No newline at end of file diff --git a/BUILD b/BUILD index ff9cc8f..7697059 100644 --- a/BUILD +++ b/BUILD @@ -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", ] @@ -13,6 +16,7 @@ cc_library( cc_test( name = "wamon_test", srcs = glob(["test/*.cc"]), + copts = WAMON_COPTS, deps = [ ":wamon", "@googletest//:gtest", @@ -23,6 +27,7 @@ cc_test( cc_binary( name = "hello_world", srcs = ["example/hello_world.cc"], + copts = WAMON_COPTS, deps = [ ":wamon" ], @@ -31,6 +36,7 @@ cc_binary( cc_binary( name = "register_cpp_func", srcs = ["example/register_cpp_function.cc"], + copts = WAMON_COPTS, deps = [ ":wamon" ], @@ -39,6 +45,7 @@ cc_binary( cc_binary( name = "interpreter_api", srcs = ["example/interpreter_api.cc"], + copts = WAMON_COPTS, deps = [ ":wamon" ], @@ -47,6 +54,7 @@ cc_binary( cc_binary( name = "lambda", srcs = ["example/lambda.cc"], + copts = WAMON_COPTS, deps = [ ":wamon" ], @@ -55,6 +63,7 @@ cc_binary( cc_binary( name = "struct_trait", srcs = ["example/struct_trait.cc"], + copts = WAMON_COPTS, deps = [ ":wamon" ], @@ -63,6 +72,7 @@ cc_binary( cc_binary( name = "merge_sort", srcs = ["example/merge_sort.cc"], + copts = WAMON_COPTS, deps = [ ":wamon" ], diff --git a/WORKSPACE b/WORKSPACE index 8a79a54..9d630ee 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,3 +1,5 @@ +workspace(name = "com_github_wamon") + load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository') git_repository( diff --git a/bazel/config/BUILD b/bazel/config/BUILD new file mode 100644 index 0000000..d2b0bb9 --- /dev/null +++ b/bazel/config/BUILD @@ -0,0 +1,6 @@ +config_setting( + name = "msvc_compiler", + flag_values = { + "@bazel_tools//tools/cpp:compiler": "msvc-cl", + }, +) diff --git a/bazel/config/copt.bzl b/bazel/config/copt.bzl new file mode 100644 index 0000000..3a94073 --- /dev/null +++ b/bazel/config/copt.bzl @@ -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", + ], +} + +) \ No newline at end of file diff --git a/include/wamon/ast.h b/include/wamon/ast.h index 2b435fe..1f40a3d 100644 --- a/include/wamon/ast.h +++ b/include/wamon/ast.h @@ -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_"; }