Exemplo n.º 1
0
  /**
   * Build the {@link HeaderSymlinkTree} rule using the original build params from a target node. In
   * particular, make sure to drop all dependencies from the original build rule params, as these
   * are modeled via {@link CxxPreprocessAndCompile}.
   */
  public static HeaderSymlinkTree createHeaderSymlinkTreeBuildRule(
      SourcePathResolver resolver,
      BuildTarget target,
      BuildRuleParams params,
      Path root,
      Optional<Path> headerMapPath,
      ImmutableMap<Path, SourcePath> links) {
    // Symlink trees never need to depend on anything.
    BuildRuleParams paramsWithoutDeps =
        params.copyWithChanges(
            target,
            Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>of()),
            Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>of()));

    try {
      if (headerMapPath.isPresent()) {
        return new HeaderSymlinkTreeWithHeaderMap(
            paramsWithoutDeps, resolver, root, headerMapPath.get(), links);
      } else {
        return new HeaderSymlinkTree(paramsWithoutDeps, resolver, root, links);
      }
    } catch (SymlinkTree.InvalidSymlinkTreeException e) {
      throw e.getHumanReadableExceptionForBuildTarget(target.getUnflavoredBuildTarget());
    }
  }