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

项目:buck-cutom    文件:CxxPreprocessables.java   
/**
 * 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();
}
项目:buck-cutom    文件:CxxPreprocessables.java   
/**
 * 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);
}
项目:buck-cutom    文件:CxxCompilableEnhancer.java   
/**
 * 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();
}
项目:buck-cutom    文件:BuckExtensionTest.java   
@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);
}
项目:buck-cutom    文件:Archives.java   
/**
 * 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)));
}
项目:buck-cutom    文件:PythonPackageableComponentsTest.java   
@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"));
  }
}
项目:buck-cutom    文件:JavacStep.java   
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);
}
项目:buck-cutom    文件:ApkGenrule.java   
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);
}
项目:buck-cutom    文件:AndroidBinaryTest.java   
@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());
}
项目: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    文件:AndroidBuildConfigJavaLibrary.java   
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());
}
项目:buck-cutom    文件:PythonUtil.java   
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();
}
项目:buck-cutom    文件:PythonBinary.java   
@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;
}
项目:buck-cutom    文件:TargetSources.java   
/**
 * 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());
}
项目:buck-cutom    文件:PythonBinaryTest.java   
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();
}
项目:buck-cutom    文件:GroupedSource.java   
private GroupedSource(
    Type type,
    @Nullable SourcePath sourcePath,
    @Nullable String sourceGroupName,
    @Nullable ImmutableList<GroupedSource> sourceGroup) {
  this.type = Preconditions.checkNotNull(type);
  switch (this.type) {
    case SOURCE_PATH:
      Preconditions.checkNotNull(sourcePath);
      Preconditions.checkArgument(sourceGroupName == null);
      Preconditions.checkArgument(sourceGroup == null);
      break;
    case SOURCE_GROUP:
      Preconditions.checkArgument(sourcePath == null);
      Preconditions.checkNotNull(sourceGroupName);
      Preconditions.checkNotNull(sourceGroup);
      break;
    default:
      throw new RuntimeException("Unhandled type: " + type);
  }
  this.sourcePath = sourcePath;
  this.sourceGroupName = sourceGroupName;
  this.sourceGroup = sourceGroup;
}
项目:buck-cutom    文件:ProjectGenerator.java   
private void addSourcePathToSourcesBuildPhase(
    SourcePath sourcePath,
    PBXGroup sourcesGroup,
    PBXSourcesBuildPhase sourcesBuildPhase,
    ImmutableMap<SourcePath, String> sourceFlags) {
  Path path = sourcePath.resolve();
  PBXFileReference fileReference = sourcesGroup.getOrCreateFileReferenceBySourceTreePath(
      new SourceTreePath(
          PBXReference.SourceTree.SOURCE_ROOT,
          repoRootRelativeToOutputDirectory.resolve(path)));
  PBXBuildFile buildFile = new PBXBuildFile(fileReference);
  sourcesBuildPhase.getFiles().add(buildFile);
  String customFlags = sourceFlags.get(sourcePath);
  if (customFlags != null) {
    NSDictionary settings = new NSDictionary();
    settings.put("COMPILER_FLAGS", customFlags);
    buildFile.setSettings(Optional.of(settings));
  }
  LOG.verbose(
      "Added source path %s to group %s, flags %s, PBXFileReference %s",
      sourcePath,
      sourcesGroup.getName(),
      customFlags,
      fileReference);
}
项目:buck-cutom    文件:AppleResource.java   
@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();
}
项目:onos    文件:OnosJarStepFactory.java   
private ImmutableSortedSet<Path> findSwaggerModelDefs(SourcePathResolver resolver,
                                                      ImmutableSortedSet<SourcePath> resourcePaths) {
    if (resourcePaths == null) {
        return ImmutableSortedSet.of();
    }
    return ImmutableSortedSet.copyOf(resourcePaths.stream()
                                             .filter(sp -> sp.toString().contains(DEFINITIONS))
                                             .map(resolver::getRelativePath)
                                             .collect(Collectors.toList()));
}
项目:buck-cutom    文件:AndroidPrebuiltAarGraphEnhancer.java   
private UnzipAar(BuildRuleParams buildRuleParams, SourcePath aarFile) {
  super(buildRuleParams);
  this.aarFile = Preconditions.checkNotNull(aarFile);
  this.unpackDirectory = BuildTargets.getBinPath(
      buildRuleParams.getBuildTarget(),
      "__unpack_%s__");
}
项目:buck-cutom    文件:CxxDescriptionEnhancer.java   
/**
 * @return a map of header locations to input {@link SourcePath} objects formed by parsing the
 *    input {@link SourcePath} objects for the "headers" parameter.
 */
