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