Browse code

* add mulle-bootstrap log command, for looking at build logs of a specific dependency pass -v to non-make generators as a hacque

Nat! authored on 20-09-2017 17:30:44
Showing 7 changed files
... ...
@@ -1,3 +1,8 @@
1
+## 3.13.0
2
+
3
+* add mulle-bootstrap log command, for looking at build logs of a specific dependency
4
+
5
+
1 6
 ### 3.12.4
2 7
 
3 8
 * MAKE_FLAGS is MAKEFLAGS for consistency
... ...
@@ -30,8 +30,8 @@
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 #
32 32
 MULLE_EXECUTABLE_VERSION_MAJOR=3
33
-MULLE_EXECUTABLE_VERSION_MINOR=12
34
-MULLE_EXECUTABLE_VERSION_PATCH=4
33
+MULLE_EXECUTABLE_VERSION_MINOR=13
34
+MULLE_EXECUTABLE_VERSION_PATCH=0
35 35
 
36 36
 MULLE_EXECUTABLE_VERSION="${MULLE_EXECUTABLE_VERSION_MAJOR}.${MULLE_EXECUTABLE_VERSION_MINOR}.${MULLE_EXECUTABLE_VERSION_PATCH}"
37 37
 
... ...
@@ -70,6 +70,7 @@ HIDDEN_COMMANDS="\
70 70
    expansion     : read or edit fetch expansions
71 71
    git           : run git commands on fetched repositories
72 72
    library-path  : print path to mulle-bootstrap libexec
73
+   log           : show build logs
73 74
    project-path  : print path to folder containing .bootstrap
74 75
    run           : run command with proper dependencies PATHs
75 76
    setting       : read or edit build settings
... ...
@@ -587,6 +588,12 @@ bootstrap_main()
587 588
          return 0
588 589
       ;;
589 590
 
591
+      log|logs)
592
+         [ -z "${MULLE_BOOTSTRAP_LOG_SH}" ] && . mulle-bootstrap-log.sh
593
+
594
+         log_main "$@" || exit 1
595
+      ;;
596
+
590 597
       master-path)
591 598
          echo "${PWD}"
592 599
          return 0
... ...
@@ -765,6 +765,10 @@ build_fail()
765 765
 }
766 766
 
767 767
 
768
+#
769
+# build log will be of form
770
+# <name>--<configuration>-<sdk>.<tool>.log
771
+# It is ensured, that
768 772
 build_log_name()
769 773
 {
770 774
    local tool="$1"; shift
... ...
@@ -774,18 +778,38 @@ build_log_name()
774 778
    [ -z "${name}" ] && internal_fail "name missing"
775 779
 
776 780
    local logfile
781
+   local  s
782
+
783
+   case "${name}" in
784
+      *-)
785
+         fail "Dependency \"${name}\" ends with -, that won't work here"
786
+      ;;
787
+
788
+      *--*)
789
+         fail "Dependency \"${name}\" contains --, that won't work here"
790
+      ;;
791
+   esac
777 792
 
778 793
    logfile="${BUILDLOGS_DIR}/${name}"
779 794
 
795
+   if [ $# -ne 0 ]
796
+   then
797
+      logfile="${logfile}-"
798
+   fi
799
+
780 800
    while [ $# -gt 0 ]
781 801
    do
782
-      if [ ! -z "$1" ]
802
+      s="$1"
803
+      shift
804
+
805
+      if [ ! -z "$s" ]
783 806
       then
784
-         logfile="${logfile}-$1"
807
+         s="$(tr '-' '_' <<< "${s}")"
808
+         logfile="${logfile}-${s}"
785 809
       fi
786
-      [ $# -eq 0 ] || shift
787 810
    done
788 811
 
812
+   tool="$(tr '-' '_' <<< "${tool}")"
789 813
    absolutepath "${logfile}.${tool}.log"
790 814
 }
791 815
 
... ...
@@ -1145,7 +1169,18 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
1145 1169
 
1146 1170
       if [ "${MULLE_FLAG_VERBOSE_BUILD}" = "YES" ]
1147 1171
       then
1148
-         local_make_flags="${local_make_flags} VERBOSE=1"
1172
+         #
1173
+         # ugliness ensues
1174
+         #
1175
+         case "${MAKE}" in
1176
+            *[mM]ake*)
1177
+               local_make_flags="${local_make_flags} VERBOSE=1"
1178
+            ;;
1179
+
1180
+            *)
1181
+               local_make_flags="${local_make_flags} -v"
1182
+            ;;
1183
+         esac
1149 1184
       fi
