gdbus-codegen: If writing body to stdout, don't try to include header

If we're writing the body to standard output, we cannot know what the
filename of the corresponding header is going to be, but it seems
vanishingly unlikely that it will be either `stdout.h` (which we would
traditionally have generated) or `-.h` (which we would have generated
since !3886).

This makes some of the output snippets sufficiently short that black(1)
requires that they are folded into a single line.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2024-02-06 13:48:45 +00:00
parent 5e8f053d33
commit fc7942f46b
4 changed files with 34 additions and 23 deletions

View File

@@ -336,7 +336,11 @@ def codegen_main():
print_error("Using --body requires --output")
c_file = args.output
header_name = os.path.splitext(os.path.basename(c_file))[0] + ".h"
if c_file == "-":
header_name = ""
else:
header_name = os.path.splitext(os.path.basename(c_file))[0] + ".h"
elif args.interface_info_header:
if args.output is None:
print_error("Using --interface-info-header requires --output")
@@ -358,7 +362,11 @@ def codegen_main():
)
c_file = args.output
header_name = os.path.splitext(os.path.basename(c_file))[0] + ".h"
if c_file == "-":
header_name = ""
else:
header_name = os.path.splitext(os.path.basename(c_file))[0] + ".h"
# Check the minimum GLib version. The minimum --glib-min-required is 2.30,
# because thats when gdbus-codegen was introduced. Support 1, 2 or 3