遇见Google Abseil开源项目(二):bazel方式编译源代码

`
1.源码下载

git clone https://github.com/abseil/abseil-cpp

2. bazel build -c opt //absl/…
bazel会在abseil-cpp目录创建WORKSPACE文件,自动根据absl/BUILD.bazel,及子目录的BUILD.bazel编译abseil项目。

-c opt选项解释:
–compilation_mode [-c] (fastbuild, dbg or opt; default: “fastbuild”)
Specify the mode the binary will be built in. Values: ‘fastbuild’, ‘dbg’,
‘opt’.
Tags: affects_outputs, action_command_lines
命令举例:
bazel test --cxxopt=-std=c++17 -c opt --test_timeout 800 --runs_per_test=1 --jobs 1 --nocache_test_results //absl/synchronization:graphcycles_benchmark --verbose_failures --sandbox_debug

//清除重建:
bazel clean --async

//设置不使用cache
bazel test --test_timeout 8,80,800,1200 --nocache_test_results //absl/container:inlined_vector_benchmark

//超时设置
–test_timeout (a single integer or comma-separated list of 4 integers; default: “-1”)

//每个Test Case run 几遍
–runs_per_test (a positive integer or test_regex@runs. This flag may be passed more than once; may be used multiple times)

//多任务在多CPU上测试
bazel test -j HOST_RAM //absl/…
bazel test -j HOST_CPUS //absl/…
bazel test -j HOST_CPUS2.0 //absl/…
bazel test -j HOST_CPUS
4.0 //absl/…

//cpu参数
–cpu (a string; default: “”)

//编译参数
–cxxopt (a string; may be used multiple times)

//只跑benchmark
bazel test --cxxopt=-std=c++17 --test_timeout 800 --runs_per_test=1 --jobs HOST_CPUS --nocache_test_results --test_tag_filters=benchmark //absl/…

//测试benchmark的某些case
bazel test --test_timeout 800 --runs_per_test=1 --jobs HOST_CPUS --noca che_test_results --test_tag_filters=benchmark //absl/types:* //absl/strings:*

//不跑benchmark
bazel test --cxxopt=-std=c++17 --test_timeout 800 --runs_per_test=1 --jobs HOST_CPUS --nocache_test_results --test_tag_filters=-benchmark //absl/…

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值