本文整理汇总了Java中com.facebook.buck.rules.BuildContext.getSourcePathResolver方法的典型用法代码示例。如果您正苦于以下问题:Java BuildContext.getSourcePathResolver方法的具体用法?Java BuildContext.getSourcePathResolver怎么用?Java BuildContext.getSourcePathResolver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.buck.rules.BuildContext
的用法示例。
在下文中一共展示了BuildContext.getSourcePathResolver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
ProjectFilesystem filesystem = getProjectFilesystem();
SourcePathResolver sourcePathResolver = context.getSourcePathResolver();
Path classAbiPath = sourcePathResolver.getAbsolutePath(classAbi);
Path sourceAbiPath = sourcePathResolver.getAbsolutePath(sourceAbi);
buildableContext.recordArtifact(outputPath);
return ImmutableList.of(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), outputPath.getParent())),
DiffAbisStep.of(classAbiPath, sourceAbiPath, verificationMode),
CopyStep.forFile(filesystem, classAbiPath, outputPath));
}
示例2: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
private static ImmutableList<Step> getBuildSteps(
BuildContext context,
BuildableContext buildableContext,
BuildTargetSourcePath output,
ProjectFilesystem filesystem,
WorkerTool worker,
BiFunction<SourcePathResolver, Path, String> jobArgs) {
SourcePathResolver resolver = context.getSourcePathResolver();
Path outputPath = resolver.getAbsolutePath(output);
buildableContext.recordArtifact(resolver.getRelativePath(output));
return ImmutableList.of(
RmStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), filesystem, outputPath)),
JsUtil.workerShellStep(
worker, jobArgs.apply(resolver, outputPath), output.getTarget(), resolver, filesystem));
}
示例3: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
final SourcePathResolver sourcePathResolver = context.getSourcePathResolver();
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(getSourcePathToOutput()));
Path outputPath = sourcePathResolver.getAbsolutePath(getSourcePathToOutput());
String jobArgs =
JsonBuilder.object()
.addString("command", "optimize")
.addString("outputFilePath", outputPath.toString())
.addString("platform", JsUtil.getPlatformString(getBuildTarget().getFlavors()))
.addString(
"transformedJsFilePath", sourcePathResolver.getAbsolutePath(devFile).toString())
.addRaw("extraData", getExtraJson().map(a -> Arg.stringify(a, sourcePathResolver)))
.addString("extraArgs", getExtraArgs())
.toString();
return getBuildSteps(context, jobArgs, outputPath);
}
示例4: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<? extends Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
final SourcePathResolver sourcePathResolver = context.getSourcePathResolver();
SourcePath outputFile = getSourcePathToOutput();
String jobArgs = getJobArgs(sourcePathResolver, outputFile);
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(outputFile));
return ImmutableList.<Step>builder()
.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
sourcePathResolver.getRelativePath(outputFile).getParent())),
JsUtil.workerShellStep(
worker, jobArgs, getBuildTarget(), sourcePathResolver, getProjectFilesystem()))
.build();
}
示例5: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<? extends Step> getBuildSteps(
BuildContext buildContext, BuildableContext buildableContext) {
SourcePathResolver resolver = buildContext.getSourcePathResolver();
Path configPath = resolver.getAbsolutePath(proguardConfigPath);
ImmutableList.Builder<Step> builder = ImmutableList.builder();
builder.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
buildContext.getBuildCellRootPath(), getProjectFilesystem(), getOutputPath())));
for (String file : ImmutableList.of("configuration.txt", "mapping.txt")) {
builder.add(
CopyStep.forFile(
getProjectFilesystem(), configPath.resolve(file), getOutputPath().resolve(file)));
}
buildableContext.recordArtifact(getOutputPath());
return builder.build();
}
示例6: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext buildContext, BuildableContext buildableContext) {
SourcePathResolver pathResolver = buildContext.getSourcePathResolver();
ImmutableList.Builder<Step> steps = ImmutableList.builder();
// Merge R.txt of HasAndroidRes and generate the resulting R.java files per package.
Path rDotJavaSrc = getPathToGeneratedRDotJavaSrcFiles();
steps.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
buildContext.getBuildCellRootPath(), getProjectFilesystem(), rDotJavaSrc)));
Path rDotTxtPath = pathResolver.getAbsolutePath(pathToRDotTxtFile);
MergeAndroidResourcesStep mergeStep =
MergeAndroidResourcesStep.createStepForUberRDotJava(
getProjectFilesystem(),
buildContext.getSourcePathResolver(),
resourceDeps,
rDotTxtPath,
rDotJavaSrc,
bannedDuplicateResourceTypes,
duplicateResourceWhitelistPath.map(pathResolver::getAbsolutePath),
pathToOverrideSymbolsFile.map(pathResolver::getAbsolutePath),
resourceUnionPackage);
steps.add(mergeStep);
// Ensure the generated R.txt and R.java files are also recorded.
buildableContext.recordArtifact(rDotJavaSrc);
return steps.build();
}
示例7: createGenruleStep
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
public AbstractGenruleStep createGenruleStep(BuildContext context) {
SourcePathResolver sourcePathResolver = context.getSourcePathResolver();
// The user's command (this.cmd) should be run from the directory that contains only the
// symlinked files. This ensures that the user can reference only the files that were declared
// as srcs. Without this, a genrule is not guaranteed to be hermetic.
ProgramRunner programRunner;
if (sandboxExecutionStrategy.isSandboxEnabled() && enableSandboxingInGenrule) {
programRunner =
sandboxExecutionStrategy.createSandboxProgramRunner(
createSandboxConfiguration(sourcePathResolver));
} else {
programRunner = new DirectProgramRunner();
}
return new AbstractGenruleStep(
getProjectFilesystem(),
getBuildTarget(),
new CommandString(
Arg.flattenToSpaceSeparatedString(cmd, sourcePathResolver),
Arg.flattenToSpaceSeparatedString(bash, sourcePathResolver),
Arg.flattenToSpaceSeparatedString(cmdExe, sourcePathResolver)),
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), pathToSrcDirectory)
.getPathRelativeToBuildCellRoot(),
programRunner) {
@Override
protected void addEnvironmentVariables(
ExecutionContext executionContext, Builder<String, String> environmentVariablesBuilder) {
Genrule.this.addEnvironmentVariables(sourcePathResolver, environmentVariablesBuilder);
}
};
}
示例8: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
SourcePathResolver resolver = context.getSourcePathResolver();
// This file is copied rather than symlinked so that when it is included in an archive zip and
// unpacked on another machine, it is an ordinary file in both scenarios.
ImmutableList.Builder<Step> builder = ImmutableList.builder();
if (mode == ExportFileDescription.Mode.COPY) {
Path out = getCopiedPath();
builder.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), out.getParent())));
if (resolver.getFilesystem(src).isDirectory(resolver.getRelativePath(src))) {
builder.add(
CopyStep.forDirectory(
getProjectFilesystem(),
resolver.getAbsolutePath(src),
out,
CopyStep.DirectoryMode.CONTENTS_ONLY));
} else {
builder.add(CopyStep.forFile(getProjectFilesystem(), resolver.getAbsolutePath(src), out));
}
buildableContext.recordArtifact(out);
}
return builder.build();
}
示例9: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
SourcePathResolver resolver = context.getSourcePathResolver();
String name = getBuildTarget().getShortName();
Path dir = getOutputDir();
LOG.info(name);
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), dir)));
steps.add(new HaddockStep(getBuildTarget(), getProjectFilesystem().getRootPath(), context));
// Copy the generated data from dependencies into our output directory
for (SourcePath odir : outputDirs) {
steps.add(
CopyStep.forDirectory(
getProjectFilesystem(),
resolver.getRelativePath(odir),
dir,
CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS));
}
buildableContext.recordArtifact(dir);
return steps.build();
}
示例10: testBuildInternal
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Test
public void testBuildInternal() throws IOException {
AndroidManifest androidManifest = createSimpleAndroidManifestRule();
ProjectFilesystem filesystem = androidManifest.getProjectFilesystem();
Path skeletonPath = Paths.get("java/com/example/AndroidManifestSkeleton.xml");
// Mock out a BuildContext whose DependencyGraph will be traversed.
BuildContext buildContext = FakeBuildContext.NOOP_CONTEXT;
SourcePathResolver pathResolver = buildContext.getSourcePathResolver();
expect(pathResolver.getAbsolutePath(FakeSourcePath.of(filesystem, skeletonPath)))
.andStubReturn(filesystem.resolve(skeletonPath));
expect(pathResolver.getAllAbsolutePaths(ImmutableSortedSet.of()))
.andStubReturn(ImmutableSortedSet.of());
Path outPath = Paths.get("foo/bar");
expect(pathResolver.getRelativePath(androidManifest.getSourcePathToOutput()))
.andStubReturn(outPath);
replay(pathResolver);
List<Step> steps = androidManifest.getBuildSteps(buildContext, new FakeBuildableContext());
Step generateManifestStep = steps.get(2);
assertEquals(
new GenerateManifestStep(
filesystem,
filesystem.resolve(skeletonPath),
/* libraryManifestPaths */ ImmutableSet.of(),
outPath),
generateManifestStep);
}
示例11: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, final BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
SourcePathResolver resolver = context.getSourcePathResolver();
// Create a copy of the JAR in case it was generated by another rule.
Path resolvedBinaryJar = resolver.getAbsolutePath(binaryJar);
Path resolvedCopiedBinaryJar = getProjectFilesystem().resolve(copiedBinaryJar);
Preconditions.checkState(
!resolvedBinaryJar.equals(resolvedCopiedBinaryJar),
"%s: source (%s) can't be equal to destination (%s) when copying prebuilt JAR.",
getBuildTarget().getFullyQualifiedName(),
resolvedBinaryJar,
copiedBinaryJar);
if (resolver.getFilesystem(binaryJar).isDirectory(resolvedBinaryJar)) {
steps.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), copiedBinaryJar)));
steps.add(
CopyStep.forDirectory(
getProjectFilesystem(),
resolvedBinaryJar,
copiedBinaryJar,
CopyStep.DirectoryMode.CONTENTS_ONLY));
} else {
if (!MorePaths.getFileExtension(copiedBinaryJar.getFileName())
.equals(MorePaths.getFileExtension(resolvedBinaryJar))) {
context
.getEventBus()
.post(
ConsoleEvent.warning(
"Assuming %s is a JAR and renaming to %s in %s. "
+ "Change the extension of the binary_jar to '.jar' to remove this warning.",
resolvedBinaryJar.getFileName(),
copiedBinaryJar.getFileName(),
getBuildTarget().getFullyQualifiedName()));
}
steps.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
copiedBinaryJar.getParent())));
steps.add(CopyStep.forFile(getProjectFilesystem(), resolvedBinaryJar, copiedBinaryJar));
}
buildableContext.recordArtifact(copiedBinaryJar);
JavaLibraryRules.addAccumulateClassNamesStep(
getBuildTarget(),
getProjectFilesystem(),
getSourcePathToOutput(),
buildableContext,
context,
steps);
return steps.build();
}
示例12: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
// Cache the archive we built.
buildableContext.recordArtifact(output);
SourcePathResolver resolver = context.getSourcePathResolver();
// We only support packaging inputs that use the same filesystem root as the output, as thin
// archives embed relative paths from output to input inside the archive. If this becomes a
// limitation, we could make this rule uncacheable and allow thin archives to embed absolute
// paths.
for (SourcePath input : inputs) {
Preconditions.checkState(
resolver.getFilesystem(input).getRootPath().equals(getProjectFilesystem().getRootPath()));
}
ImmutableList.Builder<Step> builder = ImmutableList.builder();
builder.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), output.getParent())),
RmStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), output)));
if (archiver.isArgfileRequired()) {
builder.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), getScratchPath())));
}
builder.add(
new ArchiveStep(
getProjectFilesystem(),
archiver.getEnvironment(resolver),
archiver.getCommandPrefix(resolver),
archiverFlags,
archiver.getArchiveOptions(contents == ArchiveContents.THIN),
output,
inputs.stream().map(resolver::getRelativePath).collect(ImmutableList.toImmutableList()),
archiver,
getScratchPath()));
if (archiver.isRanLibStepRequired()) {
builder.add(
new RanlibStep(
getBuildTarget(),
getProjectFilesystem(),
ranlib.get().getEnvironment(resolver),
ranlib.get().getCommandPrefix(resolver),
ranlibFlags,
output));
}
if (!archiver.getScrubbers().isEmpty()) {
builder.add(new FileScrubberStep(getProjectFilesystem(), output, archiver.getScrubbers()));
}
return builder.build();
}
示例13: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
Path binPath = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput());
// Make sure the parent directory exists.
steps.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), binPath.getParent())));
// Delete any other pex that was there (when switching between pex styles).
steps.add(
RmStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), binPath))
.withRecursive(true));
Path workingDirectory =
BuildTargets.getGenPath(
getProjectFilesystem(), getBuildTarget(), "__%s__working_directory");
steps.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), workingDirectory)));
SourcePathResolver resolver = context.getSourcePathResolver();
// Generate and return the PEX build step.
steps.add(
new PexStep(
getBuildTarget(),
getProjectFilesystem(),
builder.getEnvironment(resolver),
ImmutableList.<String>builder()
.addAll(builder.getCommandPrefix(resolver))
.addAll(buildArgs)
.build(),
pythonEnvironment.getPythonPath(),
pythonEnvironment.getPythonVersion(),
workingDirectory,
binPath,
mainModule,
resolver.getMappedPaths(getComponents().getModules()),
resolver.getMappedPaths(getComponents().getResources()),
resolver.getMappedPaths(getComponents().getNativeLibraries()),
ImmutableSet.copyOf(
resolver.getAllAbsolutePaths(getComponents().getPrebuiltLibraries())),
preloadLibraries,
getComponents().isZipSafe().orElse(true)));
// Record the executable package for caching.
buildableContext.recordArtifact(binPath);
return steps.build();
}
示例14: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
final SourcePathResolver sourcePathResolver = context.getSourcePathResolver();
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(getSourcePathToOutput()));
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(getSourcePathToSourceMap()));
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(getSourcePathToResources()));
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(getSourcePathToMisc()));
Path jsDir = sourcePathResolver.getRelativePath(getSourcePathToOutput());
Path resourcesDir = sourcePathResolver.getRelativePath(getSourcePathToResources());
Path sourceMapFile = sourcePathResolver.getRelativePath(getSourcePathToSourceMap());
Path miscDirPath = sourcePathResolver.getRelativePath(getSourcePathToMisc());
return ImmutableList.<Step>builder()
.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
sourcePathResolver.getRelativePath(
JsUtil.relativeToOutputRoot(
getBuildTarget(), getProjectFilesystem(), "")))))
.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), jsDir.getParent())),
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
resourcesDir.getParent())),
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
sourceMapFile.getParent())),
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
miscDirPath.getParent())),
CopyStep.forDirectory(
getProjectFilesystem(),
sourcePathResolver.getAbsolutePath(delegate.getSourcePathToOutput()),
jsDir.getParent(),
CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS),
CopyStep.forDirectory(
getProjectFilesystem(),
sourcePathResolver.getAbsolutePath(delegate.getSourcePathToResources()),
resourcesDir.getParent(),
CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS),
CopyStep.forDirectory(
getProjectFilesystem(),
sourcePathResolver.getAbsolutePath(delegate.getSourcePathToSourceMap()),
sourceMapFile.getParent(),
CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS),
CopyStep.forDirectory(
getProjectFilesystem(),
sourcePathResolver.getAbsolutePath(delegate.getSourcePathToMisc()),
miscDirPath.getParent(),
CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS))
.build();
}
示例15: getBuildSteps
import com.facebook.buck.rules.BuildContext; //导入方法依赖的package包/类
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
SourcePathResolver sourcePathResolver = context.getSourcePathResolver();
ImmutableList<Step> buildSteps = super.getBuildSteps(context, buildableContext);
OptionalInt lastRmStep =
IntStream.range(0, buildSteps.size())
.map(x -> buildSteps.size() - 1 - x)
.filter(i -> buildSteps.get(i) instanceof RmStep)
.findFirst();
Preconditions.checkState(
lastRmStep.isPresent(), "Genrule is expected to have at least on RmDir step");
ImmutableList.Builder<Step> builder =
ImmutableList.<Step>builder()
// First, all Genrule steps including the last RmDir step are added
.addAll(buildSteps.subList(0, lastRmStep.getAsInt() + 1))
// Our MkdirStep must run after all RmSteps created by Genrule to prevent immediate
// deletion of the directory. It must, however, run before the genrule command itself
// runs.
.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
sourcePathResolver.getRelativePath(getSourcePathToOutput()))));
if (rewriteSourcemap) {
// If the genrule rewrites the source map, we have to create the parent dir, and record
// the build artifact
SourcePath sourcePathToSourceMap = getSourcePathToSourceMap();
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(sourcePathToSourceMap));
builder.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
sourcePathResolver.getRelativePath(sourcePathToSourceMap).getParent())));
}
if (rewriteMisc) {
// If the genrule rewrites the misc folder, we have to create the corresponding dir, and
// record its contents
SourcePath miscDirPath = getSourcePathToMisc();
buildableContext.recordArtifact(sourcePathResolver.getRelativePath(miscDirPath));
builder.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
sourcePathResolver.getRelativePath(miscDirPath))));
}
// Last, we add all remaining genrule commands after the last RmStep
return builder.addAll(buildSteps.subList(lastRmStep.getAsInt() + 1, buildSteps.size())).build();
}