use of com.facebook.buck.shell.WorkerTool in project buck by facebook.
the class JsLibraryDescription method createDevFileRule.
private static <A extends Arg> BuildRule createDevFileRule(BuildRuleParams params, SourcePathRuleFinder ruleFinder, SourcePathResolver sourcePathResolver, A args, Either<SourcePath, Pair<SourcePath, String>> source, WorkerTool worker) {
final SourcePath sourcePath = source.transform(x -> x, Pair::getFirst);
final Optional<String> subPath = Optional.ofNullable(source.transform(x -> null, Pair::getSecond));
final Optional<Path> virtualPath = args.basePath.map(basePath -> changePathPrefix(sourcePath, basePath, params, sourcePathResolver, params.getBuildTarget().getUnflavoredBuildTarget()).resolve(subPath.orElse("")));
return new JsFile.JsFileDev(ruleFinder.getRule(sourcePath).map(params::copyAppendingExtraDeps).orElse(params), sourcePath, subPath, virtualPath, args.extraArgs, worker);
}
use of com.facebook.buck.shell.WorkerTool in project buck by facebook.
the class JsLibraryDescription method createBuildRule.
@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {
params.getBuildTarget().getBasePath();
// this params object is used as base for the JsLibrary build rule, but also for all dynamically
// created JsFile rules.
// For the JsLibrary case, we want to propagate flavors to library dependencies
// For the JsFile case, we only want to depend on the worker, not on any libraries
params = JsUtil.withWorkerDependencyOnly(params, resolver, args.worker);
final WorkerTool worker = resolver.getRuleWithType(args.worker, WorkerTool.class);
final SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
final SourcePathResolver sourcePathResolver = new SourcePathResolver(ruleFinder);
final ImmutableBiMap<Either<SourcePath, Pair<SourcePath, String>>, Flavor> sourcesToFlavors = mapSourcesToFlavors(sourcePathResolver, args.srcs);
final Optional<Either<SourcePath, Pair<SourcePath, String>>> file = JsFlavors.extractSourcePath(sourcesToFlavors.inverse(), params.getBuildTarget().getFlavors().stream());
if (file.isPresent()) {
return params.getBuildTarget().getFlavors().contains(JsFlavors.RELEASE) ? createReleaseFileRule(params, resolver, args, worker) : createDevFileRule(params, ruleFinder, sourcePathResolver, args, file.get(), worker);
} else {
return new LibraryBuilder(targetGraph, resolver, params, sourcesToFlavors).setSources(args.srcs).setLibraryDependencies(args.libs).build(worker);
}
}
use of com.facebook.buck.shell.WorkerTool in project buck by facebook.
the class JsUtil method workerShellStep.
static WorkerShellStep workerShellStep(WorkerTool worker, String jobArgs, BuildTarget buildTarget, SourcePathResolver sourcePathResolver, ProjectFilesystem projectFilesystem) {
final Tool tool = worker.getTool();
final WorkerJobParams params = WorkerJobParams.of(worker.getTempDir(), tool.getCommandPrefix(sourcePathResolver), worker.getArgs(sourcePathResolver), tool.getEnvironment(sourcePathResolver), jobArgs, worker.getMaxWorkers(), worker.isPersistent() ? Optional.of(buildTarget.getCellPath().toString() + buildTarget.toString()) : Optional.empty(), Optional.of(worker.getInstanceKey()));
return new WorkerShellStep(Optional.of(params), Optional.empty(), Optional.empty(), new WorkerProcessPoolFactory(projectFilesystem));
}
Aggregations