]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
build: More robust temp file handling
authorMatthew Barr <matthew.barr@intel.com>
Wed, 15 Mar 2017 02:27:18 +0000 (13:27 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 26 Apr 2017 05:17:18 +0000 (15:17 +1000)
cmake/build_wrapper.sh

index 5baf209b39a7a1412393f338dc1deec46497407d..756d70e8258143186099ee658e24e2a18c9e3559 100755 (executable)
@@ -1,13 +1,18 @@
 #!/bin/sh -e
 # This is used for renaming symbols for the fat runtime, don't call directly
 # TODO: make this a lot less fragile!
+cleanup () {
+    rm -f ${SYMSFILE} ${KEEPSYMS}
+}
+
 PREFIX=$1
 KEEPSYMS_IN=$2
 shift 2
 BUILD=$@
 OUT=$(echo $BUILD | sed 's/.* -o \(.*\.o\).*/\1/')
-SYMSFILE=/tmp/${PREFIX}_rename.syms.$$
-KEEPSYMS=/tmp/keep.syms.$$
+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//;')
@@ -24,4 +29,3 @@ if test -s ${SYMSFILE}
 then
     objcopy --redefine-syms=${SYMSFILE} ${OUT}
 fi
-rm -f ${SYMSFILE} ${KEEPSYMS}