3 source $FEISTY_MEOW_SCRIPTS/core/functions.sh
5 #hmmm: make this support multiple vars as parameters.
6 # replaces a specific environment variable with a dos approved equivalent.
7 function dossify_environment_variable()
11 #cygpath doesn't handle multiple path variables properly and otherwise operates only on one path element.
12 ## new_value="$(cygpath -p -d ${!var})"
13 ## eval "export $var=\"$new_value\""
14 ##echo "hey now the var is '${!var}'"
17 #echo "var is '$var' and old value is '$old_value'"
18 if [[ ! "$old_value" =~ \/cygdrive\/ ]]; then
19 #echo didnt have a cygdrive in it: $old_value
23 # replace single back-slashes with double ones.
24 local new_value="$(unix_to_dos_path "${old_value}")"
26 # remove any quote characters in the value.
27 new_value="${new_value//\"/}"
29 echo "new value: '$var' = '$new_value'"
30 eval "export $var=\"$new_value\""
33 # for a windows build, this will replace any forward slashes
34 # and other cygwin notation with the appropriate dos style paths.
35 function dossify_and_run_commands()
37 if [ "$OS" != "Windows_NT" ]; then
38 # for non windows, just run the commands straight up.
43 # force all slashes to be dossy.
44 # export SERIOUS_SLASH_TREATMENT=true
46 dossify_environment_variable INCLUDE
48 declare -a darc_commands=()
51 if [[ "$i" =~ ^-[a-zA-z][/\"].* ]]; then
53 filename="$(unix_to_dos_path ${i:2})"
54 #echo "first two chars are $flag"
55 #echo "last after that are $filename"
56 recombined="$flag$filename"
57 #echo combined flag and file is $recombined
58 darc_commands+=("$recombined")
59 elif [[ "$i" =~ ^-libpath:.* ]]; then
61 filename="$(unix_to_dos_path ${i:9})"
62 #echo "libflag flag is $flag"
63 #echo "name after that is $filename"
64 recombined="$flag$filename"
65 #echo combined flag and file is $recombined
66 darc_commands+=("$recombined")
68 darc_commands+=($(unix_to_dos_path $i))
72 declare -a real_commands=()
73 for i in "${darc_commands[@]}"; do
74 real_commands+=($(echo $i | sed -e 's/\//\\/g'))
77 if [ ! -z "$SHELL_DEBUG" ]; then
78 echo commands are now:
79 for i in "${real_commands[@]}"; do
85 # this nonsense is only necessary because cygwin is screwing up our carefully constructed
86 # command line. it can't seem to leave the dos style paths alone in some cases, and insists
87 # on changing their form to use forward slashes, which breaks the windows compiler.
88 # this is NOT what cygwin is supposed to be doing, according to their documentation that
89 # claims all styles of paths are supported. and of course this worked fine in msys.
91 # now actually run the chewed command.
93 # old approach, not working since cygwin is hosing us on some paths.
94 #cmd /c "${real_commands[@]}"
96 #new approach that creates a cmd file.
97 cmdfile="$(mktemp $CLAM_TMP/build_cmds.XXXXXX)"
98 echo "${real_commands[@]}" >"$cmdfile"
99 echo "** cmd file is: '$cmdfile')"
100 #echo "** cmd file has: $(cat "$cmdfile")"
101 cmd /c $(cat "$cmdfile")
103 # leave the file for inspection if there was an error.
104 if [ $retval -eq 0 ]; then
110 dossify_and_run_commands "$@"