本文整理汇总了Java中com.facebook.buck.rules.BuildRuleType类的典型用法代码示例。如果您正苦于以下问题:Java BuildRuleType类的具体用法?Java BuildRuleType怎么用?Java BuildRuleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildRuleType类属于com.facebook.buck.rules包,在下文中一共展示了BuildRuleType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerFlavors
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
@Override
public void registerFlavors(
Arg arg,
BuildRule buildRule,
ProjectFilesystem projectFilesystem,
RuleKeyBuilderFactory ruleKeyBuilderFactory,
BuildRuleResolver ruleResolver) {
BuildTarget prebuiltJarBuildTarget = buildRule.getBuildTarget();
BuildTarget flavoredBuildTarget = BuildTargets.createFlavoredBuildTarget(
prebuiltJarBuildTarget, JavaLibrary.GWT_MODULE_FLAVOR);
BuildRuleParams params = new BuildRuleParams(
flavoredBuildTarget,
/* declaredDeps */ ImmutableSortedSet.of(buildRule),
/* inferredDeps */ ImmutableSortedSet.<BuildRule>of(),
BuildTargetPattern.PUBLIC,
projectFilesystem,
ruleKeyBuilderFactory,
BuildRuleType.GWT_MODULE);
BuildRule gwtModule = createGwtModule(params, arg);
ruleResolver.addToIndex(gwtModule.getBuildTarget(), gwtModule);
}
示例2: parseRawRulesInternal
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
/**
* @param rules the raw rule objects to parse.
*/
@VisibleForTesting
synchronized void parseRawRulesInternal(Iterable<Map<String, Object>> rules)
throws BuildTargetException, IOException {
for (Map<String, Object> map : rules) {
if (isMetaRule(map)) {
parseMetaRule(map);
continue;
}
BuildTarget target = parseBuildTargetFromRawRule(map);
BuildRuleType buildRuleType = parseBuildRuleTypeFromRawRule(map);
Description<?> description = repository.getDescription(buildRuleType);
if (description == null) {
throw new HumanReadableException("Unrecognized rule %s while parsing %s.",
buildRuleType,
repository.getAbsolutePathToBuildFile(target));
}
state.put(target, map);
}
}
示例3: getSchemeBuildableRules
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
public static ImmutableSet<BuildRule> getSchemeBuildableRules(BuildRule primaryRule) {
final Iterable<BuildRule> buildRulesIterable = Iterables.concat(
getRecursiveRuleDependenciesOfTypes(
RecursiveRuleDependenciesMode.BUILDING,
primaryRule,
Optional.<ImmutableSet<BuildRuleType>>absent()),
ImmutableSet.of(primaryRule));
return ImmutableSet.copyOf(
Iterables.filter(
buildRulesIterable,
new Predicate<BuildRule>() {
@Override
public boolean apply(@Nullable BuildRule input) {
if (!isXcodeTargetBuildRuleType(input.getType()) &&
XcodeNativeDescription.TYPE != input.getType()) {
return false;
}
return true;
}
}));
}
示例4: collectRecursiveResources
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
/**
* Collect resources from recursive dependencies.
*
* @param rule Build rule at the tip of the traversal.
* @return The recursive resource buildables.
*/
private Iterable<AppleResource> collectRecursiveResources(
BuildRule rule,
BuildRuleType resourceRuleType) {
Iterable<BuildRule> resourceRules = AppleBuildRules.getRecursiveRuleDependenciesOfType(
AppleBuildRules.RecursiveRuleDependenciesMode.COPYING,
rule,
resourceRuleType);
ImmutableSet.Builder<AppleResource> resources = ImmutableSet.builder();
for (BuildRule resourceRule : resourceRules) {
AppleResource resource =
(AppleResource) Preconditions.checkNotNull(resourceRule);
resources.add(resource);
}
return resources.build();
}
示例5: TargetsCommandPredicate
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
/**
* @param referencedPaths All of these paths must be relative to the project root.
*/
public TargetsCommandPredicate(
PartialGraph partialGraph,
ImmutableSet<BuildRuleType> buildRuleTypes,
ImmutableSet<String> referencedPaths,
ImmutableSet<BuildTarget> matchingBuildRules) {
this.graph = partialGraph.getActionGraph();
this.buildRuleTypes = Preconditions.checkNotNull(buildRuleTypes);
this.matchingBuildRules = Preconditions.checkNotNull(matchingBuildRules);
Preconditions.checkNotNull(referencedPaths);
if (!referencedPaths.isEmpty()) {
this.referencedInputs = MorePaths.asPaths(referencedPaths);
BuildFileTree tree = new InMemoryBuildFileTree(partialGraph.getTargets());
basePathOfTargets = Sets.newHashSet();
dependentTargets = Sets.newHashSet();
for (Path input : referencedInputs) {
basePathOfTargets.add(tree.getBasePathOfAncestorTarget(input));
}
} else {
basePathOfTargets = ImmutableSet.of();
dependentTargets = ImmutableSet.of();
}
}
示例6: testIncludingATestOnTheCommandLineMeansYouWouldLikeItRun
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
@Test
public void testIncludingATestOnTheCommandLineMeansYouWouldLikeItRun() throws CmdLineException {
String excludedLabel = "exclude_me";
BuckConfig config = new FakeBuckConfig(
ImmutableMap.<String, Map<String, String>>of(
"test",
ImmutableMap.of("excluded_labels", excludedLabel)));
assertThat(config.getDefaultRawExcludedLabelSelectors(), contains(excludedLabel));
TestCommandOptions options = new TestCommandOptions(config);
new CmdLineParserAdditionalOptions(options).parseArgument("//example:test");
FakeTestRule rule = new FakeTestRule(
new BuildRuleType("java_test"),
/* labels */ ImmutableSet.of(new Label(excludedLabel)),
BuildTargetFactory.newInstance("//example:test"),
/* deps */ ImmutableSortedSet.<BuildRule>of(),
/* visibility */ ImmutableSet.<BuildTargetPattern>of());
Iterable<TestRule> filtered =
TestCommand.filterTestRules(options, ImmutableSet.<TestRule>of(rule));
assertEquals(rule, Iterables.getOnlyElement(filtered));
}
示例7: addImplicitFlavorsForRuleTypes
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
public ImmutableSortedSet<Flavor> addImplicitFlavorsForRuleTypes(
ImmutableSortedSet<Flavor> argDefaultFlavors, BuildRuleType... types) {
Optional<Flavor> platformFlavor =
getCxxPlatformsProvider().getCxxPlatforms().getFlavor(argDefaultFlavors);
for (BuildRuleType type : types) {
ImmutableMap<String, Flavor> libraryDefaults =
cxxBuckConfig.getDefaultFlavorsForRuleType(type);
if (!platformFlavor.isPresent()) {
platformFlavor =
Optional.ofNullable(libraryDefaults.get(CxxBuckConfig.DEFAULT_FLAVOR_PLATFORM));
}
}
if (platformFlavor.isPresent()) {
return ImmutableSortedSet.of(platformFlavor.get());
} else {
// To avoid changing the output path of binaries built without a flavor,
// we'll default to no flavor, which implicitly builds the default platform.
return ImmutableSortedSet.of();
}
}
示例8: getDescriptionClassFromParams
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Optional<ImmutableSet<Class<? extends Description<?>>>> getDescriptionClassFromParams(
CommandRunnerParams params) {
ImmutableSet<String> types = getTypes();
ImmutableSet.Builder<Class<? extends Description<?>>> descriptionClassesBuilder =
ImmutableSet.builder();
for (String name : types) {
try {
KnownBuildRuleTypes knownBuildRuleTypes =
params.getKnownBuildRuleTypesProvider().get(params.getCell());
BuildRuleType type = knownBuildRuleTypes.getBuildRuleType(name);
Description<?> description = knownBuildRuleTypes.getDescription(type);
descriptionClassesBuilder.add((Class<? extends Description<?>>) description.getClass());
} catch (IllegalArgumentException e) {
params.getBuckEventBus().post(ConsoleEvent.severe("Invalid build rule type: " + name));
return Optional.empty();
}
}
return Optional.of(descriptionClassesBuilder.build());
}
示例9: tryCreateGwtModule
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
/**
* Creates a {@link BuildRule} with the {@link JavaLibrary#GWT_MODULE_FLAVOR}, if appropriate.
* <p>
* If {@code arg.srcs} or {@code arg.resources} is non-empty, then the return value will not be
* absent.
*/
@VisibleForTesting
static Optional<GwtModule> tryCreateGwtModule(
BuildTarget originalBuildTarget,
ProjectFilesystem projectFilesystem,
RuleKeyBuilderFactory ruleKeyBuilderFactory,
Arg arg) {
if (arg.srcs.get().isEmpty() &&
arg.resources.get().isEmpty() &&
Flavor.DEFAULT.equals(originalBuildTarget.getFlavor())) {
return Optional.absent();
}
BuildTarget gwtModuleBuildTarget = BuildTargets.createFlavoredBuildTarget(
originalBuildTarget.getUnflavoredTarget(),
JavaLibrary.GWT_MODULE_FLAVOR);
ImmutableSortedSet<SourcePath> filesForGwtModule = ImmutableSortedSet
.<SourcePath>naturalOrder()
.addAll(arg.srcs.get())
.addAll(arg.resources.get())
.build();
// If any of the srcs or resources are BuildRuleSourcePaths, then their respective BuildRules
// must be included as deps.
ImmutableSortedSet<BuildRule> deps =
ImmutableSortedSet.copyOf(SourcePaths.filterBuildRuleInputs(filesForGwtModule));
GwtModule gwtModule = new GwtModule(
new BuildRuleParams(
gwtModuleBuildTarget,
deps,
/* inferredDeps */ ImmutableSortedSet.<BuildRule>of(),
BuildTargetPattern.PUBLIC,
projectFilesystem,
ruleKeyBuilderFactory,
BuildRuleType.GWT_MODULE),
filesForGwtModule);
return Optional.of(gwtModule);
}
示例10: matchBuildRuleType
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
public static RuleJsonPredicate matchBuildRuleType(final BuildRuleType type) {
return new RuleJsonPredicate() {
@Override
public boolean isMatch(
Map<String, Object> rawParseData,
BuildRuleType buildRuleType, BuildTarget buildTarget) {
return buildRuleType == type;
}
};
}
示例11: isTestRule
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
public static RuleJsonPredicate isTestRule() {
return new RuleJsonPredicate() {
@Override
public boolean isMatch(
Map<String, Object> rawParseData,
BuildRuleType buildRuleType,
BuildTarget buildTarget) {
return buildRuleType.isTestRule();
}
};
}
示例12: filterTargets
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
public ImmutableSet<BuildTarget> filterTargets(RuleJsonPredicate filter) {
ImmutableSet.Builder<BuildTarget> matchingTargets = ImmutableSet.builder();
for (Map<String, Object> map : parsedBuildFiles.values()) {
BuildRuleType buildRuleType = parseBuildRuleTypeFromRawRule(map);
BuildTarget target = parseBuildTargetFromRawRule(map);
if (filter.isMatch(map, buildRuleType, target)) {
matchingTargets.add(target);
}
}
return matchingTargets.build();
}
示例13: addRunScriptBuildPhasesForDependenciesWithType
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
private void addRunScriptBuildPhasesForDependenciesWithType(
BuildRule rule,
PBXNativeTarget target,
BuildRuleType type) {
for (BuildRule dependency : rule.getDeps()) {
if (dependency.getType().equals(type)) {
Genrule genrule = (Genrule) dependency;
addRunScriptBuildPhase(target, genrule.getSrcs(), genrule.createGenruleStep());
}
}
}
示例14: getRuleDependenciesOfType
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
private Iterable<BuildRule> getRuleDependenciesOfType(
final Iterable<BuildRule> rules, BuildRuleType... types) {
final ImmutableSet<BuildRuleType> requestedTypes = ImmutableSet.copyOf(types);
return Iterables.filter(
rules,
new Predicate<BuildRule>() {
@Override
public boolean apply(BuildRule input) {
return requestedTypes.contains(input.getType());
}
});
}
示例15: createFrom
import com.facebook.buck.rules.BuildRuleType; //导入依赖的package包/类
/**
* Returns transitive android resource deps which are _not_ sorted topologically, only to be used
* when the order of the resource rules does not matter, for instance, when graph enhancing
* UberRDotJava, DummyRDotJava, AaptPackageResources where we only need the deps to correctly
* order the execution of those buildables.
*/
public static UnsortedAndroidResourceDeps createFrom(
Collection<BuildRule> rules,
final Optional<Callback> callback) {
final ImmutableSet.Builder<HasAndroidResourceDeps> androidResources = ImmutableSet.builder();
// This visitor finds all AndroidResourceRules that are reachable from the specified rules via
// rules with types in the TRAVERSABLE_TYPES collection.
AbstractDependencyVisitor visitor = new AbstractDependencyVisitor(rules) {
@Override
public ImmutableSet<BuildRule> visit(BuildRule rule) {
HasAndroidResourceDeps androidResourceRule = null;
if (rule instanceof HasAndroidResourceDeps) {
androidResourceRule = (HasAndroidResourceDeps) rule;
}
if (androidResourceRule != null && androidResourceRule.getRes() != null) {
androidResources.add(androidResourceRule);
}
// Only certain types of rules should be considered as part of this traversal.
BuildRuleType type = rule.getType();
ImmutableSet<BuildRule> depsToVisit = maybeVisitAllDeps(rule,
TRAVERSABLE_TYPES.contains(type));
if (callback.isPresent()) {
callback.get().onRuleVisited(rule, depsToVisit);
}
return depsToVisit;
}
};
visitor.start();
return new UnsortedAndroidResourceDeps(androidResources.build());
}