1#
2#  Copyright 2024 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 c++ headers for each sysprop file
18#
19# Parameters:
20#   sources: sysprop source files
21template("sysprop") {
22  assert(defined(invoker.sources), "sources must be set")
23
24  outdir = rebase_path(target_gen_dir, root_build_dir)
25
26  action_foreach("${target_name}_sources") {
27    script = "//common-mk/file_generator_wrapper.py"
28    args = [
29      "sysprop_cpp",
30      "--header-dir=${outdir}/include",
31      "--public-header-dir=${outdir}/public",
32      "--source-dir=${outdir}/src",
33      "--include-name={{source_file_part}}.h",
34      "{{source}}",
35    ]
36    sources = invoker.sources
37    outputs = [
38      "${target_gen_dir}/include/{{source_file_part}}.h",
39      "${target_gen_dir}/src/{{source_file_part}}.cpp",
40      "${target_gen_dir}/public/{{source_file_part}}.h",
41    ]
42  }
43
44  all_dependent_config_name = "_${target_name}_all_dependent_config"
45  config(all_dependent_config_name) {
46    include_dirs = [ "${target_gen_dir}/include" ]
47  }
48
49  static_library(target_name) {
50    public_deps = [ ":${target_name}_sources" ]
51    sources = get_target_outputs(":${target_name}_sources")
52    deps = invoker.deps
53    all_dependent_configs = [ ":${all_dependent_config_name}" ]
54  }
55}
56