Browse code

* improvements for mingw, also improved speed a bit

Nat! authored on 06-09-2017 21:15:39
Showing 11 changed files
... ...
@@ -31,7 +31,7 @@
31 31
 #
32 32
 MULLE_EXECUTABLE_VERSION_MAJOR=3
33 33
 MULLE_EXECUTABLE_VERSION_MINOR=11
34
-MULLE_EXECUTABLE_VERSION_PATCH=1
34
+MULLE_EXECUTABLE_VERSION_PATCH=2
35 35
 
36 36
 MULLE_EXECUTABLE_VERSION="${MULLE_EXECUTABLE_VERSION_MAJOR}.${MULLE_EXECUTABLE_VERSION_MINOR}.${MULLE_EXECUTABLE_VERSION_PATCH}"
37 37
 
... ...
@@ -681,6 +681,7 @@ bootstrap_main()
681 681
          mulle_bootstrap_usage
682 682
       ;;
683 683
    esac
684
+   log_debug ":bootstrap_main done:"
684 685
 }
685 686
 
686 687
 
... ...
@@ -2,4 +2,4 @@
2 2
 
3 3
 REM "C:\Program Files\Git\usr\bin\sh.exe" and "/usr/local/bin" are replaced by install.sh 
4 4
 
5
-"C:\Program Files\Git\usr\bin\sh.exe" "mulle-mingw-dumpdef.sh" %*
5
+"C:\Program Files\Git\usr\bin\sh.exe" "%~dp0\mulle-mingw-dumpdef.sh" %*
... ...
@@ -81,7 +81,25 @@ _bootstrap_auto_copy()
81 81
    do
82 82
       IFS="${DEFAULT_IFS}"
83 83
 
84
+      #
85
+      # os specific overrides present, skip dis
86
+      #
87
+      if [ -f "${name}.${UNAME}" ]
88
+      then
89
+         continue
90
+      fi
91
+
84 92
       filepath="${tmpdir}/${name}"
93
+
94
+      #
95
+      # cut off os specific for general name
96
+      #
97
+      case "${name}" in
98
+         *".${UNAME}")
99
+            name="${name%.*}"
100
+         ;;
101
+      esac
102
+
85 103
       dstfilepath="${dst}/${name}"
86 104
 
87 105
       # only inherit, don't override
... ...
@@ -303,18 +321,37 @@ _bootstrap_auto_merge_root_settings()
303 321
 
304 322
       settingname="`basename -- "${i}"`"
305 323
       srcfile="${directory}/.bootstrap/${settingname}"
324
+
306 325
       if [ -d "${srcfile}" ]
307 326
       then
308 327
          # log_fluff "Directory \"${srcfile}\" not copied"
309 328
          continue
310 329
       fi
311 330
 
331
+      #
332
+      # os specific overrides present, skip dis
333
+      #
334
+      if [ -f "${srcfile}.${UNAME}" ]
335
+      then
336
+         continue
337
+      fi
338
+
339
+      #
340
+      # cut off os specific for general name
341
+      #
342
+      case "${settingname}" in
343
+         *".${UNAME}")
344
+            settingname="${settingname%.*}"
345
+         ;;
346
+      esac
347
+
312 348
       dstfile="${dst}/${settingname}"
313 349
 
314 350
       #
315 351
       # "repositories" files gets special treatment
316 352
       # "additional_repositories" is just a local patch thing
317 353
       # "embedded_repositories" is not merged though
354
+      #
318 355
       case "${settingname}" in
319 356
          "embedded_repositories"|"minions")
320 357
             continue  # done by caller
... ...
@@ -2522,6 +2522,7 @@ build_main()
2522 2522
 
2523 2523
    OPTION_CHECK_USR_LOCAL_INCLUDE="`read_config_setting "check_usr_local_include" "NO"`"
2524 2524
    OPTION_USE_CC_CXX="`read_config_setting "use_cc_cxx" "YES"`"
2525
+   OPTION_CLEAN_BEFORE_BUILD=`read_config_setting "clean_before_build" "NO"`
2525 2526
 
2526 2527
    #
2527 2528
    # it is useful, that fetch understands build options and
... ...
@@ -2568,7 +2569,7 @@ build_main()
2568 2569
          ;;
2569 2570
 
2570 2571
          -k|--no-clean)
2571
-            OPTION_CLEAN_BEFORE_BUILD=
2572
+            OPTION_CLEAN_BEFORE_BUILD="NO"
2572 2573
          ;;
2573 2574
 
2574 2575
          -K|--clean)
