Browse code

improvements in mingw code

Nat! authored on 13-09-2017 14:16:21
Showing 4 changed files
... ...
@@ -30,9 +30,11 @@
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 #
32 32
 
33
-PATH="/usr/local/libexec/mulle-bootstrap:$PATH"
33
+LIBEXEC_PATH="`mulle-bootstrap library-path`"
34
+
35
+PATH="${LIBEXEC_PATH}:$PATH"
34 36
 export PATH
35 37
 
36
-[ -z "${MULLE_BOOTSTRAP_MINGW_SH}" ] && . mulle-bootstrap-mingw.sh && mingw_initialize
38
+[ -z "${MULLE_BOOTSTRAP_MINGW_SH}" ] && . "mulle-bootstrap-mingw.sh" 
37 39
 
38 40
 PATH="`mingw_buildpath "${PATH}"`" cmake.exe "$@"
... ...
@@ -100,6 +100,16 @@ platform_make()
100 100
 
101 101
    name="`basename -- "${compilerpath}"`"
102 102
 
103
+   #
104
+   # Ninja is probably preferable if installed
105
+   # Should configure this though somewhere
106
+   #
107
+   if [ ! -z "`command -v ninja`" ]
108
+   then
109
+      echo "ninja"
110
+      return
111
+   fi
112
+
103 113
    case "${UNAME}" in
104 114
       mingw)
105 115
          case "${name%.*}" in
... ...
@@ -127,26 +137,30 @@ platform_cmake_generator()
127 137
    local name
128 138
 
129 139
    name="`basename -- "${makepath}"`"
130
-   case "${UNAME}" in
131
-      mingw)
132
-         case "${name%.*}" in
133
-            nmake)
134
-               echo "NMake Makefiles"
135
-            ;;
140
+   case "${name%.*}" in
141
+      nmake)
142
+         echo "NMake Makefiles"
143
+      ;;
136 144
 
137
-            mingw*|MINGW*)
138
-               echo "MinGW Makefiles"
145
+      mingw*|MINGW*)
146
+         echo "MinGW Makefiles"
147
+      ;;
148
+
149
+      ninja)
150
+         echo "Ninja"
151
+      ;;
152
+
153
+      *)
154
+         case "${UNAME}" in
155
+            mingw*)
156
+               echo "MSYS Makefiles"
139 157
             ;;
140 158
 
141 159
             *)
142
-               echo "MSYS Makefiles"
160
+               echo "Unix Makefiles"
143 161
             ;;
144 162
          esac
145 163
       ;;
146
-
147
-      *)
148
-         echo "Unix Makefiles"
149
-      ;;
150 164
    esac
151 165
 }
152 166
 
... ...
@@ -650,6 +650,9 @@ cd_physical()
650 650
 absolutepath()
651 651
 {
652 652
    case "${1}" in
653
+      "")
654
+      ;;
655
+
653 656
       '/'*|'~'*)
654 657
         simplified_path "${1}"
655 658
       ;;
... ...
@@ -67,6 +67,44 @@ find_msvc_executable()
67 67
 }
68 68
 
69 69
 
