public class GenruleBuildable extends Object implements Buildable
Genrule
suitable for building Genrules directly and also for subclasses
extending the functionality of a bare Genrule.Modifier and Type | Field and Description |
---|---|
protected Optional<Arg> |
bash
The bash shell command to generate the output file.
|
protected BuildTarget |
buildTarget
The build target for this genrule.
|
protected Optional<Arg> |
cmd
The shell command to run to generate the output file.
|
protected Optional<Arg> |
cmdExe
The cmd shell command to generate the output file.
|
protected boolean |
isCacheable
Whether or not this genrule can be cached.
|
protected Optional<String> |
out
The name of the output file that this genrule intends to generate.
|
protected Optional<PublicOutputPath> |
outputPath
The output path of the file generated by this genrule, if present.
|
protected Optional<com.google.common.collect.ImmutableMap<OutputLabel,com.google.common.collect.ImmutableSet<OutputPath>>> |
outputPaths
The output paths of the files generated by this genrule organized by their output labels.
|
protected Optional<com.google.common.collect.ImmutableMap<OutputLabel,com.google.common.collect.ImmutableSet<String>>> |
outs
The names of the output files that this genrule intends to generate relative to $OUT mapped to
their respective output group names.
|
protected static String |
SRC_DIRECTORY_PATTERN
Name of the "srcs" subdirectory in the gen directory tree.
|
protected SourceSet |
srcs
SourceSet for this Genrule, exposed as SRCS in the genrule command.
|
protected Optional<String> |
type
Type for this genrule, if one was provided.
|
Constructor and Description |
---|
GenruleBuildable(BuildTarget buildTarget,
ProjectFilesystem filesystem,
SandboxExecutionStrategy sandboxExecutionStrategy,
SourceSet srcs,
Optional<Arg> cmd,
Optional<Arg> bash,
Optional<Arg> cmdExe,
Optional<String> type,
Optional<String> out,
Optional<com.google.common.collect.ImmutableMap<OutputLabel,com.google.common.collect.ImmutableSet<String>>> outs,
boolean enableSandboxingInGenrule,
boolean isCacheable,
String environmentExpansionSeparator,
Optional<SandboxProperties> sandboxProperties,
Optional<GenruleAndroidTools> androidTools,
boolean executeRemotely) |
Modifier and Type | Method and Description |
---|---|
void |
addEnvironmentVariables(SourcePathResolverAdapter pathResolver,
OutputPathResolver outputPathResolver,
ProjectFilesystem filesystem,
Path srcPath,
Path tmpPath,
com.google.common.collect.ImmutableMap.Builder<String,String> environmentVariablesBuilder)
Adds the standard set of environment variables to the genrule, which are then exposed to the
genrule command.
|
com.google.common.collect.ImmutableList<Step> |
getBuildSteps(BuildContext buildContext,
ProjectFilesystem filesystem,
OutputPathResolver outputPathResolver,
BuildCellRelativePathFactory buildCellPathFactory) |
Optional<Arg> |
getCmd() |
com.google.common.collect.ImmutableSet<OutputLabel> |
getOutputLabels()
Returns a set of output labels associated with this buildable.
|
String |
getOutputName(OutputLabel outputLabel)
Returns a String representation of the output path relative to the root output directory.
|
com.google.common.collect.ImmutableSet<OutputPath> |
getOutputs(OutputLabel outputLabel)
Returns the set of
OutputPath instances associated with the given OutputLabel . |
SourceSet |
getSrcs() |
boolean |
shouldExecuteRemotely() |
protected static final String SRC_DIRECTORY_PATTERN
protected final BuildTarget buildTarget
protected final SourceSet srcs
The order in which elements are specified in the srcs
attribute of a genrule
matters.
protected final Optional<Arg> cmd
protected final Optional<Arg> bash
protected final Optional<Arg> cmdExe
protected final Optional<com.google.common.collect.ImmutableMap<OutputLabel,com.google.common.collect.ImmutableSet<String>>> outs
protected final Optional<PublicOutputPath> outputPath
outputPath
and outputPaths
must be present.protected final Optional<com.google.common.collect.ImmutableMap<OutputLabel,com.google.common.collect.ImmutableSet<OutputPath>>> outputPaths
The paths are relative to the directory buck-out/gen/ One and only one of outputPath
places the output in buck-out/gen/foo.
outputPath
and outputPaths
must be present.
protected final boolean isCacheable
public GenruleBuildable(BuildTarget buildTarget, ProjectFilesystem filesystem, SandboxExecutionStrategy sandboxExecutionStrategy, SourceSet srcs, Optional<Arg> cmd, Optional<Arg> bash, Optional<Arg> cmdExe, Optional<String> type, Optional<String> out, Optional<com.google.common.collect.ImmutableMap<OutputLabel,com.google.common.collect.ImmutableSet<String>>> outs, boolean enableSandboxingInGenrule, boolean isCacheable, String environmentExpansionSeparator, Optional<SandboxProperties> sandboxProperties, Optional<GenruleAndroidTools> androidTools, boolean executeRemotely)
public com.google.common.collect.ImmutableSet<OutputPath> getOutputs(OutputLabel outputLabel)
OutputPath
instances associated with the given OutputLabel
.
If multiple outputs are available, returns either the default or named output group. The default output group is the set of all named outputs.
If multiple outputs are not available, returns a set containing the single output.
public com.google.common.collect.ImmutableSet<OutputLabel> getOutputLabels()
public String getOutputName(OutputLabel outputLabel)
public com.google.common.collect.ImmutableList<Step> getBuildSteps(BuildContext buildContext, ProjectFilesystem filesystem, OutputPathResolver outputPathResolver, BuildCellRelativePathFactory buildCellPathFactory)
getBuildSteps
in interface Buildable
public SourceSet getSrcs()
public final boolean shouldExecuteRemotely()
public void addEnvironmentVariables(SourcePathResolverAdapter pathResolver, OutputPathResolver outputPathResolver, ProjectFilesystem filesystem, Path srcPath, Path tmpPath, com.google.common.collect.ImmutableMap.Builder<String,String> environmentVariablesBuilder)
This method populates these well-known environment variables:
SRCS
, a delimited list of source file inputs to the genrule
OUT
, the genrule's output file
GEN_DIR
, Buck's gendir
SRCDIR
, the symlink-populated source directory readable to the command
TMP
, the temp directory usable by the command
ANDROID_HOME
, deprecated, the path to the Android SDK (if present)
ANDROID_SDK_ROOT
, the path to the Android SDK (if present)
DX
, the path to the Android DX executable (if present)
ZIPALIGN
, the path to the Android Zipalign executable (if present)
AAPT
, the path to the Android AAPT executable (if present)
AAPT2
, the path to the Android AAPT2 executable (if present)
NDK_HOME
, the path to the Android NDK (if present)
NO_BUCKD
to 1
.pathResolver
- Path resolver for resolving paths for SRCS
outputPathResolver
- Path resolver for resolving OUT
filesystem
- Filesystem for resolving relative paths for SRCDIR
and TMP
srcPath
- Path to the generated symlink source directorytmpPath
- Path to the genrule temporary directoryenvironmentVariablesBuilder
- Environment map builder