@@ -2,6 +2,16 @@
# SPDX-License-Identifier: GPL-2.0-only */
# Copyright 2022 Collabora Ltd.
+my $outdir = ".";
+my %outtype = ( "common" => 1, "trace" => 1, "retrace" => 1 );
+
+while ($ARGV[0] =~ /^-/) {
+ my $arg = shift @ARGV;
+
+ $outdir = shift @ARGV if $arg eq "-o";
+ %outtype = (shift @ARGV => 1) if $arg eq '-t';
+}
+
sub convert_type_to_json_type {
my $type = shift;
if ($type eq __u8 || $type eq char || $type eq __u16 || $type eq __s8 || $type eq __s16 || $type eq __s32 || $type eq 'int') {
@@ -696,29 +706,45 @@ sub struct_gen_ctrl {
printf $fh_retrace_cpp "}\n\n";
}
-open($fh_trace_cpp, '>', 'trace-gen.cpp') or die "Could not open trace-gen.cpp for writing";
+sub do_open($$) {
+ my ($type, $fname) = @_;
+ my $fh;
+
+ if (defined $outtype{$type}) {
+ $fname = "$outdir/$fname";
+ } else {
+ $fname = "/dev/null";
+ }
+
+ open($fh, "> $fname") or die "Could not open $fname for writing";
+
+ return $fh;
+}
+
+
+$fh_trace_cpp = do_open("trace", "trace-gen.cpp");
printf $fh_trace_cpp "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n";
printf $fh_trace_cpp " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__;
printf $fh_trace_cpp "#include \"v4l2-tracer-common.h\"\n\n";
-open($fh_trace_h, '>', 'trace-gen.h') or die "Could not open trace-gen.h for writing";
+$fh_trace_h = do_open("trace", "trace-gen.h");
printf $fh_trace_h "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n";
printf $fh_trace_h " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__;
printf $fh_trace_h "\#ifndef TRACE_GEN_H\n";
printf $fh_trace_h "\#define TRACE_GEN_H\n\n";
-open($fh_retrace_cpp, '>', 'retrace-gen.cpp') or die "Could not open retrace-gen.cpp for writing";
+$fh_retrace_cpp = do_open("retrace", "retrace-gen.cpp");
printf $fh_retrace_cpp "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n";
printf $fh_retrace_cpp " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__;
printf $fh_retrace_cpp "#include \"v4l2-tracer-common.h\"\n\n";
-open($fh_retrace_h, '>', 'retrace-gen.h') or die "Could not open retrace-gen.h for writing";
+$fh_retrace_h = do_open("retrace", "retrace-gen.h");
printf $fh_retrace_h "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n";
printf $fh_retrace_h " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__;
printf $fh_retrace_h "\#ifndef RETRACE_GEN_H\n";
printf $fh_retrace_h "\#define RETRACE_GEN_H\n\n";
-open($fh_common_info_h, '>', 'v4l2-tracer-info-gen.h') or die "Could not open v4l2-tracer-info-gen.h for writing";
+$fh_common_info_h = do_open("common", "v4l2-tracer-info-gen.h");
printf $fh_common_info_h "/* SPDX-License-Identifier: GPL-2.0-only */\n/*\n * Copyright 2022 Collabora Ltd.\n";
printf $fh_common_info_h " *\n * AUTOMATICALLY GENERATED BY \'%s\' DO NOT EDIT\n */\n\n", __FILE__;
printf $fh_common_info_h "\#ifndef V4L2_TRACER_INFO_GEN_H\n";