]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Make the build wrapper less fragile
authorMatthew Barr <matthew.barr@intel.com>
Tue, 18 Apr 2017 01:48:17 +0000 (11:48 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Tue, 30 May 2017 03:57:32 +0000 (13:57 +1000)
This script was failing for certain paths (dots, whitespace), and using
sed to replace parts of the command line was overkill. Do less mangling,
and quote command line args.

Fixes 01org/hyperscan#51

cmake/build_wrapper.sh

index 756d70e8258143186099ee658e24e2a18c9e3559..70392229cec114804255fb18d48c16e925606372 100755 (executable)
@@ -8,21 +8,18 @@ cleanup () {
 PREFIX=$1
 KEEPSYMS_IN=$2
 shift 2
-BUILD=$@
-OUT=$(echo $BUILD | sed 's/.* -o \(.*\.o\).*/\1/')
+# $@ contains the actual build command
+OUT=$(echo "$@" | sed 's/.* -o \(.*\.o\).*/\1/')
 trap cleanup INT QUIT EXIT
 SYMSFILE=$(mktemp --tmpdir ${PREFIX}_rename.syms.XXXXX)
 KEEPSYMS=$(mktemp --tmpdir keep.syms.XXXXX)
-# grab the command without the target obj or src file flags
-# we don't just call gcc directly as there may be flags modifying the arch
-CC_CMD=$(echo $BUILD | sed 's/ -o .*\.o//;s/ -c //;s/ .[^ ]*\.c//;')
-# find me a libc
-LIBC_SO=$(${CC_CMD} --print-file-name=libc.so.6)
+# find the libc used by gcc
+LIBC_SO=$("$@" --print-file-name=libc.so.6)
 cp ${KEEPSYMS_IN} ${KEEPSYMS}
 # get all symbols from libc and turn them into patterns
 nm -f p -g -D ${LIBC_SO} | sed -s 's/\([^ ]*\).*/^\1$/' >> ${KEEPSYMS}
 # build the object
-${BUILD}
+"$@"
 # rename the symbols in the object
 nm -f p -g ${OUT} | cut -f1 -d' ' | grep -v -f ${KEEPSYMS} | sed -e "s/\(.*\)/\1\ ${PREFIX}_\1/" >> ${SYMSFILE}
 if test -s ${SYMSFILE}