Bazel

495 阅读1分钟

1.bazel简单示例

2.bazel concepts

  • workspace:根目录包含workspace这个txt文件的文件夹,这个文件夹内包含你想要编译的源文件
  • packages:package是项目目录下的子文件夹,包含build或者build.bazel
  • targets: targets是package下的元素,一个target有两部分组成:files和rules

3.单个package下多个targets(多个源文件和头文件)

3-1.bazel的好处

  • High-level build language
  • Bazel is fast and reliable.
  • Bazel is multi-platform
  • Bazel scales
  • Bazel is extensible

3-2.bazel增量编译的实现

  • Loads the BUILD files relevant to the target.
  • Analyzes the inputs and their dependencies, applies the specified build rules, and produces an action graph.
  • Executes the build actions on the inputs until the final build outputs are produced.

bazel query --notool_deps --noimplicit_deps 'deps(//main:hello-world)' \

--output graph

4.多个package下的编译

5.注入本地外部依赖(bazel和non-bazel)

6.注入远程外部依赖(bazel和non-bazel)

7.使用git注入外部依赖

copts的概念

linkopts???

gtest??