#!/bin/bash
if [ -f "$BUILD_LIST_FILE" ]; then
- echo Compiling [$(cat $BUILD_LIST_FILE | while read line; do echo $(basename $line); done )]
+ echo Compiling [$(cat $BUILD_LIST_FILE | while read line; do echo $(basename $line); done )]
rm -f $(cat $BUILD_WHACK_FILE)
#echo got line to run: $*
eval "${@}"
# switches from a /X/path form to an X:/ form. this also processes cygwin paths.
function unix_to_dos_path() {
# we usually remove dos slashes in favor of forward slashes.
+ local DOSSYHOME
+ if [[ ! "$OS" =~ ^WIN ]]; then
+ # fake this value for non-windows (non-cygwin) platforms.
+ DOSSYHOME="$HOME"
+ else
+ # for cygwin, we must replace the /home/X path with an absolute one, since cygwin
+ # insists on the /home form instead of /c/cygwin/home being possible. this is
+ # super frustrating and nightmarish.
+ DOSSYHOME="$(cygpath -am "$HOME")"
+ fi
+
if [ ! -z "$SERIOUS_SLASH_TREATMENT" ]; then
# unless this flag is set, in which case we force dos slashes.
- echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\/cygdrive//' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/' | sed -e 's/\//\\/g'
+ echo "$1" | sed -e "s?^$HOME?$DOSSYHOME?g" | sed -e 's/\\/\//g' | sed -e 's/\/cygdrive//' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/' | sed -e 's/\//\\/g'
else
- echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\/cygdrive//' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/'
+ echo "$1" | sed -e "s?^$HOME?$DOSSYHOME?g" | sed -e 's/\\/\//g' | sed -e 's/\/cygdrive//' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/'
fi
}
#on hold: export PLATFORM_DIR="$(short_path "$PROGRAMFILES/Microsoft SDKs/Windows/v7.0A" | tr "A-Z" "a-z" | sed -e 's/^\(.*\)\/[^\/]*\/[^\/]*[\/]$/\1/' )"
##| sed -e 's/^\(.\):/\/\1/' )"
-export PLATFORM_DIR="c:\progra~2\micros~1\windows\v7.0a"
+ # guess at where we can find this damned directory in its short form.
+#hmmm: this is needed until there's a replacement for short path, or we can build again.
+ export PLATFORM_DIR="c:/progra~2/micros~1/windows/v7.0a"
+ if [ ! -d "$PLATFORM_DIR" ]; then
+ PLATFORM_DIR="c:/progra~1/micros~1/windows/v7.0a"
+ if [ ! -d "$PLATFORM_DIR" ]; then
+ PLATFORM_DIR="c:/progra~1/micros~2/windows/v7.0a"
+ if [ ! -d "$PLATFORM_DIR" ]; then
+ PLATFORM_DIR="c:/progra~2/micros~2/windows/v7.0a"
+ fi
+ fi
+ fi
+
+ if [ ! -d "$PLATFORM_DIR" ]; then
+ echo "*** Failure to calculate the platform directory based on several attempts using c:\\program files\\microsoft sdks\\windows\\v7.0a as the basic pattern"
+ fi
+
fi
export WindowsSdkDir="$PLATFORM_DIR"
#echo "first two chars are $flag"
#echo "last after that are $filename"
recombined="$flag$filename"
+#echo combined flag and file is $recombined
+ darc_commands+=("$recombined")
+ elif [[ "$i" =~ ^-libpath:.* ]]; then
+ flag="-libpath:"
+ filename="$(unix_to_dos_path ${i:9})"
+#echo "libflag flag is $flag"
+#echo "name after that is $filename"
+ recombined="$flag$filename"
#echo combined flag and file is $recombined
darc_commands+=("$recombined")
else
declare -a real_commands=()
for i in "${darc_commands[@]}"; do
- real_commands+=($(echo $i | sed -e 's/\\/\\\\/g'))
+ real_commands+=($(echo $i | sed -e 's/\//\\/g'))
done
if [ ! -z "$SHELL_DEBUG" ]; then
echo
fi
+# this nonsense is only necessary because cygwin is screwing up our carefully constructed
+# command line. it can't seem to leave the dos style paths alone in some cases, and insists
+# on changing their form to use forward slashes, which breaks the windows compiler.
+# this is NOT what cygwin is supposed to be doing, according to their documentation that
+# claims all styles of paths are supported. and of course this worked fine in msys.
+
# now actually run the chewed command.
- cmd /c "${real_commands[@]}"
+
+# old approach, not working since cygwin is hosing us on some paths.
+#cmd /c "${real_commands[@]}"
+
+#new approach that creates a cmd file.
+ cmdfile="$(mktemp $CLAM_TMP/build_cmds.XXXXXX)"
+ echo "${real_commands[@]}" >"$cmdfile"
+#echo "**** cmd file is $cmdfile"
+ cmd /c $(cat "$cmdfile")
+ retval=$?
+ rm "$cmdfile"
+
+ return $retval
}
dossify_and_run_commands "$@"