Skip to content

Commit

Permalink
Update make variables documentation:
Browse files Browse the repository at this point in the history
- Remove outdated warning about C++ variables and "bazel --show_make_env"
- Clarify what "execroot" means for source vs. output files
- Make the genrule example more readable

PiperOrigin-RevId: 231459264
  • Loading branch information
gregestren authored and weixiao-huang committed Jan 31, 2019
1 parent b129197 commit 48bfb25
Showing 1 changed file with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ title: Make Variables
and look at the top output lines with capital letters.
</p>

<p>
<b>Nov 7, 2018</b>: C++ variables appear in the predefined list unless
<code><a
href="https://github.com/bazelbuild/bazel/issues/6381">--incompatible_disable_cc_configuration_make_variables</a></code>
is set. They will no longer appear after this flag is removed.
</p>

<p><strong>Toolchain option variables</strong></p>

<ul><!-- keep alphabetically sorted -->
Expand Down Expand Up @@ -206,12 +199,14 @@ title: Make Variables
<p>
The predefined variables <code>execpath</code>, <code>execpaths</code>,
<code>rootpath</code>, <code>rootpaths</code>, <code>location</code>, and
<code>locations</code> take a label parameter (e.g. <code>$(execpath
<code>locations</code> take label parameters (e.g. <code>$(execpath
//foo:bar)</code>) and substitute the file paths denoted by that label.
</p>
<p>
For source files, this is the path of the file. For other rules, this is the
output path(s) of the file(s) generated by that rule.

For source files, this is the path relative to your workspace root.
For files that are outputs of rules, this is the file's <i>output path</i>
(see the explanation of <i>output files</i> below).
</p>

<p>Example:</p>
Expand All @@ -228,15 +223,17 @@ genrule(
name = "show_app_output",
srcs = ["empty.source"],
outs = ["app_output"],
cmd = "echo :app output paths > $@;"
+ "echo ' ' execpath: $(execpath :app) >> $@;"
+ "echo ' ' runfiles: $(rootpath :app) >> $@;"
+ "echo ' ' location: $(location :app) >> $@;"
+ "echo >> $@;"
+ "echo source file paths >> $@;"
+ "echo ' ' execpath: $(execpath empty.source) >> $@;"
+ "echo ' ' runfiles: $(rootpath empty.source) >> $@",
+ "echo ' ' location: $(location empty.source) >> $@;"
cmd = """cat <<EOF > $@
:app output paths
execpath: $(execpath :app)
runfiles: $(rootpath :app)
location: $(location :app)

source file paths
execpath: $(execpath empty.source)
runfiles: $(rootpath empty.source)
location: $(location empty.source)
EOF""",
tools = [":app"])

$ bazel build //testapp:show_app_output && cat bazel-genfiles/testapp/app_output
Expand All @@ -258,9 +255,10 @@ source file paths
<ul>
<li>
<p>
<code>execpath</code>: Denotes the path beneath the <a
href="../output_directories.html">execroot</a> where Bazel runs build
actions.
<code>execpath</code>: Denotes the path beneath the

<a href="../output_directories.html">execroot</a>
where Bazel runs build actions.
</p>
<p>
In the above example, Bazel runs all build actions in the directory linked
Expand Down

0 comments on commit 48bfb25

Please sign in to comment.