1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
#!/bin/sh
#
# GCC-compatible wrapper for cl.exe
#
MSVC="/c/Program Files (x86)/Microsoft Visual Studio 9.0/vc/bin"
nowarn="/wd4127 /wd4820 /wd4706 /wd4100 /wd4255 /wd4668"
args="/nologo /EHac /W3 /LD $nowarn" # /WX
# FIXME is this equivalent to --static-libgcc? links to msvcrt.lib
# I've forgotten why it was originally added
# /MD causes link problems
#md=/MD
cl="$MSVC/cl"
ml="$MSVC/ml"
output=
while [ $# -gt 0 ]
do
case $1
in
-fexceptions)
shift 1
;;
-fno-omit-frame-pointer)
# TODO: does this have an equivalent?
shift 1
;;
-fno-strict-aliasing)
# TODO: does this have an equivalent?
shift 1
;;
-mno-cygwin)
shift 1
;;
-m32)
cl="$MSVC/cl"
ml="$MSVC/ml"
shift 1
;;
-m64)
cl="$MSVC/x86_amd64/cl"
ml="$MSVC/x86_amd64/ml64"
shift 1
;;
-O*)
args="$args $i"
shift 1
;;
-g)
# using /RTC1 instead of /GZ
args="$args /Od /D_DEBUG /RTC1 /Zi"
md=/MDd
shift 1
;;
-c)
args="$args /c"
args="$(echo $args | sed 's%/Fe%/Fo%g')"
single="/c"
shift 1
;;
-D*=*)
name="$(echo $1|sed 's/-D\([^=][^=]*\)=.*/\1/g')"
value="$(echo $1|sed 's/-D[^=][^=]*=//g')"
args="$args -D${name}='$value'"
defines="$defines -D${name}='$value'"
shift 1
;;
-D*)
args="$args $1"
defines="$defines $1"
shift 1
;;
-I)
args="$args /I\"$2\""
includes="$includes /I\"$2\""
shift 2
;;
-I*)
args="$args /I\"$(echo $1|sed -e 's/-I//g')\""
includes="$includes /I\"$(echo $1|sed -e 's/-I//g')\""
shift 1
;;
-W|-Wextra)
# TODO map extra warnings
shift 1
;;
-Wall)
args="$args /Wall"
shift 1
;;
-Werror)
args="$args /WX"
shift 1
;;
-W*)
# TODO map specific warnings
shift 1
;;
-S)
args="$args /FAs"
shift 1
;;
-o)
outdir="$(dirname $2)"
base="$(basename $2|sed 's/\.[^.]*//g')"
if [ -n "$single" ]; then
output="/Fo$2"
else
output="/Fe$2"
fi
if [ -n "$assembly" ]; then
args="$args $output"
else
args="$args $output /Fd$outdir/$base /Fp$outdir/$base /Fa$outdir/$base"
fi
shift 2
;;
*.S)
src="$(echo $1|sed -e 's/.S$/.asm/g' -e 's%\\%/%g')"
echo "$cl /EP $includes $defines $1 > $src"
"$cl" /nologo /EP $includes $defines $1 > $src || exit $?
md=""
cl="$ml"
output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')"
args="/nologo $single $src $output"
assembly="true"
shift 1
;;
*.c)
args="$args $(echo $1|sed -e 's%\\%/%g')"
shift 1
;;
*)
echo "Unsupported argument '$1'"
exit 1
;;
esac
done
args="$md $args"
echo "$cl $args"
eval "\"$cl\" $args"
result=$?
# @#!%@!# ml64 broken output
if [ -n "$assembly" ]; then
mv $src $outdir
mv *.obj $outdir
fi
exit $result
|