Java 类com.facebook.buck.rules.BuildRuleResolver 实例源码

项目:buck-cutom    文件:SourcePathTypeCoercerTest.java   
@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);
}
项目:buck-cutom    文件:CxxCompilableEnhancer.java   
/**
 * @return a set of {@link CxxCompile} rules preprocessing, compiling, and assembling the
 *    given input {@link CxxSource} sources.
 */
public static ImmutableSortedSet<BuildRule> createCompileBuildRules(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    Path compiler,
    CxxPreprocessorInput preprocessorInput,
    ImmutableList<String> compilerFlags,
    Iterable<CxxSource> sources) {

  ImmutableSortedSet.Builder<BuildRule> rules = ImmutableSortedSet.naturalOrder();

  // Iterate over the input C/C++ sources that we need to preprocess, assemble, and compile,
  // and generate compile rules for them.
  for (CxxSource source : sources) {
    rules.add(createCompileBuildRule(
        params,
        resolver,
        compiler,
        preprocessorInput,
        compilerFlags,
        source));
  }

  return rules.build();
}
项目:buck-cutom    文件:PrebuiltJarDescription.java   
@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);
}
项目:buck-cutom    文件:SortedSetTypeCoercer.java   
protected void fillSortedSet(
    BuildRuleResolver buildRuleResolver,
    ProjectFilesystem filesystem,
    Path pathRelativeToProjectRoot,
    SortedSet<T> builder,
    Object object) throws CoerceFailedException {

  if (object instanceof Collection) {
    for (Object element : (Iterable<?>) object) {
      // if any element failed, the entire collection fails
      T coercedElement = elementTypeCoercer.coerce(
          buildRuleResolver, filesystem, pathRelativeToProjectRoot, element);
      boolean alreadyExists = !builder.add(coercedElement);
      if (alreadyExists) {
        throw new CoerceFailedException(
            String.format("duplicate element \"%s\"", coercedElement));
      }
    }
  } else {
    throw CoerceFailedException.simple(object, getOutputClass());
  }
}
项目:buck-cutom    文件:GenruleTest.java   
@Test
public void testDepsGenrule() {
  BuildRuleResolver ruleResolver = new BuildRuleResolver();
  BuildRule javaBinary = createSampleJavaBinaryRule(ruleResolver);

  // Interpolate the build target in the genrule cmd string.
  String originalCmd = "$(exe :ManifestGenerator) $OUT";
  Set<? extends BuildRule> deps = ImmutableSet.of(javaBinary);
  Path contextBasePath = Paths.get("java/com/facebook/util");

  Genrule rule = (Genrule) createGenrule(ruleResolver, originalCmd, contextBasePath, deps);
  AbstractGenruleStep genruleStep = rule.createGenruleStep();

  String transformedString = genruleStep.replaceMatches(fakeFilesystem, originalCmd);

  // Verify that the correct cmd was created.
  Path expectedClasspath = getAbsolutePathInBase(
      GEN_DIR + "/java/com/facebook/util/ManifestGenerator.jar");
  String expectedCmd = String.format(
      "java -jar %s $OUT",
      expectedClasspath);
  assertEquals(expectedCmd, transformedString);
}
项目:buck-cutom    文件:GenruleTest.java   
@Test
public void replaceLocationOfFullyQualifiedBuildTarget() throws IOException {
  ProjectFilesystem filesystem = new FakeProjectFilesystem();

  BuildRuleResolver ruleResolver = new BuildRuleResolver();
  BuildRule javaBinary = createSampleJavaBinaryRule(ruleResolver);
  Path outputPath = javaBinary.getPathToOutputFile();
  Path absolutePath = outputPath.toAbsolutePath();

  String originalCmd = String.format("$(location :%s) $(location %s) $OUT",
      javaBinary.getBuildTarget().getShortName(),
      javaBinary.getBuildTarget().getFullyQualifiedName());

  Path contextBasePath = javaBinary.getBuildTarget().getBasePath();
  Set<? extends BuildRule> deps = ImmutableSet.of(javaBinary);

  Genrule buildable = (Genrule) createGenrule(ruleResolver, originalCmd, contextBasePath, deps);
  AbstractGenruleStep genruleStep = buildable.createGenruleStep();

  // Interpolate the build target in the genrule cmd string.
  String transformedString = genruleStep.replaceMatches(filesystem, originalCmd);

  // Verify that the correct cmd was created.
  String expectedCmd = String.format("%s %s $OUT", absolutePath, absolutePath);
  assertEquals(expectedCmd, transformedString);
}
项目:buck-cutom    文件:GenruleBuilder.java   
public Genrule build() {
  final ImmutableSortedSet<BuildRule> depRules = ImmutableSortedSet.copyOf(deps);
  args.deps = Optional.of(depRules);
  args.srcs = Optional.of(FluentIterable
      .from(srcs.build())
      .transform(SourcePaths.TO_SOURCE_PATH)
      .toList());

  BuildRuleParams params = new FakeBuildRuleParamsBuilder(target)
      .setDeps(depRules)
      .setType(GenruleDescription.TYPE)
      .setProjectFilesystem(
          new ProjectFilesystem(Paths.get(".")) {
            @Override
            public Function<Path, Path> getAbsolutifier() {
              return Optional.fromNullable(absolutifier)
                  .or(IdentityPathAbsolutifier.getIdentityAbsolutifier());
            }
          })
      .build();
  return description.createBuildRule(params, new BuildRuleResolver(), args);
}
项目:buck-cutom    文件:GenruleTest.java   
@Test
public void testReplaceRelativeBinaryBuildRuleRefsInCmd() {
  BuildRuleResolver ruleResolver = new BuildRuleResolver();
  BuildRule javaBinary = createSampleJavaBinaryRule(ruleResolver);

  String originalCmd = "$(exe :ManifestGenerator) $OUT";
  Path contextBasePath = Paths.get("java/com/facebook/util");
  Set<? extends BuildRule> deps = ImmutableSet.of(javaBinary);

  Genrule buildable = (Genrule) createGenrule(ruleResolver, originalCmd, contextBasePath, deps);
  AbstractGenruleStep genruleStep = buildable.createGenruleStep();

  // Interpolate the build target in the genrule cmd string.
  String transformedString = genruleStep.replaceMatches(fakeFilesystem, originalCmd);

  // Verify that the correct cmd was created.
  Path expectedClasspath = getAbsolutePathInBase(
      GEN_DIR + "/java/com/facebook/util/ManifestGenerator.jar");
  String expectedCmd = String.format(
      "java -jar %s $OUT",
      expectedClasspath);
  assertEquals(expectedCmd, transformedString);
}
项目:buck-cutom    文件:MapTypeCoercer.java   
@Override
public ImmutableMap<K, V> coerce(
    BuildRuleResolver buildRuleResolver,
    ProjectFilesystem filesystem,
    Path pathRelativeToProjectRoot,
    Object object)
    throws CoerceFailedException {
  if (object instanceof Map) {
    ImmutableMap.Builder<K, V> builder = ImmutableMap.builder();

    for (Map.Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) {
      K key = keyTypeCoercer.coerce(
          buildRuleResolver, filesystem, pathRelativeToProjectRoot, entry.getKey());
      V value = valueTypeCoercer.coerce(
          buildRuleResolver, filesystem, pathRelativeToProjectRoot, entry.getValue());
      builder.put(key, value);
    }

    return builder.build();
  } else {
    throw CoerceFailedException.simple(object, getOutputClass());
  }
}
项目:buck-cutom    文件:AuditClasspathCommandTest.java   
@Test
public void testJsonClassPathOutput() throws IOException {
  // Build a DependencyGraph of build rules manually.
  BuildRuleResolver ruleResolver = new BuildRuleResolver();
  ImmutableList<String> targets = ImmutableList.of(
      "//:test-android-library",
      "//:test-java-library");

  BuildRule library = JavaLibraryBuilder
      .createBuilder(BuildTargetFactory.newInstance("//:test-java-library"))
      .addSrc(Paths.get("src/com/facebook/TestJavaLibrary.java"))
      .build(ruleResolver);
  AndroidLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:test-android-library"))
      .addSrc(Paths.get("src/com/facebook/TestAndroidLibrary.java"))
      .addDep(library)
      .build(ruleResolver);

  PartialGraph partialGraph = createGraphFromBuildRules(ruleResolver, targets);
  auditClasspathCommand.printJsonClasspath(partialGraph);

  assertEquals(EXPECTED_JSON, console.getTextWrittenToStdOut());
  assertEquals("", console.getTextWrittenToStdErr());
}
项目:buck-cutom    文件:PrebuiltNativeLibraryDescription.java   
@Override
public <A extends Args> PrebuiltNativeLibrary createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  ImmutableSortedSet<Path> librarySources;
  try {
    librarySources = ImmutableSortedSet.copyOf(
        params.getProjectFilesystem().getFilesUnderPath(args.nativeLibs));
  } catch (IOException e) {
    throw new HumanReadableException(e, "Error traversing directory %s.", args.nativeLibs);
  }

  return new PrebuiltNativeLibrary(
      params,
      args.nativeLibs,
      args.isAsset.or(false),
      librarySources
  );
}
项目:buck-cutom    文件:ApkGenruleTest.java   
private void createSampleAndroidBinaryRule(BuildRuleResolver ruleResolver) {
  // Create a java_binary that depends on a java_library so it is possible to create a
  // java_binary rule with a classpath entry and a main class.
  BuildTarget libAndroidTarget = BuildTargetFactory.newInstance("//:lib-android");
  BuildRule androidLibRule = JavaLibraryBuilder.createBuilder(libAndroidTarget)
      .addSrc(Paths.get("java/com/facebook/util/Facebook.java"))
      .build(ruleResolver);

  BuildTarget keystoreTarget = BuildTargetFactory.newInstance("//keystore:debug");
  Keystore keystore = (Keystore) KeystoreBuilder.createBuilder(keystoreTarget)
      .setStore(Paths.get("keystore/debug.keystore"))
      .setProperties(Paths.get("keystore/debug.keystore.properties"))
      .build(ruleResolver);

  AndroidBinaryBuilder.createBuilder(BuildTargetFactory.newInstance("//:fb4a"))
      .setManifest(new TestSourcePath("AndroidManifest.xml"))
      .setTarget("Google Inc.:Google APIs:16")
      .setOriginalDeps(ImmutableSortedSet.of(androidLibRule))
      .setKeystore(keystore)
      .build(ruleResolver);
}
项目:buck-cutom    文件:AndroidLibraryTest.java   
@Test
public void testGetInputsToCompareToOuts() {
  BuildRuleResolver ruleResolver = new BuildRuleResolver();
  BuildRule androidLibraryBuilderBar = getAndroidLibraryRuleBar(ruleResolver);
  BuildRule androidLibraryBuilderFoo = getAndroidLibraryRuleFoo(ruleResolver);
  BuildContext context = createMock(BuildContext.class);
  replay(context);

  MoreAsserts.assertIterablesEquals(
      "getInputsToCompareToOutput() should include manifest and src.",
      ImmutableList.of(
          Paths.get("java/src/com/foo/Foo.java"),
          Paths.get("java/src/com/foo/AndroidManifest.xml")),
      androidLibraryBuilderFoo.getInputs());

  MoreAsserts.assertIterablesEquals(
      "getInputsToCompareToOutput() should include only src.",
      ImmutableList.of(Paths.get("java/src/com/bar/Bar.java")),
      androidLibraryBuilderBar.getInputs());

  assertEquals(
      "foo's exported deps should include bar",
      ImmutableSet.of(androidLibraryBuilderBar),
      ((AndroidLibrary) (androidLibraryBuilderFoo)).getExportedDeps());
}
项目:buck-cutom    文件:DefaultJavaLibraryTest.java   
@Test
public void testJavaLibaryThrowsIfResourceIsDirectory() {
  ProjectFilesystem filesystem = new AllExistingProjectFilesystem() {
    @Override
    public boolean isDirectory(Path path, LinkOption... linkOptionsk) {
      return true;
    }
  };

  try {
    JavaLibraryBuilder
        .createBuilder(BuildTargetFactory.newInstance("//library:code"))
        .addResource(new TestSourcePath("library"))
        .build(new BuildRuleResolver(), filesystem);
    fail("An exception should have been thrown because a directory was passed as a resource.");
  } catch (HumanReadableException e) {
    assertTrue(e.getHumanReadableErrorMessage().contains("a directory is not a valid input"));
  }
}
项目:buck-cutom    文件:AndroidBinaryTest.java   
@Test
public void testGetUnsignedApkPath() {
  BuildRuleResolver ruleResolver = new BuildRuleResolver();
  Keystore keystore = (Keystore) addKeystoreRule(ruleResolver);

  AndroidBinary ruleInRootDirectory = (AndroidBinary) AndroidBinaryBuilder.createBuilder(
      BuildTargetFactory.newInstance("//:fb4a"))
      .setManifest(new TestSourcePath("AndroidManifest.xml"))
      .setKeystore(keystore)
      .setTarget("Google Inc.:Google APIs:16")
      .build(ruleResolver);
  assertEquals(Paths.get(GEN_DIR + "/fb4a.apk"), ruleInRootDirectory.getApkPath());

  AndroidBinary ruleInNonRootDirectory = (AndroidBinary) AndroidBinaryBuilder.createBuilder(
      BuildTargetFactory.newInstance("//java/com/example:fb4a"))
      .setManifest(new TestSourcePath("AndroidManifest.xml"))
      .setKeystore(keystore)
      .setTarget("Google Inc.:Google APIs:16")
      .build(ruleResolver);
  assertEquals(
      Paths.get(GEN_DIR + "/java/com/example/fb4a.apk"), ruleInNonRootDirectory.getApkPath());
}
项目:buck-cutom    文件:DefaultJavaLibraryTest.java   
@Test
public void testEmptySuggestBuildFunction() {
  BuildRuleResolver ruleResolver = new BuildRuleResolver();

  BuildTarget libraryOneTarget = BuildTargetFactory.newInstance("//:libone");
  JavaLibrary libraryOne = (JavaLibrary) JavaLibraryBuilder
      .createBuilder(libraryOneTarget)
      .addSrc(Paths.get("java/src/com/libone/bar.java"))
      .build();

  BuildContext context = createSuggestContext(ruleResolver,
      BuildDependencies.FIRST_ORDER_ONLY);

  ImmutableSetMultimap<JavaLibrary, Path> classpathEntries =
      libraryOne.getTransitiveClasspathEntries();

  assertEquals(
      Optional.<JavacInMemoryStep.SuggestBuildRules>absent(),
      ((DefaultJavaLibrary) libraryOne).createSuggestBuildFunction(
          context,
          classpathEntries,
          classpathEntries,
          createJarResolver(/* classToSymbols */ImmutableMap.<Path, String>of())));

  EasyMock.verify(context);
}
项目:buck-cutom    文件:PythonBinaryDescriptionTest.java   
@Test
public void thatMainSourcePathPropagatesToDeps() {
  BuildRuleResolver resolver = new BuildRuleResolver();

  Genrule genrule = GenruleBuilder.createGenrule(BuildTargetFactory.newInstance("//:gen"))
      .setOut("blah.py")
      .build();
  BuildRuleParams params = BuildRuleParamsFactory.createTrivialBuildRuleParams(
      BuildTargetFactory.newInstance("//:bin"));
  PythonBinaryDescription desc = new PythonBinaryDescription(PEX_PATH);
  PythonBinaryDescription.Arg arg = desc.createUnpopulatedConstructorArg();
  arg.deps = Optional.of(ImmutableSortedSet.<BuildRule>of());
  arg.main = new BuildRuleSourcePath(genrule);
  BuildRule rule = desc.createBuildRule(params, resolver, arg);
  assertEquals(
      ImmutableSortedSet.<BuildRule>of(genrule),
      rule.getDeps());
}
项目:buck-cutom    文件:PythonTestDescriptionTest.java   
@Test
public void thatTestModulesAreInComponents() {
  BuildRuleResolver resolver = new BuildRuleResolver();
  BuildRuleParams params =
      new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:bin"))
          .build();
  PythonTestDescription desc = new PythonTestDescription(PEX_PATH, TEST_MAIN);
  PythonTestDescription.Arg arg = desc.createUnpopulatedConstructorArg();
  arg.deps = Optional.of(ImmutableSortedSet.<BuildRule>of());
  arg.srcs = Optional.of(ImmutableSortedSet.<SourcePath>of(new TestSourcePath("blah.py")));
  arg.resources = Optional.absent();
  arg.contacts = Optional.absent();
  arg.labels = Optional.absent();
  arg.sourceUnderTest = Optional.absent();
  PythonTest testRule = desc.createBuildRule(params, resolver, arg);

  PythonBinary binRule = (PythonBinary) resolver.get(
      desc.getBinaryBuildTarget(testRule.getBuildTarget()));
  assertNotNull(binRule);

  PythonPackageComponents components = binRule.getComponents();
  assertTrue(components.getModules().containsKey(desc.getTestModulesListName()));
  assertTrue(components.getModules().containsKey(desc.getTestMainName()));
  assertEquals(binRule.getMain(), desc.getTestMainName());
}
项目:buck-cutom    文件:AppleLibraryTest.java   
@Test
public void getInputsToCompareToOutput() {
  AppleNativeTargetDescriptionArg arg = description.createUnpopulatedConstructorArg();
  arg.srcs = ImmutableList.of(
      AppleSource.ofSourcePath(new TestSourcePath("some_source.m")),
      AppleSource.ofSourcePath(new TestSourcePath("some_header.h")));
  arg.configs = ImmutableMap.of();
  arg.frameworks = ImmutableSortedSet.of();
  arg.deps = Optional.absent();
  arg.gid = Optional.absent();
  arg.headerPathPrefix = Optional.absent();
  arg.useBuckHeaderMaps = Optional.absent();

  BuildRuleParams params =
      new FakeBuildRuleParamsBuilder(BuildTarget.builder("//foo", "foo").build()).build();
  AppleLibrary buildable = description.createBuildRule(params, new BuildRuleResolver(), arg);

  assertThat(buildable.getInputsToCompareToOutput(), containsInAnyOrder(
      Paths.get("some_header.h"),
      Paths.get("some_source.m")));
}
项目:buck-cutom    文件:AppleLibraryTest.java   
@Test
public void getDynamicFlavorOutputName() {
  AppleNativeTargetDescriptionArg arg = description.createUnpopulatedConstructorArg();
  arg.srcs = ImmutableList.of();
  arg.configs = ImmutableMap.of();
  arg.frameworks = ImmutableSortedSet.of();
  arg.deps = Optional.absent();
  arg.gid = Optional.absent();
  arg.headerPathPrefix = Optional.absent();
  arg.useBuckHeaderMaps = Optional.absent();

  BuildTarget target = BuildTarget.builder("//foo", "foo")
      .setFlavor(AppleLibraryDescription.DYNAMIC_LIBRARY)
      .build();
  BuildRuleParams params = new FakeBuildRuleParamsBuilder(target).build();
  AppleLibrary buildable = description.createBuildRule(params, new BuildRuleResolver(), arg);

  assertEquals(Paths.get("buck-out/bin/foo/#dynamic/foo.dylib"), buildable.getPathToOutputFile());
}
项目:buck-cutom    文件:JavaBinaryDescription.java   
@Override
public <A extends Args> JavaBinary createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  return new JavaBinary(
      params,
      args.mainClass.orNull(),
      args.manifestFile.orNull(),
      args.mergeManifests.or(true),
      args.metaInfDirectory.orNull(),
      args.blacklist.or(ImmutableSortedSet.<String>of()),
      new DefaultDirectoryTraverser());
}
项目:buck-cutom    文件:JavaTestDescription.java   
public static ImmutableSet<BuildRule> validateAndGetSourcesUnderTest(
    ImmutableSet<BuildTarget> sourceUnderTestTargets,
    BuildTarget owner,
    BuildRuleResolver resolver) {
  ImmutableSet.Builder<BuildRule> sourceUnderTest = ImmutableSet.builder();
  for (BuildTarget target : sourceUnderTestTargets) {
    BuildRule rule = resolver.get(target);
    if (rule == null) {
      throw new HumanReadableException(
          "Specified source under test for %s is not among its dependencies: %s",
          owner,
          target);
    }
    if (!(rule instanceof JavaLibrary)) {
      // In this case, the source under test specified in the build file was not a Java library
      // rule. Since EMMA requires the sources to be in Java, we will throw this exception and
      // not continue with the tests.
      throw new HumanReadableException(
          "Specified source under test for %s is not a Java library: %s (%s).",
          owner,
          rule.getFullyQualifiedName(),
          rule.getType().getName());
    }
    sourceUnderTest.add(rule);
  }
  return sourceUnderTest.build();
}
项目:buck-cutom    文件:PrebuiltJarDescription.java   
@Override
public <A extends Arg> BuildRule createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  return new PrebuiltJar(
      params,
      args.binaryJar,
      args.sourceJar,
      args.gwtJar,
      args.javadocUrl);
}
项目:buck-cutom    文件:KeystoreDescription.java   
@Override
public <A extends Arg> Keystore createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  return new Keystore(params, args.store, args.properties);
}
项目:buck-cutom    文件:GenParcelableDescription.java   
@Override
public <A extends Arg> GenParcelable createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  return new GenParcelable(params, args.srcs);
}
项目:buck-cutom    文件:TargetsCommandTest.java   
private PartialGraph createGraphFromBuildRules(BuildRuleResolver ruleResolver,
    List<String> targets) {
  ImmutableSet<BuildTarget> buildTargets = ImmutableSet.copyOf(
      Iterables.transform(
          targets,
          new Function<String, BuildTarget>() {
            @Override
            public BuildTarget apply(String target) {
              return BuildTargetFactory.newInstance(target);
            }
          }));

  ActionGraph actionGraph = RuleMap.createGraphFromBuildRules(ruleResolver);
  return PartialGraphFactory.newInstance(actionGraph, buildTargets);
}
项目:buck-cutom    文件:AndroidBinaryTest.java   
@Test
public void testDexingCommand() {
  BuildRuleResolver ruleResolver = new BuildRuleResolver();
  AndroidBinary splitDexRule = (AndroidBinary) AndroidBinaryBuilder.createBuilder(
      BuildTargetFactory.newInstance("//:fbandroid_with_dash_debug_fbsign"))
      .setManifest(new TestSourcePath("AndroidManifest.xml"))
      .setKeystore((Keystore) addKeystoreRule(ruleResolver))
      .setTarget("Google Inc.:Google APIs:16")
      .setShouldSplitDex(true)
      .setLinearAllocHardLimit(0)
      .setPrimaryDexScenarioOverflowAllowed(true)
      .setDexCompression(DexStore.JAR)
      .build(ruleResolver);

  Set<Path> classpath = Sets.newHashSet();
  ImmutableSet.Builder<Path> secondaryDexDirectories = ImmutableSet.builder();
  ImmutableList.Builder<Step> commandsBuilder = ImmutableList.builder();
  Path primaryDexPath = BIN_PATH.resolve(".dex/classes.dex");
  splitDexRule.addDexingSteps(
      classpath,
      Suppliers.<Map<String, HashCode>>ofInstance(ImmutableMap.<String, HashCode>of()),
      secondaryDexDirectories,
      commandsBuilder,
      primaryDexPath);

  assertEquals("Expected 2 new assets paths (one for metadata.txt and the other for the " +
      "secondary zips)", 2, secondaryDexDirectories.build().size());

  List<Step> steps = commandsBuilder.build();
  assertCommandsInOrder(steps,
      ImmutableList.<Class<?>>of(SplitZipStep.class, SmartDexingStep.class));
}
项目:buck-cutom    文件:AppleTestDescription.java   
@Override
public <A extends Arg> AppleTest createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  return new AppleTest(params, args);
}
项目:buck-cutom    文件:AppleAssetCatalogDescription.java   
@Override
public <A extends Arg> AppleAssetCatalog createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  ProjectFilesystem projectFilesystem = params.getProjectFilesystem();
  Supplier<ImmutableCollection<Path>> inputPathsSupplier =
      RuleUtils.subpathsOfPathsSupplier(projectFilesystem, args.dirs);
  return new AppleAssetCatalog(params, inputPathsSupplier, args);
}
项目:buck-cutom    文件:AppleLibraryDescription.java   
@Override
public <A extends AppleNativeTargetDescriptionArg> AppleLibrary createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  return new AppleLibrary(
      params,
      args,
      TargetSources.ofAppleSources(args.srcs),
      archiver,
      params.getBuildTarget().getFlavor().equals(DYNAMIC_LIBRARY));
}
项目:buck-cutom    文件:XcodeWorkspaceConfigDescription.java   
@Override
public <A extends Arg> XcodeWorkspaceConfig createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  return new XcodeWorkspaceConfig(params, args);
}
项目:buck-cutom    文件:ProjectGeneratorTest.java   
@Test
public void targetGidInDescriptionSetsTargetGidInGeneratedProject() throws IOException {
  BuildRuleParams params =
      new FakeBuildRuleParamsBuilder(BuildTarget.builder("//foo", "lib").build())
          .setType(AppleLibraryDescription.TYPE)
          .build();
  AppleNativeTargetDescriptionArg arg = appleLibraryDescription.createUnpopulatedConstructorArg();
  arg.configs = ImmutableMap.of();
  arg.srcs = ImmutableList.of();
  arg.frameworks = ImmutableSortedSet.of();
  arg.deps = Optional.absent();
  arg.gid = Optional.of("D00D64738");
  arg.headerPathPrefix = Optional.absent();
  arg.useBuckHeaderMaps = Optional.absent();

  BuildRule rule = appleLibraryDescription.createBuildRule(params, new BuildRuleResolver(), arg);

  ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(
      ImmutableSet.of(rule),
      ImmutableSet.of(rule.getBuildTarget()));

  projectGenerator.createXcodeProjects();

  PBXTarget target = assertTargetExistsAndReturnTarget(
      projectGenerator.getGeneratedProject(),
      "//foo:lib");
  // Ensure the GID for the target uses the gid value in the description.
  assertThat(target.getGlobalID(), equalTo("D00D64738"));
}
项目:buck-cutom    文件:XcodeProjectConfigDescription.java   
@Override
public <A extends Arg> XcodeProjectConfig createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  return new XcodeProjectConfig(params, args);
}
项目:buck-cutom    文件:CoreDataModelDescription.java   
@Override
public <A extends Arg> CoreDataModel createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  ProjectFilesystem projectFilesystem = params.getProjectFilesystem();
  Supplier<ImmutableCollection<Path>> inputPathsSupplier = RuleUtils.subpathsOfPathsSupplier(
      projectFilesystem,
      ImmutableSet.of(args.path));
  return new CoreDataModel(params, inputPathsSupplier, args);
}
项目:buck-cutom    文件:AppleBundleDescription.java   
@Override
public <A extends Arg> AppleBundle createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  return new AppleBundle(params, args);
}
项目:buck-cutom    文件:BuildRuleTypeCoercer.java   
@Override
public BuildRule coerce(
    BuildRuleResolver buildRuleResolver,
    ProjectFilesystem filesystem,
    Path pathRelativeToProjectRoot,
    Object object)
    throws CoerceFailedException {
  try {
    BuildTarget buildTarget = buildTargetTypeCoercer.coerce(
        buildRuleResolver, filesystem, pathRelativeToProjectRoot, object);
    return buildRuleResolver.get(buildTarget);
  } catch (CoerceFailedException e) {
    throw CoerceFailedException.simple(object, getOutputClass());
  }
}
项目:buck-cutom    文件:SortedSetTypeCoercer.java   
@Override
public ImmutableSortedSet<T> coerce(
    BuildRuleResolver buildRuleResolver,
    ProjectFilesystem filesystem,
    Path pathRelativeToProjectRoot,
    Object object)
    throws CoerceFailedException {
  final SortedSet<T> builder = Sets.newTreeSet();
  fillSortedSet(buildRuleResolver, filesystem, pathRelativeToProjectRoot, builder, object);
  return ImmutableSortedSet.copyOf(builder);
}
项目:buck-cutom    文件:IdentityTypeCoercer.java   
@Override
public T coerce(
    BuildRuleResolver buildRuleResolver,
    ProjectFilesystem filesystem,
    Path pathRelativeToProjectRoot,
    Object object)
    throws CoerceFailedException {
  if (type.isAssignableFrom(object.getClass())) {
    return type.cast(object);
  }
  throw CoerceFailedException.simple(object, getOutputClass());
}
项目:buck-cutom    文件:ListTypeCoercer.java   
@Override
public ImmutableList<T> coerce(
    BuildRuleResolver buildRuleResolver,
    ProjectFilesystem filesystem,
    Path pathRelativeToProjectRoot,
    Object object) throws CoerceFailedException {
  ImmutableList.Builder<T> builder = ImmutableList.builder();
  fill(buildRuleResolver, filesystem, pathRelativeToProjectRoot, builder, object);
  return builder.build();
}
项目:buck-cutom    文件:LabelTypeCoercer.java   
@Override
public Label coerce(
    BuildRuleResolver buildRuleResolver,
    ProjectFilesystem filesystem,
    Path pathRelativeToProjectRoot,
    Object object) throws CoerceFailedException {
  if (object instanceof String) {
    return new Label((String) object);
  }
  throw CoerceFailedException.simple(object, getOutputClass());
}