Skip to content

Commit

Permalink
Merge pull request #58 from kroma-network/build/check-node-buildable-…
Browse files Browse the repository at this point in the history
…using-bazel-condition

build: check node buildable using bazel condition
  • Loading branch information
chokobole authored Sep 21, 2023
2 parents a00a1c9 + 1dda9d6 commit bba38a4
Show file tree
Hide file tree
Showing 41 changed files with 36 additions and 156 deletions.
3 changes: 2 additions & 1 deletion tachyon/node/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
],
Expand Down
4 changes: 2 additions & 2 deletions tachyon/node/base/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions tachyon/node/base/node_constructors.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if defined(TACHYON_NODE_BINDING)

#include "tachyon/node/base/node_constructors.h"

namespace tachyon::node {
Expand Down Expand Up @@ -35,5 +33,3 @@ bool NodeConstructors::InstanceOf(Napi::Object object, std::string_view name) {
}

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)
4 changes: 0 additions & 4 deletions tachyon/node/base/node_constructors.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef TACHYON_NODE_BASE_NODE_CONSTRUCTORS_H_
#define TACHYON_NODE_BASE_NODE_CONSTRUCTORS_H_

#if defined(TACHYON_NODE_BINDING)

#include <string>
#include <string_view>

Expand Down Expand Up @@ -38,6 +36,4 @@ class TACHYON_EXPORT NodeConstructors {

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)

#endif // TACHYON_NODE_BASE_NODE_CONSTRUCTORS_H_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_bindable.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if defined(TACHYON_NODE_BINDING)

#include "tachyon/node/base/node_cpp_bindable.h"

#include "absl/strings/substitute.h"
Expand Down Expand Up @@ -27,5 +25,3 @@ NodeCppBindable& NodeCppBindable::operator=(NodeCppBindable&& other) noexcept =
NodeCppBindable::~NodeCppBindable() = default;

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_bindable.h
Original file line number Diff line number Diff line change
@@ -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 <string>
#include <string_view>

Expand Down Expand Up @@ -32,6 +30,4 @@ class TACHYON_EXPORT NodeCppBindable {

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)

#endif // TACHYON_NODE_BASE_NODE_CPP_BINDABLE_H_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_callable.h
Original file line number Diff line number Diff line change
@@ -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 <tuple>

#include "absl/strings/substitute.h"
Expand Down Expand Up @@ -346,6 +344,4 @@ class NodeCppCallable {

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)

#endif // TACHYON_NODE_BASE_NODE_CPP_CALLABLE_H_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_callable_data.h
Original file line number Diff line number Diff line change
@@ -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 <type_traits>
#include <vector>

Expand Down Expand Up @@ -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_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_class.h
Original file line number Diff line number Diff line change
@@ -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 <string_view>

#include "absl/strings/substitute.h"
Expand Down Expand Up @@ -368,6 +366,4 @@ class NodeCppClass : public NodeCppBindable {

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)

#endif // TACHYON_NODE_BASE_NODE_CPP_CLASS_H_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_constructor.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if defined(TACHYON_NODE_BINDING)

#include "tachyon/node/base/node_cpp_constructor.h"

#include "tachyon/base/strings/string_util.h"
Expand Down Expand Up @@ -75,5 +73,3 @@ bool NodeCppConstructor::Match(const Napi::CallbackInfo& info) const {
}

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_constructor.h
Original file line number Diff line number Diff line change
@@ -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 <string>
#include <vector>

Expand Down Expand Up @@ -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_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_constructor_matcher.h
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_enum.h
Original file line number Diff line number Diff line change
@@ -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 <string_view>
#include <type_traits>

Expand Down Expand Up @@ -47,6 +45,4 @@ class NodeCppEnum : public NodeCppBindable {

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)

#endif // TACHYON_NODE_BASE_NODE_CPP_ENUM_H_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_cpp_object.h
Original file line number Diff line number Diff line change
@@ -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 <string_view>

