Skip to content

Commit

Permalink
feat(bazel-compile)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaPaPig-Melody committed Jun 1, 2024
1 parent 68aaa4a commit 00c0077
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 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版本)
```
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
14 changes: 4 additions & 10 deletions example/BUILD
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
# 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/"],
Expand Down
4 changes: 0 additions & 4 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@ cc_library(
name = "CGraph",
srcs = glob(["**/*.cpp"]),
hdrs = glob(["**/*.h", "**/*.inl"]),
copts = [
"-D_CGRAPH_SILENCE",
"-D_ENABLE_LIKELY_",
],
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion test/Functional/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CGRAPH_FUNCTIONAL_LIST = [
]

[
cc_test(
cc_binary(
name = "%s" % fun_name,
srcs = ["%s.cpp" % fun_name],
copts = ["-Isrc/"],
Expand Down
2 changes: 1 addition & 1 deletion test/Performance/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CGRAPH_PERFORMANCE_LIST = [
]

[
cc_test(
cc_binary(
name = "%s" % perf_name,
srcs = ["%s.cpp" % perf_name],
copts = ["-Isrc/"],
Expand Down
6 changes: 3 additions & 3 deletions tutorial/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cc_library(
name = "Tutorial_header",
hdrs = glob(["MyGAspect/**/*.h",
srcs = glob(["MyGAspect/**/*.h",
"MyGCondition/**/*.h",
"MyGDaemon/**/*.h",
"MyGEvent/**/*.h",
Expand Down Expand Up @@ -42,11 +42,11 @@ CGRAPH_TUTORIAL_LIST = [
]

[
cc_test(
cc_binary(
name = "%s" % tutorial_name,
srcs = ["%s.cpp" % tutorial_name],
copts = ["-Isrc/"],
deps = [":Tutorial_header","//src:CGraph",],
deps = [":Tutorial_header","//src:CGraph"],
)
for tutorial_name in CGRAPH_TUTORIAL_LIST
]

0 comments on commit 00c0077

Please sign in to comment.