diff options
Diffstat (limited to 'update-fmtmod.pl')
-rwxr-xr-x | update-fmtmod.pl | 25 |
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; |