diff --git a/tachyon/node/BUILD.bazel b/tachyon/node/BUILD.bazel index 61cd457d2..27863617a 100644 --- a/tachyon/node/BUILD.bazel +++ b/tachyon/node/BUILD.bazel @@ -1,8 +1,9 @@ +load("//bazel:tachyon.bzl", "if_node_binding") load("//bazel:tachyon_node.bzl", "tachyon_node_library") tachyon_node_library( name = "tachyon", - srcs = ["tachyon.cc"], + srcs = if_node_binding(["tachyon.cc"]), deps = [ "//tachyon/node/math", ], diff --git a/tachyon/node/base/BUILD.bazel b/tachyon/node/base/BUILD.bazel index 3928f524a..8dd8d1a13 100644 --- a/tachyon/node/base/BUILD.bazel +++ b/tachyon/node/base/BUILD.bazel @@ -3,7 +3,7 @@ load("//bazel:tachyon_cc.bzl", "tachyon_cc_library") tachyon_cc_library( name = "node_base", - srcs = [ + srcs = if_node_binding([ "node_constructors.cc", "node_constructors.h", "node_cpp_bindable.cc", @@ -18,7 +18,7 @@ tachyon_cc_library( "node_internals.h", "node_internals_forwards.h", "node_module.cc", - ], + ]), hdrs = [ "node_cpp_class.h", "node_cpp_enum.h", diff --git a/tachyon/node/base/node_constructors.cc b/tachyon/node/base/node_constructors.cc index 57996d6e0..54e1dad09 100644 --- a/tachyon/node/base/node_constructors.cc +++ b/tachyon/node/base/node_constructors.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/base/node_constructors.h" namespace tachyon::node { @@ -35,5 +33,3 @@ bool NodeConstructors::InstanceOf(Napi::Object object, std::string_view name) { } } // namespace tachyon::node - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/base/node_constructors.h b/tachyon/node/base/node_constructors.h index 3bb87888d..24e33bae2 100644 --- a/tachyon/node/base/node_constructors.h +++ b/tachyon/node/base/node_constructors.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_CONSTRUCTORS_H_ #define TACHYON_NODE_BASE_NODE_CONSTRUCTORS_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include @@ -38,6 +36,4 @@ class TACHYON_EXPORT NodeConstructors { } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_CONSTRUCTORS_H_ diff --git a/tachyon/node/base/node_cpp_bindable.cc b/tachyon/node/base/node_cpp_bindable.cc index 6a6ccc4ba..a2bd86709 100644 --- a/tachyon/node/base/node_cpp_bindable.cc +++ b/tachyon/node/base/node_cpp_bindable.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/base/node_cpp_bindable.h" #include "absl/strings/substitute.h" @@ -27,5 +25,3 @@ NodeCppBindable& NodeCppBindable::operator=(NodeCppBindable&& other) noexcept = NodeCppBindable::~NodeCppBindable() = default; } // namespace tachyon::node - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/base/node_cpp_bindable.h b/tachyon/node/base/node_cpp_bindable.h index 979406d55..93dc27e77 100644 --- a/tachyon/node/base/node_cpp_bindable.h +++ b/tachyon/node/base/node_cpp_bindable.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_CPP_BINDABLE_H_ #define TACHYON_NODE_BASE_NODE_CPP_BINDABLE_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include @@ -32,6 +30,4 @@ class TACHYON_EXPORT NodeCppBindable { } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_CPP_BINDABLE_H_ diff --git a/tachyon/node/base/node_cpp_callable.h b/tachyon/node/base/node_cpp_callable.h index 1d4ef8030..6094fabcd 100644 --- a/tachyon/node/base/node_cpp_callable.h +++ b/tachyon/node/base/node_cpp_callable.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_CPP_CALLABLE_H_ #define TACHYON_NODE_BASE_NODE_CPP_CALLABLE_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include "absl/strings/substitute.h" @@ -346,6 +344,4 @@ class NodeCppCallable { } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_CPP_CALLABLE_H_ diff --git a/tachyon/node/base/node_cpp_callable_data.h b/tachyon/node/base/node_cpp_callable_data.h index 8fc5fa323..fdea3be02 100644 --- a/tachyon/node/base/node_cpp_callable_data.h +++ b/tachyon/node/base/node_cpp_callable_data.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_CPP_CALLABLE_DATA_H_ #define TACHYON_NODE_BASE_NODE_CPP_CALLABLE_DATA_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include @@ -63,6 +61,4 @@ struct TACHYON_EXPORT NodeCppStaticPropertyAccessorData } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_CPP_CALLABLE_DATA_H_ diff --git a/tachyon/node/base/node_cpp_class.h b/tachyon/node/base/node_cpp_class.h index 2a44f90d2..fbcccdac6 100644 --- a/tachyon/node/base/node_cpp_class.h +++ b/tachyon/node/base/node_cpp_class.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_CPP_CLASS_H_ #define TACHYON_NODE_BASE_NODE_CPP_CLASS_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include "absl/strings/substitute.h" @@ -368,6 +366,4 @@ class NodeCppClass : public NodeCppBindable { } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_CPP_CLASS_H_ diff --git a/tachyon/node/base/node_cpp_constructor.cc b/tachyon/node/base/node_cpp_constructor.cc index d73e2a0b3..93a44e0dd 100644 --- a/tachyon/node/base/node_cpp_constructor.cc +++ b/tachyon/node/base/node_cpp_constructor.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/base/node_cpp_constructor.h" #include "tachyon/base/strings/string_util.h" @@ -75,5 +73,3 @@ bool NodeCppConstructor::Match(const Napi::CallbackInfo& info) const { } } // namespace tachyon::node - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/base/node_cpp_constructor.h b/tachyon/node/base/node_cpp_constructor.h index 09e0c562b..7bdc979ba 100644 --- a/tachyon/node/base/node_cpp_constructor.h +++ b/tachyon/node/base/node_cpp_constructor.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_CPP_CONSTRUCTOR_H_ #define TACHYON_NODE_BASE_NODE_CPP_CONSTRUCTOR_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include @@ -63,6 +61,4 @@ class TACHYON_EXPORT NodeCppConstructor : public base::CppConstructor { } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_CPP_CONSTRUCTOR_H_ diff --git a/tachyon/node/base/node_cpp_constructor_matcher.h b/tachyon/node/base/node_cpp_constructor_matcher.h index c14b17d5d..07ec71468 100644 --- a/tachyon/node/base/node_cpp_constructor_matcher.h +++ b/tachyon/node/base/node_cpp_constructor_matcher.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_CPP_CONSTRUCTOR_MATCHER_H_ #define TACHYON_NODE_BASE_NODE_CPP_CONSTRUCTOR_MATCHER_H_ -#if defined(TACHYON_NODE_BINDING) - #include "third_party/node_addon_api/napi.h" #include "tachyon/base/binding/cpp_constructor_matcher.h" @@ -44,6 +42,4 @@ class NodeCppConstructorMatcher : public base::CppConstructorMatcher { } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_CPP_CONSTRUCTOR_MATCHER_H_ diff --git a/tachyon/node/base/node_cpp_enum.h b/tachyon/node/base/node_cpp_enum.h index e7b7ade8a..dec74d130 100644 --- a/tachyon/node/base/node_cpp_enum.h +++ b/tachyon/node/base/node_cpp_enum.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_CPP_ENUM_H_ #define TACHYON_NODE_BASE_NODE_CPP_ENUM_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include @@ -47,6 +45,4 @@ class NodeCppEnum : public NodeCppBindable { } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_CPP_ENUM_H_ diff --git a/tachyon/node/base/node_cpp_object.h b/tachyon/node/base/node_cpp_object.h index 5f1761906..a63d6059b 100644 --- a/tachyon/node/base/node_cpp_object.h +++ b/tachyon/node/base/node_cpp_object.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_CPP_OBJECT_H_ #define TACHYON_NODE_BASE_NODE_CPP_OBJECT_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include "tachyon/base/binding/cpp_stack_value.h" @@ -154,6 +152,4 @@ Napi::FunctionReference NodeCppObject::s_constructor_; } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_CPP_OBJECT_H_ diff --git a/tachyon/node/base/node_errors.cc b/tachyon/node/base/node_errors.cc index 1c0fd30d4..e61f1d3b4 100644 --- a/tachyon/node/base/node_errors.cc +++ b/tachyon/node/base/node_errors.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/base/node_errors.h" #include "absl/strings/substitute.h" @@ -27,5 +25,3 @@ Napi::Error NoSuchConstructor(Napi::Env env) { } } // namespace tachyon::node - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/base/node_errors.h b/tachyon/node/base/node_errors.h index 179a5a4f2..dc6a3d8c8 100644 --- a/tachyon/node/base/node_errors.h +++ b/tachyon/node/base/node_errors.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_ERRORS_H_ #define TACHYON_NODE_BASE_NODE_ERRORS_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include "third_party/node_addon_api/napi.h" @@ -19,6 +17,4 @@ TACHYON_EXPORT Napi::Error NoSuchConstructor(Napi::Env env); } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_ERRORS_H_ diff --git a/tachyon/node/base/node_internals.h b/tachyon/node/base/node_internals.h index 5898823a5..fd24fe191 100644 --- a/tachyon/node/base/node_internals.h +++ b/tachyon/node/base/node_internals.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_INTERNALS_H_ #define TACHYON_NODE_BASE_NODE_INTERNALS_H_ -#if defined(TACHYON_NODE_BINDING) - #include #include #include @@ -497,6 +495,4 @@ Napi::Value ToJSValue(const Napi::CallbackInfo& info, T&& value) { } // namespace internal } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_INTERNALS_H_ diff --git a/tachyon/node/base/node_internals_forwards.h b/tachyon/node/base/node_internals_forwards.h index 05da0f3b9..4dbf8a064 100644 --- a/tachyon/node/base/node_internals_forwards.h +++ b/tachyon/node/base/node_internals_forwards.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_INTERNALS_FORWARDS_H_ #define TACHYON_NODE_BASE_NODE_INTERNALS_FORWARDS_H_ -#if defined(TACHYON_NODE_BINDING) - #include "absl/meta/type_traits.h" #include "third_party/node_addon_api/napi.h" @@ -51,6 +49,4 @@ struct HasToJSValue< } // namespace internal } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_INTERNALS_FORWARDS_H_ diff --git a/tachyon/node/base/node_module.cc b/tachyon/node/base/node_module.cc index 09430a96e..499a0dbd1 100644 --- a/tachyon/node/base/node_module.cc +++ b/tachyon/node/base/node_module.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/base/node_module.h" namespace tachyon::node { @@ -24,5 +22,3 @@ NodeModule NodeModule::AddSubModule(std::string_view name) { } } // namespace tachyon::node - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/base/node_module.h b/tachyon/node/base/node_module.h index ac5181f9c..a1bfd2b46 100644 --- a/tachyon/node/base/node_module.h +++ b/tachyon/node/base/node_module.h @@ -1,8 +1,6 @@ #ifndef TACHYON_NODE_BASE_NODE_MODULE_H_ #define TACHYON_NODE_BASE_NODE_MODULE_H_ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/export.h" #include "tachyon/node/base/node_cpp_bindable.h" #include "tachyon/node/base/node_cpp_callable.h" @@ -56,6 +54,4 @@ class TACHYON_EXPORT NodeModule : public NodeCppBindable { } // namespace tachyon::node -#endif // defined(TACHYON_NODE_BINDING) - #endif // TACHYON_NODE_BASE_NODE_MODULE_H_ diff --git a/tachyon/node/base/test/BUILD.bazel b/tachyon/node/base/test/BUILD.bazel index dd5c7a0c9..cbb67cd0a 100644 --- a/tachyon/node/base/test/BUILD.bazel +++ b/tachyon/node/base/test/BUILD.bazel @@ -1,10 +1,11 @@ +load("//bazel:tachyon.bzl", "if_node_binding") load("//bazel:tachyon_cc.bzl", "tachyon_cc_library") load("//bazel:tachyon_node.bzl", "tachyon_node_library") tachyon_cc_library( name = "color", testonly = True, - srcs = ["color.cc"], + srcs = if_node_binding(["color.cc"]), hdrs = ["color.h"], deps = [ "//tachyon/base/binding/test:enum", @@ -15,7 +16,7 @@ tachyon_cc_library( tachyon_cc_library( name = "point", testonly = True, - srcs = ["point.cc"], + srcs = if_node_binding(["point.cc"]), hdrs = ["point.h"], deps = [ "//tachyon/base/binding/test:class", @@ -26,7 +27,7 @@ tachyon_cc_library( tachyon_node_library( name = "test", testonly = True, - srcs = ["test.cc"], + srcs = if_node_binding(["test.cc"]), deps = [ ":color", ":point", diff --git a/tachyon/node/base/test/color.cc b/tachyon/node/base/test/color.cc index 6874544cb..6eac911d7 100644 --- a/tachyon/node/base/test/color.cc +++ b/tachyon/node/base/test/color.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/base/test/color.h" #include "tachyon/base/binding/test/color.h" @@ -7,5 +5,3 @@ void AddColor(tachyon::node::NodeModule& m) { using namespace tachyon::base::test; } - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/base/test/color.h b/tachyon/node/base/test/color.h index 85b9b6f19..e9a2142c0 100644 --- a/tachyon/node/base/test/color.h +++ b/tachyon/node/base/test/color.h @@ -1,7 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/base/node_module.h" void AddColor(tachyon::node::NodeModule& m); - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/base/test/enum.cc b/tachyon/node/base/test/enum.cc new file mode 100644 index 000000000..7d6266425 --- /dev/null +++ b/tachyon/node/base/test/enum.cc @@ -0,0 +1,9 @@ +#include "tachyon/node/base/test/color.h" + +Napi::Object Init(Napi::Env env, Napi::Object exports) { + tachyon::node::NodeModule module(env, exports); + AddColor(module); + return exports; +} + +NODE_API_MODULE(enum, Init) diff --git a/tachyon/node/base/test/function.cc b/tachyon/node/base/test/function.cc new file mode 100644 index 000000000..b5a2cf956 --- /dev/null +++ b/tachyon/node/base/test/function.cc @@ -0,0 +1,13 @@ +#include "tachyon/base/binding/test/functions.h" +#include "tachyon/node/base/node_module.h" + +Napi::Object Init(Napi::Env env, Napi::Object exports) { + using namespace tachyon::base::test; + tachyon::node::NodeModule module(env, exports); + module.AddFunction("hello", &Hello) + .AddFunction("sum", &Sum, 1, 2) + .AddFunction("do_nothing", &DoNothing); + return exports; +} + +NODE_API_MODULE(function, Init) diff --git a/tachyon/node/base/test/point.cc b/tachyon/node/base/test/point.cc index 8aa5286d0..305a74439 100644 --- a/tachyon/node/base/test/point.cc +++ b/tachyon/node/base/test/point.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/base/test/point.h" void AddPoint(tachyon::node::NodeModule& m) { @@ -29,5 +27,3 @@ void DoubleWithSharedPtr(std::shared_ptr p) { } void DoubleWithUniquePtr(std::unique_ptr p) {} - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/base/test/point.h b/tachyon/node/base/test/point.h index 2903584db..cac625a2d 100644 --- a/tachyon/node/base/test/point.h +++ b/tachyon/node/base/test/point.h @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include #include "tachyon/base/binding/test/point.h" @@ -40,5 +38,3 @@ void DoubleWithReference(tachyon::base::test::Point& p); void DoubleWithSharedPtr(std::shared_ptr p); void DoubleWithUniquePtr(std::unique_ptr p); - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/base/test/test.cc b/tachyon/node/base/test/test.cc index afeed4bea..efe471f49 100644 --- a/tachyon/node/base/test/test.cc +++ b/tachyon/node/base/test/test.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/base/binding/test/adder.h" #include "tachyon/base/binding/test/colored_point.h" #include "tachyon/base/binding/test/functions.h" @@ -77,5 +75,3 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) { } NODE_API_MODULE(test, Init) - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/math/BUILD.bazel b/tachyon/node/math/BUILD.bazel index c442b1234..59ebfb330 100644 --- a/tachyon/node/math/BUILD.bazel +++ b/tachyon/node/math/BUILD.bazel @@ -1,3 +1,4 @@ +load("//bazel:tachyon.bzl", "if_node_binding") load("//bazel:tachyon_cc.bzl", "tachyon_cc_library") package(default_visibility = ["//tachyon/node:__pkg__"]) @@ -17,7 +18,7 @@ CURVE_DEPS = [tpl.format(curve) for tpl in TPLS for curve in CURVES] tachyon_cc_library( name = "math", - srcs = ["math.cc"], + srcs = if_node_binding(["math.cc"]), hdrs = ["math.h"], deps = CURVE_DEPS, ) diff --git a/tachyon/node/math/base/big_int.h b/tachyon/node/math/base/big_int.h index b30e9a8d4..8336f7f1e 100644 --- a/tachyon/node/math/base/big_int.h +++ b/tachyon/node/math/base/big_int.h @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #ifndef TACHYON_NODE_MATH_BASE_BIG_INT_H_ #define TACHYON_NODE_MATH_BASE_BIG_INT_H_ @@ -71,5 +69,3 @@ class CppValueTraits> { } // namespace tachyon::node #endif // TACHYON_NODE_MATH_FINITE_FIELDS_PRIME_FIELD_H_ - -#endif // defined(TACHYON_NODE_MATH_BASE_BIG_INT_H_ diff --git a/tachyon/node/math/elliptic_curves/generator/build_defs.bzl b/tachyon/node/math/elliptic_curves/generator/build_defs.bzl index 5cac81034..f733490f5 100644 --- a/tachyon/node/math/elliptic_curves/generator/build_defs.bzl +++ b/tachyon/node/math/elliptic_curves/generator/build_defs.bzl @@ -1,3 +1,4 @@ +load("//bazel:tachyon.bzl", "if_node_binding") load("//bazel:tachyon_cc.bzl", "tachyon_cc_library") def _generate_ec_point_impl(ctx): @@ -50,7 +51,7 @@ def generate_ec_points( tachyon_cc_library( name = "fq", hdrs = ["fq.h"], - srcs = ["fq.cc"], + srcs = if_node_binding(["fq.cc"]), deps = g1_deps + [ "//tachyon/node/math/finite_fields:prime_field", ], @@ -59,7 +60,7 @@ def generate_ec_points( tachyon_cc_library( name = "fr", hdrs = ["fr.h"], - srcs = ["fr.cc"], + srcs = if_node_binding(["fr.cc"]), deps = g1_deps + [ "//tachyon/node/math/finite_fields:prime_field", ], @@ -68,7 +69,7 @@ def generate_ec_points( tachyon_cc_library( name = "g1", hdrs = ["g1.h"], - srcs = ["g1.cc"], + srcs = if_node_binding(["g1.cc"]), deps = g1_deps + [ "//tachyon/node/math/elliptic_curves/short_weierstrass:points", ], diff --git a/tachyon/node/math/elliptic_curves/generator/generator.cc b/tachyon/node/math/elliptic_curves/generator/generator.cc index ee6ab7ae4..68e250af7 100644 --- a/tachyon/node/math/elliptic_curves/generator/generator.cc +++ b/tachyon/node/math/elliptic_curves/generator/generator.cc @@ -25,8 +25,6 @@ struct GenerationConfig : public build::CcWriter { int GenerationConfig::GeneratePrimeFieldHdr(std::string_view suffix) const { // clang-format off std::vector tpl = { - "#if defined(TACHYON_NODE_BINDING)", - "", "#include \"tachyon/node/base/node_module.h\"", "", "namespace tachyon::node::math::%{type} {", @@ -34,8 +32,6 @@ int GenerationConfig::GeneratePrimeFieldHdr(std::string_view suffix) const { "void Add%{cc_field}(NodeModule& m);", "", "} // namespace tachyon::node::math::%{type}", - "", - "#endif // defined(TACHYON_NODE_BINDING)", }; // clang-format on @@ -60,8 +56,6 @@ int GenerationConfig::GenerateFrHdr() const { int GenerationConfig::GeneratePrimeFieldSrc(std::string_view suffix) const { // clang-format off std::vector tpl = { - "#if defined(TACHYON_NODE_BINDING)", - "", "#include \"tachyon/math/elliptic_curves/%{header_dir_name}/%{suffix}.h\"", "#include \"tachyon/node/math/finite_fields/prime_field.h\"", "", @@ -72,8 +66,6 @@ int GenerationConfig::GeneratePrimeFieldSrc(std::string_view suffix) const { "}", "", "} // namespace tachyon::node::math::%{type}", - "", - "#endif // defined(TACHYON_NODE_BINDING)", }; // clang-format on @@ -100,8 +92,6 @@ int GenerationConfig::GenerateFrSrc() const { int GenerationConfig::GenerateG1Hdr() const { // clang-format off std::vector tpl = { - "#if defined(TACHYON_NODE_BINDING)", - "", "#include \"tachyon/node/base/node_module.h\"", "", "namespace tachyon::node::math::%{type} {", @@ -109,8 +99,6 @@ int GenerationConfig::GenerateG1Hdr() const { "void AddG1(NodeModule& m);", "", "} // namespace tachyon::node::math::%{type}", - "", - "#endif // defined(TACHYON_NODE_BINDING)", }; // clang-format on @@ -125,8 +113,6 @@ int GenerationConfig::GenerateG1Hdr() const { int GenerationConfig::GenerateG1Src() const { // clang-format off std::vector tpl = { - "#if defined(TACHYON_NODE_BINDING)", - "", "#include \"tachyon/math/elliptic_curves/%{header_dir_name}/g1.h\"", "#include \"tachyon/node/math/elliptic_curves/short_weierstrass/affine_point.h\"", "#include \"tachyon/node/math/elliptic_curves/short_weierstrass/projective_point.h\"", @@ -143,8 +129,6 @@ int GenerationConfig::GenerateG1Src() const { "}", "", "} // namespace tachyon::node::math::%{type}", - "", - "#endif // defined(TACHYON_NODE_BINDING)", }; // clang-format on diff --git a/tachyon/node/math/elliptic_curves/short_weierstrass/affine_point.h b/tachyon/node/math/elliptic_curves/short_weierstrass/affine_point.h index a8ba863ea..0a26a3f69 100644 --- a/tachyon/node/math/elliptic_curves/short_weierstrass/affine_point.h +++ b/tachyon/node/math/elliptic_curves/short_weierstrass/affine_point.h @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #ifndef TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_AFFINE_POINT_H_ #define TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_AFFINE_POINT_H_ @@ -34,5 +32,3 @@ void AddAffinePoint(NodeModule& m, std::string_view name) { } // namespace tachyon::node::math #endif // TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_AFFINE_POINT_H_ - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/math/elliptic_curves/short_weierstrass/jacobian_point.h b/tachyon/node/math/elliptic_curves/short_weierstrass/jacobian_point.h index d057623cb..1e81fa53c 100644 --- a/tachyon/node/math/elliptic_curves/short_weierstrass/jacobian_point.h +++ b/tachyon/node/math/elliptic_curves/short_weierstrass/jacobian_point.h @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #ifndef TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_JACOBIAN_POINT_H_ #define TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_JACOBIAN_POINT_H_ @@ -44,5 +42,3 @@ void AddJacobianPoint(NodeModule& m, std::string_view name) { } // namespace tachyon::node::math #endif // TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_JACOBIAN_POINT_H_ - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/math/elliptic_curves/short_weierstrass/point_xyzz.h b/tachyon/node/math/elliptic_curves/short_weierstrass/point_xyzz.h index 7b224cd03..acf78023e 100644 --- a/tachyon/node/math/elliptic_curves/short_weierstrass/point_xyzz.h +++ b/tachyon/node/math/elliptic_curves/short_weierstrass/point_xyzz.h @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #ifndef TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_POINT_XYZZ_H_ #define TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_POINT_XYZZ_H_ @@ -45,5 +43,3 @@ void AddPointXYZZ(NodeModule& m, std::string_view name) { } // namespace tachyon::node::math #endif // TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_POINT_XYZZ_H_ - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/math/elliptic_curves/short_weierstrass/projective_point.h b/tachyon/node/math/elliptic_curves/short_weierstrass/projective_point.h index 6bfcff879..92b41b92f 100644 --- a/tachyon/node/math/elliptic_curves/short_weierstrass/projective_point.h +++ b/tachyon/node/math/elliptic_curves/short_weierstrass/projective_point.h @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #ifndef TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_PROJECTIVE_POINT_H_ #define TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_PROJECTIVE_POINT_H_ @@ -44,5 +42,3 @@ void AddProjectivePoint(NodeModule& m, std::string_view name) { } // namespace tachyon::node::math #endif // TACHYON_NODE_MATH_ELLIPTIC_CURVES_SHORT_WEIERSTRASS_PROJECTIVE_POINT_H_ - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/math/finite_fields/prime_field.h b/tachyon/node/math/finite_fields/prime_field.h index 1110bbc36..49249f39b 100644 --- a/tachyon/node/math/finite_fields/prime_field.h +++ b/tachyon/node/math/finite_fields/prime_field.h @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #ifndef TACHYON_NODE_MATH_FINITE_FIELDS_PRIME_FIELD_H_ #define TACHYON_NODE_MATH_FINITE_FIELDS_PRIME_FIELD_H_ @@ -54,5 +52,3 @@ void AddPrimeField(NodeModule& m, std::string_view name) { } // namespace tachyon::node::math #endif // TACHYON_NODE_MATH_FINITE_FIELDS_PRIME_FIELD_H_ - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/math/math.cc b/tachyon/node/math/math.cc index d555c5121..e6b7550cd 100644 --- a/tachyon/node/math/math.cc +++ b/tachyon/node/math/math.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/math/math.h" #include "tachyon/math/elliptic_curves/bls/bls12_381/g1.h" @@ -28,5 +26,3 @@ void AddMath(NodeModule& m) { } } // namespace tachyon::node::math - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/math/math.h b/tachyon/node/math/math.h index 20513a76d..d4fe73f5c 100644 --- a/tachyon/node/math/math.h +++ b/tachyon/node/math/math.h @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #ifndef TACHYON_NODE_MATH_MATH_H_ #define TACHYON_NODE_MATH_MATH_H_ @@ -12,5 +10,3 @@ void AddMath(NodeModule& m); } // namespace tachyon::node::math #endif // TACHYON_NODE_MATH_MATH_H_ - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/tachyon/node/tachyon.cc b/tachyon/node/tachyon.cc index 26d7860f8..496761dff 100644 --- a/tachyon/node/tachyon.cc +++ b/tachyon/node/tachyon.cc @@ -1,5 +1,3 @@ -#if defined(TACHYON_NODE_BINDING) - #include "tachyon/node/math/math.h" Napi::Object Init(Napi::Env env, Napi::Object exports) { @@ -10,5 +8,3 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) { } NODE_API_MODULE(tachyon, Init) - -#endif // defined(TACHYON_NODE_BINDING) diff --git a/third_party/node_addon_api/BUILD.tpl b/third_party/node_addon_api/BUILD.tpl index c81dae512..4c602ef71 100644 --- a/third_party/node_addon_api/BUILD.tpl +++ b/third_party/node_addon_api/BUILD.tpl @@ -8,8 +8,6 @@ cc_library( "node_modules/node-addon-api/napi-inl.h", ], defines = [ - "TACHYON_NODE_BINDING", - ] + [ "NODE_GYP_MODULE_NAME", "USING_UV_SHARED=1", "USING_V8_SHARED=1",