use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class RustTestDescription method findDepsForTargetFromConstructorArgs.
@Override
public Iterable<BuildTarget> findDepsForTargetFromConstructorArgs(BuildTarget buildTarget, CellPathResolver cellRoots, RustTestDescription.Arg constructorArg) {
ImmutableSet.Builder<BuildTarget> deps = ImmutableSet.builder();
ToolProvider compiler = rustBuckConfig.getRustCompiler();
deps.addAll(compiler.getParseTimeDeps());
deps.addAll(CxxPlatforms.getParseTimeDeps(cxxPlatforms.getValues()));
return deps.build();
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class ExportFileDescription method createBuildRule.
@Override
public <A extends Arg> ExportFile createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) {
BuildTarget target = params.getBuildTarget();
Mode mode = args.mode.orElse(Mode.COPY);
String name;
if (args.out.isPresent()) {
if (mode == ExportFileDescription.Mode.REFERENCE) {
throw new HumanReadableException("%s: must not set `out` for `export_file` when using `REFERENCE` mode", params.getBuildTarget());
}
name = args.out.get();
} else {
name = target.getShortNameAndFlavorPostfix();
}
SourcePath src;
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
if (args.src.isPresent()) {
if (mode == ExportFileDescription.Mode.REFERENCE && !pathResolver.getFilesystem(args.src.get()).equals(params.getProjectFilesystem())) {
throw new HumanReadableException("%s: must use `COPY` mode for `export_file` when source (%s) uses a different cell", target, args.src.get());
}
src = args.src.get();
} else {
src = new PathSourcePath(params.getProjectFilesystem(), target.getBasePath().resolve(target.getShortNameAndFlavorPostfix()));
}
return new ExportFile(params, ruleFinder, pathResolver, name, mode, src);
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class GraphEnhancementQueryEnvironment method getNode.
private TargetNode<?, ?> getNode(QueryTarget target) {
Preconditions.checkState(target instanceof QueryBuildTarget);
Preconditions.checkArgument(targetGraph.isPresent());
BuildTarget buildTarget = ((QueryBuildTarget) target).getBuildTarget();
return targetGraph.get().getOptional(buildTarget).orElse(null);
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class RustCompileUtils method requireBuild.
public static RustCompileRule requireBuild(BuildRuleParams params, BuildRuleResolver resolver, SourcePathResolver pathResolver, SourcePathRuleFinder ruleFinder, CxxPlatform cxxPlatform, RustBuckConfig rustConfig, ImmutableList<String> extraFlags, ImmutableList<String> extraLinkerFlags, Iterable<Arg> linkerInputs, String crateName, CrateType crateType, Linker.LinkableDepType depType, ImmutableSortedSet<SourcePath> sources, SourcePath rootModule) throws NoSuchBuildTargetException {
BuildTarget target = getCompileBuildTarget(params.getBuildTarget(), cxxPlatform, crateType);
// If this rule has already been generated, return it.
Optional<RustCompileRule> existing = resolver.getRuleOptionalWithType(target, RustCompileRule.class);
if (existing.isPresent()) {
return existing.get();
}
return createBuild(target, crateName, params, resolver, pathResolver, ruleFinder, cxxPlatform, rustConfig, extraFlags, extraLinkerFlags, linkerInputs, crateType, depType, true, sources, rootModule);
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class NeededCoverageSpecTypeCoercer method coerce.
@Override
public NeededCoverageSpec coerce(CellPathResolver cellRoots, ProjectFilesystem filesystem, Path pathRelativeToProjectRoot, Object object) throws CoerceFailedException {
if (object instanceof NeededCoverageSpec) {
return (NeededCoverageSpec) object;
}
if (object instanceof Collection<?>) {
Collection<?> collection = (Collection<?>) object;
if (collection.size() == 2 || collection.size() == 3) {
Iterator<?> iter = collection.iterator();
Float neededRatio = floatTypeCoercer.coerce(cellRoots, filesystem, pathRelativeToProjectRoot, iter.next());
if (neededRatio < 0 || neededRatio > 1) {
throw CoerceFailedException.simple(object, getOutputClass(), "the needed coverage ratio should be in range [0; 1]");
}
BuildTarget buildTarget = buildTargetTypeCoercer.coerce(cellRoots, filesystem, pathRelativeToProjectRoot, iter.next());
Optional<String> pathName = Optional.empty();
if (iter.hasNext()) {
pathName = Optional.of(pathNameTypeCoercer.coerce(cellRoots, filesystem, pathRelativeToProjectRoot, iter.next()));
}
return NeededCoverageSpec.of(neededRatio, buildTarget, pathName);
}
}
throw CoerceFailedException.simple(object, getOutputClass(), "input should be a tuple of needed coverage ratio, a build target, and optionally a path");
}
Aggregations