11cb0ef41Sopenharmony_ci# Copyright 2016 The Chromium Authors. All rights reserved.
21cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci# found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci# This template will generate inspector protocol source code. The code will
61cb0ef41Sopenharmony_ci# not be compiled, use get_target_outputs(<name>) to compile them.
71cb0ef41Sopenharmony_ci#
81cb0ef41Sopenharmony_ci# Inputs
91cb0ef41Sopenharmony_ci#
101cb0ef41Sopenharmony_ci#   config_file  (required)
111cb0ef41Sopenharmony_ci#       Path to json file specifying inspector protocol configuration.
121cb0ef41Sopenharmony_ci#
131cb0ef41Sopenharmony_ci#   out_dir  (required)
141cb0ef41Sopenharmony_ci#       Path to put the generated files in. It must be inside output or
151cb0ef41Sopenharmony_ci#       generated file directory.
161cb0ef41Sopenharmony_ci#
171cb0ef41Sopenharmony_ci#   outputs (required)
181cb0ef41Sopenharmony_ci#       Files generated. Relative to out_dir.
191cb0ef41Sopenharmony_ci#
201cb0ef41Sopenharmony_ci#   inputs  (optional)
211cb0ef41Sopenharmony_ci#       Extra inputs specified by the config file.
221cb0ef41Sopenharmony_citemplate("inspector_protocol_generate") {
231cb0ef41Sopenharmony_ci  assert(defined(invoker.config_file))
241cb0ef41Sopenharmony_ci  assert(defined(invoker.out_dir))
251cb0ef41Sopenharmony_ci  assert(defined(invoker.outputs))
261cb0ef41Sopenharmony_ci  assert(defined(invoker.inspector_protocol_dir))
271cb0ef41Sopenharmony_ci  inspector_protocol_dir = invoker.inspector_protocol_dir
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci  action(target_name) {
301cb0ef41Sopenharmony_ci    script = "$inspector_protocol_dir/code_generator.py"
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci    inputs = [
331cb0ef41Sopenharmony_ci      invoker.config_file,
341cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/base_string_adapter_cc.template",
351cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/base_string_adapter_h.template",
361cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/encoding_h.template",
371cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/encoding_cpp.template",
381cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Allocator_h.template",
391cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Array_h.template",
401cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/DispatcherBase_cpp.template",
411cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/DispatcherBase_h.template",
421cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/ErrorSupport_cpp.template",
431cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/ErrorSupport_h.template",
441cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Forward_h.template",
451cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/FrontendChannel_h.template",
461cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Maybe_h.template",
471cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Object_cpp.template",
481cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Object_h.template",
491cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Parser_cpp.template",
501cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Parser_h.template",
511cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Protocol_cpp.template",
521cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/ValueConversions_h.template",
531cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Values_cpp.template",
541cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/lib/Values_h.template",
551cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/templates/Exported_h.template",
561cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/templates/Imported_h.template",
571cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/templates/TypeBuilder_cpp.template",
581cb0ef41Sopenharmony_ci      "$inspector_protocol_dir/templates/TypeBuilder_h.template",
591cb0ef41Sopenharmony_ci    ]
601cb0ef41Sopenharmony_ci    if (defined(invoker.inputs)) {
611cb0ef41Sopenharmony_ci      inputs += invoker.inputs
621cb0ef41Sopenharmony_ci    }
631cb0ef41Sopenharmony_ci
641cb0ef41Sopenharmony_ci    args = [
651cb0ef41Sopenharmony_ci      "--jinja_dir",
661cb0ef41Sopenharmony_ci      rebase_path("//third_party/", root_build_dir),  # jinja is in chromium's third_party
671cb0ef41Sopenharmony_ci      "--output_base",
681cb0ef41Sopenharmony_ci      rebase_path(invoker.out_dir, root_build_dir),
691cb0ef41Sopenharmony_ci      "--config",
701cb0ef41Sopenharmony_ci      rebase_path(invoker.config_file, root_build_dir),
711cb0ef41Sopenharmony_ci    ]
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ci    if (defined(invoker.config_values)) {
741cb0ef41Sopenharmony_ci      foreach(value, invoker.config_values) {
751cb0ef41Sopenharmony_ci        args += [
761cb0ef41Sopenharmony_ci          "--config_value",
771cb0ef41Sopenharmony_ci          value,
781cb0ef41Sopenharmony_ci        ]
791cb0ef41Sopenharmony_ci      }
801cb0ef41Sopenharmony_ci    }
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ci    outputs = get_path_info(rebase_path(invoker.outputs, ".", invoker.out_dir),
831cb0ef41Sopenharmony_ci                            "abspath")
841cb0ef41Sopenharmony_ci
851cb0ef41Sopenharmony_ci    forward_variables_from(invoker,
861cb0ef41Sopenharmony_ci                           [
871cb0ef41Sopenharmony_ci                             "visibility",
881cb0ef41Sopenharmony_ci                             "deps",
891cb0ef41Sopenharmony_ci                             "public_deps",
901cb0ef41Sopenharmony_ci                           ])
911cb0ef41Sopenharmony_ci  }
921cb0ef41Sopenharmony_ci}
93