1# 2# Copyright 2021 Google, Inc. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at: 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# Generate single c++ headers for each pdl 18# 19# Parameters: 20# include: Base include path (i.e. bt/gd) 21# source_root: Root of source relative to current BUILD.gn 22# sources: PDL files to use for generation. 23template("packetgen_headers") { 24 all_dependent_config_name = "_${target_name}_all_dependent_config" 25 config(all_dependent_config_name) { 26 include_dirs = [ "${root_gen_dir}" ] 27 } 28 29 action(target_name) { 30 forward_variables_from(invoker, [ "include", "sources", "source_root" ]) 31 assert(defined(sources), "sources must be set") 32 assert(defined(include), "include must be set") 33 assert(defined(source_root), "source root must be set") 34 35 outdir = rebase_path(root_gen_dir) 36 source_root = rebase_path(source_root) 37 38 script = "//common-mk/file_generator_wrapper.py" 39 binfile = "${root_out_dir}/bluetooth_packetgen" 40 args = [ 41 binfile, 42 "--include=${include}", 43 "--out=${outdir}", 44 "--source_root=${source_root}", 45 ] 46 47 outputs = [] 48 foreach (source, sources) { 49 rel_source = rebase_path(source, ".") 50 args += [ rebase_path(source, source_root) ] 51 outputs += [ string_replace("${outdir}/${rel_source}.h", ".pdl", "") ] 52 } 53 54 all_dependent_configs = [ ":${all_dependent_config_name}" ] 55 if (defined(invoker.all_dependent_configs)) { 56 all_dependent_configs += invoker.all_dependent_configs 57 } 58 59 if (defined(invoker.configs)) { 60 configs += invoker.configs 61 } 62 } 63} 64