use of com.facebook.buck.rules.SourcePath in project buck by facebook.
the class SceneKitAssets method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> stepsBuilder = ImmutableList.builder();
stepsBuilder.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDir));
for (SourcePath inputPath : sceneKitAssetsPaths) {
final Path absoluteInputPath = context.getSourcePathResolver().getAbsolutePath(inputPath);
if (copySceneKitAssets.isPresent()) {
stepsBuilder.add(new ShellStep(getProjectFilesystem().getRootPath()) {
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();
commandBuilder.addAll(copySceneKitAssets.get().getCommandPrefix(context.getSourcePathResolver()));
commandBuilder.add(absoluteInputPath.toString(), "-o", getProjectFilesystem().resolve(outputDir).resolve(absoluteInputPath.getFileName()).toString(), "--target-platform=" + sdkName, "--target-version=" + minOSVersion);
return commandBuilder.build();
}
@Override
public ImmutableMap<String, String> getEnvironmentVariables(ExecutionContext executionContext) {
return copySceneKitAssets.get().getEnvironment(context.getSourcePathResolver());
}
@Override
public String getShortName() {
return "copy-scenekit-assets";
}
});
} else {
stepsBuilder.add(CopyStep.forDirectory(getProjectFilesystem(), absoluteInputPath, outputDir, CopyStep.DirectoryMode.CONTENTS_ONLY));
}
}
buildableContext.recordArtifact(context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()));
return stepsBuilder.build();
}
use of com.facebook.buck.rules.SourcePath in project buck by facebook.
the class ProjectGenerator method getPublicCxxHeaders.
private ImmutableSortedMap<Path, SourcePath> getPublicCxxHeaders(TargetNode<? extends CxxLibraryDescription.Arg, ?> targetNode) {
CxxLibraryDescription.Arg arg = targetNode.getConstructorArg();
if (arg instanceof AppleNativeTargetDescriptionArg) {
Path headerPathPrefix = AppleDescriptions.getHeaderPathPrefix((AppleNativeTargetDescriptionArg) arg, targetNode.getBuildTarget());
ImmutableSortedMap<String, SourcePath> cxxHeaders = AppleDescriptions.convertAppleHeadersToPublicCxxHeaders(this::resolveSourcePath, headerPathPrefix, arg);
return convertMapKeysToPaths(cxxHeaders);
} else {
BuildRuleResolver resolver = buildRuleResolverForNode.apply(targetNode);
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
try {
return ImmutableSortedMap.copyOf(CxxDescriptionEnhancer.parseExportedHeaders(targetNode.getBuildTarget(), resolver, ruleFinder, pathResolver, Optional.empty(), arg));
} catch (NoSuchBuildTargetException e) {
throw new RuntimeException(e);
}
}
}
use of com.facebook.buck.rules.SourcePath 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.SourcePath in project buck by facebook.
the class AbstractPrebuiltCxxLibraryGroupDescription method getSharedLinkArgs.
/**
* @return the link args formed from the user-provided shared link line after resolving library
* macro references.
*/
private Iterable<Arg> getSharedLinkArgs(BuildTarget target, ImmutableMap<String, SourcePath> libs, ImmutableList<String> args) {
ImmutableList.Builder<Arg> builder = ImmutableList.builder();
for (String arg : args) {
Optional<Pair<String, String>> libRef = getLibRef(ImmutableSet.of(LIB_MACRO, REL_LIB_MACRO), arg);
if (libRef.isPresent()) {
SourcePath lib = libs.get(libRef.get().getSecond());
if (lib == null) {
throw new HumanReadableException("%s: library \"%s\" (in \"%s\") must refer to keys in the `sharedLibs` parameter", target, libRef.get().getSecond(), arg);
}
Arg libArg;
if (libRef.get().getFirst().equals(LIB_MACRO)) {
libArg = SourcePathArg.of(lib);
} else if (libRef.get().getFirst().equals(REL_LIB_MACRO)) {
if (!(lib instanceof PathSourcePath)) {
throw new HumanReadableException("%s: can only link prebuilt DSOs without sonames", target);
}
libArg = new RelativeLinkArg((PathSourcePath) lib);
} else {
throw new IllegalStateException();
}
builder.add(libArg);
} else {
builder.add(StringArg.of(arg));
}
}
return builder.build();
}
use of com.facebook.buck.rules.SourcePath 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();
}
Aggregations