aboutsummaryrefslogtreecommitdiffstats
path: root/update-fmtmod.pl
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2018-10-02 11:58:12 +0200
committerGerd Hoffmann <kraxel@redhat.com>2018-10-02 11:58:12 +0200
commitcb0ab87935c13c6d3e642b7ce0dc8d9a1f739b8e (patch)
tree65e5bf2e6d42256688af722efd0a134dd866e81e /update-fmtmod.pl
parent57a2a5731c6a7893597b7fa16c86a5c848b6cb72 (diff)
downloaddrminfo-cb0ab87935c13c6d3e642b7ce0dc8d9a1f739b8e.tar.gz
tweak format modifier listing
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'update-fmtmod.pl')
-rwxr-xr-xupdate-fmtmod.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/update-fmtmod.pl b/update-fmtmod.pl
new file mode 100755
index 0000000..e27cfad
--- /dev/null
+++ b/update-fmtmod.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+my $header;
+my @syms;
+
+open FILE, "<", "/usr/include/libdrm/drm_fourcc.h" or die "open drm_fourcc.h: $!";
+{ local $/; undef $/; $header = <FILE>; }
+close FILE;
+
+$header =~ s/\\\n//g;
+foreach my $line (split /\n/, $header) {
+ next unless $line =~ m/#define\s+([a-zA-Z0-9_]+)\s+fourcc_mod_code/;
+ push @syms, $1;
+}
+
+open FILE, ">", "drmfmtmods.h" or die "open drmfmtmods.h: $!";
+print FILE "/* generated by update-fmtmod.pl */\n";
+for my $sym (@syms) {
+ my $name = $sym;
+ $name =~ s/^DRM_FORMAT_MOD_//;
+ printf FILE "{ .mod = %s, .name = \"%s\" },\n", $sym, $name;
+}
+close FILE;