70
+# used by tests
71
+mingw_demangle_path()
72
+{
73
+   echo "$1" | sed 's|^/\(.\)|\1:|' | sed s'|/|\\|g'
74
+}
75
+
76
+
77
+
78
+mingw_eval_demangle_path()
79
+{
80
+   echo "$1" | sed 's|^/\(.\)|\1:|' | sed s'|/|\\\\|g'
81
+}
82
+
83
+
84
+#
85
+# mingw wille demangle first -I/c/users but not the next one
86
+# but when one -I looks demangled, it doesn't demangle the first
87
+# one. It's so complicated
88
+#
89
+mingw_eval_demangle_paths()
90
+{
91
+#   if [ $# -eq 0 ]
92
+#   then
93
+#      return
94
+#   fi
95
+#
96
+#   echo "$1"
97
+#   shift
98
+
99
+   while [ $# -ne 0 ]
100
+   do
101
+      mingw_eval_demangle_path "$1"
102
+      shift
103
+   done
104
+}
105
+
106
+
107
+# used by anyone ?
70 108
 mingw_mangle_compiler()
71 109
 {
72 110
    local compiler
... ...
@@ -86,6 +124,32 @@ mingw_mangle_compiler()
86 124
 }
87 125
 
88 126
 
127
+
128
+# used by tests, probably old and wrong
129
+mingw_mangle_compiler_exe()
130
+{
131
+   local compiler
132
+
133
+   compiler="$1"
134
+   case "${compiler}" in
135
+      mulle-clang|clang)
136
+         compiler="${compiler}-cl"
137
+         echo "Using ${compiler} on mingw for $2" >&2
138
+      ;;
139
+
140
+      mulle-clang-*|clang-*)
141
+      ;;
142
+
143
+      *)
144
+         compiler="cl.exe"
145
+         echo "Using default compiler cl for $2" >&2
146
+      ;;
147
+   esac
148
+   echo "${compiler}"
149
+}
150
+
151
+
152
+
89 153
 #
90 154
 # fix path fckup
91 155
 #
... ...
@@ -126,13 +190,15 @@ setup_mingw_buildenvironment()
126 190
 }
127 191
 
128 192
 
193
+
129 194
 #
130
-# mingw32-make can't have sh.exe in its path
195
+# mingw32-make can't have sh.exe in its path, so remove it
131 196
 #
132 197
 mingw_buildpath()
133 198
 {
134 199
    local i
135
-   local fetchpath
200
+   local buildpath
201
+   local vspath
136 202
 
137 203
    IFS=":"
138 204
    for i in $PATH
... ...
@@ -145,17 +211,72 @@ mingw_buildpath()
145 211
          continue
146 212
       fi
147 213
 
148
-      if [ -z "${fetchpath}" ]
214
+      if [ -z "${buildpath}" ]
149 215
       then
150
-         fetchpath="${i}"
216
+         buildpath="${i}"
151 217
       else
152
-         fetchpath="${fetchpath}:${i}"
218
+         buildpath="${buildpath}:${i}"
153 219
       fi
154 220
    done
155 221
 
222
+   echo "${buildpath}"
223
+}
224
+
225
+
226
+#
227
+# mingw likes to put it's stuff in front, obscuring Visual Studio
228
+# executables this function resorts this (used in mulle-tests)
229
+#
230
+mingw_visualstudio_buildpath()
231
+{
232
+   local i
233
+   local buildpath
234
+   local vspath
235
+
236
+   IFS=":"
237
+   for i in $PATH
238
+   do
239
+      IFS="${DEFAULT_IFS}"
240
+
241
+      case "$i" in
242
+         *"/Microsoft Visual Studio"*)
243
+            if [ -z "${vspath}" ]
244
+            then
245
+               vspath="${i}"
246
+            else
247
+               vspath="${vspath}:${i}"
248
+            fi
249
+         ;;
250
+      
251
+         *)         
252
+            if [ -z "${buildpath}" ]
253
+            then
254
+               buildpath="${i}"
255
+            else
256
+               buildpath="${buildpath}:${i}"
257
+            fi
258
+         ;;
259
+      esac
260
+   done
156 261
    IFS="${DEFAULT_IFS}"
157 262
 
158
-   echo "${fetchpath}"
263
+   if [ ! -z "${vspath}" ]
264
+   then
265
+      if [ -z "${buildpath}" ]
266
+      then
267
+         buildpath="${vspath}"
268
+      else
269
+         buildpath="${vspath}:${buildpath}"
270
+      fi
271
+   fi
272
+
273
+   echo "${buildpath}"
274
+}
275
+
276
+
277
+mingw32_make_buildpath()
278
+{
279
+   mingw_buildpath
159 280
 }
160 281
 
161 282