I have the following directory structure:
my_dir
|
--> src
| |
| --> foo.cc
| --> BUILD
|
--> WORKSPACE
|
--> bazel-out/ (symlink)
|
| ...
src/BUILD
contains the following code:
cc_binary(
name = "foo",
srcs = ["foo.cc"]
)
The file foo.cc
creates a file named bar.txt
using the regular way with <fstream>
utilities.
However, when I invoke Bazel with bazel run //src:foo
the file bar.txt
is created and placed in bazel-out/darwin-fastbuild/bin/src/foo.runfiles/foo/bar.txt
instead of my_dir/src/bar.txt
, where the original source is.
I tried adding an outs
field to the foo
rule, but Bazel complained that outs
is not a recognized attribute for cc_binary
.
I also thought of creating a filegroup
rule, but there is no deps
field where I can declare foo
as a dependency for those files.
How can I make sure that the files generated by running the cc_binary
rule are placed in my_dir/src/bar.txt
instead of bazel-out/...
?