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()
12 if [[ ! "$old_value" =~ \/cygdrive\/ ]]; then
13 #echo didnt have a cygdrive in it: $old_value
15 #hmmm: want this to continue in multi parm version.
18 # replace single back-slashes with double ones.
19 local new_value="$(unix_to_dos_path "${old_value}")"
21 # remove any quote characters in the value.
22 new_value="${new_value//\"/}"
24 # echo "new value: $var = $new_value"
25 eval "export $var=\"$new_value\""
28 # for a windows build, this will replace any forward slashes
29 # and other cygwin notation with the appropriate dos style paths.
30 function dossify_and_run_commands()
32 if [ "$OS" != "Windows_NT" ]; then
33 # for non windows, just run the commands straight up.
38 # force all slashes to be dossy.
39 # export SERIOUS_SLASH_TREATMENT=true
41 dossify_environment_variable INCLUDE
43 declare -a darc_commands=()
46 if [[ "$i" =~ ^-[a-zA-z][/\"].* ]]; then
48 filename="$(unix_to_dos_path ${i:2})"
49 #echo "first two chars are $flag"
50 #echo "last after that are $filename"
51 recombined="$flag$filename"
52 #echo combined flag and file is $recombined
53 darc_commands+=("$recombined")
54 elif [[ "$i" =~ ^-libpath:.* ]]; then
56 filename="$(unix_to_dos_path ${i:9})"
57 #echo "libflag flag is $flag"
58 #echo "name after that is $filename"
59 recombined="$flag$filename"
60 #echo combined flag and file is $recombined
61 darc_commands+=("$recombined")
63 darc_commands+=($(unix_to_dos_path $i))
67 declare -a real_commands=()
68 for i in "${darc_commands[@]}"; do
69 real_commands+=($(echo $i | sed -e 's/\//\\/g'))
72 if [ ! -z "$SHELL_DEBUG" ]; then
73 echo commands are now:
74 for i in "${real_commands[@]}"; do
80 # this nonsense is only necessary because cygwin is screwing up our carefully constructed
81 # command line. it can't seem to leave the dos style paths alone in some cases, and insists
82 # on changing their form to use forward slashes, which breaks the windows compiler.
83 # this is NOT what cygwin is supposed to be doing, according to their documentation that
84 # claims all styles of paths are supported. and of course this worked fine in msys.
86 # now actually run the chewed command.
88 # old approach, not working since cygwin is hosing us on some paths.
89 #cmd /c "${real_commands[@]}"
91 #new approach that creates a cmd file.
92 cmdfile="$(mktemp $CLAM_TMP/build_cmds.XXXXXX)"
93 echo "${real_commands[@]}" >"$cmdfile"
94 #echo "**** cmd file is $cmdfile"
95 cmd /c $(cat "$cmdfile")
102 dossify_and_run_commands "$@"