use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class KotlinBuckConfig method getKotlinCompiler.
/**
* Get the Tool instance for the Kotlin compiler.
* @return the Kotlin compiler Tool
*/
public Supplier<Tool> getKotlinCompiler() {
Path compilerPath = getKotlinHome().resolve("kotlinc");
if (!Files.isExecutable(compilerPath)) {
compilerPath = getKotlinHome().resolve(Paths.get("bin", "kotlinc"));
if (!Files.isExecutable(compilerPath)) {
throw new HumanReadableException("Could not resolve kotlinc location.");
}
}
Path compiler = new ExecutableFinder().getExecutable(compilerPath, delegate.getEnvironment());
return Suppliers.ofInstance(new HashedFileTool(compiler));
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class ScalaBuckConfig method findScalac.
private Tool findScalac(BuildRuleResolver resolver) {
Optional<Tool> configScalac = delegate.getTool(SECTION, "compiler", resolver);
if (configScalac.isPresent()) {
return configScalac.get();
}
Optional<Path> externalScalac = new ExecutableFinder().getOptionalExecutable(Paths.get("scalac"), delegate.getEnvironment());
if (externalScalac.isPresent()) {
return new HashedFileTool(externalScalac.get());
}
String scalaHome = delegate.getEnvironment().get("SCALA_HOME");
if (scalaHome != null) {
Path scalacInHomePath = Paths.get(scalaHome, "bin", "scalac");
if (scalacInHomePath.toFile().exists()) {
return new HashedFileTool(scalacInHomePath);
}
throw new HumanReadableException("Could not find scalac at $SCALA_HOME/bin/scalac.");
}
throw new HumanReadableException("Could not find scalac. Consider setting scala.compiler or $SCALA_HOME.");
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class DoctorCommand method generateRageReport.
private Optional<DefectSubmitResult> generateRageReport(CommandRunnerParams params, UserInput userInput, BuildLogEntry entry) throws IOException, InterruptedException {
RageConfig rageConfig = RageConfig.of(params.getBuckConfig());
VersionControlCmdLineInterfaceFactory vcsFactory = new DefaultVersionControlCmdLineInterfaceFactory(params.getCell().getFilesystem().getRootPath(), new PrintStreamProcessExecutorFactory(), new VersionControlBuckConfig(params.getBuckConfig()), params.getBuckConfig().getEnvironment());
Optional<WatchmanDiagReportCollector> watchmanDiagReportCollector = WatchmanDiagReportCollector.newInstanceIfWatchmanUsed(params.getCell(), params.getCell().getFilesystem(), new DefaultProcessExecutor(params.getConsole()), new ExecutableFinder(), params.getEnvironment());
DoctorInteractiveReport report = new DoctorInteractiveReport(new DefaultDefectReporter(params.getCell().getFilesystem(), params.getObjectMapper(), rageConfig, params.getBuckEventBus(), params.getClock()), params.getCell().getFilesystem(), params.getConsole(), userInput, params.getBuildEnvironmentDescription(), VcsInfoCollector.create(vcsFactory.createCmdLineInterface()), rageConfig, new DefaultExtraInfoCollector(rageConfig, params.getCell().getFilesystem(), new DefaultProcessExecutor(params.getConsole())), ImmutableSet.of(entry), watchmanDiagReportCollector);
return report.collectAndSubmitResult();
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class ProjectCommand method generateWorkspacesForTargets.
@VisibleForTesting
static ImmutableSet<BuildTarget> generateWorkspacesForTargets(final CommandRunnerParams params, final TargetGraphAndTargets targetGraphAndTargets, ImmutableSet<BuildTarget> passedInTargetsSet, ImmutableSet<ProjectGenerator.Option> options, ImmutableList<String> buildWithBuckFlags, Optional<ImmutableSet<UnflavoredBuildTarget>> focusModules, Map<Path, ProjectGenerator> projectGenerators, boolean combinedProject, boolean buildWithBuck) throws IOException, InterruptedException {
ImmutableSet<BuildTarget> targets;
if (passedInTargetsSet.isEmpty()) {
targets = targetGraphAndTargets.getProjectRoots().stream().map(TargetNode::getBuildTarget).collect(MoreCollectors.toImmutableSet());
} else {
targets = passedInTargetsSet;
}
LOG.debug("Generating workspace for config targets %s", targets);
ImmutableSet.Builder<BuildTarget> requiredBuildTargetsBuilder = ImmutableSet.builder();
for (final BuildTarget inputTarget : targets) {
TargetNode<?, ?> inputNode = targetGraphAndTargets.getTargetGraph().get(inputTarget);
XcodeWorkspaceConfigDescription.Arg workspaceArgs;
if (inputNode.getDescription() instanceof XcodeWorkspaceConfigDescription) {
TargetNode<XcodeWorkspaceConfigDescription.Arg, ?> castedWorkspaceNode = castToXcodeWorkspaceTargetNode(inputNode);
workspaceArgs = castedWorkspaceNode.getConstructorArg();
} else if (canGenerateImplicitWorkspaceForDescription(inputNode.getDescription())) {
workspaceArgs = createImplicitWorkspaceArgs(inputNode);
} else {
throw new HumanReadableException("%s must be a xcode_workspace_config, apple_binary, apple_bundle, or apple_library", inputNode);
}
BuckConfig buckConfig = params.getBuckConfig();
AppleConfig appleConfig = new AppleConfig(buckConfig);
HalideBuckConfig halideBuckConfig = new HalideBuckConfig(buckConfig);
CxxBuckConfig cxxBuckConfig = new CxxBuckConfig(buckConfig);
SwiftBuckConfig swiftBuckConfig = new SwiftBuckConfig(buckConfig);
CxxPlatform defaultCxxPlatform = params.getCell().getKnownBuildRuleTypes().getDefaultCxxPlatforms();
WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(params.getCell(), targetGraphAndTargets.getTargetGraph(), workspaceArgs, inputTarget, options, combinedProject, buildWithBuck, buildWithBuckFlags, focusModules, !appleConfig.getXcodeDisableParallelizeBuild(), new ExecutableFinder(), params.getEnvironment(), params.getCell().getKnownBuildRuleTypes().getCxxPlatforms(), defaultCxxPlatform, params.getBuckConfig().getView(ParserConfig.class).getBuildFileName(), input -> ActionGraphCache.getFreshActionGraph(params.getBuckEventBus(), targetGraphAndTargets.getTargetGraph().getSubgraph(ImmutableSet.of(input))).getResolver(), params.getBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
ListeningExecutorService executorService = params.getExecutors().get(ExecutorPool.PROJECT);
Preconditions.checkNotNull(executorService, "CommandRunnerParams does not have executor for PROJECT pool");
generator.generateWorkspaceAndDependentProjects(projectGenerators, executorService);
ImmutableSet<BuildTarget> requiredBuildTargetsForWorkspace = generator.getRequiredBuildTargets();
LOG.debug("Required build targets for workspace %s: %s", inputTarget, requiredBuildTargetsForWorkspace);
requiredBuildTargetsBuilder.addAll(requiredBuildTargetsForWorkspace);
}
return requiredBuildTargetsBuilder.build();
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class Cell method createBuildFileParserFactory.
private ProjectBuildFileParserFactory createBuildFileParserFactory() {
ParserConfig parserConfig = getBuckConfig().getView(ParserConfig.class);
boolean useWatchmanGlob = parserConfig.getGlobHandler() == ParserConfig.GlobHandler.WATCHMAN && watchman.hasWildmatchGlob();
boolean watchmanGlobStatResults = parserConfig.getWatchmanGlobSanityCheck() == ParserConfig.WatchmanGlobSanityCheck.STAT;
boolean watchmanUseGlobGenerator = watchman.getCapabilities().contains(Watchman.Capability.GLOB_GENERATOR);
boolean useMercurialGlob = parserConfig.getGlobHandler() == ParserConfig.GlobHandler.MERCURIAL;
String pythonInterpreter = parserConfig.getPythonInterpreter(new ExecutableFinder());
Optional<String> pythonModuleSearchPath = parserConfig.getPythonModuleSearchPath();
return new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(getFilesystem().getRootPath()).setCellRoots(getCellPathResolver().getCellPaths()).setPythonInterpreter(pythonInterpreter).setPythonModuleSearchPath(pythonModuleSearchPath).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(filesystem.getIgnorePaths()).setBuildFileName(getBuildFileName()).setAutodepsFilesHaveSignatures(config.getIncludeAutodepsSignature()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(getAllDescriptions()).setUseWatchmanGlob(useWatchmanGlob).setWatchmanGlobStatResults(watchmanGlobStatResults).setWatchmanUseGlobGenerator(watchmanUseGlobGenerator).setWatchman(watchman).setWatchmanQueryTimeoutMs(parserConfig.getWatchmanQueryTimeoutMs()).setUseMercurialGlob(useMercurialGlob).setRawConfig(getBuckConfig().getRawConfigForParser()).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
}
Aggregations