Search in sources :

Example 1 with Optionals

use of com.facebook.buck.util.Optionals in project buck by facebook.

the class AbstractGenruleDescription method createBuildRule.

@Override
public <A extends T> BuildRule createBuildRule(final TargetGraph targetGraph, final BuildRuleParams params, final BuildRuleResolver resolver, final A args) throws NoSuchBuildTargetException {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    java.util.function.Function<String, com.facebook.buck.rules.args.Arg> macroArgFunction = MacroArg.toMacroArgFunction(getMacroHandler(params.getBuildTarget(), params.getProjectFilesystem(), resolver, targetGraph, args), params.getBuildTarget(), params.getCellRoots(), resolver)::apply;
    final Optional<com.facebook.buck.rules.args.Arg> cmd = args.cmd.map(macroArgFunction);
    final Optional<com.facebook.buck.rules.args.Arg> bash = args.bash.map(macroArgFunction);
    final Optional<com.facebook.buck.rules.args.Arg> cmdExe = args.cmdExe.map(macroArgFunction);
    return createBuildRule(params.copyReplacingExtraDeps(Suppliers.ofInstance(Stream.concat(ruleFinder.filterBuildRuleInputs(args.srcs).stream(), Stream.of(cmd, bash, cmdExe).flatMap(Optionals::toStream).flatMap(input -> input.getDeps(ruleFinder).stream())).collect(MoreCollectors.toImmutableSortedSet(Comparator.<BuildRule>naturalOrder())))), resolver, args, cmd, bash, cmdExe);
}
Also used : CellPathResolver(com.facebook.buck.rules.CellPathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePath(com.facebook.buck.rules.SourcePath) QueryTargetsMacroExpander(com.facebook.buck.rules.macros.QueryTargetsMacroExpander) HasTests(com.facebook.buck.model.HasTests) ClasspathMacroExpander(com.facebook.buck.rules.macros.ClasspathMacroExpander) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) BuildRule(com.facebook.buck.rules.BuildRule) ImmutableList(com.google.common.collect.ImmutableList) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) ImplicitDepsInferringDescription(com.facebook.buck.rules.ImplicitDepsInferringDescription) Suppliers(com.google.common.base.Suppliers) QueryOutputsMacroExpander(com.facebook.buck.rules.macros.QueryOutputsMacroExpander) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) WorkerMacroExpander(com.facebook.buck.rules.macros.WorkerMacroExpander) MoreCollectors(com.facebook.buck.util.MoreCollectors) MavenCoordinatesMacroExpander(com.facebook.buck.rules.macros.MavenCoordinatesMacroExpander) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) MacroArg(com.facebook.buck.rules.args.MacroArg) Optionals(com.facebook.buck.util.Optionals) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) TargetGraph(com.facebook.buck.rules.TargetGraph) MacroException(com.facebook.buck.model.MacroException) HumanReadableException(com.facebook.buck.util.HumanReadableException) BuildTarget(com.facebook.buck.model.BuildTarget) SuppressFieldNotInitialized(com.facebook.infer.annotation.SuppressFieldNotInitialized) ExecutableMacroExpander(com.facebook.buck.rules.macros.ExecutableMacroExpander) MacroExpander(com.facebook.buck.rules.macros.MacroExpander) Stream(java.util.stream.Stream) AbstractDescriptionArg(com.facebook.buck.rules.AbstractDescriptionArg) Hint(com.facebook.buck.rules.Hint) Optional(java.util.Optional) LocationMacroExpander(com.facebook.buck.rules.macros.LocationMacroExpander) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) MacroHandler(com.facebook.buck.rules.macros.MacroHandler) Comparator(java.util.Comparator) Description(com.facebook.buck.rules.Description) Optionals(com.facebook.buck.util.Optionals) MacroArg(com.facebook.buck.rules.args.MacroArg) AbstractDescriptionArg(com.facebook.buck.rules.AbstractDescriptionArg) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder)

Aggregations

ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 HasTests (com.facebook.buck.model.HasTests)1 MacroException (com.facebook.buck.model.MacroException)1 NoSuchBuildTargetException (com.facebook.buck.parser.NoSuchBuildTargetException)1 AbstractDescriptionArg (com.facebook.buck.rules.AbstractDescriptionArg)1 BuildRule (com.facebook.buck.rules.BuildRule)1 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)1 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)1 CellPathResolver (com.facebook.buck.rules.CellPathResolver)1 Description (com.facebook.buck.rules.Description)1 Hint (com.facebook.buck.rules.Hint)1 ImplicitDepsInferringDescription (com.facebook.buck.rules.ImplicitDepsInferringDescription)1 SourcePath (com.facebook.buck.rules.SourcePath)1 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)1 TargetGraph (com.facebook.buck.rules.TargetGraph)1 MacroArg (com.facebook.buck.rules.args.MacroArg)1 ClasspathMacroExpander (com.facebook.buck.rules.macros.ClasspathMacroExpander)1 ExecutableMacroExpander (com.facebook.buck.rules.macros.ExecutableMacroExpander)1 LocationMacroExpander (com.facebook.buck.rules.macros.LocationMacroExpander)1