public static ImmutableMap<Path, SourcePath> parseHeaders(
    BuildTarget target,
    Iterable<SourcePath> inputs) {

  return CxxPreprocessables.resolveHeaderMap(
      target,
      SourcePaths.getSourcePathNames(
          target,
          "headers",
          inputs));
}
项目:buck-cutom    文件:ShTest.java   
protected ShTest(
    BuildRuleParams params,
    SourcePath test,
    Set<Label> labels) {
  super(params);
  this.test = Preconditions.checkNotNull(test);
  this.labels = ImmutableSet.copyOf(labels);
}
项目:buck-cutom    文件:ProjectGeneratorTest.java   
@Test
public void ruleToTargetMapContainsPBXTarget() throws IOException {
  BuildRuleParams params =
      new FakeBuildRuleParamsBuilder(BuildTarget.builder("//foo", "lib").build())
          .setType(AppleLibraryDescription.TYPE)
          .build();
  AppleNativeTargetDescriptionArg arg = appleLibraryDescription.createUnpopulatedConstructorArg();
  arg.configs = ImmutableMap.of(
      "Debug", ImmutableList.<Either<Path, ImmutableMap<String, String>>>of());
  arg.srcs = ImmutableList.of(
      AppleSource.ofSourcePathWithFlags(
          new Pair<SourcePath, String>(new TestSourcePath("foo.m"), "-foo")),
      AppleSource.ofSourcePath(new TestSourcePath("foo.h")),
      AppleSource.ofSourcePath(new TestSourcePath("bar.m")));
  arg.frameworks = ImmutableSortedSet.of();
  arg.deps = Optional.absent();
  arg.gid = Optional.absent();
  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();

  assertEquals(rule, Iterables.getOnlyElement(
          projectGenerator.getBuildRuleToGeneratedTargetMap().keySet()));

  PBXTarget target = Iterables.getOnlyElement(
      projectGenerator.getBuildRuleToGeneratedTargetMap().values());
  assertHasSingletonSourcesPhaseWithSourcesAndFlags(
      target, ImmutableMap.of(
          "foo.m", Optional.of("-foo"),
          "bar.m", Optional.<String>absent()));
}
项目:buck-cutom    文件:RobolectricTest.java   
protected RobolectricTest(
    BuildRuleParams buildRuleParams,
    Set<SourcePath> srcs,
    Set<SourcePath> resources,
    Set<Label> labels,
    Set<String> contacts,
    Optional<Path> proguardConfig,
    ImmutableSet<Path> additionalClasspathEntries,
    JavacOptions javacOptions,
    List<String> vmArgs,
    ImmutableSet<BuildRule> sourceTargetsUnderTest,
    Optional<Path> resourcesRoot,
    Optional<DummyRDotJava> optionalDummyRDotJava) {
  super(
      buildRuleParams,
      srcs,
      resources,
      labels,
      contacts,
      proguardConfig,
      additionalClasspathEntries,
      javacOptions,
      vmArgs,
      sourceTargetsUnderTest,
      resourcesRoot);
  this.optionalDummyRDotJava = Preconditions.checkNotNull(optionalDummyRDotJava);
}
项目:buck-cutom    文件:CxxHeaderSourceSpec.java   
public CxxHeaderSourceSpec(
    ImmutableMap<Path, SourcePath> cxxHeaders,
    ImmutableList<CxxSource> cxxSources) {

  this.cxxHeaders = Preconditions.checkNotNull(cxxHeaders);
  this.cxxSources = Preconditions.checkNotNull(cxxSources);
}
项目:buck-cutom    文件:CxxPreprocessablesTest.java   
@Test
public void createHeaderSymlinkTreeBuildRuleHasNoDeps() {

  // Setup up the main build target and build params, which some random dep.  We'll make
  // sure the dep doesn't get propagated to the symlink rule below.
  FakeBuildRule dep = createFakeBuildRule(BuildTargetFactory.newInstance("//random:dep"));
  BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
  BuildRuleParams params = new FakeBuildRuleParamsBuilder(target)
      .setDeps(ImmutableSortedSet.<BuildRule>of(dep))
      .build();
  Path root = Paths.get("root");

  // Setup a simple genrule we can wrap in a BuildRuleSourcePath to model a input source
  // that is built by another rule.
  Genrule genrule = GenruleBuilder
      .createGenrule(BuildTargetFactory.newInstance("//:genrule"))
      .setOut("foo/bar.o")
      .build();

  // Setup the link map with both a regular path-based source path and one provided by
  // another build rule.
  ImmutableMap<Path, SourcePath> links = ImmutableMap.<Path, SourcePath>of(
      Paths.get("link1"), new TestSourcePath("hello"),
      Paths.get("link2"), new BuildRuleSourcePath(genrule));

  // Build our symlink tree rule using the helper method.
  SymlinkTree symlinkTree = CxxPreprocessables.createHeaderSymlinkTreeBuildRule(
      target,
      params,
      root,
      links);

  // Verify that the symlink tree has no deps.  This is by design, since setting symlinks can
  // be done completely independently from building the source that the links point to and
  // independently from the original deps attached to the input build rule params.
  assertTrue(symlinkTree.getDeps().isEmpty());
}
项目:buck-cutom    文件:AaptPackageResources.java   
AaptPackageResources(
    BuildRuleParams params,
    SourcePath manifest,
    FilteredResourcesProvider filteredResourcesProvider,
    ImmutableSet<Path> assetsDirectories,
    PackageType packageType,
    ImmutableSet<TargetCpuType> cpuFilters) {
  super(params);
  this.manifest = Preconditions.checkNotNull(manifest);
  this.filteredResourcesProvider = Preconditions.checkNotNull(filteredResourcesProvider);
  this.assetsDirectories = Preconditions.checkNotNull(assetsDirectories);
  this.packageType = Preconditions.checkNotNull(packageType);
  this.cpuFilters = Preconditions.checkNotNull(cpuFilters);
  this.buildOutputInitializer = new BuildOutputInitializer<>(params.getBuildTarget(), this);
}
项目:buck-cutom    文件:AbstractNativeBuildRule.java   
public AbstractNativeBuildRule(
    BuildRuleParams params,
    ImmutableSortedSet<SourcePath> srcs,
    ImmutableSortedSet<SourcePath> headers,
    ImmutableMap<SourcePath, String> perSrcFileFlags) {
  super(params);
  this.headers = Preconditions.checkNotNull(headers);
  this.srcs = Preconditions.checkNotNull(srcs);
  this.perSrcFileFlags = Preconditions.checkNotNull(perSrcFileFlags);
}
项目:buck-cutom    文件:AbstractNativeBuildRule.java   
private static Collection<String> commandLineArgsForFile(
    SourcePath file,
    ImmutableMap<SourcePath, String> perSrcFileFlags) {
  String srcFileFlags = perSrcFileFlags.get(file);
  if (srcFileFlags == null) {
    return ImmutableList.of();
  }
  // TODO(user): Ugh, this is terrible. We need to pass in an array everywhere, then
  // join it on space for Xcode (which takes a single string of course).
  return ImmutableList.copyOf(srcFileFlags.split(" "));
}
项目:buck-cutom    文件:AndroidManifest.java   
protected AndroidManifest(
    BuildRuleParams params,
    SourcePath skeletonFile,
    Set<SourcePath> manifestFiles) {
  super(params);
  this.skeletonFile = Preconditions.checkNotNull(skeletonFile);
  this.manifestFiles = ImmutableSortedSet.copyOf(manifestFiles);
  BuildTarget buildTarget = params.getBuildTarget();
  this.pathToOutputFile = BuildTargets.getGenPath(buildTarget, "AndroidManifest__%s__.xml");
}
项目:buck-cutom    文件:JavaSourceJarTest.java   
@Test
public void shouldOnlyIncludePathBasedSources() {
  SourcePath fileBased = new TestSourcePath("some/path/File.java");
  SourcePath ruleBased = new BuildRuleSourcePath(
      new FakeBuildRule(JavaLibraryDescription.TYPE,
      BuildTargetFactory.newInstance("//cheese:cake")));

  JavaPackageFinder finderStub = createNiceMock(JavaPackageFinder.class);
  expect(finderStub.findJavaPackageFolderForPath((String) anyObject())).andStubReturn("cheese");
  expect(finderStub.findJavaPackageForPath((String) anyObject())).andStubReturn("cheese");

  // No need to verify. It's a stub. I don't care about the interactions.
  EasyMock.replay(finderStub);

  JavaSourceJar rule = new JavaSourceJar(
      new FakeBuildRuleParamsBuilder("//example:target").build(),
      ImmutableSortedSet.of(fileBased, ruleBased));

  assertEquals(ImmutableList.of(fileBased.resolve()), rule.getInputsToCompareToOutput());

  BuildContext buildContext = FakeBuildContext.newBuilder(new FakeProjectFilesystem())
      .setActionGraph(new ActionGraph(new MutableDirectedGraph<BuildRule>()))
      .setJavaPackageFinder(finderStub)
      .build();
  ImmutableList<Step> steps = rule.getBuildSteps(
      buildContext,
      new FakeBuildableContext());

  // There should be a CopyStep per file being copied. Count 'em.
  int copyStepsCount = FluentIterable.from(steps)
      .filter(Predicates.instanceOf(CopyStep.class))
      .size();

  assertEquals(1, copyStepsCount);
}
项目:buck-cutom    文件:ExternalJavacStep.java   
public ExternalJavacStep(
    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,
    BuildTarget target,
    Optional<Path> workingDirectory) {
  super(outputDirectory,
      javaSourceFilePaths,
      transitiveClasspathEntries,
      declaredClasspathEntries,
      javacOptions,
      pathToOutputAbiFile,
      invokingRule,
      buildDependencies,
      suggestBuildRules,
      pathToSrcsList);
  this.pathToJavac = javacOptions.getJavaCompilerEnvironment().getJavacPath().get();
  this.target = Preconditions.checkNotNull(target);
  this.workingDirectory = Preconditions.checkNotNull(workingDirectory);
}
项目:buck-cutom    文件:ShBinary.java   
protected ShBinary(
    BuildRuleParams params,
    SourcePath main,
    ImmutableSet<SourcePath> resources) {
  super(params);
  this.main = Preconditions.checkNotNull(main);
  this.resources = Preconditions.checkNotNull(resources);

  BuildTarget target = params.getBuildTarget();
  this.output = BuildTargets.getGenPath(
      target,
      String.format("__%%s__/%s.sh", target.getShortName()));
  this.buildOutputInitializer = new BuildOutputInitializer<>(target, this);
}
项目:buck-cutom    文件:GenerateManifestStep.java   
public GenerateManifestStep(
    Path skeletonManifestPath,
    ImmutableSet<SourcePath> libraryManifestPaths,
    Path outManifestPath) {
  this.skeletonManifestPath = Preconditions.checkNotNull(skeletonManifestPath);
  this.libraryManifestPaths = ImmutableSet.copyOf(libraryManifestPaths);
  this.outManifestPath = Preconditions.checkNotNull(outManifestPath);
}
项目:buck-cutom    文件:ShBinary.java   
@Override
public ImmutableCollection<Path> getInputsToCompareToOutput() {
  ImmutableSortedSet<SourcePath> allPaths = ImmutableSortedSet.<SourcePath>naturalOrder()
      .add(main)
      .addAll(resources)
      .build();

  return SourcePaths.filterInputsToCompareToOutput(allPaths);
}
项目:buck-cutom    文件:PythonBinaryDescriptionTest.java   
@Test
public void thatComponentSourcePathDepsPropagateProperly() {
  BuildRuleResolver resolver = new BuildRuleResolver();

  Genrule genrule = GenruleBuilder.createGenrule(BuildTargetFactory.newInstance("//:gen"))
      .setOut("blah.py")
      .build();
  BuildRuleParams libParams = BuildRuleParamsFactory.createTrivialBuildRuleParams(
      BuildTargetFactory.newInstance("//:lib"));
  PythonLibrary lib = new PythonLibrary(
      libParams,
      ImmutableMap.<Path, SourcePath>of(
          Paths.get("hello"), new BuildRuleSourcePath(genrule)),
      ImmutableMap.<Path, SourcePath>of());

  BuildRuleParams params =
      new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:bin"))
          .setDeps(ImmutableSortedSet.<BuildRule>of(lib))
          .build();
  PythonBinaryDescription desc = new PythonBinaryDescription(PEX_PATH);
  PythonBinaryDescription.Arg arg = desc.createUnpopulatedConstructorArg();
  arg.deps = Optional.of(ImmutableSortedSet.<BuildRule>of());
  arg.main = new TestSourcePath("blah.py");
  BuildRule rule = desc.createBuildRule(params, resolver, arg);

  assertEquals(
      ImmutableSortedSet.<BuildRule>of(genrule),
      rule.getDeps());
}
项目:buck-cutom    文件:AppleResourceTest.java   
/**
 * Tests the inputs of an apple_resource rule with a directory, files, and variants.
 */
