QA

  1. bazel如何指定编译的dbg和opt模式?

    使用 --compilation_mode 参数

     bazel build ... --compilation_mode=dbg
    

    bazel debug info

    bazel doc compilation_mode

    mac下,要加上--spawn_strategy=standalone参数,避免程序运行在sandbox中,而且用lldb调试。

    bazel cpp debuging symbol

  2. bazel对thirdparty用源码方式还是library的方式?

    希望用源码的方式,这样对于不同平台,不同的系统版本,不需要将已经编译过的lib再重新编译,而且bazel的cache机制可以加快编译速度。

  3. bazel如何打印编译过程的详细命令?

     bazel build -s xxx
    

    bazel doc subcommands

  4. bazel如何只生成静态库?

     cc_library:    linkstatic = 1
    

    bazel doc cc_library

  5. bazel的注释格式?

     The Python comment syntax of #... is supported. Triple-quoted string literals may span multiple lines, and can be used for multi-line comments.
    

    bazel doc comment

  6. bazel如何指定生成的文件路径,默认是在~/下

  7. bazel如何引用动态生成的文件(genfiles)?

     -I$(GENDIR)
    

    bazel doc output_directories

  8. bazel 报错“clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]”

    clang是在编译阶段使用-pthread参数的,在链接阶段不会使用,所以编译报错,暂时不需要处理。

  9. bazel中如何区分不同的编译环境,比如mac和linux来使用不同的目录,头文件或者库文件?

  10. bazel如何在编译的binary中加入一些通用选项?比如使用tcmalloc的时候,希望所有binary都是可以使用copts = ["-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free"]

results matching ""

    No results matching ""