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_py_library") { 18 action(target_name) { 19 forward_variables_from(invoker, [ "deps" ]) 20 21 data = [] 22 if (defined(invoker.data)) { 23 data += invoker.data 24 } 25 26 out_path = "$target_gen_dir/" + target_name 27 rebased_out_path = 28 rebase_path(target_gen_dir, root_build_dir) + "/" + target_name 29 30 sources = [] 31 if (defined(invoker.sources)) { 32 sources += invoker.sources 33 } 34 script = "$perfetto_root_path/tools/touch_file.py" 35 args = [ 36 "--output", 37 rebased_out_path, 38 ] 39 outputs = [ out_path ] 40 metadata = { 41 perfetto_action_type_for_generator = [ "python_library" ] 42 perfetto_data = data 43 } 44 } 45} 46 47template("perfetto_py_binary") { 48 action(target_name) { 49 forward_variables_from(invoker, [ "deps" ]) 50 51 data = [] 52 if (defined(invoker.data)) { 53 data += invoker.data 54 } 55 56 out_path = "$target_gen_dir/" + target_name 57 rebased_out_path = 58 rebase_path(target_gen_dir, root_build_dir) + "/" + target_name 59 60 sources = invoker.sources 61 script = "$perfetto_root_path/tools/touch_file.py" 62 args = [ 63 "--output", 64 rebased_out_path, 65 ] 66 outputs = [ out_path ] 67 metadata = { 68 perfetto_action_type_for_generator = [ "python_binary" ] 69 perfetto_python_main = [ invoker.main ] 70 perfetto_data = data 71 } 72 } 73} 74