args_orig=$@
args="-nologo -W3"
+linkargs=
static_crt=
debug_crt=
cl="cl"
ml="ml"
safeseh="-safeseh"
output=
+libpaths=
+libversion=8
+verbose=
while [ $# -gt 0 ]
do
case $1
in
+ --verbose)
+ verbose=1
+ shift 1
+ ;;
+ --version)
+ args="-help"
+ shift 1
+ ;;
-fexceptions)
# Don't enable exceptions for now.
#args="$args -EHac"
safeseh=
shift 1
;;
+ -marm)
+ ml='armasm'
+ safeseh=
+ shift 1
+ ;;
+ -marm64)
+ ml='armasm64'
+ safeseh=
+ shift 1
+ ;;
-clang-cl)
cl="clang-cl"
- safeseh=
shift 1
;;
-O0)
shift 1
;;
-I)
- args="$args -I$2"
- includes="$includes -I$2"
+ p=$(cygpath -ma "$2")
+ args="$args -I\"$p\""
+ includes="$includes -I\"$p\""
shift 2
;;
-I*)
- args="$args $1"
- includes="$includes $1"
+ p=$(cygpath -ma "${1#-I}")
+ args="$args -I\"$p\""
+ includes="$includes -I\"$p\""
+ shift 1
+ ;;
+ -L)
+ p=$(cygpath -ma $2)
+ linkargs="$linkargs -LIBPATH:$p"
+ shift 2
+ ;;
+ -L*)
+ p=$(cygpath -ma ${1#-L})
+ linkargs="$linkargs -LIBPATH:$p"
+ shift 1
+ ;;
+ -link)
+ # add next argument verbatim to linker args
+ linkargs="$linkargs $2"
+ shift 2
+ ;;
+ -l*)
+ case $1
+ in
+ -lffi)
+ linkargs="$linkargs lib${1#-l}-${libversion}.lib"
+ ;;
+ *)
+ # ignore other libraries like -lm, hope they are
+ # covered by MSVCRT
+ # linkargs="$linkargs ${1#-l}.lib"
+ ;;
+ esac
shift 1
;;
-W|-Wextra)
# libffi tests -pedantic with -Wall, so drop it also.
shift 1
;;
+ -warn)
+ # ignore -warn all from libtool as well.
+ if test "$2" = "all"; then
+ shift 2
+ else
+ args="$args -warn"
+ shift 1
+ fi
+ ;;
-Werror)
args="$args -WX"
shift 1
else
output="-Fe$2"
fi
+ armasm_output="-o $2"
if [ -n "$assembly" ]; then
args="$args $output"
else
shift 2
;;
*.S)
- src=$1
+ src="$(cygpath -ma $1)"
assembly="true"
shift 1
;;
*.c)
- args="$args $1"
+ args="$args $(cygpath -ma $1)"
shift 1
;;
*)
esac
done
-# If -Zi is specified, certain optimizations are implicitly disabled
-# by MSVC. Add back those optimizations if this is an optimized build.
-# NOTE: These arguments must come after all others.
-if [ -n "$opt" ]; then
- args="$args -link -OPT:REF -OPT:ICF -INCREMENTAL:NO"
+if [ -n "$linkargs" ]; then
+
+ # If -Zi is specified, certain optimizations are implicitly disabled
+ # by MSVC. Add back those optimizations if this is an optimized build.
+ # NOTE: These arguments must come after all others.
+ if [ -n "$opt" ]; then
+ linkargs="$linkargs -OPT:REF -OPT:ICF -INCREMENTAL:NO"
+ fi
+
+ args="$args -link $linkargs"
fi
if [ -n "$static_crt" ]; then
outdir="."
fi
ppsrc="$outdir/$(basename $src|sed 's/.S$/.asm/g')"
- echo "$cl -nologo -EP $includes $defines $src > $ppsrc"
- "$cl" -nologo -EP $includes $defines $src > $ppsrc || exit $?
+
+ if [ $ml = "armasm" ]; then
+ defines="$defines -D_M_ARM"
+ fi
+
+ if [ $ml = "armasm64" ]; then
+ defines="$defines -D_M_ARM64"
+ fi
+
+ if test -n "$verbose"; then
+ echo "$cl -nologo -EP $includes $defines $src > $ppsrc"
+ fi
+
+ eval "\"$cl\" -nologo -EP $includes $defines $src" > $ppsrc || exit $?
output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')"
- args="-nologo $safeseh $single $output $ppsrc"
+ if [ $ml = "armasm" ]; then
+ args="-nologo -g -oldit $armasm_output $ppsrc -errorReport:prompt"
+ elif [ $ml = "armasm64" ]; then
+ args="-nologo -g $armasm_output $ppsrc -errorReport:prompt"
+ else
+ args="-nologo $safeseh $single $output $ppsrc"
+ fi
+
+ if test -n "$verbose"; then
+ echo "$ml $args"
+ fi
- echo "$ml $args"
eval "\"$ml\" $args"
result=$?
#mv *.obj $outdir
else
args="$md $args"
- echo "$cl $args"
+
+ if test -n "$verbose"; then
+ echo "$cl $args"
+ fi
# Return an error code of 1 if an invalid command line parameter is passed
- # instead of just ignoring it.
+ # instead of just ignoring it. Any output that is not a warning or an
+ # error is filtered so this command behaves more like gcc. cl.exe prints
+ # the name of the compiled file otherwise, which breaks the dejagnu checks
+ # for excess warnings and errors.
eval "(\"$cl\" $args 2>&1 1>&3 | \
- awk '{print \$0} /D9002/ {error=1} END{exit error}' >&2) 3>&1"
+ awk '{print \$0} /D9002/ {error=1} END{exit error}' >&2) 3>&1 | \
+ awk '/warning|error/'"
result=$?
fi
exit $result
+# vim: noai:ts=4:sw=4