本文整理汇总了Java中com.facebook.buck.rules.BuildRules类的典型用法代码示例。如果您正苦于以下问题:Java BuildRules类的具体用法?Java BuildRules怎么用?Java BuildRules使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildRules类属于com.facebook.buck.rules包,在下文中一共展示了BuildRules类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputsToCompareToOutput
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
@Override
public ImmutableCollection<Path> getInputsToCompareToOutput() {
ImmutableSortedSet.Builder<Path> inputsToConsiderForCachingPurposes = ImmutableSortedSet
.naturalOrder();
for (Path dir : dirs) {
BuildRules.addInputsToSortedSet(
dir,
inputsToConsiderForCachingPurposes,
directoryTraverser);
}
for (String virtualPathName : variants.keySet()) {
Map<String, SourcePath> variant = variants.get(virtualPathName);
inputsToConsiderForCachingPurposes.addAll(
SourcePaths.filterInputsToCompareToOutput(variant.values()));
}
inputsToConsiderForCachingPurposes.addAll(SourcePaths.filterInputsToCompareToOutput(files));
return inputsToConsiderForCachingPurposes.build();
}
示例2: getBundleParamsWithUpdatedDeps
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
private static BuildRuleParams getBundleParamsWithUpdatedDeps(
BuildRuleParams params,
final BuildTarget originalBinaryTarget,
final Set<BuildRule> newDeps) {
// Remove the unflavored binary rule and add the flavored one instead.
final Predicate<BuildRule> notOriginalBinaryRule =
BuildRules.isBuildRuleWithTarget(originalBinaryTarget).negate();
return params
.withDeclaredDeps(
FluentIterable.from(params.getDeclaredDeps().get())
.filter(notOriginalBinaryRule::test)
.append(newDeps)
.toSortedSet(Ordering.natural()))
.withExtraDeps(
params
.getExtraDeps()
.get()
.stream()
.filter(notOriginalBinaryRule)
.collect(ImmutableSortedSet.toImmutableSortedSet(Ordering.natural())));
}
示例3: getAllDeps
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
static ImmutableSortedSet<BuildRule> getAllDeps(
BuildTarget aaptTarget,
SourcePathRuleFinder ruleFinder,
BuildRuleResolver ruleResolver,
SourcePath manifest,
FilteredResourcesProvider filteredResourcesProvider,
ImmutableList<HasAndroidResourceDeps> resourceDeps) {
ImmutableSortedSet.Builder<BuildRule> depsBuilder = ImmutableSortedSet.naturalOrder();
Stream<BuildTarget> resourceTargets =
resourceDeps.stream().map(HasAndroidResourceDeps::getBuildTarget);
depsBuilder.addAll(
BuildRules.toBuildRulesFor(aaptTarget, ruleResolver, resourceTargets::iterator));
depsBuilder.addAll(
resourceDeps
.stream()
.map(HasAndroidResourceDeps::getRes)
.flatMap(ruleFinder.FILTER_BUILD_RULE_INPUTS)
.iterator());
ruleFinder.getRule(manifest).ifPresent(depsBuilder::add);
filteredResourcesProvider.getResourceFilterRule().ifPresent(depsBuilder::add);
return depsBuilder.build();
}
示例4: runtimeDepOnDeps
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
@Test
public void runtimeDepOnDeps() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildTarget cxxBinaryTarget = BuildTargetFactory.newInstance("//:dep");
BuildTarget cxxLibraryTarget = BuildTargetFactory.newInstance("//:lib");
CxxBinaryBuilder cxxBinaryBuilder = new CxxBinaryBuilder(cxxBinaryTarget);
CxxLibraryBuilder cxxLibraryBuilder =
new CxxLibraryBuilder(cxxLibraryTarget).setDeps(ImmutableSortedSet.of(cxxBinaryTarget));
BuildRuleResolver resolver =
new SingleThreadedBuildRuleResolver(
TargetGraphFactory.newInstance(cxxLibraryBuilder.build(), cxxBinaryBuilder.build()),
new DefaultTargetNodeToBuildRuleTransformer());
addFramework(resolver, filesystem);
BuildRule cxxBinary = cxxBinaryBuilder.build(resolver, filesystem);
cxxLibraryBuilder.build(resolver, filesystem);
CxxTestBuilder cxxTestBuilder =
createTestBuilder().setDeps(ImmutableSortedSet.of(cxxLibraryTarget));
addSandbox(resolver, filesystem, cxxTestBuilder.getTarget());
CxxTest cxxTest = cxxTestBuilder.build(resolver, filesystem);
assertThat(
BuildRules.getTransitiveRuntimeDeps(cxxTest, resolver),
hasItem(cxxBinary.getBuildTarget()));
}
示例5: getInputsToCompareToOutput
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
@Override
public ImmutableCollection<Path> getInputsToCompareToOutput() {
// Build a sorted set so that metaInfDirectory contents are listed in a canonical order.
ImmutableSortedSet.Builder<Path> builder = ImmutableSortedSet.naturalOrder();
if (manifestFile != null) {
builder.addAll(
SourcePaths.filterInputsToCompareToOutput(Collections.singleton(manifestFile)));
}
BuildRules.addInputsToSortedSet(metaInfDirectory, builder, directoryTraverser);
return builder.build();
}
示例6: getTargetsAsRules
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
private ImmutableSortedSet<BuildRule> getTargetsAsRules(Collection<BuildTarget> buildTargets) {
return BuildRules.toBuildRulesFor(
originalBuildTarget,
ruleResolver,
buildTargets,
/* allowNonExistentRules */ false);
}
示例7: getCompileTimeClasspathUnfilteredFullDeps
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
@Value.Lazy
ImmutableSet<BuildRule> getCompileTimeClasspathUnfilteredFullDeps() {
Iterable<BuildRule> firstOrderDeps =
Iterables.concat(
getAllFirstOrderNonProvidedDeps(),
Preconditions.checkNotNull(getDeps()).getProvidedDeps());
ImmutableSet<BuildRule> rulesExportedByDependencies =
BuildRules.getUnsortedExportedRules(firstOrderDeps);
return RichStream.from(Iterables.concat(firstOrderDeps, rulesExportedByDependencies))
.collect(ImmutableSet.toImmutableSet());
}
示例8: createBuildRule
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
@Override
public AndroidInstrumentationTest createBuildRule(
TargetGraph targetGraph,
BuildTarget buildTarget,
ProjectFilesystem projectFilesystem,
BuildRuleParams params,
BuildRuleResolver resolver,
CellPathResolver cellRoots,
AndroidInstrumentationTestDescriptionArg args) {
BuildRule apk = resolver.getRule(args.getApk());
if (!(apk instanceof HasInstallableApk)) {
throw new HumanReadableException(
"In %s, instrumentation_apk='%s' must be an android_binary(), apk_genrule() or "
+ "android_instrumentation_apk(), but was %s().",
buildTarget, apk.getFullyQualifiedName(), apk.getType());
}
return new AndroidInstrumentationTest(
buildTarget,
projectFilesystem,
toolchainProvider.getByName(
AndroidPlatformTarget.DEFAULT_NAME, AndroidPlatformTarget.class),
params.copyAppendingExtraDeps(BuildRules.getExportedRules(params.getDeclaredDeps().get())),
(HasInstallableApk) apk,
args.getLabels(),
args.getContacts(),
toolchainProvider
.getByName(JavaOptionsProvider.DEFAULT_NAME, JavaOptionsProvider.class)
.getJavaOptions()
.getJavaRuntimeLauncher(),
args.getTestRuleTimeoutMs()
.map(Optional::of)
.orElse(buckConfig.getDefaultTestRuleTimeoutMs()),
getRelativePackagedResource(projectFilesystem, "ddmlib.jar"),
getRelativePackagedResource(projectFilesystem, "kxml2.jar"),
getRelativePackagedResource(projectFilesystem, "guava.jar"),
getRelativePackagedResource(projectFilesystem, "android-tools-common.jar"));
}
示例9: runtimeDepOnDeps
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
@Test
public void runtimeDepOnDeps() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildTarget leafBinaryTarget = BuildTargetFactory.newInstance("//:dep");
CxxBinaryBuilder leafCxxBinaryBuilder = new CxxBinaryBuilder(leafBinaryTarget, cxxBuckConfig);
BuildTarget libraryTarget = BuildTargetFactory.newInstance("//:lib");
CxxLibraryBuilder cxxLibraryBuilder =
new CxxLibraryBuilder(libraryTarget).setDeps(ImmutableSortedSet.of(leafBinaryTarget));
BuildTarget topLevelBinaryTarget = BuildTargetFactory.newInstance("//:bin");
CxxBinaryBuilder topLevelCxxBinaryBuilder =
new CxxBinaryBuilder(topLevelBinaryTarget, cxxBuckConfig)
.setDeps(ImmutableSortedSet.of(libraryTarget));
BuildRuleResolver resolver =
new SingleThreadedBuildRuleResolver(
TargetGraphFactory.newInstance(
leafCxxBinaryBuilder.build(),
cxxLibraryBuilder.build(),
topLevelCxxBinaryBuilder.build()),
new DefaultTargetNodeToBuildRuleTransformer());
BuildRule leafCxxBinary = leafCxxBinaryBuilder.build(resolver, filesystem);
cxxLibraryBuilder.build(resolver, filesystem);
CxxBinary topLevelCxxBinary = topLevelCxxBinaryBuilder.build(resolver, filesystem);
assertThat(
BuildRules.getTransitiveRuntimeDeps(topLevelCxxBinary, resolver),
Matchers.hasItem(leafCxxBinary.getBuildTarget()));
}
示例10: runtimeDepOnDeps
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
@Test
public void runtimeDepOnDeps() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
for (PythonBuckConfig.PackageStyle packageStyle : PythonBuckConfig.PackageStyle.values()) {
CxxBinaryBuilder cxxBinaryBuilder =
new CxxBinaryBuilder(BuildTargetFactory.newInstance("//:dep"));
PythonLibraryBuilder pythonLibraryBuilder =
new PythonLibraryBuilder(BuildTargetFactory.newInstance("//:lib"))
.setSrcs(
SourceList.ofUnnamedSources(
ImmutableSortedSet.of(FakeSourcePath.of("something.py"))))
.setDeps(ImmutableSortedSet.of(cxxBinaryBuilder.getTarget()));
PythonBinaryBuilder pythonBinaryBuilder =
PythonBinaryBuilder.create(BuildTargetFactory.newInstance("//:bin"))
.setMainModule("main")
.setDeps(ImmutableSortedSet.of(pythonLibraryBuilder.getTarget()))
.setPackageStyle(packageStyle);
TargetGraph targetGraph =
TargetGraphFactory.newInstance(
cxxBinaryBuilder.build(), pythonLibraryBuilder.build(), pythonBinaryBuilder.build());
BuildRuleResolver resolver =
new SingleThreadedBuildRuleResolver(
targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule cxxBinary = cxxBinaryBuilder.build(resolver, filesystem, targetGraph);
pythonLibraryBuilder.build(resolver, filesystem, targetGraph);
PythonBinary pythonBinary = pythonBinaryBuilder.build(resolver, filesystem, targetGraph);
assertThat(
String.format(
"Transitive runtime deps of %s [%s]", pythonBinary, packageStyle.toString()),
BuildRules.getTransitiveRuntimeDeps(pythonBinary, resolver),
Matchers.hasItem(cxxBinary.getBuildTarget()));
}
}
示例11: runtimeDepOnDeps
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
@Test
public void runtimeDepOnDeps() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
for (PythonBuckConfig.PackageStyle packageStyle : PythonBuckConfig.PackageStyle.values()) {
CxxBinaryBuilder cxxBinaryBuilder =
new CxxBinaryBuilder(BuildTargetFactory.newInstance("//:dep"));
PythonLibraryBuilder pythonLibraryBuilder =
new PythonLibraryBuilder(BuildTargetFactory.newInstance("//:lib"))
.setDeps(ImmutableSortedSet.of(cxxBinaryBuilder.getTarget()));
PythonTestBuilder pythonTestBuilder =
PythonTestBuilder.create(BuildTargetFactory.newInstance("//:test"))
.setDeps(ImmutableSortedSet.of(pythonLibraryBuilder.getTarget()))
.setPackageStyle(packageStyle);
TargetGraph targetGraph =
TargetGraphFactory.newInstance(
cxxBinaryBuilder.build(), pythonLibraryBuilder.build(), pythonTestBuilder.build());
BuildRuleResolver resolver =
new SingleThreadedBuildRuleResolver(
targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule cxxBinary = cxxBinaryBuilder.build(resolver, filesystem, targetGraph);
pythonLibraryBuilder.build(resolver, filesystem, targetGraph);
PythonTest pythonTest = pythonTestBuilder.build(resolver, filesystem, targetGraph);
assertThat(
String.format("Transitive runtime deps of %s [%s]", pythonTest, packageStyle.toString()),
BuildRules.getTransitiveRuntimeDeps(pythonTest, resolver),
Matchers.hasItem(cxxBinary.getBuildTarget()));
}
}
示例12: createCompileBuildRule
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
/**
* @return a {@link CxxCompile} rule that preprocesses, compiles, and assembles the given
* {@link CxxSource}.
*/
public static CxxCompile createCompileBuildRule(
BuildRuleParams params,
BuildRuleResolver resolver,
Path compiler,
CxxPreprocessorInput preprocessorInput,
ImmutableList<String> compilerFlags,
CxxSource source) {
BuildTarget target = createCompileBuildTarget(
params.getBuildTarget(),
source.getName());
boolean cxx = !Files.getFileExtension(source.getName()).equals("c");
// The customized build rule params for each compilation.
BuildRuleParams compileParams = params.copyWithChanges(
COMPILE_TYPE,
target,
// Compile rules don't inherit any of the declared deps.
/* declaredDeps */ ImmutableSortedSet.<BuildRule>of(),
/* extraDeps */ ImmutableSortedSet.<BuildRule>naturalOrder()
// Depend on the rule that generates the source we're compiling.
.addAll(SourcePaths.filterBuildRuleInputs(ImmutableList.of(source.getSource())))
// Since compilation will consume our own headers, and the headers of our
// dependencies, we need to depend on the rule that represent all headers.
.addAll(BuildRules.toBuildRulesFor(
params.getBuildTarget(),
resolver,
preprocessorInput.getRules(),
false))
.build());
// Build the CxxCompile rule and add it to our sorted set of build rules.
return new CxxCompile(
compileParams,
compiler,
ImmutableList.<String>builder()
.add("-x", cxx ? "c++" : "c")
.addAll(cxx ? preprocessorInput.getCxxppflags() : preprocessorInput.getCppflags())
.addAll(compilerFlags)
.build(),
source.getObject(),
source.getSource(),
preprocessorInput.getIncludes(),
preprocessorInput.getSystemIncludes());
}
示例13: createCxxLinkableBuildRule
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
/**
* Construct a {@link CxxLink} rule that builds a native linkable from top-level input objects
* and a dependency tree of {@link NativeLinkable} dependencies.
*/
public static CxxLink createCxxLinkableBuildRule(
BuildRuleParams params,
BuildRuleResolver resolver,
Path linker,
ImmutableList<String> cxxLdFlags,
ImmutableList<String> ldFlags,
BuildTarget target,
Path output,
Iterable<SourcePath> objects,
Iterable<BuildRule> nativeLinkableDeps) {
// Collect and topologically sort our deps that contribute to the link.
NativeLinkableInput linkableInput = NativeLinkableInput.concat(
FluentIterable
.from(topoSort(nativeLinkableDeps).reverse())
.filter(NativeLinkable.class)
.transform(NativeLinkable.GET_NATIVE_LINKABLE_INPUT));
// Construct our link build rule params. The important part here is combining the build rules
// that construct our object file inputs and also the deps that build our dependencies.
BuildRuleParams linkParams = params.copyWithChanges(
NativeLinkable.NATIVE_LINKABLE_TYPE,
target,
ImmutableSortedSet.copyOf(
Iterables.concat(
// Add dependencies for build rules generating the object files.
SourcePaths.filterBuildRuleInputs(objects),
// Add dependencies for the target-node-level dependencies that
// contribute to the link.
BuildRules.toBuildRulesFor(target, resolver, linkableInput.getTargets(), false))),
ImmutableSortedSet.<BuildRule>of());
// Build up the arguments to pass to the linker.
ImmutableList<String> args = ImmutableList.<String>builder()
.addAll(cxxLdFlags)
.addAll(
MoreIterables.zipAndConcat(
Iterables.cycle("-Xlinker"),
ldFlags))
.addAll(
MoreIterables.zipAndConcat(
Iterables.cycle("-Xlinker"),
Iterables.concat(
FluentIterable.from(objects)
.transform(SourcePaths.TO_PATH)
.transform(Functions.toStringFunction()),
linkableInput.getArgs())))
.build();
// Build the C/C++ link step.
return new CxxLink(
linkParams,
linker,
output,
ImmutableList.<SourcePath>builder()
.addAll(objects)
.addAll(SourcePaths.toSourcePathsSortedByNaturalOrder(linkableInput.getInputs()))
.build(),
args);
}
示例14: getExportedDeps
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
private ImmutableSortedSet<BuildRule> getExportedDeps() {
return BuildRules.getExportedRules(getBuildDeps());
}
示例15: getTargetsAsRules
import com.facebook.buck.rules.BuildRules; //导入依赖的package包/类
private ImmutableSortedSet<BuildRule> getTargetsAsRules(Collection<BuildTarget> buildTargets) {
return BuildRules.toBuildRulesFor(originalBuildTarget, ruleResolver, buildTargets);
}