1# Copyright (C) 2022 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import("perfetto.gni") 16 17template("perfetto_tp_tables") { 18 config_name = target_name + "_config" 19 action_name = target_name 20 relative_args = [ 21 "--relative-input-dir", 22 rebase_path(perfetto_root_path, root_build_dir), 23 ] 24 25 config(config_name) { 26 include_dirs = [ root_gen_dir ] 27 } 28 29 action(action_name) { 30 sources = invoker.sources 31 script = "${perfetto_root_path}/tools/gen_tp_table_headers.py" 32 33 outputs = [] 34 foreach(table, invoker.sources) { 35 outputs += [ "$target_gen_dir/" + string_replace(table, ".py", "_py.h") ] 36 } 37 38 deps = [ "$perfetto_root_path/python:trace_processor_table_generator" ] 39 if (defined(invoker.deps)) { 40 deps += invoker.deps 41 } 42 public_configs = [ ":$config_name" ] 43 44 gen_args = [ 45 "--gen-dir", 46 rebase_path("$root_gen_dir/$perfetto_root_path", root_build_dir), 47 ] 48 input_args = [ "--inputs" ] + rebase_path(invoker.sources, root_build_dir) 49 args = gen_args + input_args + relative_args 50 51 metadata = { 52 perfetto_action_type_for_generator = [ "tp_tables" ] 53 } 54 } 55 56 if (defined(invoker.generate_docs) && invoker.generate_docs && 57 perfetto_build_standalone) { 58 docs_name = target_name + "_docs" 59 action(docs_name) { 60 sources = invoker.sources 61 script = "$perfetto_root_path/tools/gen_tp_table_docs.py" 62 deps = [ "$perfetto_root_path/python:trace_processor_table_generator" ] 63 outputs = [ "$target_gen_dir/$docs_name.json" ] 64 args = [ "--out" ] + rebase_path(outputs, root_build_dir) + 65 rebase_path(invoker.sources, root_build_dir) + relative_args 66 } 67 } 68} 69