How to write files to current directory instead of bazel-out

后端 未结 3 1294
伪装坚强ぢ
伪装坚强ぢ 2020-12-16 04:12

I have the following directory structure:

my_dir
|
 --> src
|    |
|     --> foo.cc
|     --> BUILD
|
 --> WORKSPACE
|
 --> bazel-out/ (symlin         


        
3条回答
  •  时光说笑
    2020-12-16 04:35

    Bazel doesn't allow you to modify the state of your workspace, by design.

    The short answer is that you don't want the results of the past builds to modify the state of your workspace, hence potentially modifying the results of the future builds. It'll violate reproducibility if running Bazel multiple times on the same workspace results in different outputs.

    Given your example: imagine calling bazel run //src:foo which inserts

    #define true false
    #define false true
    

    at the top of the src/foo.cc. What happens if you call bazel run //src:foo again?

    The long answer: https://docs.bazel.build/versions/master/rule-challenges.html#assumption-aim-for-correctness-throughput-ease-of-use-latency

    Here's more information on the output directory: https://docs.bazel.build/versions/master/output_directories.html#documentation-of-the-current-bazel-output-directory-layout

提交回复
热议问题