Search in sources :

Example 1 with TargetNodeTranslator

use of com.facebook.buck.versions.TargetNodeTranslator in project buck by facebook.

the class CxxGenruleDescription method translateConstructorArg.

@Override
public Optional<Arg> translateConstructorArg(BuildTarget target, CellPathResolver cellNames, TargetNodeTranslator translator, Arg constructorArg) {
    Arg newConstructorArg = createUnpopulatedConstructorArg();
    translator.translateConstructorArg(cellNames, BuildTargetPatternParser.forBaseName(target.getBaseName()), constructorArg, newConstructorArg);
    newConstructorArg.cmd = newConstructorArg.cmd.map(c -> translateCmd(target, cellNames, translator, "cmd", c));
    newConstructorArg.bash = newConstructorArg.bash.map(c -> translateCmd(target, cellNames, translator, "bash", c));
    newConstructorArg.cmdExe = newConstructorArg.cmdExe.map(c -> translateCmd(target, cellNames, translator, "cmd_exe", c));
    return Optional.of(newConstructorArg);
}
Also used : Genrule(com.facebook.buck.shell.Genrule) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) AbstractGenruleDescription(com.facebook.buck.shell.AbstractGenruleDescription) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) RuleKeyAppendable(com.facebook.buck.rules.RuleKeyAppendable) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) SymlinkTree(com.facebook.buck.rules.SymlinkTree) FlavorDomain(com.facebook.buck.model.FlavorDomain) BuildTargetPatternParser(com.facebook.buck.parser.BuildTargetPatternParser) FluentIterable(com.google.common.collect.FluentIterable) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) MacroFinder(com.facebook.buck.model.MacroFinder) StringArg(com.facebook.buck.rules.args.StringArg) Map(java.util.Map) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) Path(java.nio.file.Path) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) TargetGraph(com.facebook.buck.rules.TargetGraph) Collection(java.util.Collection) MacroException(com.facebook.buck.model.MacroException) BuildTarget(com.facebook.buck.model.BuildTarget) ExecutableMacroExpander(com.facebook.buck.rules.macros.ExecutableMacroExpander) BuildTargetParseException(com.facebook.buck.parser.BuildTargetParseException) Optional(java.util.Optional) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Pattern(java.util.regex.Pattern) Joiner(com.google.common.base.Joiner) Iterables(com.google.common.collect.Iterables) CellPathResolver(com.facebook.buck.rules.CellPathResolver) SourcePath(com.facebook.buck.rules.SourcePath) AbstractMacroExpander(com.facebook.buck.rules.macros.AbstractMacroExpander) VersionPropagator(com.facebook.buck.versions.VersionPropagator) Flavored(com.facebook.buck.model.Flavored) BuildRule(com.facebook.buck.rules.BuildRule) TargetTranslatorOverridingDescription(com.facebook.buck.versions.TargetTranslatorOverridingDescription) Tool(com.facebook.buck.rules.Tool) ImmutableList(com.google.common.collect.ImmutableList) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) BuildTargetParser(com.facebook.buck.parser.BuildTargetParser) BuildTargetSourcePath(com.facebook.buck.rules.BuildTargetSourcePath) Escaper(com.facebook.buck.util.Escaper) StringExpander(com.facebook.buck.rules.macros.StringExpander) MoreCollectors(com.facebook.buck.util.MoreCollectors) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) LocationMacro(com.facebook.buck.rules.macros.LocationMacro) MacroReplacer(com.facebook.buck.model.MacroReplacer) Iterator(java.util.Iterator) CaseFormat(com.google.common.base.CaseFormat) HumanReadableException(com.facebook.buck.util.HumanReadableException) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) MacroExpander(com.facebook.buck.rules.macros.MacroExpander) BuildTargetPattern(com.facebook.buck.model.BuildTargetPattern) Ordering(com.google.common.collect.Ordering) LocationMacroExpander(com.facebook.buck.rules.macros.LocationMacroExpander) Preconditions(com.google.common.base.Preconditions) Flavor(com.facebook.buck.model.Flavor) MacroHandler(com.facebook.buck.rules.macros.MacroHandler) BuildTargets(com.facebook.buck.model.BuildTargets) StringArg(com.facebook.buck.rules.args.StringArg)

