]> git.sesse.net Git - ffmpeg/commitdiff
compat/cuda/ptx2c: remove shell loop; fix BSD sed compat
authorrcombs <rcombs@rcombs.me>
Thu, 22 Aug 2019 05:40:47 +0000 (00:40 -0500)
committerrcombs <rcombs@rcombs.me>
Tue, 2 Jun 2020 03:10:41 +0000 (22:10 -0500)
This fixes building on macOS, and improves build times dramatically there

compat/cuda/ptx2c.sh

index 0750e7a3b78ebacca9156f13541891287be1a34b..48452379c2b4ed286eefab94529fad34d7a1b87d 100755 (executable)
@@ -27,10 +27,8 @@ IN="$2"
 NAME="$(basename "$IN" | sed 's/\..*//')"
 
 printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
-while IFS= read -r LINE
-do
-    printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed -e 's/\r//g' -e 's/["\\]/\\&/g')" >> "$OUT"
-done < "$IN"
-printf ";\n" >> "$OUT"
+echo >> "$OUT"
+sed -e "$(printf 's/\r//g')" -e 's/["\\]/\\&/g' -e "$(printf 's/^/\t"/')" -e 's/$/\\n"/' < "$IN" >> "$OUT"
+echo ";" >> "$OUT"
 
 exit 0