title: How to get WORKSPACE directory in bazel rule
body: <p>I order to use clang tools like <code>clang-format</code>, <code>clang-tidy</code> or generate a <a href="https://sarcasm.github.io/notes/dev/compilation-database.html" rel="noreferrer">compilation database</a> like <a href="https://github.com/Grailbio/bazel-compilation-database" rel="noreferrer">this</a>, I need to know the WORKSPACE directory within the .bzl file. How can I obtain it? Consider the following example where I just want to print the full path of all the src files in my workspace:</p>
  
  <p><code># simple_example.bzl</code></p>
  
  <pre><code>def _impl(ctx):
    workspace_dir = // ---&gt; what comes here? &lt;---
    command = "\n".join([echo %s/%s" % (workspace_dir, f.short_path) 
                         for f in ctx.files.srcs])
  
    ctx.actions.write(
        output=ctx.outputs.executable,
        content=command,
        is_executable=True)
  
  
  echo_full_path = rule(
      implementation=_impl,
      executable=True,
      attrs={
        "srcs": attr.label_list(allow_files=True),
      }
  )
  </code></pre>
  
  <p><code># BUILD</code></p>
  
  <pre><code>echo_full_path(
      name = "echo",
      srcs = glob(["src/**/*.cc"])
  )
  </code></pre>
  
  <p>Is there a cleaner/nicer way of doing this?</p>