couch/shaders/makeheaders.pl

28 lines
604 B
Perl
Raw Permalink Normal View History

use strict;
use warnings;
2021-01-18 18:25:47 -06:00
use File::Basename;
2021-01-18 18:25:47 -06:00
my ($filename, $outfilename) = @ARGV;
my $headerguard = basename $outfilename;
$headerguard =~ tr/a-z./A-Z_/;
my $constname = basename "$filename";
$constname =~ tr/./_/;
open(my $fin, '<', $filename) or die("Couldn't find $filename");
open my $fout, '>', $outfilename;
2021-01-18 18:25:47 -06:00
print $fout "#ifndef $headerguard \n#define $headerguard\nconst char * $constname = \n";
while(my $line = <$fin>) {
$line =~ s/(\r?\n)/\\n/;
2021-01-18 18:25:47 -06:00
print $fout "\"$line\"\n";
}
2021-01-18 18:25:47 -06:00
print $fout ";\n#endif // $headerguard\n";
close $fin;
close $fout;
print "Generated $outfilename\n";