[x264-devel] [PATCH] build: Replace cltostr.pl by a shell script

Diego Biurrun diego at biurrun.de
Tue May 13 10:53:08 CEST 2014


On Mon, May 12, 2014 at 06:13:18PM +0200, Janne Grunau wrote:
> On 2014-05-07 17:04:37 +0200, Diego Biurrun wrote:
> > --- /dev/null
> > +++ b/tools/cltostr.sh
> > @@ -0,0 +1,30 @@
> > +#!/bin/sh
> > +# Convert standard input to a C char array, write to a file, then create an
> > +# MD5 sum of that file and append said MD5 sum as char array to the file.
> > +
> > +FILE=$1
> > +
> > +# Filter out whitespace, empty lines, and comments.
> > +sanitize() {
> > +    sed 's/^[[:space:]]*//; /^$/d; /^\/\//d'
> > +}
> > +
> > +# Convert stdin to a \0-terminated char array.
> > +dump() {
> > +    printf 'static const char %s[] = {\n' $1
> > +    od -v -A n -t x1 | sed 's/.\(..\)/0x\1, /g'
> > +    printf '0x00 };\n'
> 
> the perl script was printing too newlines after the end of array, probably 
> doesn't matter

You mean the empty line between the two generated arrays?  Yeah, I skipped
that one for simplicity's sake.  Of course I can restore it if you prefer.

> > +# Print MD5 hash w/o newline character to not embed the character in the array.
> > +hash() {
> > +    # md5sum is not standard, so try different platform-specific alternatives.
> > +    { md5sum $1 2> /dev/null || md5 -q $1 || digest -a md5 $1; } |
> 
> libav's tests/md5.sh uses /sbin/md5 or 'command md5' instead of plain md5 
> and iirc it was using plain md5 at some point and we changed it for some 
> reason. I'm not sure if it's worth testing for a working md5 or how it 
> should behave if there is none.

It was changed to "command md5" to avoid conflicting with the shell function
called md5() in tests/fate-run.sh.  There is no such problem here, so I
believe just plain "md5" is safe.

It's probably a good idea to error out if no suitable MD5 program is found.
I'll update the patch to do just that.

Diego


More information about the x264-devel mailing list