[x264-devel] [PATCH] build: Replace cltostr.pl by a shell script
Janne Grunau
janne-x264 at jannau.net
Mon May 12 18:13:18 CEST 2014
On 2014-05-07 17:04:37 +0200, Diego Biurrun wrote:
> This avoids a dependency on Perl to build OpenCL support.
> ---
> Makefile | 2 +-
> configure | 9 --------
> tools/cltostr.pl | 65 --------------------------------------------------------
> tools/cltostr.sh | 30 ++++++++++++++++++++++++++
> 4 files changed, 31 insertions(+), 75 deletions(-)
> delete mode 100644 tools/cltostr.pl
> create mode 100755 tools/cltostr.sh
>
> diff --git a/Makefile b/Makefile
> index 4cdb2e7..26c7c25 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -125,7 +125,7 @@ endif
>
> ifeq ($(HAVE_OPENCL),yes)
> common/oclobj.h: common/opencl/x264-cl.h $(wildcard $(SRCPATH)/common/opencl/*.cl)
> - cat $^ | perl $(SRCPATH)/tools/cltostr.pl x264_opencl_source > $@
> + cat $^ | $(SRCPATH)/tools/cltostr.sh $@
> GENERATED += common/oclobj.h
> SRCS += common/opencl.c encoder/slicetype-cl.c
> endif
> diff --git a/configure b/configure
> index 67cdf05..697ae17 100755
> --- a/configure
> +++ b/configure
> @@ -1050,15 +1050,6 @@ ASFLAGS="$ASFLAGS -DBIT_DEPTH=$bit_depth"
> libdl=""
> if [ "$opencl" = "yes" ]; then
> opencl="no"
> - log_check "for perl"
> - output=$(perl -v)
> - if [ "$output" = "" ]; then
> - log_fail
> - echo 'OpenCL support requires perl to compile.'
> - echo 'use --disable-opencl to compile without OpenCL.'
> - exit 1
> - fi
> - log_ok
> # cygwin can use opencl if it can use LoadLibrary
> if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibraryW(0);") ; then
> opencl="yes"
> diff --git a/tools/cltostr.sh b/tools/cltostr.sh
> new file mode 100755
> index 0000000..c8b544e
> --- /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
> +}
> +
> +# 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.
> + cut -b -32 | tr -d '\n\r'
> +}
> +
> +sanitize |
> + dump x264_opencl_source > $FILE
> +
> +hash $FILE |
> + dump x264_opencl_source_hash >> $FILE
hardcoding the variable name x264_opencl_source* is probably ok as long as
all opencl code is lumped together
except md5 issue ok
Janne
More information about the x264-devel
mailing list