... ...
@@ -102,10 +102,11 @@ platform_make()
102 102
 
103 103
    case "${UNAME}" in
104 104
       mingw)
105
-         case "${name}" in
106
-            ""|cl|cl.exe)
105
+         case "${name%.*}" in
106
+            ""|cl|clang-cl|mulle-clang-cl)
107 107
                echo "nmake"
108 108
             ;;
109
+
109 110
             *)
110 111
                echo "mingw32-make"
111 112
             ;;
... ...
@@ -128,8 +129,8 @@ platform_cmake_generator()
128 129
    name="`basename -- "${makepath}"`"
129 130
    case "${UNAME}" in
130 131
       mingw)
131
-         case "${name}" in
132
-            nmake|*nmake.exe)
132
+         case "${name%.*}" in
133
+            nmake)
133 134
                echo "NMake Makefiles"
134 135
             ;;
135 136
 
... ...
@@ -86,28 +86,27 @@ simplified_dispense_style()
86 86
 _simplified_dispense_style_subdirectory()
87 87
 {
88 88
    local dispense_style="$1"
89
+   local configurations="$2"
90
+   local sdks="$3"
89 91
 
90 92
    local configuration
91 93
    local sdk
92 94
 
93
-   [ -z "${OPTION_CONFIGURATIONS}" ] && internal_fail "OPTION_CONFIGURATIONS is empty"
94
-   [ -z "${OPTION_SDKS}" ]           && internal_fail "OPTION_SDKS is empty"
95
+   [ -z "${configurations}" ] && internal_fail "configurations is empty"
96
+   [ -z "${sdks}" ]           && internal_fail "sdks is empty"
95 97
 
96 98
    case "${dispense_style}" in
97 99
       none)
