1 # Copyright (c) 2020 Project CHIP Authors
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 glib_config = rebase_path(":glib")
16 gen_dbus_wrapper = rebase_path("gen_gdbus_wrapper.py")
18 # Runs gdbus-codegen and defines the resulting library.
21 # sources - The dbux XML files.
22 # dbus_out_dir - Subdirectory for generated files within root_gen_dir.
23 # replace_config_header - Replace the config header.
24 template("gdbus_library") {
25 library_name = target_name
26 visibility = [ ":${library_name}" ]
28 assert(defined(invoker.sources), "Please specify sources")
29 assert(defined(invoker.dbus_out_dir), "Please specify dbus_out_dir")
31 dbus_out_dir = invoker.dbus_out_dir
32 dbus_gen_dir = "${root_gen_dir}/${dbus_out_dir}"
34 config("${library_name}_config") {
35 include_dirs = [ root_gen_dir ]
39 foreach(xml, invoker.sources) {
40 name = get_path_info(xml, "name")
42 "${dbus_gen_dir}/${name}.c",
43 "${dbus_gen_dir}/${name}.h",
47 action_foreach("${library_name}_gen") {
48 script = gen_dbus_wrapper
50 sources = invoker.sources
52 source_file = "$dbus_gen_dir/{{source_name_part}}.c"
53 header_file = "$dbus_gen_dir/{{source_name_part}}.h"
64 rebase_path(source_file, root_build_dir),
66 rebase_path(header_file, root_build_dir),
69 if (defined(invoker.c_namespace)) {
76 if (defined(invoker.interface_prefix)) {
79 invoker.interface_prefix,
83 if (invoker.c_generate_object_manager) {
84 args += [ "--c-generate-object-manager" ]
88 static_library(library_name) {
89 forward_variables_from(invoker,
94 sources = dbus_sources
95 deps = [ ":${library_name}_gen" ]
98 ":${library_name}_config",
103 if (defined(invoker.visibility)) {
104 visibility = invoker.visibility