1150 1185
 
1151 1186
       local oldpath
... ...
@@ -2313,50 +2348,6 @@ build_wrapper()
2313 2348
 }
2314 2349
 
2315 2350
 
2316
-# keep until "to" but excluding it
2317
-# cut stuff until "to"
2318
-# keep "to" and keep rest
2319
-
2320
-force_rebuild()
2321
-{
2322
-   log_debug "force_rebuild" "$*"
2323
-
2324
-   local from="$1"
2325
-   local to="$2"
2326
-
2327
-   remove_file_if_present "${REPOS_DIR}/.build_started"
2328
-
2329
-   # if nothing's build yet, fine with us
2330
-   if [ ! -f "${REPOS_DIR}/.build_done" ]
2331
-   then
2332
-      log_fluff "Nothing has been built yet"
2333
-      return
2334
-   fi
2335
-
2336
-   if [ -z "${from}" -a -z "${to}" ]
2337
-   then
2338
-      remove_file_if_present "${REPOS_DIR}/.build_done"
2339
-      return
2340
-   fi
2341
-
2342
-   #
2343
-   # keep entries above parameter
2344
-   # os x doesn't have 'Q'
2345
-   # also q and i doesn't work on OS X <sigh>
2346
-   #
2347
-   local tmpfile
2348
-
2349
-   [ -z "${MULLE_BOOTSTRAP_SNIP_SH}" ] && . mulle-bootstrap-snip.sh
2350
-
2351
-   tmpfile="`exekutor mktemp "mulle-bootstrap.XXXXXXXX"`" || exit 1
2352
-
2353
-   redirect_exekutor "${tmpfile}" snip_from_to_file "${from}" "${to}" "${REPOS_DIR}/.build_done"
2354
-   exekutor mv "${tmpfile}" "${REPOS_DIR}/.build_done"
2355
-
2356
-   log_debug ".build_done=`cat "${REPOS_DIR}/.build_done"`"
2357
-}
2358
-
2359
-
2360 2351
 build_if_alive()
