blob: 78d49d6d4486bcce2c7f68d6293a21af45b307e3 [file] [log] [blame]
* Copyright (c) Facebook, Inc. and its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* See the License for the specific language governing permissions and
* limitations under the License.
{namespace genrule}
{template .soyweb}
{param title: 'genrule()' /}
{param navid: 'rule_genrule' /}
{param prettify: true /}
{param description}
A rule that is used to generate files from a shell command. It must
produce a single output file or folder.
{param content}
{call buck.rule}
{param status: 'FROZEN' /}
{param overview}
A <code>genrule()</code> is used to generate files from a shell
command. It must produce a single output file or folder.
{param args}
{call buck.name_arg /}
{call genrule_common.srcs_arg /}
{call genrule_common.cmd_arg /}
{call genrule_common.bash_arg /}
{call genrule_common.cmd_exe_arg /}
{call genrule_common.type_arg /}
{call genrule_common.out_arg /}
{call genrule_common.environment_expansion_separator /}
{call buck.arg}
{param name: 'enable_sandbox' /}
{param default : 'False' /}
{param desc}
Whether this target should be executed in a sandbox or not.
{call buck.arg}
{param name: 'executable' /}
{param default : 'False' /}
{param desc}
Whether the output of the genrule is itself executable. Marking an output as
executable makes <code>buck run</code> and <code>$(exe ...)</code> macro
expansion work with this target.
{call buck.arg}
{param name: 'remote' /}
{param default : 'False' /}
{param desc}
Opts this genrule in to remote execution. Note that it is only safe to
execute a genrule remotely if it is completely hermetic and completely
and correctly describes its dependencies. Defaults to false. This parameter
is unstable. It is subject to removal, default reversal, and other arbitrary
changes in the future.
{call buck.tests_arg /}
{/param} // args
{param examples}
This genrule() uses a Python script to derive a new
{sp}<code>AndroidManifest.xml</code> from an
{sp}<code>AndroidManifest.xml</code> in the source tree.
Note you don't need to prepend execution commands with
{sp}<code>python</code>: Buck knows how to execute different
kinds of binaries using <code>$(exe)</code> command.
{literal}<pre class="prettyprint lang-py">
name = 'generate_manifest',
srcs = [
bash = '$(exe //python/android:basic_to_full) ' \
'$SRCDIR/AndroidManifest.xml > $OUT',
cmd_exe = '$(exe //python/android:basic_to_full) ' \
'%SRCDIR%\\AndroidManifest.xml > %OUT%',
out = 'AndroidManifest.xml',
{/param} // examples
{/call} // buck.rule