| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
# Source file. |
| 4 |
src="$(printf %q "$1")" |
| 5 |
shift |
| 6 |
|
| 7 |
# Output file the compiler expects. |
| 8 |
out="$(printf %q "$1")" |
| 9 |
shift |
| 10 |
|
| 11 |
# Create the file the compiler expects. It will check syntax. |
| 12 |
>"$out" |
| 13 |
|
| 14 |
cpp='cpp' |
| 15 |
opts='' |
| 16 |
while test "$#" != 0; do |
| 17 |
case "$1" in |
| 18 |
# Extract the option for the path to cpp. |
| 19 |
--cpp) shift; cpp="$(printf %q "$1")" ;; |
| 20 |
# Extract the option for our own output file. |
| 21 |
--out) shift; out="$(printf %q "$1")" ;; |
| 22 |
# Collect the rest of the command line. |
| 23 |
*) opts="$opts $(printf %q "$1")" ;; |
| 24 |
esac |
| 25 |
shift |
| 26 |
done |
| 27 |
|
| 28 |
# Execute the real preprocessor tool. |
| 29 |
eval "exec $cpp $src $out $opts" |