+
+glue_files = []
+
+for file, prefix in dbus_introspection_xml.items():
+ source_xml = file + '.xml'
+ glue = file + '-glue'
+ glue_source = glue + '.c'
+ glue_header = glue + '.h'
+
+ glue_files.append(glue_source)
+
+ # Generate GDBus skeletons in the variant (build) directory.
+ #
+ # A link to the generated GDBus glue header is also created in the
+ # source directory to avoid having to explicitly add the variant
+ # directory to the preprocessor include path.
+ targets = [ glue_source, glue_header ]
+ glue_header_gen = os.path.join(this_build_dir, glue_header)
+ glue_header_copy = os.path.join(this_src_dir, glue_header)
+
+ gen = env.Command(targets,
+ source_xml,
+ 'cd %s '
+ '&& gdbus-codegen --generate-c-code %s '
+ ' --interface-prefix %s ${SOURCE.abspath} '
+ '&& ln -sf %s %s '
+ '&& cd -'
+ % (this_build_dir,
+ glue, prefix,
+ glue_header_gen, glue_header_copy))
+
+ # Mark generated file for cleaning when running "scons -c".
+ for target in targets:
+ generated_target = os.path.join(this_build_dir, target)
+ env.Clean(target, generated_target)
+
+ env.Clean(glue_source, glue_header_copy)
+
+ # Force a dependency on copied glue header to make sure it exists
+ # before compilation of the non-generated source files begins.
+ env.Depends(src_files, gen)
+
+src_files += glue_files