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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
#!/bin/sh
#
# GCC-compatible wrapper for cl.exe
#
# Assumes CL.EXE and ML.EXE are in PATH and INCLUDE/LIB appropriately set
#
nowarn="/wd4127 /wd4820 /wd4706 /wd4100 /wd4255 /wd4668"
args="/nologo /EHac /W3 $nowarn" # /WX
#md="/MD"
cl="cl"
ml="ml"
if [ -z "$INCLUDE" -a -z "$Include" -o -z "$LIB" -a -z "$Lib" ]; then
exit "INCLUDE and LIB must be set for CL.EXE to function properly"
fi
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)
if type cl | grep amd64 >& /dev/null; then
echo "Wrong CL.EXE in path; use 32-bit version"
exit 1
fi
if echo $LIB | grep amd64 >& /dev/null; then
echo "Wrong paths in LIB; use 32-bit version"
exit 1
fi
ml=ml
shift 1
;;
-m64)
if ! type cl | grep amd64 >& /dev/null; then
echo "Wrong CL.EXE in path; use 64-bit version"
exit 1
fi
if ! echo $LIB | grep amd64 >& /dev/null; then
echo "Wrong paths in LIB; use 64-bit version"
exit 1
fi
ml=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
;;
-shared)
args="$args /LD"
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
;;
-E)
args="$args /E"
shift 1
;;
-I)
file=$(cygpath -m "$2")
args="$args /I\"$file\""
includes="$includes /I\"$file\""
shift 2
;;
-I*)
file="$(echo $1|sed -e 's/-I//g')"
file=$(cygpath -m "$file")
args="$args /I\"$file\""
includes="$includes /I\"$file\""
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)
file=$(cygpath -m "$2")
outdir=$(dirname "$file")
base=$(basename "$file"|sed 's/\.[^.]*//g')
if [ -n "$assembly" ]; then
target="$file"
fi
if [ -n "$single" ]; then
output="/Fo$file"
else
output="/Fe$file"
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)
file=$(cygpath -m "$1")
src=$(echo $file|sed -e 's/.S$/.asm/g' -e 's%\\%/%g')
echo "$cl /nologo /EP $includes $defines \"$file\" > \"$src\""
eval "$cl /nologo /EP $includes $defines \"$file\"" > "$src" || exit $?
md=""
cl="$ml"
output=$(echo $output | sed 's%/F[dpa][^ ]*%%g')
args="/nologo $single \"$src\" $output"
assembly="true"
shift 1
;;
*.c)
file=$(cygpath -m "$1")
args="$args \"$(echo $file|sed -e 's%\\%/%g')\""
shift 1
;;
-print-multi-os-directory)
# Ignore this when called by accident
echo ""
exit 0
;;
*)
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 $target
fi
exit $result
|