2361 2352
 {
2362 2353
    log_debug "build_if_alive" "$*"
... ...
@@ -2700,6 +2691,8 @@ build_main()
2700 2691
       if [ "${MULLE_FLAG_MAGNUM_FORCE}" != "NONE" ] || \
2701 2692
          [ ! -z "${OPTION_FROM}" -o ! -z "${OPTION_TO}" ]
2702 2693
       then
2694
+         [ -z "${MULLE_BOOTSTRAP_SNIP_SH}" ] && . mulle-bootstrap-snip.sh
2695
+
2703 2696
          force_rebuild "${OPTION_FROM}" "${OPTION_TO}"
2704 2697
       fi
2705 2698
    fi
... ...
@@ -180,6 +180,8 @@ print_stashdir_embedded_repositories()
180 180
 
181 181
 setup_clean_environment()
182 182
 {
183
+   log_debug "setup_clean_environment" "$@"
184
+
183 185
    build_complete_environment
184 186
 
185 187
    [ -z "${DEPENDENCIES_DIR}"  ]   && internal_fail "DEPENDENCIES_DIR is empty"
... ...
@@ -190,6 +192,30 @@ setup_clean_environment()
190 192
    CLEAN_EMPTY_PARENTS="`read_config_setting "clean_empty_parent_folders" "YES"`"
191 193
 
192 194
 
195
+   if [ $# -ne 0 ]
196
+   then
197
+      case "${style}" in
198
+         cruft|build)
199
+         ;;
200
+
201
+         *)
202
+            fail "You can only give repository names to cruft and build clean styles"
203
+         ;;
204
+      esac
205
+
206
+      local i
207
+
208
+      CRUFT_CLEANABLE_SUBDIRS="${DEPENDENCIES_DIR}/tmp"
209
+      for i in "$@"
210
+      do
211
+         CRUFT_CLEANABLE_SUBDIRS="`add_line "${CRUFT_CLEANABLE_SUBDIRS}" "${CLONESBUILD_DIR}/${i}"`"
212
+         FORCE_REBUILDS="`concat "${FORCE_REBUILDS}" "${i}"`"
213
+      done
214
+
215
+      return 0
216
+   fi
217
+
218
+
193 219
    CRUFT_CLEANABLE_SUBDIRS="`read_sane_config_path_setting "clean_folders" "${CLONESBUILD_DIR}
194 220
 ${DEPENDENCIES_DIR}/tmp"`"
195 221
 
... ...
@@ -240,6 +266,8 @@ ${BOOTSTRAP_DIR}.auto"`"
240 266
 
241 267
 clean_asserted_folder()
242 268
 {
269
+   log_debug "clean_asserted_folder" "$@"
270
+
243 271
    if [ -d "$1" ]
244 272
    then
245 273
       log_info "Deleting \"$1\""
... ...
@@ -253,6 +281,8 @@ clean_asserted_folder()
253 281
 
254 282
 clean_asserted_file()
255 283
 {
284
+   log_debug "clean_asserted_file" "$@"
285
+
256 286
    if [ -f "$1" ]
257 287
    then
258 288
       log_info "Deleting \"$1\""
... ...
@@ -266,14 +296,16 @@ clean_asserted_file()
266 296
 
267 297
 clean_parent_folders_if_empty()
268 298
 {
269
-   local dir="$1"
299
+   log_debug "clean_parent_folders_if_empty" "$@"
300
+
301
+   local directory="$1"
270 302
    local stop="$2"
271 303
 
272 304
    if [ "${CLEAN_EMPTY_PARENTS}" = "YES" ]
273 305
    then
274 306
       local parent
275 307
 
276
-      parent="${dir}"
308
+      parent="${directory}"
277 309
       while :
278 310
       do
279 311
          parent="`dirname -- "${parent}"`"
... ...
@@ -296,17 +328,19 @@ clean_parent_folders_if_empty()
296 328
 
297 329
 clean_files()
298 330
 {
331
+   log_debug "clean_files" "$@"
332
+
299 333
    local files="$1"
300 334
 
301
-   local file
335
+   local filename
302 336
 
303 337
    IFS="
304 338
 "
305
-   for file in ${files}
339
+   for filename in ${files}
306 340
    do
307 341
       IFS="${DEFAULT_IFS}"
308 342
 
309
-      clean_asserted_file "${file}"
343
+      clean_asserted_file "${filename}"
310 344
    done
311 345
 
312 346
    IFS="${DEFAULT_IFS}"
... ...
@@ -315,6 +349,8 @@ clean_files()
315 349
 
316 350
 clean_directories()
317 351
 {
352
+   log_debug "clean_directories" "$@"
353
+
318 354
    local directories="$1"
319 355
 
320 356
    local directory
... ...
@@ -342,9 +378,21 @@ clean_directories()
342 378
 #
343 379
 clean_execute()
344 380
 {
345
-   local style="$1"
381
+   log_debug "clean_execute" "$@"
346 382
 
347
-   setup_clean_environment
383
+   local style="$1"; shift
384
+
385
+   setup_clean_environment "$@"
386
+
387
+   if [ ! -z "${FORCE_REBUILDS}" ]
388
+   then
389
+      [ -z "${MULLE_BOOTSTRAP_SNIP_SH}" ] && . mulle-bootstrap-snip.sh
390
+
391
+      for i in ${FORCE_REBUILDS}
392
+      do
393
+         force_rebuild "$i"
394
+      done
395
+   fi
348 396
 
349 397
    # CRUFT
350 398
    case "${style}" in
... ...
@@ -404,6 +452,8 @@ clean_execute()
404 452
 #
405 453
 clean_minion()
406 454
 {
455
+   log_debug "clean_minion" "$@"
456
+
407 457
    local minion="$1"
408 458
 
409 459
    local directories
... ...
@@ -428,6 +478,7 @@ clean_main()
428 478
    local ROOT_DIR="`pwd -P`"
429 479
 
430 480
    local MINION_NAME
481
+   local NAME
431 482
 
432 483
    [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ]        && . mulle-bootstrap-settings.sh
433 484
    [ -z "${MULLE_BOOTSTRAP_COMMON_SETTINGS_SH}" ] && . mulle-bootstrap-common-settings.sh
... ...
@@ -442,7 +493,6 @@ clean_main()
442 493
             clean_usage
443 494
          ;;
444 495
 
445
-
446 496
          -m|--minion)
447 497
             shift
448 498
             [ $# -ne 0 ] || clean_usage
... ...
@@ -466,12 +516,13 @@ clean_main()
466 516
    local style
467 517
 
468 518
    style=${1:-"full"}
519
+   [ $# -ne 0 ] && shift
469 520
 
470 521
    case "${style}" in
471 522
       "cruft"|"build"|"output"|"full"|"dist"|"install"|"output")
472 523
          if [ -z "${MINION_NAME}" ]
473 524
          then
474
-            clean_execute "${style}"
525
+            clean_execute "${style}" "$@"
475 526
          else
476 527
             clean_minion "${MINION_NAME}"
477 528
          fi
... ...
@@ -482,8 +533,7 @@ clean_main()
482 533
       ;;
483 534
 
484 535
       *)
485
-         log_error "Unknown clean style \"${style}\""
486
-         clean_usage
536
+         clean_execute "build" "${style}" "$@"
487 537
       ;;
488 538
    esac
489 539
 }
... ...
@@ -36,9 +36,16 @@ init_usage()
36 36
 {
37 37
     cat <<EOF >&2
38 38
 Usage:
39
-  ${MULLE_EXECUTABLE} init [options]
39
+   ${MULLE_EXECUTABLE} init [options] [directory]
40 40
 
41
-Options
41
+   Prepare current directory for mulle-bootstrap. (Analog to git init)
42
+   You can specify a directory, otherwise the current directory is used.
43
+
44
+   mulle-bootstap -s init -n
45
+
46
+   is the usual favorite.
47
+
48
+Options:
42 49
    -d : create default files
43 50
    -n : don't ask for editor
44 51
 
... ...
@@ -122,7 +129,7 @@ init_main()
122 129
             MULLE_FLAG_ANSWER="NO"
123 130
          ;;
124 131
 
125
-         -d)
132
+         --default-files|-d)
126 133
             OPTION_CREATE_DEFAULT_FILES="YES"
127 134
          ;;
128 135
 
... ...
@@ -140,6 +147,17 @@ init_main()
140 147
       shift
141 148
    done
142 149
 
150
+   if [ $# -eq 1 ]
151
+   then
152
+      local directory="$1"; shift
153
+
154
+      if [ ! -d "${directory}" ]
155
+      then
156
+         mkdir_if_missing "${directory}" || exit 1
157
+      fi
158
+      cd "${directory}" || fail "Failed to enter directory \"${directory}\""
159
+   fi
160
+
143 161
    if [ -d "${BOOTSTRAP_DIR}" ]
144 162
    then
145 163
       fail "\"${BOOTSTRAP_DIR}\" already exists"
... ...
@@ -138,6 +138,49 @@ snip_from_to_file()
138 138
 }
139 139
 
140 140
 
141
+# keep until "to" but excluding it
142
+# cut stuff until "to"
143
+# keep "to" and keep rest
144
+
145
+force_rebuild()
146
+{
147
+   log_debug "force_rebuild" "$*"
148
+
149
+   local from="$1"
150
+   local to="$2"
151
+
152
+   remove_file_if_present "${REPOS_DIR}/.build_started"
153
+
154
+   # if nothing's build yet, fine with us
155
+   if [ ! -f "${REPOS_DIR}/.build_done" ]
156
+   then
157
+      log_fluff "Nothing has been built yet"
158
+      return
159
+   fi
160
+
161
+   if [ -z "${from}" -a -z "${to}" ]
162
+   then
163
+      remove_file_if_present "${REPOS_DIR}/.build_done"
164
+      return
165
+   fi
166
+
167
+   #
168
+   # keep entries above parameter
169
+   # os x doesn't have 'Q'
170
+   # also q and i doesn't work on OS X <sigh>
171
+   #
172
+   local tmpfile
173
+
174
+   tmpfile="`exekutor mktemp "mulle-bootstrap.XXXXXXXX"`" || exit 1
175
+
176
+   redirect_exekutor "${tmpfile}" snip_from_to_file "${from}" "${to}" "${REPOS_DIR}/.build_done"
177
+   exekutor mv "${tmpfile}" "${REPOS_DIR}/.build_done"
178
+
179
+   log_debug ".build_done=`cat "${REPOS_DIR}/.build_done"`"
180
+}
181
+
182
+
183
+
141 184
 snip_initialize()
142 185
 {
143 186
    log_debug ":snip_initialize:"
144 187
new file mode 100755
... ...
@@ -0,0 +1,89 @@
1
+#! /usr/bin/env bash
2
+
3
+clear_test_dirs()
4
+{
5
+   local i
6
+
7
+   for i in "$@"
8
+   do
9
+      if [ -d "$i" ]
10
+      then
11
+         rm -rf "$i"
12
+      fi
13
+   done
14
+}
15
+
16
+
17
+fail()
18
+{
19
+   echo "failed" "$@" >&2
20
+   exit 1
21
+}
22
+
23
+
24
+run_mulle_bootstrap()
25
+{
26
+   echo "####################################" >&2
27
+   echo mulle-bootstrap "$@"  >&2
28
+   echo "####################################" >&2
29
+
30
+   mulle-bootstrap "$@" || fail "mulle-bootstrap failed"
31
+}
32
+
33
+
34
+#
35
+#
36
+#
37
+create_demo_dir()
38
+{
39
+   local directory
40
+
41
+   directory="$1"
42
+   shift
43
+
44
+   mkdir "${directory}"
45
+
46
+   local name
47
+
48
+   while [ $# -ne 0 ]
49
+   do
50
+      name="$1"
51
+      shift
52
+
53
+      echo "${directory}/${name}" > "${directory}/${name}"
54
+   done
55
+}
56
+
57
+expect_file()
58
+{
59
+   local  value
60
+
61
+   [ -f "$1" ] || fail "expected file $1 is missing"
62
+
63
+   value="`cat "$1" 2> /dev/null`"
64
+   [ "${value}" != "${2}" ] && fail "${2} expected, ${value} found"
65
+}
66
+
67
+
68
+test_copy()
69
+{
70
+   clear_test_dirs a
71
+
72
+   run_mulle_bootstrap -s init -n a
73
+
74
+   mkdir "a/.bootstrap/b.build/"
75
+
76
+   echo "-DX=a -DY=B" > a/.bootstrap/b.build/CMAKEFLAGS
77
+
78
+
79
+   ( cd a ; run_mulle_bootstrap fetch )
80
+
81
+   expect_file "a/.bootstrap.auto/b.build/CMAKEFLAGS" "-DX=a -DY=B"
82
+
83
+   clear_test_dirs a
84
+}
85
+
86
+
87
+test_copy
88
+
89
+echo "Test passed" >&2