#include "tachyon/base/binding/cpp_stack_value.h"
Expand Down Expand Up @@ -154,6 +152,4 @@ Napi::FunctionReference NodeCppObject<T>::s_constructor_;

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)

#endif // TACHYON_NODE_BASE_NODE_CPP_OBJECT_H_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_errors.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if defined(TACHYON_NODE_BINDING)

#include "tachyon/node/base/node_errors.h"

#include "absl/strings/substitute.h"
Expand Down Expand Up @@ -27,5 +25,3 @@ Napi::Error NoSuchConstructor(Napi::Env env) {
}

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)
4 changes: 0 additions & 4 deletions tachyon/node/base/node_errors.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef TACHYON_NODE_BASE_NODE_ERRORS_H_
#define TACHYON_NODE_BASE_NODE_ERRORS_H_

#if defined(TACHYON_NODE_BINDING)

#include <stddef.h>

#include "third_party/node_addon_api/napi.h"
Expand All @@ -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_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_internals.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef TACHYON_NODE_BASE_NODE_INTERNALS_H_
#define TACHYON_NODE_BASE_NODE_INTERNALS_H_

#if defined(TACHYON_NODE_BINDING)

#include <string>
#include <string_view>
#include <vector>
Expand Down Expand Up @@ -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_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_internals_forwards.h
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -51,6 +49,4 @@ struct HasToJSValue<
} // namespace internal
} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)

#endif // TACHYON_NODE_BASE_NODE_INTERNALS_FORWARDS_H_
4 changes: 0 additions & 4 deletions tachyon/node/base/node_module.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if defined(TACHYON_NODE_BINDING)

#include "tachyon/node/base/node_module.h"

namespace tachyon::node {
Expand All @@ -24,5 +22,3 @@ NodeModule NodeModule::AddSubModule(std::string_view name) {
}

} // namespace tachyon::node

#endif // defined(TACHYON_NODE_BINDING)
4 changes: 0 additions & 4 deletions tachyon/node/base/node_module.h
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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_
7 changes: 4 additions & 3 deletions tachyon/node/base/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions tachyon/node/base/test/color.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#if defined(TACHYON_NODE_BINDING)

#include "tachyon/node/base/test/color.h"

#include "tachyon/base/binding/test/color.h"

void AddColor(tachyon::node::NodeModule& m) {
using namespace tachyon::base::test;
}

#endif // defined(TACHYON_NODE_BINDING)
4 changes: 0 additions & 4 deletions tachyon/node/base/test/color.h
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions tachyon/node/base/test/enum.cc
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 13 additions & 0 deletions tachyon/node/base/test/function.cc
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 0 additions & 4 deletions tachyon/node/base/test/point.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if defined(TACHYON_NODE_BINDING)

#include "tachyon/node/base/test/point.h"

void AddPoint(tachyon::node::NodeModule& m) {
Expand Down Expand Up @@ -29,5 +27,3 @@ void DoubleWithSharedPtr(std::shared_ptr<tachyon::base::test::Point> p) {
}

void DoubleWithUniquePtr(std::unique_ptr<tachyon::base::test::Point> p) {}

#endif // defined(TACHYON_NODE_BINDING)
4 changes: 0 additions & 4 deletions tachyon/node/base/test/point.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if defined(TACHYON_NODE_BINDING)

#include <string_view>

#include "tachyon/base/binding/test/point.h"
Expand Down Expand Up @@ -40,5 +38,3 @@ void DoubleWithReference(tachyon::base::test::Point& p);
void DoubleWithSharedPtr(std::shared_ptr<tachyon::base::test::Point> p);

void DoubleWithUniquePtr(std::unique_ptr<tachyon::base::test::Point> p);

#endif // defined(TACHYON_NODE_BINDING)
Loading

0 comments on commit bba38a4

Please sign in to comment.