98
-         PATH="`prepend_to_search_path_if_missing "$PATH" \
99
-                                                  "${DEPENDENCIES_DIR}/bin" \
100
-                                                  "${ADDICTIONS_DIR}/bin"`"
101 100
       ;;
102 101
 
103 102
       configuration-strict)
104
-         configuration="$(head -1 <<< "${OPTION_CONFIGURATIONS}")"
103
+         configuration="$(head -1 <<< "${configurations}")"
105 104
          echo "/${configuration}"
106 105
       ;;
107 106
 
108 107
       configuration-sdk-strict)
109
-         configuration="$(head -1 <<< "${OPTION_CONFIGURATIONS}")"
110
-         sdk="$(head -1 <<< "${OPTION_SDKS}")"
108
+         configuration="$(head -1 <<< "${configurations}")"
109
+         sdk="$(head -1 <<< "${sdks}")"
111 110
          echo "/${configuration}-${sdk}"
112 111
       ;;
113 112
 
... ...
@@ -118,15 +117,9 @@ _simplified_dispense_style_subdirectory()
118 117
 }
119 118
 
120 119
 
121
-#
122
-# only needed for true builds
123
-#
124
-build_complete_environment()
120
+build_environment_options()
125 121
 {
126
-   log_debug ":build_complete_environment:"
127
-
128
-   [ -z "${__BUILD_COMPLETE_ENVIRONMENT}" ] || internal_fail "build_complete_environment run twice"
129
-   __BUILD_COMPLETE_ENVIRONMENT="YES"
122
+   log_debug ":build_environment_options:"
130 123
 
131 124
    [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ] && . mulle-bootstrap-settings.sh
132 125
 
... ...
@@ -142,8 +135,31 @@ build_complete_environment()
142 135
       OPTION_CONFIGURATIONS="`read_root_setting "configurations" "${OPTION_CONFIGURATIONS}"`"
143 136
    fi
144 137
 
145
-   OPTION_CLEAN_BEFORE_BUILD=`read_config_setting "clean_before_build"`
138
+   #
139
+   # Determine dispense_style
140
+   #
141
+   if [ -z "${OPTION_DISPENSE_STYLE}" ]
142
+   then
143
+      OPTION_DISPENSE_STYLE="`read_config_setting "dispense_style" "none"`"
144
+   fi
145
+}
146
+
146 147
 
148
+#
149
+# only needed for true builds
150
+#
151
+build_complete_environment()
152
+{
153
+   log_debug ":build_complete_environment:"
154
+
155
+   [ -z "${__BUILD_COMPLETE_ENVIRONMENT}" ] || internal_fail "build_complete_environment run twice"
156
+   __BUILD_COMPLETE_ENVIRONMENT="YES"
157
+
158
+   build_environment_options
159
+
160
+   ##
161
+   ## try to minimize this
162
+   ##
147 163
    # experimentally, these could reside outside the project folder but never tested
148 164
    CLONESBUILD_DIR="`read_sane_config_path_setting "build_dir" "build/.repos"`"
149 165
    BUILDLOGS_DIR="`read_sane_config_path_setting "build_log_dir" "${CLONESBUILD_DIR}/.logs"`"
... ...
@@ -151,13 +167,6 @@ build_complete_environment()
151 167
    [ -z "${CLONESBUILD_DIR}" ]  && internal_fail "variable CLONESBUILD_DIR is empty"
152 168
    [ -z "${BUILDLOGS_DIR}" ]    && internal_fail "variable BUILDLOGS_DIR is empty"
153 169
 
154
-   #
155
-   # Determine dispense_style
156
-   #
157
-   if [ -z "${OPTION_DISPENSE_STYLE}" ]
158
-   then
159
-      OPTION_DISPENSE_STYLE="`read_config_setting "dispense_style" "none"`"
160
-   fi
161 170
 
162 171
    #
163 172
    # expand PATH for build, but it's kinda slow
... ...
@@ -908,22 +908,33 @@ ${i}"
908 908
 
909 909
 simplified_path()
910 910
 {
911
-   if [ "${MULLE_TRACE_PATHS_FLIP_X}" = "YES" ]
912
-   then
913
-      set +x
914
-   fi
911
+   #
912
+   # quick check if there is something to simplify 
913
+   # because this isn't fast at all
914
+   #
915
+   case "${1}" in
916
+      ""|".")
917
+         echo "."
918
+      ;;
915 919
 
916
-   if [ ! -z "$1" ]
917
-   then
918
-      _simplified_path "$@"
919
-   else
920
-      echo "."
921
-   fi
920
+      */|*\.\.*|*\./*)
921
+         if [ "${MULLE_TRACE_PATHS_FLIP_X}" = "YES" ]
922
+         then
923
+            set +x
924
+         fi
925
+   
926
+         _simplified_path "$@"
922 927
 
923
-   if [ "${MULLE_TRACE_PATHS_FLIP_X}" = "YES" ]
924
-   then
925
-      set -x
926
-   fi
928
+         if [ "${MULLE_TRACE_PATHS_FLIP_X}" = "YES" ]
929
+         then
930
+            set -x
931
+         fi
932
+      ;;
933
+      
934
+      *)
935
+         echo "$1"
936
+      ;;
937
+   esac
927 938
 }
928 939
 
929 940
 
... ...
@@ -125,13 +125,29 @@ log_debug()
125 125
 
126 126
 log_trace()
127 127
 {
128
-   log_printf "${C_TRACE}%b${C_RESET}\n" "$*"
128
+   case "${UNAME}" in
129
+      linux)
130
+         log_printf "${C_TRACE}$(date "+%s.%N") %b${C_RESET}\n" "$*"
131
+         ;;
132
+
133
+      *)
134
+         log_printf "${C_TRACE}$(date "+%s") %b${C_RESET}\n" "$*"
135
+      ;;
136
+   esac
129 137
 }
130 138
 
131 139
 
132 140
 log_trace2()
133 141
 {
134
-   log_printf "${C_TRACE2}%b${C_RESET}\n" "$*"
142
+   case "${UNAME}" in
143
+      linux)
144
+         log_printf "${C_TRACE2}$(date "+%s.%N") %b${C_RESET}\n" "$*"
145
+         ;;
146
+         
147
+      *)
148
+         log_printf "${C_TRACE2}$(date "+%s") %b${C_RESET}\n" "$*"
149
+      ;;
150
+   esac
135 151
 }
136 152
 
137 153
 
... ...
@@ -34,17 +34,15 @@ MULLE_BOOTSTRAP_MINGW_SH="included"
34 34
 
35 35
 find_msvc_executable()
36 36
 {
37
-   local exe
38
-   local name
39
-
40
-   exe="${1:-cl.exe}"
41
-   name="${2:-compiler}"
37
+   local exe="${1:-cl.exe}"
38
+   local name="${2:-compiler}"
39
+   local searchpath="${3:-$PATH}"
42 40
 
43 41
    local path
44 42
    local compiler
45 43
 
46 44
    IFS=":"
47
-   for path in $PATH
45
+   for path in ${searchpath}
48 46
    do
49 47
       IFS="${DEFAULT_IFS}"
50 48
 
... ...
@@ -93,6 +91,8 @@ mingw_mangle_compiler()
93 91
 #
94 92
 setup_mingw_buildenvironment()
95 93
 {
94
+   log_debug "setup_mingw_buildenvironment"
95
+   
96 96
    local linker
97 97
 
98 98
    if [ -z "${LIBPATH}" -o  -z "${INCLUDE}" ] && [ -z "${DONT_USE_VS}" ]
... ...
@@ -111,8 +111,10 @@ setup_mingw_buildenvironment()
111 111
    fi
112 112
 
113 113
    local preprocessor
114
-
115
-   preprocessor="`find_msvc_executable "mulle-mingw-cpp.sh" "preprocessor"`"
114
+   local searchpath
115
+ 
116
+   searchpath="`dirname -- "${MULLE_EXECUTABLE_PATH}"`:$PATH"
117
+   preprocessor="`find_msvc_executable "mulle-mingw-cpp.sh" "preprocessor" "${searchpath}"`"
116 118
    if [ ! -z "${preprocessor}" ]
117 119
    then
118 120
       CPP="${preprocessor}"
... ...
@@ -173,17 +173,19 @@ _flags_emit_path_value()
173 173
 
174 174
 _dependencies_subdir()
175 175
 {
176
-   local simplified
176
+   local dispense_style="$1"
177
+   local configurations="$2"
178
+   local sdks="$3"
177 179
 
178
-   simplified="`simplified_dispense_style "${OPTION_DISPENSE_STYLE}" \
179
-                                          "${OPTION_CONFIGURATION}" \
180
-                                          "${OPTION_SDK}"`"
180
+   simplified="`simplified_dispense_style "${dispense_style}" \
181
+                                          "${configurations}" \
182
+                                          "${sdks}"`"
181 183
    #
182 184
    # expand PATH for build, but it's kinda slow
183 185
    # so don't do it all the time
184 186
    #
185 187
 
186
-   _simplified_dispense_style_subdirectory "${simplified}"
188
+   _simplified_dispense_style_subdirectory "${simplified}" "${configurations}" "${sdks}"
187 189
 }
188 190
 
189 191
 
... ...
@@ -654,7 +656,7 @@ paths_main()
654 656
    local OPTION_WITH_LIBRARIES="NO"
655 657
    local OPTION_WITH_LIBRARYPATHS="YES"
656 658
    local OPTION_WITH_MISSING_PATHS="NO"
657
-   local OPTION_PATH_SEPARATOR=":"
659
+   local OPTION_PATH_SEPARATOR="${PATH_SEPARATOR}"
658 660
    local OPTION_QUOTE=""
659 661
    local OPTION_SHELL_QUOTE="\""
660 662
    local OPTION_LINE_SEPERATOR=" "
... ...
@@ -663,7 +665,7 @@ paths_main()
663 665
 
664 666
    log_debug ":paths_main:"
665 667
 
666
-   [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ] && . mulle-bootstrap-functions.sh
668
+   [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ]       && . mulle-bootstrap-functions.sh
667 669
    [ -z "${MULLE_BOOTSTRAP_COMMON_SETTINGS_SH}" ] && . mulle-bootstrap-common-settings.sh
668 670
 
669 671
    OPTION_WITH_HEADERPATHS="YES"
... ...
@@ -776,7 +778,6 @@ paths_main()
776 778
             OPTION_SDK="$1"
777 779
          ;;
778 780
 
779
-
780 781
          --shell-quote)
781 782
             shift
782 783
             [ $# -eq 0 ] && fail "quote missing"
... ...
@@ -800,7 +801,6 @@ paths_main()
800 801
    [ -z "${DEPENDENCIES_DIR}" ] && internal_fail "missing DEPENDENCIES_DIR"
801 802
    [ -z "${ADDICTIONS_DIR}" ]   && internal_fail "missing ADDICTIONS_DIR"
802 803
 
803
-
804 804
    local type
805 805
    local values
806 806
    local result
... ...
@@ -808,18 +808,20 @@ paths_main()
808 808
    result=""
809 809
    type="${1:-run}"
810 810
 
811
-
812 811
    #
813 812
    # if there is no "root", then pick the first configuration/sdk
814
-   # for the dependencies paths
813
+   # for the dependencies paths (FUTURE)
815 814
    #
816 815
    local old
817 816
    local subdir
818 817
 
819
-   build_complete_environment   # need this now
818
+# if we really need this, uncomment and explain what is needed
819
+# this slows mingw down a lot
820
+   build_environment_options   # need this now for _dependencies_subdir
820 821
 
821 822
    old="${DEPENDENCIES_DIR}"
822
-   subdir="`_dependencies_subdir`"
823
+   subdir="`_dependencies_subdir "${OPTION_DISPENSE_STYLE}" "${OPTION_CONFIGURATIONS}" "${OPTION_SDKS}"`"
824
+
823 825
    DEPENDENCIES_DIR="${DEPENDENCIES_DIR}${subdir}"
824 826
 
825 827
    local memo
... ...
@@ -834,11 +836,23 @@ paths_main()
834 836
       case "${type}" in
835 837
          "addictions")
836 838
             values="`_flags_emit_path_value "${ADDICTIONS_DIR}"`"
839
+            # short circuit for mingw
840
+            if [ $# -eq 0 -a -z "${result}" ]
841
+            then
842
+               echo "${values}"
843
+               return 0
844
+            fi
837 845
             result="`add_line "${result}" "${values}"`"
838 846
          ;;
839 847
 
840 848
          "dependencies")
841 849
             values="`_flags_emit_path_value "${DEPENDENCIES_DIR}"`"
850
+            # short circuit for mingw
851
+            if [ $# -eq 0 -a -z "${result}" ]
852
+            then
853
+               echo "${values}"
854
+               return 0
855
+            fi
842 856
             result="`add_line "${result}" "${values}"`"
843 857
          ;;
844 858
 
... ...
@@ -857,6 +871,12 @@ paths_main()
857 871
 
858 872
          "path")
859 873
             result="`_flags_do_path "${result}"`"
874
+            # short circuit for mingw
875
+            if [ $# -eq 0 -a -z "${result}" ]
876
+            then
877
+               echo "${values}"
878
+               return 0
879
+            fi
860 880
          ;;
861 881
 
862 882
          "make")
... ...
@@ -99,6 +99,11 @@ warn_user_setting()
99 99
 
100 100
    path="$1"
101 101
 
102
+   if [ -z "${MULLE_BOOTSTRAP_WARN_USER_SETTINGS}" ] 
103
+   then
104
+      MULLE_BOOTSTRAP_WARN_USER_SETTINGS="`read_config_setting "warn_user_setting" "YES"`"
105
+   fi
106
+
102 107
    if [ "$MULLE_BOOTSTRAP_WARN_USER_SETTINGS" = "YES" ]
103 108
    then
104 109
       log_warning "Using `dirname -- "${path}"` for `basename -- "${path}"`"
... ...
@@ -194,6 +199,12 @@ warn_environment_setting()
194 199
    local key
195 200
 
196 201
    key="$1"
202
+
203
+   if [ -z "$MULLE_BOOTSTRAP_WARN_ENVIRONMENT_SETTINGS" ]
204
+   then
205
+      MULLE_BOOTSTRAP_WARN_ENVIRONMENT_SETTINGS="`read_config_setting "warn_environment_setting" "YES"`"
206
+   fi
207
+
197 208
    if [ "$MULLE_BOOTSTRAP_WARN_ENVIRONMENT_SETTINGS" = "YES" ]
198 209
    then
199 210
       # don't trace some boring ones
... ...
@@ -274,7 +285,7 @@ _read_setting()
274 285
       then
275 286
          local key
276 287
 
277
-         key="`basename -- "${apath}"`"
288
+         key="${apath##*/}" # same as" `basename -- "${apath}"`"
278 289
          log_setting "${C_MAGENTA}${key}${C_SETTING} found as \"${apath}\""
279 290
       fi
280 291
 
... ...
@@ -399,7 +410,7 @@ _read_environment_setting()
399 410
 
400 411
    [ -z "${key}" ] && internal_fail "empty key in _read_environment_setting"
401 412
 
402
-   envname="MULLE_BOOTSTRAP_`echo "${key}" | tr '[:lower:]' '[:upper:]'`"
413
+   envname="MULLE_BOOTSTRAP_`tr '[:lower:]' '[:upper:]' <<< "${key}"`"
403 414
 
404 415
    if [ "$MULLE_FLAG_LOG_SETTINGS" = "YES" ]
405 416
    then
... ...
@@ -1595,8 +1606,6 @@ settings_initialize()
1595 1606
    [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ] && . mulle-bootstrap-functions.sh
1596 1607
 
1597 1608
    # MULLE_BOOTSTRAP_NO_WARN_LOCAL_SETTINGS="`read_config_setting "no_warn_local_setting"`"
1598
-   MULLE_BOOTSTRAP_WARN_USER_SETTINGS="`read_config_setting "warn_user_setting" "YES"`"
1599
-   MULLE_BOOTSTRAP_WARN_ENVIRONMENT_SETTINGS="`read_config_setting "warn_environment_setting" "YES"`"
1600 1609
 }
1601 1610
 
1602 1611
 settings_initialize