1 # Perl script used for compiling OpenCL src into x264 binary
3 # Copyright (C) 2013 x264 project
4 # Authors: Steve Borho <sborho@multicorewareinc.com>
6 use Digest::MD5 qw(md5_hex);
8 # xxd takes a VAR, which will be the variable name
9 # and BYTES, a string of bytes to beencoded.
14 my $bytes = $args{BYTES};
16 my @bytes = split //, $$bytes;
19 push @hexbytes, sprintf("0x%02X", ord($b));
22 # Format 'em nice and pretty-like.
23 print 'static const char ' . $var . '[] = {' . "\n";
25 foreach my $h (@hexbytes)
35 print "\n0x00 };\n\n";
42 printf "%s: VARNAME ", $0 . "\n";
50 s/^\s+//; # trim leading whitespace
53 next; # skip the line if it starts with '//'
58 my $lines = join '', @lines;
59 xxd(VAR => @ARGV[0], BYTES => \$lines);
61 my $hash = md5_hex($lines);
62 @hash = ( $hash =~ m/../g );
65 xxd(VAR => @ARGV[0] . "_hash", BYTES => \$hash);