Search in sources :

Example 11 with MacroHandler

use of com.facebook.buck.rules.macros.MacroHandler in project buck by facebook.

the class QueryOutputsMacroExpanderTest method setUp.

@Before
public void setUp() throws Exception {
    expander = new QueryOutputsMacroExpander(Optional.empty());
    handler = new MacroHandler(ImmutableMap.of("query", expander));
    filesystem = new FakeProjectFilesystem(tmp.getRoot());
    cellNames = TestCellBuilder.createCellRoots(filesystem);
    TargetNode<?, ?> depNode = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance(filesystem, "//exciting:dep"), filesystem).addSrc(Paths.get("Dep.java")).build();
    TargetNode<?, ?> ruleNode = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance(filesystem, "//exciting:target"), filesystem).addSrc(Paths.get("Other.java")).addDep(depNode.getBuildTarget()).build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(depNode, ruleNode);
    ruleResolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    dep = ruleResolver.requireRule(depNode.getBuildTarget());
    rule = ruleResolver.requireRule(ruleNode.getBuildTarget());
}
Also used : MacroHandler(com.facebook.buck.rules.macros.MacroHandler) QueryOutputsMacroExpander(com.facebook.buck.rules.macros.QueryOutputsMacroExpander) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Before(org.junit.Before)

Example 12 with MacroHandler

use of com.facebook.buck.rules.macros.MacroHandler in project buck by facebook.

the class QueryTargetsMacroExpanderTest method setUp.

@Before
public void setUp() throws Exception {
    expander = new QueryTargetsMacroExpander(Optional.empty());
    handler = new MacroHandler(ImmutableMap.of("query", expander));
    filesystem = new FakeProjectFilesystem(tmp.getRoot());
    cellNames = TestCellBuilder.createCellRoots(filesystem);
    TargetNode<?, ?> depNode = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance(filesystem, "//exciting:dep"), filesystem).addSrc(Paths.get("Dep.java")).build();
    TargetNode<?, ?> ruleNode = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance(filesystem, "//exciting:target"), filesystem).addSrc(Paths.get("Other.java")).addDep(depNode.getBuildTarget()).build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(depNode, ruleNode);
    ruleResolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    dep = ruleResolver.requireRule(depNode.getBuildTarget());
    rule = ruleResolver.requireRule(ruleNode.getBuildTarget());
}
Also used : MacroHandler(com.facebook.buck.rules.macros.MacroHandler) QueryTargetsMacroExpander(com.facebook.buck.rules.macros.QueryTargetsMacroExpander) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Before(org.junit.Before)

Example 13 with MacroHandler

use of com.facebook.buck.rules.macros.MacroHandler in project buck by facebook.

the class PrebuiltCxxLibraryDescription method getBuildRules.

private ImmutableList<BuildRule> getBuildRules(BuildTarget target, CellPathResolver cellNames, BuildRuleResolver ruleResolver, Iterable<String> paramValues) {
    ImmutableList.Builder<BuildRule> builder = ImmutableList.builder();
    MacroHandler macroHandler = getMacroHandler(Optional.empty());
    for (String p : paramValues) {
        try {
            builder.addAll(macroHandler.extractBuildTimeDeps(target, cellNames, ruleResolver, p));
        } catch (MacroException e) {
            throw new HumanReadableException(e, "%s : %s in \"%s\"", target, e.getMessage(), p);
        }
    }
    return builder.build();
}
Also used : MacroHandler(com.facebook.buck.rules.macros.MacroHandler) ImmutableList(com.google.common.collect.ImmutableList) HumanReadableException(com.facebook.buck.util.HumanReadableException) BuildRule(com.facebook.buck.rules.BuildRule) MacroException(com.facebook.buck.model.MacroException)

Aggregations

MacroHandler (com.facebook.buck.rules.macros.MacroHandler)13 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)9 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)8 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)8 MacroException (com.facebook.buck.model.MacroException)7 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)6 Test (org.junit.Test)6 BuildRule (com.facebook.buck.rules.BuildRule)5 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)4 WorkerMacroExpander (com.facebook.buck.rules.macros.WorkerMacroExpander)4 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)3 LocationMacroExpander (com.facebook.buck.rules.macros.LocationMacroExpander)3 StringExpander (com.facebook.buck.rules.macros.StringExpander)3 FakeBuildRule (com.facebook.buck.rules.FakeBuildRule)2 TargetGraph (com.facebook.buck.rules.TargetGraph)2 AbstractMacroExpander (com.facebook.buck.rules.macros.AbstractMacroExpander)2 ExecutableMacroExpander (com.facebook.buck.rules.macros.ExecutableMacroExpander)2 MacroExpander (com.facebook.buck.rules.macros.MacroExpander)2 HumanReadableException (com.facebook.buck.util.HumanReadableException)2 ImmutableMap (com.google.common.collect.ImmutableMap)2