Message ID | 20200526174223.71733-1-rcombs@rcombs.me |
---|---|
State | Accepted |
Headers | show |
Series | [FFmpeg-devel] compat/cuda/ptx2c: remove shell loop; fix BSD sed compat | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
On 26.05.2020 19:42, rcombs wrote: > This improves build times dramatically, and fixes building on macOS > --- > compat/cuda/ptx2c.sh | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh > index 0750e7a3b7..c41875a2d4 100755 > --- a/compat/cuda/ptx2c.sh > +++ b/compat/cuda/ptx2c.sh > @@ -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 $'s/\r//g' -e 's/["\\]/\\&/g' -e $'s/^[[:space:]]*/\t"/' -e 's/$/\\n"/' < "$IN" >> "$OUT" > +echo ";" >> "$OUT" > > exit 0 > Produces broken .ptx.c files: > CC libavfilter/vf_overlay_cuda.ptx.o > libavfilter/vf_overlay_cuda.ptx.c:5:1: error: stray ‘\’ in program > 5 | \n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:5:3: warning: missing terminating " character > 5 | \n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:5:3: error: missing terminating " character > libavfilter/vf_overlay_cuda.ptx.c:5:2: error: ‘n’ undeclared here (not in a function) > 5 | \n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:6:10: error: expected ‘,’ or ‘;’ before numeric constant > 6 | .version 3.2\n" > | ^~~ > libavfilter/vf_overlay_cuda.ptx.c:6:13: error: stray ‘\’ in program > 6 | .version 3.2\n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:6:15: warning: missing terminating " character > 6 | .version 3.2\n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:6:15: error: missing terminating " character > libavfilter/vf_overlay_cuda.ptx.c:7:14: error: stray ‘\’ in program > 7 | .target sm_30\n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:7:16: warning: missing terminating " character > 7 | .target sm_30\n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:7:16: error: missing terminating " character > libavfilter/vf_overlay_cuda.ptx.c:8:17: error: stray ‘\’ in program > 8 | .address_size 64\n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:8:19: warning: missing terminating " character > 8 | .address_size 64\n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:8:19: error: missing terminating " character > libavfilter/vf_overlay_cuda.ptx.c:9:1: error: stray ‘\’ in program > 9 | \n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:9:3: warning: missing terminating " character > 9 | \n" > | ^ > libavfilter/vf_overlay_cuda.ptx.c:9:3: error: missing terminating " character > libavfilter/vf_overlay_cuda.ptx.c:11:1: error: stray ‘\’ in program > 11 | \n" > | ^ And a lot more of the same. The generated .ptx.c file also looks horribly garbled up all over.
diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh index 0750e7a3b7..c41875a2d4 100755 --- a/compat/cuda/ptx2c.sh +++ b/compat/cuda/ptx2c.sh @@ -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 $'s/\r//g' -e 's/["\\]/\\&/g' -e $'s/^[[:space:]]*/\t"/' -e 's/$/\\n"/' < "$IN" >> "$OUT" +echo ";" >> "$OUT" exit 0