当前位置: 首页>>代码示例>>Java>>正文


Java BuildRuleType类代码示例

本文整理汇总了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);
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:22,代码来源:PrebuiltJarDescription.java

示例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);
  }
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:26,代码来源:Parser.java

示例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;
            }
          }));
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:24,代码来源:AppleBuildRules.java

示例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();
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:22,代码来源:ProjectGenerator.java

示例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();
  }
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:27,代码来源:TargetsCommand.java

示例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));
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:24,代码来源:TestCommandTest.java

示例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();
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:24,代码来源:CxxBinaryImplicitFlavors.java

示例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());
}
 
开发者ID:facebook,项目名称:buck,代码行数:21,代码来源:TargetsCommand.java

示例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);
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:44,代码来源:JavaLibraryDescription.java

示例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;
    }
  };
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:11,代码来源:RuleJsonPredicates.java

示例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();
    }
  };
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:12,代码来源:RuleJsonPredicates.java

示例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();
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:13,代码来源:Parser.java

示例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());
    }
  }
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:12,代码来源:ProjectGenerator.java

示例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());
        }
      });
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:13,代码来源:ProjectGenerator.java

示例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());
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:42,代码来源:UnsortedAndroidResourceDeps.java


注:本文中的com.facebook.buck.rules.BuildRuleType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。