如何在 Bazel 构建命令期间传递 FLAG 如 -DVERBOSE?

How to pass a FLAG such as -DVERBOSE during a Bazel build command?

本文关键字:FLAG -DVERBOSE Bazel 构建 命令      更新时间:2023-10-16

我想做一些事情,比如设置一个宏名称来激活我的部分代码......

g++ -DVERBOSE=1 main.cc

在 Bazel 构建命令期间:

bazel build //myproj:main

可能吗?

bazel build //myproj:main --cxxopt=-DVERBOSE=1

或者,在cc_*目标中使用copts属性。

https://docs.bazel.build/versions/master/user-manual.html#flag--cxxopt