コード例 #1
0
ファイル: ProtoSupport.java プロジェクト: dslomov/bazel
  private Iterable<Artifact> getAllProtoSources() {
    NestedSetBuilder<Artifact> protos = NestedSetBuilder.stableOrder();

    if (experimentalAutoUnion() && targetType == TargetType.LINKING_TARGET) {
      Iterable<ObjcProtoProvider> objcProtoProviders =
          ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProtoProvider.class);
      for (ObjcProtoProvider objcProtoProvider : objcProtoProviders) {
        protos.addTransitive(objcProtoProvider.getProtoSources());
      }
    }

    protos.addTransitive(attributes.getProtoFiles());

    return protos.build();
  }
コード例 #2
0
ファイル: ProtoSupport.java プロジェクト: dslomov/bazel
  /**
   * Validates proto support.
   *
   * <ul>
   *   <li>Validates that there are protos specified to be compiled.
   *   <li>Validates that, when enabling the open source protobuf library, the options for the PB2
   *       are not specified also.
   *   <li>Validates that, when enabling the open source protobuf library, the rule specifies at
   *       least one portable proto filter file.
   * </ul>
   *
   * @return this proto support
   */
  public ProtoSupport validate() {
    if (attributes.getProtoFiles().isEmpty()) {
      ruleContext.ruleError(NO_PROTOS_ERROR);
    }

    if (usesProtobufLibrary()) {
      if (attributes.getPortableProtoFilters().isEmpty()) {
        ruleContext.ruleError(PORTABLE_PROTO_FILTERS_EMPTY_ERROR);
      }

      if (attributes.outputsCpp()
          || attributes.usesObjcHeaderNames()
          || attributes.needsPerProtoIncludes()
          || attributes.getOptionsFile() != null) {
        ruleContext.ruleError(PORTABLE_PROTO_FILTERS_NOT_EXCLUSIVE_ERROR);
      }
    }
    return this;
  }