本文整理汇总了Java中com.facebook.buck.rules.SourcePath类的典型用法代码示例。如果您正苦于以下问题:Java SourcePath类的具体用法?Java SourcePath怎么用?Java SourcePath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SourcePath类属于com.facebook.buck.rules包,在下文中一共展示了SourcePath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveHeaderMap
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
/**
* Resolve the map of name to {@link SourcePath} to a map of full header name to
* {@link SourcePath}.
*/
public static ImmutableMap<Path, SourcePath> resolveHeaderMap(
BuildTarget target,
ImmutableMap<String, SourcePath> headers) {
ImmutableMap.Builder<Path, SourcePath> headerMap = ImmutableMap.builder();
// Resolve the "names" of the headers to actual paths by prepending the base path
// specified by the build target.
for (ImmutableMap.Entry<String, SourcePath> ent : headers.entrySet()) {
Path path = target.getBasePath().resolve(ent.getKey());
headerMap.put(path, ent.getValue());
}
return headerMap.build();
}
示例2: createHeaderBuildRule
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
/**
* Setup a build rule that updates whenever any header or header dependency changes.
* This includes the hash of the header contents and all corresponding transitive
* header dependencies. This should be depended on by any compile rules generated
* for this higher level rule to make sure we re-compile if any headers change.
*/
public static CxxHeader createHeaderBuildRule(
BuildTarget target,
BuildRuleParams params,
ImmutableMap<Path, SourcePath> headers) {
// TODO(agallagher): In the common case, C/C++ sources only actually use a small
// subset of all the headers in their transitive include search space, so this setup
// will cause a lot of false rebuilds. Long-term, we should add some sort of dep-file
// support to avoid this.
BuildRuleParams headerParams = params.copyWithChanges(
HEADERS_TYPE,
target,
/* declaredDeps */ ImmutableSortedSet.copyOf(
SourcePaths.filterBuildRuleInputs(headers.values())),
/* declaredDeps */ ImmutableSortedSet.<BuildRule>of());
return new CxxHeader(headerParams, headers);
}
示例3: resolveCxxSources
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
/**
* Resolve the map of names to SourcePaths to a list of CxxSource objects.
*/
public static ImmutableList<CxxSource> resolveCxxSources(
BuildTarget target,
ImmutableMap<String, SourcePath> sources) {
ImmutableList.Builder<CxxSource> cxxSources = ImmutableList.builder();
// For each entry in the input C/C++ source, build a CxxSource object to wrap
// it's name, input path, and output object file path.
for (ImmutableMap.Entry<String, SourcePath> ent : sources.entrySet()) {
cxxSources.add(
new CxxSource(
ent.getKey(),
ent.getValue(),
getCompileOutputPath(target, ent.getKey())));
}
return cxxSources.build();
}
示例4: finalStepShouldBeJarringUpExtension
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
@Test
public void finalStepShouldBeJarringUpExtension() throws IOException {
BuildTarget target = BuildTargetFactory.newInstance("//example:extension");
BuckExtension buildable = new BuckExtension(
new FakeBuildRuleParamsBuilder(target).build(),
ImmutableSortedSet.of(new TestSourcePath("ExampleExtension.java")),
ImmutableSortedSet.<SourcePath>of());
BuildContext buildContext = FakeBuildContext.NOOP_CONTEXT;
FakeBuildableContext buildableContext = new FakeBuildableContext();
List<Step> steps = buildable.getBuildSteps(buildContext, buildableContext);
// Compiling and copying resources must occur before jarring.
assertTrue(Iterables.getLast(steps) instanceof JarDirectoryStep);
}
示例5: createArchiveRule
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
/**
* Construct an {@link com.facebook.buck.cxx.Archive} from a
* {@link com.facebook.buck.rules.BuildRuleParams} object representing a target
* node. In particular, make sure to trim dependencies to *only* those that
* provide the input {@link com.facebook.buck.rules.SourcePath}.
*/
public static Archive createArchiveRule(
BuildTarget target,
BuildRuleParams originalParams,
Path archiver,
Path output,
ImmutableList<SourcePath> inputs) {
// Convert the input build params into ones specialized for this archive build rule.
// In particular, we only depend on BuildRules directly from the input file SourcePaths.
BuildRuleParams archiveParams = originalParams.copyWithChanges(
ARCHIVE_TYPE,
target,
ImmutableSortedSet.<BuildRule>of(),
ImmutableSortedSet.copyOf(
SourcePaths.filterBuildRuleInputs(
Preconditions.checkNotNull(inputs))));
return new Archive(
archiveParams,
archiver,
output,
// Reduce the source paths to regular paths.
ImmutableList.copyOf(SourcePaths.toPaths(inputs)));
}
示例6: testDuplicateSourcesInComponentsThrowsException
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
@Test
public void testDuplicateSourcesInComponentsThrowsException() {
BuildTarget me = BuildTargetFactory.newInstance("//:me");
BuildTarget them = BuildTargetFactory.newInstance("//:them");
Path dest = Paths.get("test");
PythonPackageComponents compA = new PythonPackageComponents(
ImmutableMap.<Path, SourcePath>of(dest, new TestSourcePath("sourceA")),
ImmutableMap.<Path, SourcePath>of(),
ImmutableMap.<Path, SourcePath>of());
PythonPackageComponents compB = new PythonPackageComponents(
ImmutableMap.<Path, SourcePath>of(dest, new TestSourcePath("sourceB")),
ImmutableMap.<Path, SourcePath>of(),
ImmutableMap.<Path, SourcePath>of());
PythonPackageComponents.Builder builder = new PythonPackageComponents.Builder(me);
builder.addComponent(compA, them);
try {
builder.addComponent(compB, them);
fail("expected to throw");
} catch (HumanReadableException e) {
assertTrue(e.getMessage().contains("duplicate entries"));
}
}
示例7: JavacStep
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
public JavacStep(
Path outputDirectory,
Set<? extends SourcePath> javaSourceFilePaths,
Set<Path> transitiveClasspathEntries,
Set<Path> declaredClasspathEntries,
JavacOptions javacOptions,
Optional<Path> pathToOutputAbiFile,
Optional<BuildTarget> invokingRule,
BuildDependencies buildDependencies,
Optional<SuggestBuildRules> suggestBuildRules,
Optional<Path> pathToSrcsList) {
this.outputDirectory = Preconditions.checkNotNull(outputDirectory);
this.javaSourceFilePaths = ImmutableSet.copyOf(javaSourceFilePaths);
this.transitiveClasspathEntries = ImmutableSet.copyOf(transitiveClasspathEntries);
this.javacOptions = Preconditions.checkNotNull(javacOptions);
this.pathToOutputAbiFile = Preconditions.checkNotNull(pathToOutputAbiFile);
this.declaredClasspathEntries = ImmutableSet.copyOf(declaredClasspathEntries);
this.invokingRule = Preconditions.checkNotNull(invokingRule);
this.buildDependencies = Preconditions.checkNotNull(buildDependencies);
this.suggestBuildRules = Preconditions.checkNotNull(suggestBuildRules);
this.pathToSrcsList = Preconditions.checkNotNull(pathToSrcsList);
}
示例8: ApkGenrule
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
ApkGenrule(
BuildRuleParams params,
List<SourcePath> srcs,
Optional<String> cmd,
Optional<String> bash,
Optional<String> cmdExe,
Function<Path, Path> relativeToAbsolutePathFunction,
InstallableApk apk) {
super(params,
srcs,
cmd,
bash,
cmdExe,
/* out */ params.getBuildTarget().getShortName() + ".apk",
relativeToAbsolutePathFunction);
this.apk = Preconditions.checkNotNull(apk);
this.relativeToAbsolutePathFunction =
Preconditions.checkNotNull(relativeToAbsolutePathFunction);
}
示例9: testGetInputsToCompareToOutput
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
@Test
public void testGetInputsToCompareToOutput() {
BuildRuleResolver ruleResolver = new BuildRuleResolver();
AndroidBinaryBuilder androidBinaryRuleBuilder = AndroidBinaryBuilder.createBuilder(
BuildTargetFactory.newInstance("//java/src/com/facebook:app"))
.setManifest(new TestSourcePath("java/src/com/facebook/AndroidManifest.xml"))
.setTarget("Google Inc.:Google APIs:16")
.setKeystore((Keystore) addKeystoreRule(ruleResolver));
MoreAsserts.assertIterablesEquals(
"getInputsToCompareToOutput() should include manifest.",
ImmutableList.of(Paths.get("java/src/com/facebook/AndroidManifest.xml")),
androidBinaryRuleBuilder.build().getInputs());
SourcePath proguardConfig = new TestSourcePath("java/src/com/facebook/proguard.cfg");
androidBinaryRuleBuilder.setProguardConfig(Optional.of(proguardConfig));
MoreAsserts.assertIterablesEquals(
"getInputsToCompareToOutput() should include Proguard config, if present.",
ImmutableList.of(
Paths.get("java/src/com/facebook/AndroidManifest.xml"),
Paths.get("java/src/com/facebook/proguard.cfg")),
androidBinaryRuleBuilder.build().getInputs());
}
示例10: coercingSourcePathsSetsNames
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
@Test
public void coercingSourcePathsSetsNames()
throws NoSuchFieldException, CoerceFailedException {
BuildRuleResolver buildRuleResolver = new BuildRuleResolver();
FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
PathTypeCoercer pathTypeCoercer = new PathTypeCoercer();
BuildTargetTypeCoercer buildTargetTypeCoercer = new BuildTargetTypeCoercer();
SourcePathTypeCoercer sourcePathTypeCoercer =
new SourcePathTypeCoercer(buildTargetTypeCoercer, pathTypeCoercer);
Path basePath = Paths.get("base");
// Verify that regular strings coerced as PathSourcePaths preserve their original name.
String src = "test/source.cpp";
SourcePath res = sourcePathTypeCoercer.coerce(
buildRuleResolver,
filesystem,
basePath,
src);
assertEquals(res.getName(), src);
}
示例11: AndroidBuildConfigJavaLibrary
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
AndroidBuildConfigJavaLibrary(
BuildRuleParams params,
AndroidBuildConfig androidBuildConfig) {
super(
params,
/* srcs */ ImmutableSortedSet.of(new BuildRuleSourcePath(androidBuildConfig)),
/* resources */ ImmutableSortedSet.<SourcePath>of(),
/* proguardConfig */ Optional.<Path>absent(),
/* postprocessClassesCommands */ ImmutableList.<String>of(),
/* exportedDeps */ ImmutableSortedSet.<BuildRule>of(),
/* providedDeps */ ImmutableSortedSet.<BuildRule>of(),
/* additionalClasspathEntries */ ImmutableSet.<Path>of(),
JavacOptions.DEFAULTS,
/* resourcesRoot */ Optional.<Path>absent());
this.androidBuildConfig = Preconditions.checkNotNull(androidBuildConfig);
Preconditions.checkState(
params.getDeps().contains(androidBuildConfig),
"%s must depend on the AndroidBuildConfig whose output is in this rule's srcs.",
params.getBuildTarget());
}
示例12: toModuleMap
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
public static ImmutableMap<Path, SourcePath> toModuleMap(
BuildTarget target,
String parameter,
Path baseModule,
Iterable<SourcePath> sourcePaths) {
ImmutableMap<String, SourcePath> namesAndSourcePaths =
SourcePaths.getSourcePathNames(target, parameter, sourcePaths);
ImmutableMap.Builder<Path, SourcePath> moduleNamesAndSourcePaths = ImmutableMap.builder();
for (ImmutableMap.Entry<String, SourcePath> entry : namesAndSourcePaths.entrySet()) {
moduleNamesAndSourcePaths.put(
baseModule.resolve(entry.getKey()),
entry.getValue());
}
return moduleNamesAndSourcePaths.build();
}
示例13: appendDetailsToRuleKey
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
@Override
public RuleKey.Builder appendDetailsToRuleKey(RuleKey.Builder builder) {
builder
.set("packageType", "pex")
.set("mainModule", main.toString());
// Hash all the input components here so we can detect changes in both input file content
// and module name mappings.
for (ImmutableMap.Entry<String, ImmutableMap<Path, SourcePath>> part : ImmutableMap.of(
"module", components.getModules(),
"resource", components.getResources(),
"nativeLibraries", components.getNativeLibraries()).entrySet()) {
for (Path name : ImmutableSortedSet.copyOf(part.getValue().keySet())) {
Path src = part.getValue().get(name).resolve();
builder.setInput(part.getKey() + ":" + name, src);
}
}
return builder;
}
示例14: ofAppleSources
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
/**
* Creates a {@link TargetSources} given a list of {@link AppleSource}s.
*/
public static TargetSources ofAppleSources(Collection<AppleSource> appleSources) {
ImmutableList.Builder<GroupedSource> srcsBuilder = ImmutableList.builder();
ImmutableMap.Builder<SourcePath, String> perFileFlagsBuilder = ImmutableMap.builder();
ImmutableSortedSet.Builder<SourcePath> srcPathsBuilder = ImmutableSortedSet.naturalOrder();
ImmutableSortedSet.Builder<SourcePath> headerPathsBuilder = ImmutableSortedSet.naturalOrder();
RuleUtils.extractSourcePaths(
srcsBuilder,
perFileFlagsBuilder,
srcPathsBuilder,
headerPathsBuilder,
appleSources);
return new TargetSources(
srcsBuilder.build(),
perFileFlagsBuilder.build(),
srcPathsBuilder.build(),
headerPathsBuilder.build());
}
示例15: getRuleKeyForModuleLayout
import com.facebook.buck.rules.SourcePath; //导入依赖的package包/类
private RuleKey.Builder.RuleKeyPair getRuleKeyForModuleLayout(
RuleKeyBuilderFactory ruleKeyBuilderFactory,
String main, Path mainSrc,
String mod1, Path src1,
String mod2, Path src2) throws IOException {
// The top-level python binary that lists the above libraries as deps.
PythonBinary binary = new PythonBinary(
BuildRuleParamsFactory.createTrivialBuildRuleParams(
BuildTargetFactory.newInstance("//:bin")),
Paths.get("dummy_path_to_pex"),
Paths.get("main.py"),
new PythonPackageComponents(
ImmutableMap.<Path, SourcePath>of(
Paths.get(main), new PathSourcePath(mainSrc),
Paths.get(mod1), new PathSourcePath(src1),
Paths.get(mod2), new PathSourcePath(src2)),
ImmutableMap.<Path, SourcePath>of(),
ImmutableMap.<Path, SourcePath>of()));
// Calculate and return the rule key.
RuleKey.Builder builder = ruleKeyBuilderFactory.newInstance(binary);
binary.appendToRuleKey(builder);
return builder.build();
}