use of com.facebook.buck.parser.NoSuchBuildTargetException in project buck by facebook.
the class RustTestDescription method createBuildRule.
@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {
BuildTarget exeTarget = params.getBuildTarget().withAppendedFlavors(InternalFlavor.of("unittest"));
BinaryWrapperRule testExeBuild = resolver.addToIndex(RustCompileUtils.createBinaryBuildRule(params.withBuildTarget(exeTarget), resolver, rustBuckConfig, cxxPlatforms, defaultCxxPlatform, args.crate, args.features, Stream.of(args.framework ? Stream.of("--test") : Stream.<String>empty(), rustBuckConfig.getRustTestFlags().stream(), args.rustcFlags.stream()).flatMap(x -> x).iterator(), args.linkerFlags.iterator(), RustCompileUtils.getLinkStyle(params.getBuildTarget(), args.linkStyle), args.rpath, args.srcs, args.crateRoot, ImmutableSet.of("lib.rs", "main.rs")));
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
Tool testExe = testExeBuild.getExecutableCommand();
BuildRuleParams testParams = params.copyAppendingExtraDeps(testExe.getDeps(ruleFinder));
return new RustTest(testParams, ruleFinder, testExeBuild, args.labels, args.contacts);
}
use of com.facebook.buck.parser.NoSuchBuildTargetException 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);
}
use of com.facebook.buck.parser.NoSuchBuildTargetException in project buck by facebook.
the class WorkerToolDescription method createBuildRule.
@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, final BuildRuleParams params, final BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {
BuildRule rule = resolver.requireRule(args.exe);
if (!(rule instanceof BinaryBuildRule)) {
throw new HumanReadableException("The 'exe' argument of %s, %s, needs to correspond to a " + "binary rule, such as sh_binary().", params.getBuildTarget(), args.exe.getFullyQualifiedName());
}
Function<String, com.facebook.buck.rules.args.Arg> toArg = MacroArg.toMacroArgFunction(MACRO_HANDLER, params.getBuildTarget(), params.getCellRoots(), resolver);
final ImmutableList<com.facebook.buck.rules.args.Arg> workerToolArgs = args.getStartupArgs().stream().map(toArg::apply).collect(MoreCollectors.toImmutableList());
ImmutableMap<String, String> expandedEnv = ImmutableMap.copyOf(FluentIterable.from(args.env.entrySet()).transform(input -> {
try {
return Maps.immutableEntry(input.getKey(), MACRO_HANDLER.expand(params.getBuildTarget(), params.getCellRoots(), resolver, input.getValue()));
} catch (MacroException e) {
throw new HumanReadableException(e, "%s: %s", params.getBuildTarget(), e.getMessage());
}
}));
int maxWorkers;
if (args.maxWorkers.isPresent()) {
// negative or zero: unlimited number of worker processes
maxWorkers = args.maxWorkers.get() < 1 ? Integer.MAX_VALUE : args.maxWorkers.get();
} else {
// default is 1 worker process (for backwards compatibility)
maxWorkers = 1;
}
return new DefaultWorkerTool(params, (BinaryBuildRule) rule, workerToolArgs, expandedEnv, maxWorkers, args.persistent.orElse(buckConfig.getBooleanValue(CONFIG_SECTION, CONFIG_PERSISTENT_KEY, false)));
}
use of com.facebook.buck.parser.NoSuchBuildTargetException in project buck by facebook.
the class OwnersReportTest method createTargetNode.
private TargetNode<?, ?> createTargetNode(BuildTarget buildTarget, ImmutableSet<Path> inputs) {
Description<FakeRuleDescription.FakeArg> description = new FakeRuleDescription();
FakeRuleDescription.FakeArg arg = description.createUnpopulatedConstructorArg();
arg.inputs = inputs;
try {
return new TargetNodeFactory(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())).create(Hashing.sha1().hashString(buildTarget.getFullyQualifiedName(), UTF_8), description, arg, filesystem, buildTarget, ImmutableSet.of(), ImmutableSet.of(), createCellRoots(filesystem));
} catch (NoSuchBuildTargetException e) {
throw new RuntimeException(e);
}
}
Aggregations