910e62b5创建于 1月15日历史提交
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//third_party/protobuf/proto_library.gni")

group("proto") {
  public_deps = [ ":dom_distiller_proto" ]
  deps = [ ":json_values_converter_tests" ]
}

protoc_plugin_files = [
  "//third_party/protobuf/python/google/protobuf/__init__.py",
  "//third_party/protobuf/python/google/protobuf/any.py",
  "//third_party/protobuf/python/google/protobuf/compiler/__init__.py",
  "//third_party/protobuf/python/google/protobuf/compiler/plugin_pb2.py",
  "//third_party/protobuf/python/google/protobuf/descriptor.py",
  "//third_party/protobuf/python/google/protobuf/descriptor_database.py",
  "//third_party/protobuf/python/google/protobuf/descriptor_pb2.py",
  "//third_party/protobuf/python/google/protobuf/descriptor_pool.py",
  "//third_party/protobuf/python/google/protobuf/duration.py",
  "//third_party/protobuf/python/google/protobuf/internal/__init__.py",
  "//third_party/protobuf/python/google/protobuf/internal/api_implementation.py",
  "//third_party/protobuf/python/google/protobuf/internal/builder.py",
  "//third_party/protobuf/python/google/protobuf/internal/containers.py",
  "//third_party/protobuf/python/google/protobuf/internal/decoder.py",
  "//third_party/protobuf/python/google/protobuf/internal/encoder.py",
  "//third_party/protobuf/python/google/protobuf/internal/enum_type_wrapper.py",
  "//third_party/protobuf/python/google/protobuf/internal/extension_dict.py",
  "//third_party/protobuf/python/google/protobuf/internal/field_mask.py",
  "//third_party/protobuf/python/google/protobuf/internal/message_listener.py",
  "//third_party/protobuf/python/google/protobuf/internal/python_edition_defaults.py",
  "//third_party/protobuf/python/google/protobuf/internal/python_message.py",
  "//third_party/protobuf/python/google/protobuf/internal/type_checkers.py",
  "//third_party/protobuf/python/google/protobuf/internal/well_known_types.py",
  "//third_party/protobuf/python/google/protobuf/internal/wire_format.py",
  "//third_party/protobuf/python/google/protobuf/json_format.py",
  "//third_party/protobuf/python/google/protobuf/message.py",
  "//third_party/protobuf/python/google/protobuf/message_factory.py",
  "//third_party/protobuf/python/google/protobuf/proto.py",
  "//third_party/protobuf/python/google/protobuf/proto_builder.py",
  "//third_party/protobuf/python/google/protobuf/proto_json.py",
  "//third_party/protobuf/python/google/protobuf/reflection.py",
  "//third_party/protobuf/python/google/protobuf/runtime_version.py",
  "//third_party/protobuf/python/google/protobuf/service_reflection.py",
  "//third_party/protobuf/python/google/protobuf/symbol_database.py",
  "//third_party/protobuf/python/google/protobuf/text_encoding.py",
  "//third_party/protobuf/python/google/protobuf/text_format.py",
  "//third_party/protobuf/python/google/protobuf/timestamp.py",
  "//third_party/protobuf/python/google/protobuf/unknown_fields.py",
  "protoc_plugins/json_values_converter.bat",
  "protoc_plugins/json_values_converter.py",
  "protoc_plugins/util/__init__.py",
  "protoc_plugins/util/plugin_protos.py",
  "protoc_plugins/util/types.py",
  "protoc_plugins/util/writer.py",
]

if (host_os == "win") {
  json_converter_plugin_script = "protoc_plugins/json_values_converter.bat"
} else {
  json_converter_plugin_script = "protoc_plugins/json_values_converter.py"
}

proto_library("dom_distiller_proto") {
  visibility = [ ":*" ]
  sources = [ "dist/proto/dom_distiller.proto" ]
  link_deps = [ "//base" ]
  proto_out_dir = "third_party/dom_distiller_js"

  generator_plugin_script = json_converter_plugin_script
  generator_plugin_script_deps = protoc_plugin_files
  generator_plugin_suffixes = [ "_json_converter.h" ]
  generator_plugin_options = "output_dir=:"
}

# The purpose of json_values_converter_test_proto is to test the
# protoc_plugins by generating the json_converter.h file.
proto_library("json_values_converter_test_proto") {
  visibility = [ ":*" ]
  sources = [ "test_sample.proto" ]
  link_deps = [ "//base" ]
  proto_out_dir = "third_party/dom_distiller_js"

  generator_plugin_script = json_converter_plugin_script
  generator_plugin_script_deps = protoc_plugin_files
  generator_plugin_suffixes = [ "_json_converter.h" ]
  generator_plugin_options = "output_dir=:"
}

action("json_values_converter_tests") {
  _stamp = "$target_gen_dir/json_values_converter_tests.stamp"
  _actual_file = "$target_gen_dir/test_sample_json_converter.h"
  _golden_file = "test_sample_json_converter.h.golden"
  deps = [ ":json_values_converter_test_proto_gen" ]
  inputs = [
    _actual_file,
    _golden_file,
  ]
  outputs = [ _stamp ]

  script = "protoc_plugins/json_values_converter_tests.py"
  args = [
    "--stamp",
    rebase_path(_stamp, root_build_dir),
    rebase_path(_actual_file, root_build_dir),
    rebase_path(_golden_file, root_build_dir),
  ]
}