use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.
the class CxxInferEnhancer method collectSources.
public static ImmutableMap<String, CxxSource> collectSources(BuildTarget buildTarget, BuildRuleResolver ruleResolver, CxxPlatform cxxPlatform, CxxConstructorArg args) {
InferFlavors.checkNoInferFlavors(buildTarget.getFlavors());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
return CxxDescriptionEnhancer.parseCxxSources(buildTarget, ruleResolver, ruleFinder, pathResolver, cxxPlatform, args);
}
use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.
the class CxxInferEnhancer method requireInferCaptureBuildRules.
private static ImmutableSet<CxxInferCapture> requireInferCaptureBuildRules(final BuildRuleParams params, final BuildRuleResolver resolver, CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform, ImmutableMap<String, CxxSource> sources, InferBuckConfig inferBuckConfig, CxxInferSourceFilter sourceFilter, CxxConstructorArg args) throws NoSuchBuildTargetException {
InferFlavors.checkNoInferFlavors(params.getBuildTarget().getFlavors());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
ImmutableMap<Path, SourcePath> headers = CxxDescriptionEnhancer.parseHeaders(params.getBuildTarget(), resolver, ruleFinder, pathResolver, Optional.of(cxxPlatform), args);
// Setup the header symlink tree and combine all the preprocessor input from this rule
// and all dependencies.
boolean shouldCreateHeadersSymlinks = true;
if (args instanceof CxxLibraryDescription.Arg) {
shouldCreateHeadersSymlinks = ((CxxLibraryDescription.Arg) args).xcodePrivateHeadersSymlinks.orElse(true);
}
HeaderSymlinkTree headerSymlinkTree = CxxDescriptionEnhancer.requireHeaderSymlinkTree(params, resolver, cxxPlatform, headers, HeaderVisibility.PRIVATE, shouldCreateHeadersSymlinks);
Optional<SymlinkTree> sandboxTree = Optional.empty();
if (cxxBuckConfig.sandboxSources()) {
sandboxTree = CxxDescriptionEnhancer.createSandboxTree(params, resolver, cxxPlatform);
}
ImmutableList<CxxPreprocessorInput> preprocessorInputs;
if (args instanceof CxxBinaryDescription.Arg) {
preprocessorInputs = computePreprocessorInputForCxxBinaryDescriptionArg(params, cxxPlatform, (CxxBinaryDescription.Arg) args, headerSymlinkTree, sandboxTree);
} else if (args instanceof CxxLibraryDescription.Arg) {
preprocessorInputs = computePreprocessorInputForCxxLibraryDescriptionArg(params, resolver, cxxPlatform, (CxxLibraryDescription.Arg) args, headerSymlinkTree, args.includeDirs, sandboxTree);
} else {
throw new IllegalStateException("Only Binary and Library args supported.");
}
CxxSourceRuleFactory factory = CxxSourceRuleFactory.of(params, resolver, pathResolver, ruleFinder, cxxBuckConfig, cxxPlatform, preprocessorInputs, CxxFlags.getLanguageFlags(args.compilerFlags, args.platformCompilerFlags, args.langCompilerFlags, cxxPlatform), args.prefixHeader, args.precompiledHeader, CxxSourceRuleFactory.PicType.PDC, sandboxTree);
return factory.requireInferCaptureBuildRules(sources, inferBuckConfig, sourceFilter);
}
use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.
the class Archive method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
// Cache the archive we built.
buildableContext.recordArtifact(output);
SourcePathResolver resolver = context.getSourcePathResolver();
// paths.
for (SourcePath input : inputs) {
Preconditions.checkState(resolver.getFilesystem(input).getRootPath().equals(getProjectFilesystem().getRootPath()));
}
ImmutableList.Builder<Step> builder = ImmutableList.builder();
builder.add(new MkdirStep(getProjectFilesystem(), output.getParent()), new RmStep(getProjectFilesystem(), output), new ArchiveStep(getProjectFilesystem(), archiver.getEnvironment(resolver), archiver.getCommandPrefix(resolver), archiverFlags, archiver.getArchiveOptions(contents == Contents.THIN), output, inputs.stream().map(resolver::getRelativePath).collect(MoreCollectors.toImmutableList()), archiver));
if (archiver.isRanLibStepRequired()) {
builder.add(new RanlibStep(getProjectFilesystem(), ranlib.getEnvironment(resolver), ranlib.getCommandPrefix(resolver), ranlibFlags, output));
}
if (!archiver.getScrubbers().isEmpty()) {
builder.add(new FileScrubberStep(getProjectFilesystem(), output, archiver.getScrubbers()));
}
return builder.build();
}
use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.
the class CxxBinaryDescription method createHeaderSymlinkTreeBuildRule.
/**
* @return a {@link com.facebook.buck.cxx.HeaderSymlinkTree} for the headers of this C/C++ binary.
*/
public static <A extends Arg> HeaderSymlinkTree createHeaderSymlinkTreeBuildRule(BuildRuleParams params, BuildRuleResolver resolver, CxxPlatform cxxPlatform, A args) throws NoSuchBuildTargetException {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
return CxxDescriptionEnhancer.createHeaderSymlinkTree(params, resolver, cxxPlatform, CxxDescriptionEnhancer.parseHeaders(params.getBuildTarget(), resolver, ruleFinder, pathResolver, Optional.of(cxxPlatform), args), HeaderVisibility.PRIVATE, true);
}
use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.
the class ProjectCommand method runDeprecatedIntellijProjectGenerator.
private int runDeprecatedIntellijProjectGenerator(CommandRunnerParams params, TargetGraph projectGraph, TargetGraphAndTargets targetGraphAndTargets, ImmutableSet<BuildTarget> passedInTargetsSet) throws IOException, InterruptedException {
// Create an ActionGraph that only contains targets that can be represented as IDE
// configuration files.
ActionGraphAndResolver result = Preconditions.checkNotNull(ActionGraphCache.getFreshActionGraph(params.getBuckEventBus(), targetGraphAndTargets.getTargetGraph()));
try (ExecutionContext executionContext = createExecutionContext(params)) {
Project project = new Project(new SourcePathResolver(new SourcePathRuleFinder(result.getResolver())), FluentIterable.from(result.getActionGraph().getNodes()).filter(ProjectConfig.class).toSortedSet(Ordering.natural()), getBasePathToAliasMap(params.getBuckConfig()), getJavaPackageFinder(params.getBuckConfig()), executionContext, new FilesystemBackedBuildFileTree(params.getCell().getFilesystem(), params.getBuckConfig().getView(ParserConfig.class).getBuildFileName()), params.getCell().getFilesystem(), getPathToDefaultAndroidManifest(params.getBuckConfig()), new IntellijConfig(params.getBuckConfig()), getPathToPostProcessScript(params.getBuckConfig()), new PythonBuckConfig(params.getBuckConfig(), new ExecutableFinder()).getPythonInterpreter(), params.getObjectMapper(), isAndroidAutoGenerateDisabled(params.getBuckConfig()));
File tempDir = Files.createTempDir();
File tempFile = new File(tempDir, "project.json");
int exitCode;
try {
exitCode = project.createIntellijProject(tempFile, executionContext.getProcessExecutor(), !passedInTargetsSet.isEmpty(), params.getConsole().getStdOut(), params.getConsole().getStdErr());
if (exitCode != 0) {
return exitCode;
}
List<String> additionalInitialTargets = ImmutableList.of();
if (shouldProcessAnnotations()) {
additionalInitialTargets = getAnnotationProcessingTargets(projectGraph, passedInTargetsSet);
}
// Build initial targets.
if (hasInitialTargets(params.getBuckConfig()) || !additionalInitialTargets.isEmpty()) {
BuildCommand buildCommand = createBuildCommandOptionsWithInitialTargets(params.getBuckConfig(), additionalInitialTargets);
buildCommand.setArtifactCacheDisabled(true);
exitCode = buildCommand.runWithoutHelp(params);
if (exitCode != 0) {
return exitCode;
}
}
} finally {
// Either leave project.json around for debugging or delete it on exit.
if (params.getConsole().getVerbosity().shouldPrintOutput()) {
params.getConsole().getStdErr().printf("project.json was written to %s", tempFile.getAbsolutePath());
} else {
tempFile.delete();
tempDir.delete();
}
}
if (passedInTargetsSet.isEmpty()) {
String greenStar = params.getConsole().getAnsi().asHighlightedSuccessText(" * ");
params.getConsole().getStdErr().printf(params.getConsole().getAnsi().asHighlightedSuccessText("=== Did you know ===") + "\n" + greenStar + "You can run `buck project <target>` to generate a minimal project " + "just for that target.\n" + greenStar + "This will make your IDE faster when working on large projects.\n" + greenStar + "See buck project --help for more info.\n" + params.getConsole().getAnsi().asHighlightedSuccessText("--=* Knowing is half the battle!") + "\n");
}
return 0;
}
}
Aggregations