# Copyright (C) 2022 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("perfetto.gni")

template("perfetto_tp_tables") {
  config_name = target_name + "_config"
  action_name = target_name
  relative_args = [
    "--relative-input-dir",
    rebase_path(perfetto_root_path, root_build_dir),
  ]

  config(config_name) {
    include_dirs = [ root_gen_dir ]
  }

  action(action_name) {
    sources = invoker.sources
    script = "${perfetto_root_path}/tools/gen_tp_table_headers.py"

    outputs = []
    foreach(table, invoker.sources) {
      outputs += [ "$target_gen_dir/" + string_replace(table, ".py", "_py.h") ]
    }

    deps = [ "$perfetto_root_path/python:trace_processor_table_generator" ]
    if (defined(invoker.deps)) {
      deps += invoker.deps
    }
    public_configs = [ ":$config_name" ]

    gen_args = [
      "--gen-dir",
      rebase_path("$root_gen_dir", root_build_dir),
    ]
    input_args = [ "--inputs" ] + rebase_path(invoker.sources, root_build_dir)
    args = gen_args + input_args + relative_args

    metadata = {
      perfetto_action_type_for_generator = [ "tp_tables" ]
    }
  }

  if (defined(invoker.generate_docs) && invoker.generate_docs &&
      perfetto_build_standalone) {
    docs_name = target_name + "_docs"
    action(docs_name) {
      sources = invoker.sources
      script = "$perfetto_root_path/tools/gen_tp_table_docs.py"
      deps = [ "$perfetto_root_path/python:trace_processor_table_generator" ]
      outputs = [ "$target_gen_dir/$docs_name.json" ]
      args = [ "--out" ] + rebase_path(outputs, root_build_dir) +
             rebase_path(invoker.sources, root_build_dir) + relative_args
    }
  }
}
