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 303
 
304 304
       settingname="`basename -- "${i}"`"
305 305
       srcfile="${directory}/.bootstrap/${settingname}"
306
+
306 307
       if [ -d "${srcfile}" ]
307 308
       then
308 309
          # log_fluff "Directory \"${srcfile}\" not copied"
309 310
          continue
310 311
       fi
311 312
 
313
+      #
314
+      # os specific overrides present, skip dis
315
+      #
316
+      if [ -f "${srcfile}.${UNAME}" ]
317
+      then
318
+         continue
319
+      fi
320
+
321
+      #
322
+      # cut off os specific for general name
323
+      #
324
+      case "${settingname}" in
325
+         *".${UNAME}")
326
+            settingname="${settingname%.*}"
327
+         ;;
328
+      esac
329
+
312 330
       dstfile="${dst}/${settingname}"
313 331
 
314 332
       #
315 333
       # "repositories" files gets special treatment
316 334
       # "additional_repositories" is just a local patch thing
317 335
       # "embedded_repositories" is not merged though
336
+      #
318 337
       case "${settingname}" in
319 338
          "embedded_repositories"|"minions")
320 339
             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 2568
          ;;
2569 2569
 
2570 2570
          -k|--no-clean)
2571
-            OPTION_CLEAN_BEFORE_BUILD=
2571
+            OPTION_CLEAN_BEFORE_BUILD="NO"
2572 2572
          ;;
2573 2573
 
2574 2574
          -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 128
    name="`basename -- "${makepath}"`"
129 129
    case "${UNAME}" in
130 130
       mingw)
131
-         case "${name}" in
132
-            nmake|*nmake.exe)
131
+         case "${name%.*}" in
132
+            nmake)
133 133
                echo "NMake Makefiles"
134 134
             ;;
135 135
 
... ...
@@ -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 118
 }
119 119
 
120 120
 
121
-#
122
-# only needed for true builds
123
-#
124
-build_complete_environment()
121
+build_environment_options()
125 122
 {
126
-   log_debug ":build_complete_environment:"
127
-
128
-   [ -z "${__BUILD_COMPLETE_ENVIRONMENT}" ] || internal_fail "build_complete_environment run twice"
129
-   __BUILD_COMPLETE_ENVIRONMENT="YES"
123
+   log_debug ":build_environment_options:"
130 124
 
131 125
    [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ] && . mulle-bootstrap-settings.sh
132 126
 
... ...
@@ -142,8 +135,31 @@ build_complete_environment()
142 142
       OPTION_CONFIGURATIONS="`read_root_setting "configurations" "${OPTION_CONFIGURATIONS}"`"
143 143
    fi
144 144
 
145
-   OPTION_CLEAN_BEFORE_BUILD=`read_config_setting "clean_before_build"`
145
+   #
146
+   # Determine dispense_style
147
+   #
148
+   if [ -z "${OPTION_DISPENSE_STYLE}" ]
149
+   then
150
+      OPTION_DISPENSE_STYLE="`read_config_setting "dispense_style" "none"`"
151
+   fi
152
+}
153
+
146 154
 
