Browse code

Improve copying of build output to dependencies. Improve paths output

Nat! authored on 04-05-2017 12:07:30
Showing 6 changed files
... ...
@@ -1,3 +1,11 @@
1
+## 3.6
2
+
3
+* Improved the dependencies copying routing. Now also copies `share` `sbin`
4
+`bin` `libexec` and picks up more possible output directories. `sbin` and `bin`
5
+will me merged into `dependencies/bin`.
6
+* Improve path construction, omitting empty components
7
+* Don't output superflous linefeed with paths
8
+
1 9
 ### 3.5.4
2 10
 
3 11
 * fix brews not being installed
... ...
@@ -30,8 +30,8 @@
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 #
32 32
 MULLE_EXECUTABLE_VERSION_MAJOR=3
33
-MULLE_EXECUTABLE_VERSION_MINOR=5
34
-MULLE_EXECUTABLE_VERSION_PATCH=5
33
+MULLE_EXECUTABLE_VERSION_MINOR=6
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
 
... ...
@@ -240,31 +240,28 @@ tools_environment_cmake()
240 240
 # where we expect them. Expect  others to build to
241 241
 # <prefix>/include  and <prefix>/lib or <prefix>/Frameworks
242 242
 #
243
-dispense_headers()
243
+dispense_files()
244 244
 {
245
-   local name
246
-   local src
247
-
248
-   name="$1"
249
-   src="$2"
245
+   local src="$1"
246
+   local name="$2"
247
+   local ftype="$3"
248
+   local dirpath="$4"
250 249
 
251 250
    local dst
252
-   local headerpath
253 251
 
254
-   log_fluff "Consider copying headers from \"${src}\""
252
+   log_fluff "Consider copying ${ftype} from \"${src}\""
255 253
 
256 254
    if [ -d "${src}" ]
257 255
    then
258 256
       if dir_has_files "${src}"
259 257
       then
260
-         headerpath="`read_build_setting "${name}" "dispense_headers_path" "/${HEADER_DIR_NAME}"`"
261 258
 
262
-         dst="${REFERENCE_DEPENDENCIES_DIR}${headerpath}"
259
+         dst="${REFERENCE_DEPENDENCIES_DIR}${dirpath}"
263 260
          mkdir_if_missing "${dst}"
264 261
 
265 262
          # this fails with more nested header set ups, need to fix!
266 263
 
267
-         log_fluff "Copying headers from \"${src}\" to \"${dst}\""
264
+         log_fluff "Copying ${ftype} from \"${src}\" to \"${dst}\""
268 265
          exekutor cp -Ra ${COPYMOVEFLAGS} "${src}"/* "${dst}" >&2 || exit 1
269 266
 
270 267
          rmdir_safer "${src}"
... ...
@@ -277,7 +274,73 @@ dispense_headers()
277 274
 }
278 275
 
279 276
 
280
-dispense_binaries()
277
+dispense_headers()
278
+{
279
+   local sources="$1"
280
+   local name="$2"
281
+
282
+   local headerpath
283
+
284
+   headerpath="`read_build_setting "$1" "dispense_headers_path" "/${HEADER_DIR_NAME}"`"
285
+
286
+   local src
287
+   IFS="
288
+"
289
+   for src in $sources
290
+   do
291
+      IFS="${DEFAULT_IFS}"
292
+
293
+      dispense_files "${src}" "${name}" "headers" "${headerpath}"
294
+   done
295
+   IFS="${DEFAULT_IFS}"
296
+}
297
+
298
+
299
+dispense_resources()
300
+{
301
+   local sources="$1"
302
+   local name="$2"
303
+
304
+   local resourcepath
305
+
306
+   resourcepath="`read_build_setting "$1" "dispense_resources_path" "/${RESOURCE_DIR_NAME}"`"
307
+
308
+   local src
309
+   IFS="
310
+"
311
+   for src in $sources
312
+   do
313
+      IFS="${DEFAULT_IFS}"
314
+
315
+      dispense_files "${src}" "${name}" "resources" "${resourcepath}"
316
+   done
317
+   IFS="${DEFAULT_IFS}"
318
+}
319
+
320
+
321
+dispense_libexec()
322
+{
323
+   local sources="$1"
324
+   local name="$2"
325
+
326
+   local libexecpath
327
+
328
+   libexecpath="`read_build_setting "$1" "dispense_resources_path" "/${LIBEXEC_DIR_NAME}"`"
329
+
330
+   local src
331
+   IFS="
332
+"
333
+   for src in $sources
334
+   do
335
+      IFS="${DEFAULT_IFS}"
336
+
337
+      dispense_files "${src}" "${name}" "libexec" "${libexecpath}"
338
+   done
339
+   IFS="${DEFAULT_IFS}"
340
+}
341
+
342
+
343
+_dispense_binaries()
281 344
 {
282 345
    local name
283 346
    local src
... ...
@@ -285,8 +348,8 @@ dispense_binaries()
285 348
    local depend_subdir
286 349
    local subpath
287 350
 
288
-   name="$1"
289
-   src="$2"
351
+   src="$1"
352
+   name="$2"
290 353
    findtype="$3"
291 354
    depend_subdir="$4"
292 355
    subpath="$5"
... ...
@@ -309,7 +372,7 @@ dispense_binaries()
309 372
       then
310 373
          dst="${REFERENCE_DEPENDENCIES_DIR}${depend_subdir}${subpath}"
311 374
 
312
-         log_fluff "Copying binaries from \"${src}\" to \"${dst}\""
375
+         log_fluff "Moving binaries from \"${src}\" to \"${dst}\""
313 376
          mkdir_if_missing "${dst}"
314 377
          exekutor find "${src}" -xdev -mindepth 1 -maxdepth 1 \( -type "${findtype}" -o -type "${findtype2}" \) -print0 | \
315 378
             exekutor xargs -0 -I % mulle-bootstrap-mv-force.sh ${COPYMOVEFLAGS} "${copyflag}" % "${dst}" >&2
... ...
@@ -324,17 +387,31 @@ dispense_binaries()
324 387
 }
325 388
 
326 389
 
390
+dispense_binaries()
391
+{
392
+   local sources="$1" ; shift
393
+
394
+   local src
395
+   IFS="
396
+"
397
+   for src in $sources
398
+   do
399
+      IFS="${DEFAULT_IFS}"
400
+
401
+      _dispense_binaries "${src}" "$@"
402
+   done
403
+   IFS="${DEFAULT_IFS}"
404
+}
405
+
406
+
327 407
 collect_and_dispense_product()
328 408
 {
329
-   local  name
330
-   local  build_subdir
331
-   local  depend_subdir
332
-   local  name
409
+   log_debug "collect_and_dispense_product" "$@"
333 410
 
334
-   name="$1"
335
-   build_subdir="$2"
336
-   depend_subdir="$3"
337
-   wasxcode="$4"
411
+   local name="$1"
412
+   local build_subdir="$2"
413
+   local depend_subdir="$3"
414
+   local wasxcode="$4"
338 415
 
339 416
    local  dst
340 417
    local  src
... ...
@@ -347,50 +424,93 @@ collect_and_dispense_product()
347 424
 
348 425
    log_verbose "Collecting and dispensing \"${name}\" products"
349 426
 
427
+   if [ "${MULLE_FLAG_LOG_DEBUG}" = "YES"  ]
428
+   then
429
+      log_debug "Contents of BUILD_DEPENDENCIES_DIR:"
430
+
431
+      ls -lRa ${BUILD_DEPENDENCIES_DIR} >&2
432
+   fi
433
+
434
+   [ -z "${LIBRARY_DIR_NAME}" ]     && internal_fail "LIBRARY_DIR_NAME undefined"
435
+   [ -z "${LIBEXEC_DIR_NAME}" ]     && internal_fail "LIBEXEC_DIR_NAME undefined"
436
+   [ -z "${BIN_DIR_NAME}" ]         && internal_fail "BIN_DIR_NAME undefined"
437
+   [ -z "${FRAMEWORK_DIR_NAME}" ]   && internal_fail "FRAMEWORK_DIR_NAME undefined"
438
+   [ -z "${RESOURCE_DIR_NAME}" ]    && internal_fail "LIBRARY_DIR_NAME undefined"
439
+   [ -z "${HEADER_DIR_NAME}" ]      && internal_fail "LIBRARY_DIR_NAME undefined"
440
+
350 441
    #
351 442
    # probably should use install_name_tool to hack all dylib paths that contain .ref
352 443
    # (will this work with signing stuff ?)
353 444
    #
354 445
    if true
355 446
    then
356
-      log_fluff "Choosing xcode dispense path"
357
-
358
-      # cmake
359
-
360
-      src="${BUILD_DEPENDENCIES_DIR}/usr/local/include"
361
-      dispense_headers "${name}" "${src}"
362
-
363
-      src="${BUILD_DEPENDENCIES_DIR}/usr/local/lib"
364
-      dispense_binaries "${name}" "${src}" "f" "${depend_subdir}" "/${LIBRARY_DIR_NAME}"
365
-
366
-      # pretty much xcodetool specific
367
-
368
-      src="${BUILD_DEPENDENCIES_DIR}/usr/include"
369
-      dispense_headers "${name}" "${src}"
370
-
371
-      src="${BUILD_DEPENDENCIES_DIR}/include"
372
-      dispense_headers "${name}" "${src}"
373
-
374
-      src="${BUILD_DEPENDENCIES_DIR}${build_subdir}/lib"
375
-      dispense_binaries "${name}" "${src}" "f" "${depend_subdir}" "/${LIBRARY_DIR_NAME}"
376
-
377
-      src="${BUILD_DEPENDENCIES_DIR}${build_subdir}/Library/Frameworks"
378
-      dispense_binaries "${name}" "${src}" "d" "${depend_subdir}" "/${FRAMEWORK_DIR_NAME}"
379
-
380
-      src="${BUILD_DEPENDENCIES_DIR}${build_subdir}/Frameworks"
381
-      dispense_binaries "${name}" "${src}" "d" "${depend_subdir}" "/${FRAMEWORK_DIR_NAME}"
382
-
383
-      src="${BUILD_DEPENDENCIES_DIR}${build_subdir}/Library/Frameworks"
384
-      dispense_binaries "${name}" "${src}" "d" "${depend_subdir}" "/${FRAMEWORK_DIR_NAME}"
385
-
386
-      src="${BUILD_DEPENDENCIES_DIR}${build_subdir}/Frameworks"
387
-      dispense_binaries "${name}" "${src}" "d" "${depend_subdir}" "/${FRAMEWORK_DIR_NAME}"
388
-
389
-      src="${BUILD_DEPENDENCIES_DIR}/Library/Frameworks"
390
-      dispense_binaries "${name}" "${src}" "d"  "${depend_subdir}" "/${FRAMEWORK_DIR_NAME}"
391
-
392
-      src="${BUILD_DEPENDENCIES_DIR}/Frameworks"
393
-      dispense_binaries "${name}" "${src}" "d" "${depend_subdir}" "/${FRAMEWORK_DIR_NAME}"
447
+      local sources
448
+      ##
449
+      ## copy lib
450
+      ## TODO: isn't cmake's output directory also platform specific ?
451
+      ##
452
+      sources="${BUILD_DEPENDENCIES_DIR}${build_subdir}/lib
453
+${BUILD_DEPENDENCIES_DIR}/usr/local/lib
454
+${BUILD_DEPENDENCIES_DIR}/usr/lib
455
+${BUILD_DEPENDENCIES_DIR}/lib"
456
+
457
+      dispense_binaries "${sources}" "${name}" "f" "${depend_subdir}" "/${LIBRARY_DIR_NAME}"
458
+
459
+      ##
460
+      ## copy libexec
461
+      ##
462
+      sources="${BUILD_DEPENDENCIES_DIR}${build_subdir}/libexec
463
+${BUILD_DEPENDENCIES_DIR}/usr/local/libexec
464
+${BUILD_DEPENDENCIES_DIR}/usr/libexec
465
+${BUILD_DEPENDENCIES_DIR}/libexec"
466
+
467
+      dispense_libexec "${sources}" "${name}"
468
+
469
+
470
+      ##
471
+      ## copy resources
472
+      ##
473
+      sources="${BUILD_DEPENDENCIES_DIR}${build_subdir}/share
474
+${BUILD_DEPENDENCIES_DIR}/usr/local/share
475
+${BUILD_DEPENDENCIES_DIR}/usr/share
476
+${BUILD_DEPENDENCIES_DIR}/share"
477
+
478
+      dispense_resources "${sources}" "${name}"
479
+
480
+      ##
481
+      ## copy headers
482
+      ##
483
+      sources="${BUILD_DEPENDENCIES_DIR}${build_subdir}/include
484
+${BUILD_DEPENDENCIES_DIR}/usr/local/include
485
+${BUILD_DEPENDENCIES_DIR}/usr/include
486
+${BUILD_DEPENDENCIES_DIR}/include"
487
+
488
+      dispense_headers  "${sources}" "${name}"
489
+
490
+
491
+      ##
492
+      ## copy bin and sbin
493
+      ##
494
+      sources="${BUILD_DEPENDENCIES_DIR}${build_subdir}/bin
495
+${BUILD_DEPENDENCIES_DIR}/usr/local/bin
496
+${BUILD_DEPENDENCIES_DIR}/usr/bin
497
+${BUILD_DEPENDENCIES_DIR}/bin
498
+${BUILD_DEPENDENCIES_DIR}${build_subdir}/sbin
499
+${BUILD_DEPENDENCIES_DIR}/usr/local/sbin
500
+${BUILD_DEPENDENCIES_DIR}/usr/sbin
501
+${BUILD_DEPENDENCIES_DIR}/sbin"
502
+
503
+      dispense_binaries "${sources}" "${name}" "f" "${depend_subdir}" "/${BIN_DIR_NAME}"
504
+
505
+      ##
506
+      ## copy frameworks
507
+      ##
508
+      sources="${BUILD_DEPENDENCIES_DIR}${build_subdir}/Library/Frameworks
509
+${BUILD_DEPENDENCIES_DIR}${build_subdir}/Frameworks
510
+${BUILD_DEPENDENCIES_DIR}/Library/Frameworks
511
+${BUILD_DEPENDENCIES_DIR}/Frameworks"
512
+
513
+      dispense_binaries "${sources}" "${name}" "d" "${depend_subdir}" "/${FRAMEWORK_DIR_NAME}"
394 514
    fi
395 515
 
396 516
    #
... ...
@@ -476,17 +596,15 @@ enforce_build_sanity()
476 596
 
477 597
 determine_suffix()
478 598
 {
479
-   local configuration
480
-   local sdk
481
-   local suffix
482
-   local hackish
483
-
484
-   configuration="$1"
485
-   sdk="$2"
599
+   local configuration="$1"
600
+   local sdk="$2"
486 601
 
487 602
    [ ! -z "$configuration" ] || fail "configuration must not be empty"
488 603
    [ ! -z "$sdk" ]           || fail "sdk must not be empty"
489 604
 
605
+   local suffix
606
+   local hackish
607
+
490 608
    suffix="${configuration}"
491 609
    if [ "${sdk}" != "Default" ]
492 610
    then
... ...
@@ -522,9 +640,7 @@ determine_dependencies_subdir()
522 640
 
523 641
 cmake_sdk_parameter()
524 642
 {
525
-   local sdk
526
-
527
-   sdk="$1"
643
+   local sdk="$1"
528 644
 
529 645
    local sdkpath
530 646
 
... ...
@@ -745,12 +861,16 @@ _build_flags()
745 861
 
746 862
 build_unix_flags()
747 863
 {
864
+   log_debug "build_unix_flags" "$*"
865
+
748 866
    _build_flags "$@"
749 867
 }
750 868
 
751 869
 
752 870
 build_cmake_flags()
753 871
 {
872
+   log_debug "build_cmake_flags" "$*"
873
+
754 874
    (
755 875
       PATH_SEPARATOR=";"
756 876
       _build_flags "$@"
... ...
@@ -105,9 +105,17 @@ common_settings_initialize()
105 105
    #
106 106
    # Global Settings
107 107
    # used to be configurable, but just slows me down
108
-   HEADER_DIR_NAME="include"
109
-   LIBRARY_DIR_NAME="lib"
110
-   FRAMEWORK_DIR_NAME="Frameworks"
108
+   #
109
+   case "${UNAME}" in
110
+      *)
111
+         FRAMEWORK_DIR_NAME="Frameworks"
112
+         HEADER_DIR_NAME="include"
113
+         LIBRARY_DIR_NAME="lib"
114
+         LIBEXEC_DIR_NAME="libexec"
115
+         RESOURCE_DIR_NAME="share"
116
+         BIN_DIR_NAME="bin"
117
+      ;;
118
+   esac
111 119
 
112 120
    # HEADER_DIR_NAME="`read_config_setting "header_dir_name" "include"`"
113 121
    # LIBRARY_DIR_NAME="`read_config_setting "library_dir_name" "lib"`"
... ...
@@ -443,7 +443,12 @@ add_path()
443 443
    then
444 444
       echo "${path}"
445 445
    else
446
-      echo "${line}${PATH_SEPARATOR}${path}"
446
+      if [ -z "${path}" ]
447
+      then
448
+         echo "${line}"
449
+      else
450
+         echo "${line}${PATH_SEPARATOR}${path}"
451
+      fi
447 452
    fi
448 453
 }
449 454
 
... ...
@@ -477,7 +482,12 @@ add_component()
477 482
    then
478 483
       echo "${component}"
479 484
    else
480
-      echo "${filepath}${COMPONENT_SEPARATOR}${component}"
485
+      if [ -z "${component}" ]
486
+      then
487
+         echo "${filepath}"
488
+      else
489
+         echo "${filepath}${COMPONENT_SEPARATOR}${component}"
490
+      fi
481 491
    fi
482 492
 }
483 493
 
... ...
@@ -459,11 +459,13 @@ _flags_do_path()
459 459
 
460 460
    local values
461 461
    local line
462
+   local tmppath
462 463
 
463 464
    values="`_flags_binpath_value`"
464 465
    if [ ! -z "${values}" ]
465 466
    then
466
-      line="PATH=${OPTION_QUOTE}${values}:${PATH}${OPTION_QUOTE}"
467
+      tmppath="`add_path "${values}" "${PATH}"`"
468
+      line="PATH=${OPTION_QUOTE}${tmppath}${OPTION_QUOTE}"
467 469
       result="`add_line "${result}" "${line}"`"
468 470
    fi
469 471
 
... ...
@@ -503,7 +505,7 @@ _flags_do_make_environment()
503 505
    values="`_flags_binpath_value`"
504 506
    if [ ! -z "${values}" ]
505 507
    then
506
-      line="PATH=${OPTION_QUOTE}${values}:${PATH}${OPTION_QUOTE}"
508
+      result="`_flags_do_path`"
507 509
       result="`add_line "${result}" "${line}"`"
508 510
    fi
509 511
 
... ...
@@ -559,7 +561,7 @@ _flags_do_run_environment()
559 561
    values="`_flags_binpath_value`"
560 562
    if [ ! -z "${values}" ]
561 563
    then
562
-      line="PATH=${OPTION_QUOTE}${values}:${PATH}${OPTION_QUOTE}"
564
+      result="`_flags_do_path`"
563 565
       result="`add_line "${result}" "${line}"`"
564 566
    fi
565 567
 
... ...
@@ -792,7 +794,6 @@ paths_main()
792 794
       if [ "${OPTION_LINE_SEPERATOR}" = " " ]
793 795
       then
794 796
          printf "%s" "${result}" | tr '\012' ' '  | sed 's/ *$//'
795
-         printf "\n"
796 797
       else
797 798
          printf "%s\n" "${result}"
798 799
       fi