blob: 2d864607302f189a9e0d7e6752808ff125ed50b5 [file] [log] [blame]
{namespace buck.include_defs}
{template .soyweb}
{param title: 'include_defs()' /}
{param prettify: true /}
{param content}
{call buck.rule}
{param overview}
The <code>include_defs()</code> function is used to include
{sp}<a href="{ROOT}extending/macros.html"><code>macros</code></a> and constants
from another file.
The <code>include_defs()</code> function executes a file of build-file-style
code in the context of the current build file. Therefore, code in the
included file may reference Buck functions, such as
{sp}<code>java_library()</code>, <code>java_test()</code>, etc., as well
as <code>include_defs()</code> itself!
The motivation behind <code>include_defs()</code> is to avoid
copy-and-pasting code across multiple build files. Often, included files will
contain data declarations (as shown in the example below) or definitions of
macros for creating more complex build rules.
{param args}
{call buck.functionArg}
{param desc}
The first and only argument is a path, of sorts, to a file containing
{sp}<a href="{ROOT}extending/macros.html"><code>macros</code></a> and
constants. It looks similar to a build target because it starts with
{sp}<code>//</code> (indicating the root of the project), but is not a
proper build target because it identifies a file relative to the root of
the project rather than a build rule.
{param examples}
Suppose the file <code>core/DEFS</code> contains the following:
{literal}<pre class="prettyprint lang-py">
Then another build file could include the array using
{sp}<code>include_defs()</code>. This eliminates the need to
copy-and-paste definitions across build files:
{literal}<pre class="prettyprint lang-py">
name = 'example',
# ...
{/call} // buck.rule
{/param} // content