3 # Copyright (c) 2020 Project CHIP Authors
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
23 parser = argparse.ArgumentParser(description=("Generate dbus bindings."))
25 parser.add_argument("--input_file",
27 help="The dbus service definition XML file.")
32 "The source file to generate containing the GDBus proxy implementation"
37 help="The header file to generate containing the GDBus proxy interface"
40 parser.add_argument("--c-namespace",
42 help="Prefix APIs with C namespace")
44 parser.add_argument("--interface-prefix",
46 help="Add interface prefix")
48 parser.add_argument("--c-generate-object-manager",
49 default=False, action='store_true',
50 help="Generate object manager")
52 options = parser.parse_args(argv)
55 if options.c_namespace:
56 extra_args += ["--c-namespace", options.c_namespace]
58 if options.interface_prefix:
59 extra_args += ["--interface-prefix", options.interface_prefix]
61 if options.c_generate_object_manager:
62 extra_args += ["--c-generate-object-manager"]
65 gdbus_args = ["gdbus-codegen", "--body", "--output", options.output_c
66 ] + extra_args + [options.input_file]
67 subprocess.check_call(gdbus_args)
68 sed_args = ["sed", "-i", "s/config\.h/BuildConfig.h/g", options.output_c]
69 subprocess.check_call(sed_args)
73 "gdbus-codegen", "--header", "--output", options.output_h
74 ] + extra_args + [options.input_file]
75 subprocess.check_call(gdbus_args)
80 if __name__ == '__main__':
81 sys.exit(main(sys.argv[1:]))