chromium/third_party/dom_distiller_js/BUILD.gn

# 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 = [
  "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" ]
  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" ]
  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" ]
  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),
  ]
}