155
+#
156
+# only needed for true builds
157
+#
158
+build_complete_environment()
159
+{
160
+   log_debug ":build_complete_environment:"
161
+
162
+   [ -z "${__BUILD_COMPLETE_ENVIRONMENT}" ] || internal_fail "build_complete_environment run twice"
163
+   __BUILD_COMPLETE_ENVIRONMENT="YES"
164
+
165
+   build_environment_options
166
+
167
+   ##
168
+   ## try to minimize this
169
+   ##
147 170
    # experimentally, these could reside outside the project folder but never tested
148 171
    CLONESBUILD_DIR="`read_sane_config_path_setting "build_dir" "build/.repos"`"
149 172
    BUILDLOGS_DIR="`read_sane_config_path_setting "build_log_dir" "${CLONESBUILD_DIR}/.logs"`"
... ...
@@ -151,13 +167,6 @@ build_complete_environment()
151 151
    [ -z "${CLONESBUILD_DIR}" ]  && internal_fail "variable CLONESBUILD_DIR is empty"
152 152
    [ -z "${BUILDLOGS_DIR}" ]    && internal_fail "variable BUILDLOGS_DIR is empty"
153 153
 
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 154
 
162 155
    #
163 156
    # 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 93
 #
94 94
 setup_mingw_buildenvironment()
95 95
 {
96
+   log_debug "setup_mingw_buildenvironment"
97
+   
96 98
    local linker
97 99
 
98 100
    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 654
    local OPTION_WITH_LIBRARIES="NO"
655 655
    local OPTION_WITH_LIBRARYPATHS="YES"
656 656
    local OPTION_WITH_MISSING_PATHS="NO"
657
-   local OPTION_PATH_SEPARATOR=":"
657
+   local OPTION_PATH_SEPARATOR="${PATH_SEPARATOR}"
658 658
    local OPTION_QUOTE=""
659 659
    local OPTION_SHELL_QUOTE="\""
660 660
    local OPTION_LINE_SEPERATOR=" "
... ...
@@ -663,7 +665,7 @@ paths_main()
663 663
 
664 664
    log_debug ":paths_main:"
665 665
 
666
-   [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ] && . mulle-bootstrap-functions.sh
666
+   [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ]       && . mulle-bootstrap-functions.sh
667 667
    [ -z "${MULLE_BOOTSTRAP_COMMON_SETTINGS_SH}" ] && . mulle-bootstrap-common-settings.sh
668 668
 
669 669
    OPTION_WITH_HEADERPATHS="YES"
... ...
@@ -776,7 +778,6 @@ paths_main()
776 776
             OPTION_SDK="$1"
777 777
          ;;
778 778
 
779
-
780 779
          --shell-quote)
781 780
             shift
782 781
             [ $# -eq 0 ] && fail "quote missing"
... ...
@@ -800,7 +801,6 @@ paths_main()
800 800
    [ -z "${DEPENDENCIES_DIR}" ] && internal_fail "missing DEPENDENCIES_DIR"
801 801
    [ -z "${ADDICTIONS_DIR}" ]   && internal_fail "missing ADDICTIONS_DIR"
802 802
 
803
-
804 803
    local type
805 804
    local values
806 805
    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 834
       case "${type}" in
835 835
          "addictions")
836 836
             values="`_flags_emit_path_value "${ADDICTIONS_DIR}"`"
837
+            # short circuit for mingw
838
+            if [ $# -eq 0 -a -z "${result}" ]
839
+            then
840
+               echo "${values}"
841
+               return 0
842
+            fi
837 843
             result="`add_line "${result}" "${values}"`"
838 844
          ;;
839 845
 
840 846
          "dependencies")
841 847
             values="`_flags_emit_path_value "${DEPENDENCIES_DIR}"`"
848
+            # short circuit for mingw
849
+            if [ $# -eq 0 -a -z "${result}" ]
850
+            then
851
+               echo "${values}"
852
+               return 0
853
+            fi
842 854
             result="`add_line "${result}" "${values}"`"
843 855
          ;;
844 856
 
... ...
@@ -857,6 +871,12 @@ paths_main()
857 857
 
858 858
          "path")
859 859
             result="`_flags_do_path "${result}"`"
860
+            # short circuit for mingw
861
+            if [ $# -eq 0 -a -z "${result}" ]
862
+            then
863
+               echo "${values}"
864
+               return 0
865
+            fi
860 866
          ;;
861 867
 
862 868
          "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 194
    local key
195 195
 
196 196
    key="$1"
197
+
198
+   if [ -z "$MULLE_BOOTSTRAP_WARN_ENVIRONMENT_SETTINGS" ]
199
+   then
200
+      MULLE_BOOTSTRAP_WARN_ENVIRONMENT_SETTINGS="`read_config_setting "warn_environment_setting" "YES"`"
201
+   fi
202
+
197 203
    if [ "$MULLE_BOOTSTRAP_WARN_ENVIRONMENT_SETTINGS" = "YES" ]
198 204
    then
199 205
       # don't trace some boring ones
... ...
@@ -274,7 +285,7 @@ _read_setting()
274 274
       then
275 275
          local key
276 276
 
277
-         key="`basename -- "${apath}"`"
277
+         key="${apath##*/}" # same as" `basename -- "${apath}"`"
278 278
          log_setting "${C_MAGENTA}${key}${C_SETTING} found as \"${apath}\""
279 279
       fi
280 280
 
... ...
@@ -399,7 +410,7 @@ _read_environment_setting()
399 399
 
400 400
    [ -z "${key}" ] && internal_fail "empty key in _read_environment_setting"
401 401
 
402
-   envname="MULLE_BOOTSTRAP_`echo "${key}" | tr '[:lower:]' '[:upper:]'`"
402
+   envname="MULLE_BOOTSTRAP_`tr '[:lower:]' '[:upper:]' <<< "${key}"`"
403 403
 
404 404
    if [ "$MULLE_FLAG_LOG_SETTINGS" = "YES" ]
405 405
    then
... ...
@@ -1595,8 +1606,6 @@ settings_initialize()
1595 1595
    [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ] && . mulle-bootstrap-functions.sh
1596 1596
 
1597 1597
    # 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 1598
 }
1601 1599
 
1602 1600
 settings_initialize