Example 2 with TargetNodeTranslator

use of com.facebook.buck.versions.TargetNodeTranslator in project buck by facebook.

the class NeededCoverageSpecTest method translatedTargets.

@Test
public void translatedTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    BuildTarget newTarget = BuildTargetFactory.newInstance("//something:else");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of(target, newTarget));
    NeededCoverageSpec spec = NeededCoverageSpec.of(1.0f, target, Optional.empty());
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, spec), Matchers.equalTo(Optional.of(spec.withBuildTarget(newTarget))));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) Test(org.junit.Test)

Example 3 with TargetNodeTranslator

use of com.facebook.buck.versions.TargetNodeTranslator in project buck by facebook.

the class SourceListTest method untranslatedUnnamedSourcesTargets.

@Test
public void untranslatedUnnamedSourcesTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of());
    SourceList list = SourceList.ofUnnamedSources(ImmutableSortedSet.of(new DefaultBuildTargetSourcePath(target)));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, list), Matchers.equalTo(Optional.empty()));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) Test(org.junit.Test)

Example 4 with TargetNodeTranslator

use of com.facebook.buck.versions.TargetNodeTranslator in project buck by facebook.

the class SourceListTest method translatedUnnamedSourcesTargets.

@Test
public void translatedUnnamedSourcesTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    BuildTarget newTarget = BuildTargetFactory.newInstance("//something:else");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of(target, newTarget));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, SourceList.ofUnnamedSources(ImmutableSortedSet.of(new DefaultBuildTargetSourcePath(target)))), Matchers.equalTo(Optional.of(SourceList.ofUnnamedSources(ImmutableSortedSet.of(new DefaultBuildTargetSourcePath(newTarget))))));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) Test(org.junit.Test)

Example 5 with TargetNodeTranslator

use of com.facebook.buck.versions.TargetNodeTranslator in project buck by facebook.

the class SourceListTest method untranslatedNamedSourcesTargets.

@Test
public void untranslatedNamedSourcesTargets() {
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    TargetNodeTranslator translator = new FixedTargetNodeTranslator(ImmutableMap.of());
    SourceList list = SourceList.ofNamedSources(ImmutableSortedMap.of("name", new DefaultBuildTargetSourcePath(target)));
    assertThat(translator.translate(CELL_PATH_RESOLVER, PATTERN, list), Matchers.equalTo(Optional.empty()));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) TargetNodeTranslator(com.facebook.buck.versions.TargetNodeTranslator) FixedTargetNodeTranslator(com.facebook.buck.versions.FixedTargetNodeTranslator) Test(org.junit.Test)

Aggregations

BuildTarget (com.facebook.buck.model.BuildTarget)12 TargetNodeTranslator (com.facebook.buck.versions.TargetNodeTranslator)12 FixedTargetNodeTranslator (com.facebook.buck.versions.FixedTargetNodeTranslator)11 Test (org.junit.Test)11 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)5 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 BuildTargetPattern (com.facebook.buck.model.BuildTargetPattern)1 BuildTargets (com.facebook.buck.model.BuildTargets)1 Flavor (com.facebook.buck.model.Flavor)1 FlavorDomain (com.facebook.buck.model.FlavorDomain)1 Flavored (com.facebook.buck.model.Flavored)1 MacroException (com.facebook.buck.model.MacroException)1 MacroFinder (com.facebook.buck.model.MacroFinder)1 MacroReplacer (com.facebook.buck.model.MacroReplacer)1 BuildTargetParseException (com.facebook.buck.parser.BuildTargetParseException)1 BuildTargetParser (com.facebook.buck.parser.BuildTargetParser)1 BuildTargetPatternParser (com.facebook.buck.parser.BuildTargetPatternParser)1 NoSuchBuildTargetException (com.facebook.buck.parser.NoSuchBuildTargetException)1 BuildRule (com.facebook.buck.rules.BuildRule)1 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)1