Use new actions API in docs.
Change-Id: Ibbc41193ca3f577fbbd1674e9dd1c7f04a246e93
PiperOrigin-RevId: 162612615
diff --git a/site/docs/skylark/cookbook.md b/site/docs/skylark/cookbook.md
index f7af3aa..9b5c789 100644
--- a/site/docs/skylark/cookbook.md
+++ b/site/docs/skylark/cookbook.md
@@ -281,7 +281,7 @@
output = ctx.outputs.out
input = ctx.file.file
# The command may only access files declared in inputs.
- ctx.action(
+ ctx.actions.run_shell(
inputs=[input],
outputs=[output],
progress_message="Getting size of %s" % input.short_path,
@@ -358,7 +358,7 @@
# The list of arguments we pass to the script.
args = [ctx.outputs.out.path] + [f.path for f in ctx.files.srcs]
# Action to call the script.
- ctx.action(
+ ctx.actions.run(
inputs=ctx.files.srcs,
outputs=[ctx.outputs.out],
arguments=args,
@@ -438,14 +438,13 @@
```python
def _impl(ctx):
- # ctx.new_file is used for temporary files.
- # If it should be visible for user, declare it in rule.outputs instead.
- f = ctx.new_file(ctx.configuration.bin_dir, "hello")
+ # ctx.actions.declare_file is used for temporary files.
+ f = ctx.actions.declare_file(ctx.configuration.bin_dir, "hello")
# As with outputs, each time you declare a file,
# you need an action to generate it.
- ctx.file_action(output=f, content=ctx.attr.input_content)
+ ctx.actions.write(output=f, content=ctx.attr.input_content)
- ctx.action(
+ ctx.actions.run(
inputs=[f],
outputs=[ctx.outputs.out],
executable=ctx.executable.binary,
@@ -586,9 +585,9 @@
# Skip the processing
processed = src
else:
- processed = ctx.new_file(ctx.label.name + "_processed")
+ processed = ctx.actions.declare_file(ctx.label.name + "_processed")
# Run the selected binary
- ctx.action(
+ ctx.actions.run(
outputs = [processed],
inputs = [ctx.file.src],
progress_message="Apply filter '%s'" % ctx.attr.filter,
@@ -597,7 +596,7 @@
# Compute the hash
out = ctx.outputs.text
- ctx.action(
+ ctx.actions.run(
outputs = [out],
inputs = [processed],
command = "md5sum < %s > %s" % (processed.path, out.path))
diff --git a/site/docs/skylark/depsets.md b/site/docs/skylark/depsets.md
index 66df3f6..41c3e6a 100644
--- a/site/docs/skylark/depsets.md
+++ b/site/docs/skylark/depsets.md
@@ -129,9 +129,9 @@
srcs_list = trans_srcs.to_list()
cmd_string = (foocc.path + " " + out.path + " " +
" ".join([src.path for src in srcs_list]))
- ctx.action(command=cmd_string,
- inputs=srcs_list + [foocc],
- outputs=[out])
+ ctx.actions.run_shell(command=cmd_string,
+ inputs=srcs_list + [foocc],
+ outputs=[out])
foo_binary = rule(
implementation = _foo_binary_impl,
diff --git a/site/docs/skylark/rules.md b/site/docs/skylark/rules.md
index 9c47acf..d56789e 100644
--- a/site/docs/skylark/rules.md
+++ b/site/docs/skylark/rules.md
@@ -207,9 +207,9 @@
```
This can be useful for exposing files generated with
-[ctx.new_file](lib/ctx.html#new_file). You can also have "implicit
-outputs", i.e., files that are declared in the rule, but not in the default
-outputs (like `_deploy.jar` in `java_binary`).
+[ctx.actions.declare_file](lib/actions.html#declare_file). You can also
+have "implicit outputs", i.e., files that are declared in the rule, but
+not in the default outputs (like `_deploy.jar` in `java_binary`).
## Actions
@@ -220,11 +220,12 @@
the linker must be called after compilation). In the execution phase, Bazel
decides which actions must be run and in which order.
-There are three ways to create actions:
+All functions that create actions are defined in [`ctx.actions`](lib/actions.html):
-* [ctx.action](lib/ctx.html#action), to run a command.
-* [ctx.file_action](lib/ctx.html#file_action), to write a string to a file.
-* [ctx.template_action](lib/ctx.html#template_action), to generate a file from a template.
+* [ctx.actions.run](lib/actions.html#run), to run an executable.
+* [ctx.actions.run_shell](lib/actions.html#run_shell), to run a shell command.
+* [ctx.actions.write](lib/actions.html#write), to write a string to a file.
+* [ctx.actions.expand_template](lib/actions.html#expand_template), to generate a file from a template.
Actions take a set (which can be empty) of input files and generate a (non-empty)
set of output files.
@@ -502,8 +503,8 @@
```python
def _impl(ctx):
name = ...
- binary = ctx.new_file(name)
- debug_file = ctx.new_file(name + ".pdb")
+ binary = ctx.actions.declare_file(name)
+ debug_file = ctx.actions.declare_file(name + ".pdb")
# ... add actions to generate these files
return [DefaultInfo(files = depset([binary])),
OutputGroupInfo(debug_files = depset([debug_file]),
diff --git a/src/test/py/bazel/launcher_script_test.py b/src/test/py/bazel/launcher_script_test.py
index 3a14cf3..690c7fb 100644
--- a/src/test/py/bazel/launcher_script_test.py
+++ b/src/test/py/bazel/launcher_script_test.py
@@ -182,7 +182,7 @@
self.ScratchFile('WORKSPACE')
self.ScratchFile('foo/foo.bzl', [
'def _impl(ctx):',
- ' ctx.action(',
+ ' ctx.actions.run(',
' arguments=[ctx.outputs.out.path],',
' outputs=[ctx.outputs.out],',
' executable=ctx.executable._hello_world,',
diff --git a/src/test/shell/integration/build_event_stream_test.sh b/src/test/shell/integration/build_event_stream_test.sh
index 348cb3c..93b2d5f 100755
--- a/src/test/shell/integration/build_event_stream_test.sh
+++ b/src/test/shell/integration/build_event_stream_test.sh
@@ -113,7 +113,7 @@
def _failing_aspect_impl(target, ctx):
for orig_out in ctx.rule.attr.outs:
aspect_out = ctx.actions.declare_file(orig_out.name + ".aspect")
- ctx.action(
+ ctx.actions.run_shell(
inputs = [],
outputs = [aspect_out],
command = "false",