Skip to content

Commit

Permalink
[compile] Feat bazel (#377)
Browse files Browse the repository at this point in the history
* feat(bazel)

* feat(bazel)
  • Loading branch information
PaPaPig-Melody committed May 26, 2024
1 parent 2c42a2b commit b1a663e
Show file tree
Hide file tree
Showing 49 changed files with 194 additions and 42 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@
/.scannerwork/
.vscode/
/.cache/
/bazel-bin
/bazel-CGraph
/bazel-out
/bazel-testlogs
/MODULE.bazel
/MODULE.bazel.lock

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

#### MyNode.h
```cpp
#include "CGraph.h"
#include "../src/CGraph.h"

class MyNode1 : public CGraph::GNode {
public:
Expand Down
2 changes: 1 addition & 1 deletion README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ You can transfer your params in many scenes. It is also possible to extend the f

#### MyNode.h
```cpp
#include "CGraph.h"
#include "../src/CGraph.h"

class MyNode1 : public CGraph::GNode {
public:
Expand Down
Empty file added WORKSPACE
Empty file.
40 changes: 40 additions & 0 deletions example/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# NOET: test all the examples at a time
test_suite(
name = "test_all_examples",
tests = [":E01-AutoPilot",":E02-MockGUI",":E03-ThirdFlow",":E04-MapReduce"],
)

# test-1: E01-AutoPilot
cc_test (
name = "E01-AutoPilot",
srcs = ["E01-AutoPilot.cpp"],
deps = ["//src:CGraph",],
)

# test-2: E02-MockGUI
cc_test (
name = "E02-MockGUI",
srcs = ["E02-MockGUI.cpp"],
deps = ["//src:CGraph",],
)

# test-3: E03-ThirdFlow
cc_test (
name = "E03-ThirdFlow",
srcs = ["E03-ThirdFlow.cpp"],
deps = ["//src:CGraph",],
)

# test-4: E04-MapReduce
cc_test (
name = "E04-MapReduce",
srcs = ["E04-MapReduce.cpp"],
deps = ["//src:CGraph",],
)

# import the CGraph.h from src dir
# cc_import(
# name = "CGraph_h",
# hdrs = ["src/CGraph.h"],
# visibility = ["//visibility:public"],
# )
2 changes: 1 addition & 1 deletion example/E01-AutoPilot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <cstring>
#include <memory>

#include "CGraph.h"
#include "src/CGraph.h"

using namespace CGraph;

Expand Down
2 changes: 1 addition & 1 deletion example/E02-MockGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <cmath>
#include <set>

#include "CGraph.h"
#include "src/CGraph.h"

using namespace CGraph;

Expand Down
2 changes: 1 addition & 1 deletion example/E03-ThirdFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <cmath>
#include <memory>

#include "CGraph.h"
#include "src/CGraph.h"

using namespace CGraph;

Expand Down
2 changes: 1 addition & 1 deletion example/E04-MapReduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <random>
#include <vector>

#include "CGraph.h"
#include "src/CGraph.h"

using namespace CGraph;

Expand Down
14 changes: 14 additions & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "CGraph",
srcs = glob(["**/*.cpp"]),
hdrs = glob(["**/*.h", "**/*.inl"]),
copts = [
"-D_CGRAPH_SILENCE",
"-D_CGRAPH_SHOW_THREAD_METRICS_",
"-D_ENABLE_LIKELY_",
],
linkstatic = 0,
visibility = ["//visibility:public"],
)
4 changes: 2 additions & 2 deletions src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <functional>

#include "GRegion.h"
#include "GraphCtrl/GraphElement/_GOptimizer/GOptimizerInclude.h"

// #include "GraphCtrl/GraphElement/_GOptimizer/GOptimizerInclude.h"
#include "../../_GOptimizer/GOptimizerInclude.h"
CGRAPH_NAMESPACE_BEGIN

GRegion::GRegion() : GGroup() {
Expand Down
18 changes: 18 additions & 0 deletions test/Functional/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CGRAPH_FUNCTIONAL_LIST = [
"test-functional-01",
"test-functional-02",
"test-functional-03",
"test-functional-04",
"test-functional-05",
]

[
cc_test(
name = "%s" % fun_name,
srcs = ["%s.cpp" % fun_name],

deps = ["//src:CGraph",
"//test/_Materials:test_materials",],
)
for fun_name in CGRAPH_FUNCTIONAL_LIST
]
15 changes: 15 additions & 0 deletions test/Performance/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CGRAPH_PERFORMANCE_LIST = [
"test-performance-01",
"test-performance-02",
"test-performance-03",
]

[
cc_test(
name = "%s" % perf_name,
srcs = ["%s.cpp" % perf_name],
deps = ["//src:CGraph",
"//test/_Materials:test_materials",],
)
for perf_name in CGRAPH_PERFORMANCE_LIST
]
6 changes: 6 additions & 0 deletions test/_Materials/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cc_library(
name = "test_materials",
hdrs = glob(["**/*.h"]),
linkstatic = 0,
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion test/_Materials/TestCommonDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <atomic>

#include "CGraph.h"
#include "src/CGraph.h"

std::atomic<unsigned int> g_test_node_cnt = {0};
static const char* g_test_message_key = "test-message-key";
Expand Down
52 changes: 52 additions & 0 deletions tutorial/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cc_library(
name = "Tutorial_header",
hdrs = glob(["MyGAspect/**/*.h",
"MyGCondition/**/*.h",
"MyGDaemon/**/*.h",
"MyGEvent/**/*.h",
"MyGMutable/**/*.h",
"MyGNode/**/*.h",
"MyParams/**/*.h",
"MyUtils/**/*.h",]),
linkstatic = 0,
visibility = ["//visibility:public"],
)

CGRAPH_TUTORIAL_LIST = [
"T00-HelloCGraph",
"T01-Simple",
"T02-Cluster",
"T03-Region",
"T04-Complex",
"T05-Param",
"T06-Condition",
"T07-MultiPipeline",
"T08-Template",
"T09-Aspect",
"T10-AspectParam",
"T11-Singleton",
"T12-Function",
"T13-Daemon",
"T14-Hold",
"T15-ElementParam",
"T16-MessageSendRecv",
"T17-MessagePubSub",
"T18-Event",
"T19-Cancel",
"T20-YieldResume",
"T21-MultiCondition",
"T22-Timeout",
"T23-Some",
"T24-Fence",
"T25-Coordinator",
"T26-Mutable",
]

[
cc_test(
name = "%s" % tutorial_name,
srcs = ["%s.cpp" % tutorial_name],
deps = [":Tutorial_header","//src:CGraph",],
)
for tutorial_name in CGRAPH_TUTORIAL_LIST
]
2 changes: 1 addition & 1 deletion tutorial/MyGAspect/MyConnAspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYCONNASPECT_H
#define CGRAPH_MYCONNASPECT_H

#include "CGraph.h"
#include "../../src/CGraph.h"
#include "../MyParams/MyConnParam.h"

class MyConnAspect : public CGraph::GAspect {
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGAspect/MyPipelineParamAspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYPIPELINEPARAMASPECT_H
#define CGRAPH_MYPIPELINEPARAMASPECT_H

#include "CGraph.h"
#include "../../src/CGraph.h"
#include "../MyParams/MyParam.h"

class MyPipelineParamAspect : public CGraph::GAspect {
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGAspect/MyTemplateAspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYTEMPLATEASPECT_H
#define CGRAPH_MYTEMPLATEASPECT_H

#include "CGraph.h"
#include "../../src/CGraph.h"

template<class ...Args>
class MyTemplateAspect : public CGraph::GTemplateAspect<Args...> {
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGAspect/MyTimerAspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <chrono>

#include "CGraph.h"
#include "../../src/CGraph.h"

class MyTimerAspect : public CGraph::GAspect {
public:
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGAspect/MyTraceAspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYTRACEASPECT_H
#define CGRAPH_MYTRACEASPECT_H

#include "CGraph.h"
#include "../../src/CGraph.h"

class MyTraceAspect : public CGraph::GAspect {
public:
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGCondition/MyCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYCONDITION_H
#define CGRAPH_MYCONDITION_H

#include "CGraph.h"
#include "../../src/CGraph.h"

class MyCondition : public CGraph::GCondition {
public:
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGCondition/MyParamCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYPARAMCONDITION_H
#define CGRAPH_MYPARAMCONDITION_H

#include "CGraph.h"
#include "../../src/CGraph.h"
#include "../MyParams/MyParam.h"

class MyParamCondition : public CGraph::GCondition {
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGDaemon/MyMonitorDaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYMONITORDAEMON_H
#define CGRAPH_MYMONITORDAEMON_H

#include "CGraph.h"
#include "../../src/CGraph.h"

class MyMonitorDaemon : public CGraph::GDaemon {
public:
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGDaemon/MyParamDaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYPARAMDAEMON_H
#define CGRAPH_MYPARAMDAEMON_H

#include "CGraph.h"
#include "../../src/CGraph.h"
#include "../MyParams/MyParam.h"
#include "../MyParams/MyConnParam.h"

Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGDaemon/MyTemplateDaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <string>

#include "CGraph.h"
#include "../../src/CGraph.h"

template<class ...Args>
class MyTemplateDaemon : public CGraph::GTemplateDaemon<Args...> {
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGEvent/MyPrintEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYPRINTEVENT_H
#define CGRAPH_MYPRINTEVENT_H

#include "CGraph.h"
#include "../../src/CGraph.h"
#include "../MyParams/MyParam.h"

class MyPrintEvent : public CGraph::GEvent {
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGMutable/MyMutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYMUTABLE_H
#define CGRAPH_MYMUTABLE_H

#include "CGraph.h"
#include "../../src/CGraph.h"
#include "../MyParams/MyParam.h"

class MyMutable : public CGraph::GMutable {
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGNode/HelloCGraphNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_HELLOCGRAPHNODE_H
#define CGRAPH_HELLOCGRAPHNODE_H

#include "CGraph.h"
#include "../../src/CGraph.h"

class HelloCGraphNode : public CGraph::GNode {
public:
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGNode/MyEParamNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYEPARAMNODE_H
#define CGRAPH_MYEPARAMNODE_H

#include "CGraph.h"
#include "../../src/CGraph.h"
#include "../MyParams/MyVersionParam.h"
#include "../MyParams/MyConnParam.h"

Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGNode/MyEventNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYEVENTNODE_H
#define CGRAPH_MYEVENTNODE_H

#include "CGraph.h"
#include "../../src/CGraph.h"

class MyEventNode : public CGraph::GNode {
public:
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGNode/MyHoldNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYHOLDNODE_H
#define CGRAPH_MYHOLDNODE_H

#include "CGraph.h"
#include "../../src/CGraph.h"
#include "../MyParams/MyParam.h"

static const char* HOLD_PARAM_NAME = "hold-param";
Expand Down
2 changes: 1 addition & 1 deletion tutorial/MyGNode/MyMatchNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef CGRAPH_MYMATCHNODE_H
#define CGRAPH_MYMATCHNODE_H

#include "CGraph.h"
#include "../../src/CGraph.h"
#include "../MyParams/MyParam.h"

class MyMatchNode : public CGraph::GNode {
Expand Down
Loading

0 comments on commit b1a663e

Please sign in to comment.