@Test
public void testInputsForRuleWithDirectoryAndFiles() throws IOException {
  AppleResourceDescription.Arg args = new AppleResourceDescription.Arg();
  args.dirs = ImmutableSortedSet.of(Paths.get("MyLibrary.bundle"));
  args.files = ImmutableSortedSet.<SourcePath>of(new TestSourcePath("Resources/MyImage.jpg"));

  Map<String, SourcePath> variant =
      ImmutableMap.<String, SourcePath>of("en", new TestSourcePath("Resources/Real.jpg"));
  Map<String, Map<String, SourcePath>> variants =
      ImmutableMap.of("Virtual.jpg", variant);
  args.variants = Optional.of(variants);

  AppleResource appleResource = new AppleResource(
      new FakeBuildRuleParamsBuilder(
          BuildTarget.builder("//path/to/app", "MyApp").build()).build(),
      // Pretend that MyLibrary.bundle contains two files: an image and a sound file.
      new FakeDirectoryTraverser(
          ImmutableMap.<String, Collection<FakeDirectoryTraverser.Entry>>of(
              "MyLibrary.bundle",
              ImmutableList.of(
                  new FakeDirectoryTraverser.Entry(null, "BundleImage.jpg"),
                  new FakeDirectoryTraverser.Entry(null, "BundleSound.wav")
              ))),
      args);

  MoreAsserts.assertIterablesEquals(
      "Directory should be traversed and file should be included.",
      ImmutableList.of(
          Paths.get("MyLibrary.bundle/BundleImage.jpg"),
          Paths.get("MyLibrary.bundle/BundleSound.wav"),
          Paths.get("Resources/MyImage.jpg"),
          Paths.get("Resources/Real.jpg")),
        appleResource.getInputsToCompareToOutput());
}
项目:buck-cutom    文件:AndroidBinaryGraphEnhancer.java   
AndroidBinaryGraphEnhancer(
    BuildRuleParams originalParams,
    BuildRuleResolver ruleResolver,
    ResourceCompressionMode resourceCompressionMode,
    ResourceFilter resourcesFilter,
    SourcePath manifest,
    PackageType packageType,
    ImmutableSet<TargetCpuType> cpuFilters,
    boolean shouldBuildStringSourceMap,
    boolean shouldPreDex,
    Path primaryDexPath,
    DexSplitMode dexSplitMode,
    ImmutableSet<BuildTarget> buildTargetsToExcludeFromDex,
    ImmutableSet<BuildTarget> resourcesToExclude,
    JavacOptions javacOptions,
    boolean exopackage,
    Keystore keystore,
    BuildConfigFields buildConfigValues,
    Optional<SourcePath> buildConfigValuesFile) {
  this.buildRuleParams = Preconditions.checkNotNull(originalParams);
  this.originalBuildTarget = originalParams.getBuildTarget();
  this.originalDeps = originalParams.getDeps();
  this.ruleResolver = Preconditions.checkNotNull(ruleResolver);
  this.resourceCompressionMode = Preconditions.checkNotNull(resourceCompressionMode);
  this.resourceFilter = Preconditions.checkNotNull(resourcesFilter);
  this.manifest = Preconditions.checkNotNull(manifest);
  this.packageType = Preconditions.checkNotNull(packageType);
  this.cpuFilters = Preconditions.checkNotNull(cpuFilters);
  this.shouldBuildStringSourceMap = shouldBuildStringSourceMap;
  this.shouldPreDex = shouldPreDex;
  this.primaryDexPath = Preconditions.checkNotNull(primaryDexPath);
  this.dexSplitMode = Preconditions.checkNotNull(dexSplitMode);
  this.buildTargetsToExcludeFromDex = Preconditions.checkNotNull(buildTargetsToExcludeFromDex);
  this.resourcesToExclude = Preconditions.checkNotNull(resourcesToExclude);
  this.javacOptions = Preconditions.checkNotNull(javacOptions);
  this.exopackage = exopackage;
  this.keystore = Preconditions.checkNotNull(keystore);
  this.buildConfigValues = Preconditions.checkNotNull(buildConfigValues);
  this.buildConfigValuesFile = Preconditions.checkNotNull(buildConfigValuesFile);
}
项目:buck-cutom    文件:ApkGenruleDescription.java   
@Override
public <A extends Arg> ApkGenrule createBuildRule(
    BuildRuleParams params,
    BuildRuleResolver resolver,
    A args) {
  if (!(args.apk instanceof InstallableApk)) {
    throw new HumanReadableException("The 'apk' argument of %s, %s, must correspond to an " +
        "installable rule, such as android_binary() or apk_genrule().",
        params.getBuildTarget(),
        args.apk.getFullyQualifiedName());
  }

  InstallableApk installableApk = (InstallableApk) args.apk;

  ImmutableList<SourcePath> srcs = args.srcs.get();
  ImmutableSortedSet<BuildRule> extraDeps =
      ImmutableSortedSet.<BuildRule>naturalOrder()
      .addAll(SourcePaths.filterBuildRuleInputs(srcs))
      .add(installableApk)
      .build();

  return new ApkGenrule(
      params.copyWithExtraDeps(extraDeps),
      srcs,
      args.cmd,
      args.bash,
      args.cmdExe,
      params.getPathAbsolutifier(),
      installableApk);
}
项目:buck-cutom    文件:JavaThriftLibrary.java   
public JavaThriftLibrary(
    BuildRuleParams params,
    ImmutableSortedSet<SourcePath> srcs) {
  super(params);
  this.srcs = Preconditions.checkNotNull(srcs);
  this.genPath = BuildTargets.getGenPath(getBuildTarget(), "__thrift_%s__");
  this.srcJarOutputPath = genPath.resolve("gen-java" + JavacStep.SRC_ZIP);
}