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_sql_source_set") { 18 action("${target_name}") { 19 forward_variables_from(invoker, [ "deps" ]) 20 21 out_path = "$target_gen_dir/" + target_name 22 rebased_out_path = 23 rebase_path(target_gen_dir, root_build_dir) + "/" + target_name 24 25 script = "$perfetto_root_path/tools/touch_file.py" 26 args = [ 27 "--output", 28 rebased_out_path, 29 ] 30 inputs = invoker.sources 31 outputs = [ out_path ] 32 metadata = { 33 perfetto_sql_source_files = inputs 34 perfetto_action_type_for_generator = [ "sql_source_set" ] 35 } 36 } 37} 38 39template("perfetto_amalgamated_sql_header") { 40 invoker_target = target_name 41 gen_txt_file = "$target_gen_dir/${target_name}.txt" 42 43 generated_file("${invoker_target}_generated_file") { 44 forward_variables_from(invoker, [ "deps" ]) 45 outputs = [ gen_txt_file ] 46 data_keys = [ "perfetto_sql_source_files" ] 47 rebase = root_build_dir 48 } 49 50 config("${invoker_target}_config") { 51 include_dirs = [ "${root_gen_dir}/${perfetto_root_path}" ] 52 } 53 54 action(invoker_target) { 55 deps = [ ":${invoker_target}_generated_file" ] 56 deps += invoker.deps 57 58 script = "$perfetto_root_path/tools/gen_amalgamated_sql.py" 59 generated_file = "${target_gen_dir}/" + invoker.generated_header 60 args = [ 61 "--namespace", 62 invoker.namespace, 63 "--cpp-out", 64 rebase_path(generated_file, root_build_dir), 65 "--input-list-file", 66 rebase_path(gen_txt_file, root_build_dir), 67 ] 68 inputs = [ gen_txt_file ] 69 outputs = [ generated_file ] 70 public_configs = [ ":${invoker_target}_config" ] 71 metadata = { 72 perfetto_action_type_for_generator = [ "sql_amalgamation" ] 73 } 74 } 75 76 if (defined(invoker.generate_docs) && invoker.generate_docs && 77 perfetto_build_standalone) { 78 action("${invoker_target}_json_docs") { 79 deps = [ ":${invoker_target}_generated_file" ] 80 deps += invoker.deps 81 82 script = "$perfetto_root_path/tools/gen_stdlib_docs_json.py" 83 generated_file = "${target_gen_dir}/stdlib_docs.json" 84 85 args = [ 86 "--json-out", 87 rebase_path(generated_file, root_build_dir), 88 "--input-list-file", 89 rebase_path(gen_txt_file, root_build_dir), 90 ] 91 public_configs = [ ":${invoker_target}_config" ] 92 inputs = [ gen_txt_file ] 93 outputs = [ generated_file ] 94 } 95 } 96} 97