Skip to content

Commit

Permalink
[compile] Bazel compile , add compile.md (#382)
Browse files Browse the repository at this point in the history
* feat(bazel-compile)
  • Loading branch information
PaPaPig-Melody authored Jun 1, 2024
1 parent 7fa2234 commit decb62e
Show file tree
Hide file tree
Showing 52 changed files with 68 additions and 75 deletions.
8 changes: 8 additions & 0 deletions COMPILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@
$ ./CGraph-build.sh # 编译CGraph工程,生成的内容在同级/build/文件夹中
$ ./build/tutorial/T00-HelloCGraph # 运行第一个实例程序,并且在终端输出 Hello, CGraph.
```

* Bazel编译方式(Linux/MacOS/Windows)
```shell
$ git clone https://github.com/ChunelFeng/CGraph.git
$ cd CGraph
$ bazel build //tutorial:T01-Simple -c dbg && bazel run //tutorial:T01-Simple # 编译并运行tutorial路径下的T01-Simple(debug版本)
$ bazel build //tutorial/... -c opt # 编译tutorial路径下的所有targets(release版本)
```
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 "../src/CGraph.h"
#include "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 "../src/CGraph.h"
#include "CGraph.h"
class MyNode1 : public CGraph::GNode {
public:
Expand Down
1 change: 0 additions & 1 deletion cmake/CGraph-env-include.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ ELSEIF(WIN32)
# 本工程也支持在windows平台上的mingw环境使用
ENDIF()

include_directories(${CGRAPH_PROJECT_ROOT_DIR})
include_directories(${CGRAPH_PROJECT_ROOT_DIR}/src/) # 直接加入"CGraph.h"文件对应的位置

# 以下三选一,本地编译执行,推荐OBJECT方式
Expand Down
25 changes: 8 additions & 17 deletions example/BUILD
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
# 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 (
cc_binary (
name = "E01-AutoPilot",
srcs = ["E01-AutoPilot.cpp"],
copts = ["-Isrc/"],
deps = ["//src:CGraph",],
)

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

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

# test-4: E04-MapReduce
cc_test (
cc_binary (
name = "E04-MapReduce",
srcs = ["E04-MapReduce.cpp"],
copts = ["-Isrc/"],
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 "src/CGraph.h"
#include "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 "src/CGraph.h"
#include "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 "src/CGraph.h"
#include "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 "src/CGraph.h"
#include "CGraph.h"

using namespace CGraph;

Expand Down
5 changes: 0 additions & 5 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@ cc_library(
name = "CGraph",
srcs = glob(["**/*.cpp"]),
hdrs = glob(["**/*.h", "**/*.inl"]),
copts = [
"-D_CGRAPH_SILENCE",
"-D_ENABLE_LIKELY_",
],
linkstatic = 0,
visibility = ["//visibility:public"],
)
4 changes: 2 additions & 2 deletions test/Functional/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ CGRAPH_FUNCTIONAL_LIST = [
]

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

copts = ["-Isrc/"],
deps = ["//src:CGraph",
"//test/_Materials:test_materials",],
)
Expand Down
3 changes: 2 additions & 1 deletion test/Performance/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ CGRAPH_PERFORMANCE_LIST = [
]

[
cc_test(
cc_binary(
name = "%s" % perf_name,
srcs = ["%s.cpp" % perf_name],
copts = ["-Isrc/"],
deps = ["//src:CGraph",
"//test/_Materials:test_materials",],
)
Expand Down
1 change: 0 additions & 1 deletion test/_Materials/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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 "src/CGraph.h"
#include "CGraph.h"

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

Expand Down Expand Up @@ -43,10 +42,11 @@ CGRAPH_TUTORIAL_LIST = [
]

[
cc_test(
cc_binary(
name = "%s" % tutorial_name,
srcs = ["%s.cpp" % tutorial_name],
deps = [":Tutorial_header","//src:CGraph",],
copts = ["-Isrc/"],
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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "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 "../../src/CGraph.h"
#include "CGraph.h"
#include "../MyParams/MyParam.h"

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

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

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

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

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

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

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

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

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

0 comments on commit decb62e

Please sign in to comment.