Browse code

improve code for supporting MINGW soon

Nat! authored on 20/08/2016 19:36:29
Showing 11 changed files
... ...
@@ -9,6 +9,7 @@ gems, mulle-bootstrap can now claim to do only project relative installs.
9 9
  `$(DEPENDENCIES_DIR)` setting. Admittedly an experimental hack. But the old
10 10
  more proper way, didn't work with cmake generated xcode projects.
11 11
 * reorganized repository structure a bit
12
+* You can now specify ALL (always YES) or NONE (always NO) at the y/n prompt.
12 13
 
13 14
 
14 15
 1.1
... ...
@@ -22,6 +23,7 @@ gems, mulle-bootstrap can now claim to do only project relative installs.
22 22
 * Fix help screen for refresh and update
23 23
 * Don't complain if there are no dependencies generated
24 24
 
25
+
25 26
 1.0
26 27
 ===
27 28
 
... ...
@@ -59,8 +59,9 @@ check_and_usage_and_help()
59 59
       defkk=""
60 60
    fi
61 61
 
62
-   cat <<EOF
63
-usage: build [-ck] [repos]*
62
+   cat <<EOF >&2
63
+usage:
64
+   mulle-bootstrap build [-ck] [repos]*
64 65
 
65 66
    -k         :  don't clean before building $defk
66 67
    -K         :  always clean before building $defkk
... ...
@@ -449,11 +450,14 @@ create_dummy_dirs_against_warnings()
449 449
    # to avoid warnings, make sure directories are all there
450 450
    mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}/${HEADER_DIR_NAME}"
451 451
 
452
-   mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${mappedsubdir}/${LIBRARY_DIR_NAME}"
453
-   mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${mappedsubdir}/${FRAMEWORK_DIR_NAME}"
452
+   mkdir_if_missing "${owd}/${REFERENCE_ADDICTION_SUBDIR}${mappedsubdir}/${LIBRARY_DIR_NAME}"
453
+   mkdir_if_missing "${owd}/${REFERENCE_ADDICTION_SUBDIR}${mappedsubdir}/${FRAMEWORK_DIR_NAME}"
454 454
 
455 455
    mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${suffixsubdir}/${LIBRARY_DIR_NAME}"
456 456
    mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${suffixsubdir}/${FRAMEWORK_DIR_NAME}"
457
+
458
+   mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${mappedsubdir}/${LIBRARY_DIR_NAME}"
459
+   mkdir_if_missing "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${mappedsubdir}/${FRAMEWORK_DIR_NAME}"
457 460
 }
458 461
 
459 462
 
... ...
@@ -500,6 +504,61 @@ build_log_name()
500 500
 }
501 501
 
502 502
 
503
+find_binary()
504
+{
505
+   local toolname
506
+   toolname="$1"
507
+
508
+   local path
509
+   path=`which_binary "${toolname}"`
510
+   if [ -z "${path}" ]
511
+   then
512
+      log_warning "${toolname} is an unknown build tool"
513
+      return 1
514
+   fi
515
+   echo "$path"
516
+}
517
+
518
+
519
+find_cmake()
520
+{
521
+   local toolname
522
+
523
+   toolname=`read_config_setting "cmake" "cmake"`
524
+   find_binary "${toolname}"
525
+}
526
+
527
+
528
+find_xcodebuild()
529
+{
530
+   local toolname
531
+
532
+   toolname=`read_config_setting "xcodebuild" "xcodebuild"`
533
+   find_binary "${toolname}"
534
+}
535
+
536
+
537
+
538
+find_make()
539
+{
540
+   local default_toolname
541
+   local toolname
542
+
543
+   case "`uname`" in
544
+      MINGW*)
545
+         default_toolname="nmake"
546
+         ;;
547
+
548
+      *)
549
+         default_toolname="make"
550
+         ;;
551
+   esac
552
+
553
+   toolname=`read_config_setting "make" "${default_toolname}"`
554
+   find_binary "${toolname}"
555
+}
556
+
557
+
503 558
 #
504 559
 # remove old builddir, create a new one
505 560
 # depending on configuration cmake with flags
... ...
@@ -521,6 +580,15 @@ build_cmake()
521 521
 
522 522
    enforce_build_sanity "${builddir}"
523 523
 
524
+   if [ -z "${CMAKE}" ]
525
+   then
526
+      fail "No cmake available"
527
+   fi
528
+   if [ -z "${MAKE}" ]
529
+   then
530
+      fail "No make available"
531
+   fi
532
+
524 533
    log_info "Let ${C_RESET_BOLD}cmake${C_INFO} do a \
525 534
 ${C_MAGENTA}${C_BOLD}${configuration}${C_INFO} build of \
526 535
 ${C_MAGENTA}${C_BOLD}${name}${C_INFO} for SDK \
... ...
@@ -554,6 +622,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
554 554
    local other_cppflags
555 555
    local other_ldflags
556 556
 
557
+
557 558
    other_cflags="`gcc_cflags_value "${name}"`"
558 559
    other_cppflags="`gcc_cppflags_value "${name}"`"
559 560
    other_ldflags="`gcc_ldflags_value "${name}"`"
... ...
@@ -630,7 +699,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
630 630
 
631 631
       relative_srcdir="`relative_path_between "${owd}/${srcdir}" "${PWD}"`"
632 632
 
633
-      logging_exekutor cmake "-DCMAKE_BUILD_TYPE=${mapped}" \
633
+      logging_exekutor "${CMAKE}" -G "${CMAKE_GENERATOR}" "-DCMAKE_BUILD_TYPE=${mapped}" \
634 634
 "${sdkparameter}" \
635 635
 "-DDEPENDENCIES_DIR=${owd}/${REFERENCE_DEPENDENCY_SUBDIR}" \
636 636
 "-DCMAKE_INSTALL_PREFIX:PATH=${owd}/${BUILD_DEPENDENCY_SUBDIR}"  \
... ...
@@ -668,7 +737,7 @@ ${localcmakeflags} \
668 668
          local_make_flags="${local_make_flags} VERBOSE=1"
669 669
       fi
670 670
 
671
-      logging_exekutor make ${local_make_flags} install > "${logfile2}" || build_fail "${logfile2}" "make"
671
+      logging_exekutor "${MAKE}" ${MAKE_FLAGS} ${local_make_flags} install > "${logfile2}" || build_fail "${logfile2}" "make"
672 672
 
673 673
       set +f
674 674
 
... ...
@@ -701,6 +770,11 @@ build_configure()
701 701
    name="$4"
702 702
    sdk="$5"
703 703
 
704
+   if [ -z "${MAKE}" ]
705
+   then
706
+      fail "No make available"
707
+   fi
708
+
704 709
    enforce_build_sanity "${builddir}"
705 710
 
706 711
    log_info "Let ${C_RESET_BOLD}configure${C_INFO} do a \
... ...
@@ -829,8 +903,8 @@ ${other_ldflags} \
829 829
           --prefix "${owd}/${BUILD_DEPENDENCY_SUBDIR}" >> "${logfile1}" \
830 830
       || build_fail "${logfile1}" "configure"
831 831
 
832
-      logging_exekutor make install > "${logfile2}" \
833
-      || build_fail "${logfile2}" "make"
832
+      logging_exekutor "${MAKE}" ${MAKE_FLAGS} install > "${logfile2}" \
833
+      || build_fail "${logfile2}" "${MAKE}"
834 834
 
835 835
       set +f
836 836
 
... ...
@@ -978,6 +1052,8 @@ build_xcodebuild()
978 978
 
979 979
    enforce_build_sanity "${builddir}"
980 980
 
981
+   toolname=`read_config_setting "xcodebuild" "xcodebuild"`
982
+
981 983
    local info
982 984
 
983 985
    info=""
... ...
@@ -991,7 +1067,7 @@ build_xcodebuild()
991 991
       info=" Scheme ${C_MAGENTA}${C_BOLD}${schemename}${C_INFO}"
992 992
    fi
993 993
 
994
-   log_info "Let ${C_RESET_BOLD}xcodebuild${C_INFO} do a \
994
+   log_info "Let ${C_RESET_BOLD}${toolname}${C_INFO} do a \
995 995
 ${C_MAGENTA}${C_BOLD}${configuration}${C_INFO} build of \
996 996
 ${C_MAGENTA}${C_BOLD}${name}${C_INFO} for SDK \
997 997
 ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
... ...
@@ -1044,16 +1120,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1044 1044
       skip_install="SKIP_INSTALL=NO"
1045 1045
    fi
1046 1046
 
1047
-   local xcodebuild
1048
-   local binary
1049
-
1050
-   xcodebuild=`read_config_setting "xcodebuild" "xcodebuild"`
1051
-   binary=`which "${xcodebuild}"`
1052
-   if [ "${binary}"  = "" ]
1053
-   then
1054
-      echo "${xcodebuild} is an unknown build tool" >& 2
1055
-      exit 1
1056
-   fi
1047
+   local toolname
1057 1048
 
1058 1049
 
1059 1050
    #
... ...
@@ -1061,7 +1128,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1061 1061
    # xcodebuild can just use a target
1062 1062
    # xctool is by and large useless fluff IMO
1063 1063
    #
1064
-   if [ "$xcodebuild" = "xctool"  -a "${schemename}" = ""  ]
1064
+   if [ "${toolname}" = "xctool"  -a "${schemename}" = ""  ]
1065 1065
    then
1066 1066
       if [ "$targetname" != "" ]
1067 1067
       then
... ...
@@ -1118,7 +1185,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1118 1118
 
1119 1119
    mkdir_if_missing "${BUILDLOG_SUBDIR}"
1120 1120
 
1121
-   logfile="`build_log_name "xcodebuild" "${name}" "${configuration}" "${targetname}" "${schemename}" "${sdk}"`"
1121
+   logfile="`build_log_name "${toolname}" "${name}" "${configuration}" "${targetname}" "${schemename}" "${sdk}"`"
1122 1122
    log_fluff "Build log will be in: ${C_RESET_BOLD}${logfile}${C_INFO}"
1123 1123
 
1124 1124
    set -f
... ...
@@ -1260,7 +1327,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1260 1260
       fi
1261 1261
 
1262 1262
       # if it doesn't install, probably SKIP_INSTALL is set
1263
-      cmdline="\"${xcodebuild}\" \"${command}\" ${arguments} \
1263
+      cmdline="\"${XCODEBUILD}\" \"${command}\" ${arguments} \
1264 1264
 ARCHS='${ARCHS:-\${ARCHS_STANDARD_32_64_BIT\}}' \
1265 1265
 DSTROOT='${owd}/${BUILD_DEPENDENCY_SUBDIR}' \
1266 1266
 SYMROOT='${owd}/${builddir}/' \
... ...
@@ -1272,12 +1339,13 @@ ${skip_install} \
1272 1272
 ${other_cflags} \
1273 1273
 ${other_cppflags} \
1274 1274
 ${other_ldflags} \
1275
+${XCODEBUILD_FLAGS} \
1275 1276
 HEADER_SEARCH_PATHS='${dependencies_header_search_path}' \
1276 1277
 LIBRARY_SEARCH_PATHS='${dependencies_lib_search_path}' \
1277 1278
 FRAMEWORK_SEARCH_PATHS='${dependencies_framework_search_path}'"
1278 1279
 
1279 1280
       logging_eval_exekutor "${cmdline}" > "${logfile}" \
1280
-      || build_fail "${logfile}" "xcodebuild"
1281
+      || build_fail "${logfile}" "${toolname}"
1281 1282
 
1282 1283
       set +f
1283 1284
 
... ...
@@ -1465,27 +1533,26 @@ build()
1465 1465
    # repo may override how it wants to be build
1466 1466
    #
1467 1467
    preferences="`read_build_setting "${name}" "build_preferences"`"
1468
+
1468 1469
    if [ -z "${preferences}" ]
1469 1470
    then
1470
-      if [ "`uname`" = 'Darwin' ]
1471
-      then
1472
-         preferences="`read_config_setting "build_preferences" "script
1471
+      case "`uname`" in
1472
+         Darwin)
1473
+            preferences="`read_config_setting "build_preferences" "script
1473 1474
 cmake
1474 1475
 configure
1475 1476
 xcodebuild"`"
1476
-      else
1477
-         preferences="`read_config_setting "build_preferences" "script
1477
+         ;;
1478
+
1479
+
1480
+         *)
1481
+            preferences="`read_config_setting "build_preferences" "script
1478 1482
 cmake
1479 1483
 configure"`"
1480
-      fi
1484
+         ;;
1485
+      esac
1481 1486
    fi
1482 1487
 
1483
-   local xcodebuild
1484
-   local cmake
1485
-
1486
-   xcodebuild=`which "xcodebuild"`
1487
-   cmake=`which "cmake"`
1488
-
1489 1488
    local sdk
1490 1489
    local sdks
1491 1490
 
... ...
@@ -1493,6 +1560,26 @@ configure"`"
1493 1493
    sdks=`read_build_root_setting "sdks" "Default"`
1494 1494
    [ ! -z "${sdks}" ] || fail "setting \"sdks\" must at least contain \"Default\" to build anything"
1495 1495
 
1496
+   MAKE="`find_make`"
1497
+   CMAKE="`find_cmake`"
1498
+
1499
+   case "`uname`" in
1500
+      MINGW*)
1501
+         CMAKE_FLAGS="${CMAKE_FLAGS} -G \\\"NMake Makefiles\\\""
1502
+         CMAKE_GENERATOR="`read_build_setting "${name}" "cmake_generator" "NMake Makefiles"`"
1503
+         ;;
1504
+
1505
+      Darwin)
1506
+         XCODEBUILD="`find_xcodebuild`"
1507
+         CMAKE_GENERATOR="`read_build_setting "${name}" "cmake_generator" "Unix Makefiles"`"
1508
+         ;;
1509
+
1510
+      *)
1511
+         CMAKE_GENERATOR="`read_build_setting "${name}" "cmake_generator" "Unix Makefiles"`"
1512
+         ;;
1513
+   esac
1514
+
1515
+
1496 1516
    local builddir
1497 1517
    local hasbuilt
1498 1518
    local configuration
... ...
@@ -1557,7 +1644,7 @@ configure"`"
1557 1557
                fi
1558 1558
             fi
1559 1559
 
1560
-            if [ "${preference}" = "xcodebuild" -a -x "${xcodebuild}" ]
1560
+            if [ "${preference}" = "xcodebuild" -a -x "${XCODEBUILD}" ]
1561 1561
             then
1562 1562
                project=`(cd "${srcdir}" ; find_xcodeproj "${name}")`
1563 1563
 
... ...
@@ -1569,18 +1656,23 @@ configure"`"
1569 1569
                fi
1570 1570
             fi
1571 1571
 
1572
-            if [ "${preference}" = "configure"  ]
1572
+            if [ "${preference}" = "configure" ]
1573 1573
             then
1574
-               if [ ! -f "${srcdir}/configure"  ]
1574
+               if [ ! -f "${srcdir}/configure" ]
1575 1575
                then
1576 1576
                   # try for autogen if installed (not coded yet)
1577 1577
                   :
1578 1578
                fi
1579 1579
                if [ -x "${srcdir}/configure" ]
1580 1580
                then
1581
-                  build_configure "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}"  || exit 1
1582
-                  hasbuilt=yes
1583
-                  break
1581
+                  if [ ! -x "${MAKE}" ]
1582
+                  then
1583
+                     log_warning "Found a configure, but make is not installed"
1584
+                  else
1585
+                     build_configure "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}"  || exit 1
1586
+                     hasbuilt=yes
1587
+                     break
1588
+                  fi
1584 1589
                fi
1585 1590
             fi
1586 1591
 
... ...
@@ -1588,7 +1680,7 @@ configure"`"
1588 1588
             then
1589 1589
                if [ -f "${srcdir}/CMakeLists.txt" ]
1590 1590
                then
1591
-                  if [ ! -x "${cmake}" ]
1591
+                  if [ ! -x "${CMAKE}" ]
1592 1592
                   then
1593 1593
                      log_warning "Found a CMakeLists.txt, but cmake is not installed"
1594 1594
                   else
... ...
@@ -86,8 +86,9 @@ fi
86 86
 
87 87
 usage()
88 88
 {
89
-   cat <<EOF
90
-clean [build|dist|install|output]
89
+   cat <<EOF >&2
90
+usage:
91
+   mulle-bootstrap clean [build|dist|install|output]
91 92
 
92 93
    build   : useful to remove intermediate build files. it cleans
93 94
 ---
... ...
@@ -44,8 +44,9 @@
44 44
 
45 45
 usage()
46 46
 {
47
-   cat <<EOF
48
-usage: fetch [-f] <install|nonrecursive|update>
47
+   cat <<EOF >&2
48
+usage:
49
+   mulle-bootstrap fetch [-f] <install|nonrecursive|update>
49 50
    -f           : override dirty harry check
50 51
 
51 52
    install      : clone or symlink non-exisiting repositories and other resources
... ...
@@ -428,11 +429,11 @@ ask_symlink_it()
428 428
          local prompt
429 429
 
430 430
          prompt="Should ${clone} be symlinked instead of cloned ?
431
-You usually say NO to this."
431
+NO is safe, but you often say YES here."
432 432
 
433 433
          if [ ! -z "${tag}" ]
434 434
          then
435
-            prompt="${prompt} (Even more so, since tag is set as ${tag})"
435
+            prompt="${prompt} (Since tag ${tag} is set, NO is more reasonable)"
436 436
          fi
437 437
 
438 438
          user_say_yes "$prompt"
... ...
@@ -608,9 +608,20 @@ user_say_yes()
608 608
   do
609 609
      printf "${C_WARNING}%b${C_RESET} (y/${C_GREEN}N${C_RESET}) > " "$*" >&2
610 610
      read x
611
-     x=`echo "${x}" | tr '[:lower:]' '[:upper:]'`
611
+     x=`echo "${x}" | tr '[a-z]' '[A-Z]'`
612 612
   done
613 613
 
614
+  if [ "${x}" = "ALL" ]
615
+  then
616
+     MULLE_BOOTSTRAP_ANSWER="YES"
617
+     x="YES"
618
+  fi
619
+  if [ "${x}" = "NONE" ]
620
+  then
621
+     MULLE_BOOTSTRAP_ANSWER="NO"
622
+     x="NO"
623
+  fi
624
+
614 625
   [ "$x" = "Y" -o "$x" = "YES" ]
615 626
   return $?
616 627
 }
... ...
@@ -916,17 +927,22 @@ ensure_clones_directory()
916 916
 
917 917
 ensure_consistency()
918 918
 {
919
+   local owd
920
+
921
+   owd="`pwd -P`"
922
+
919 923
    if [ -f "${CLONESFETCH_SUBDIR}/.fetch_update_started" ]
920 924
    then
921 925
       log_error "A previous fetch or update was incomplete.
922
-Suggested resolution (in $PWD):
926
+Suggested resolution (in $owd):
923 927
     ${C_RESET_BOLD}mulle-bootstrap clean dist${C_ERROR}
924 928
     ${C_RESET_BOLD}mulle-bootstrap${C_ERROR}
925 929
 
926 930
 Or do you feel lucky ?
927
-   ${C_RESET_BOLD}rm ${CLONESFETCH_SUBDIR}/.fetch_update_started${C_ERROR}
931
+   ${C_RESET_BOLD}rm $owd/${CLONESFETCH_SUBDIR}/.fetch_update_started${C_ERROR}
928 932
 and try again. But you've gotta ask yourself one question: Do I feel lucky ?
929
-Well, do ya, punk? "
933
+Well, do ya, punk?
934
+(Same difference: if you are in \"${owd}\", ${C_RESET_BOLD}mulle-bootstrap fetch -f{C_ERROR})"
930 935
       exit 1
931 936
    fi
932 937
 }
... ...
@@ -959,4 +975,18 @@ append_dir_to_gitignore_if_needed()
959 959
 }
960 960
 
961 961
 
962
+which_binary()
963
+{
964
+   local toolname
965
+
966
+   toolname="$1"
967
+   case "`uname`" in
968
+      MINGW*)
969
+         toolname="${toolname}.exe"
970
+         ;;
971
+   esac
972
+
973
+   which "${toolname}" 2> /dev/null
974
+}
975
+
962 976
 ## 962: getting close to 1000 here
963 977
\ No newline at end of file
... ...
@@ -37,7 +37,8 @@
37 37
 #
38 38
 if [ "$1" = "-h" -o "$1" = "--help" ]
39 39
 then
40
-   echo "usage: init" >&2
40
+   echo "usage:
41
+  mulle_bootstrap init" >&2
41 42
    exit 1
42 43
 fi
43 44
 
... ...
@@ -195,8 +196,7 @@ EOF
195 195
 
196 196
   fi
197 197
 
198
-  log_info "\"${BOOTSTRAP_SUBDIR}${C_INFO} folder has been set up.
199
-Now add your repositories to \"${BOOTSTRAP_SUBDIR}/repositories${C_INFO}"
198
+  log_info "\"${BOOTSTRAP_SUBDIR}\" folder has been set up."
200 199
 
201 200
   local open
202 201
 
... ...
@@ -41,8 +41,9 @@ N_CONFIGURATIONS="`echo "${CONFIGURATIONS}" | wc -l | awk '{ print $1 }'`"
41 41
 
42 42
 check_and_usage_and_help()
43 43
 {
44
-   cat <<EOF
45
-usage: install [libraryprefix] [frameworkprefix]
44
+   cat <<EOF >&2
45
+usage:
46
+   mulle-bootstrap install [libraryprefix] [frameworkprefix]
46 47
 
47 48
    You may need to run this as sudo.
48 49
    The default libraryprefix is ${DEFAULT_PREFIX}
... ...
@@ -43,8 +43,9 @@ name=`basename -- "${PWD}"`
43 43
 
44 44
 usage()
45 45
 {
46
-   cat <<EOF
47
-usage: project <clone|build|install> <options>
46
+   cat <<EOF >&2
47
+usage:
48
+   mulle-bootstrap project <clone|build|install> <options>
48 49
 
49 50
    clone   : clone a remote git repoistory and try to build something
50 51
    build   : execute ./build.sh, if missing do a mulle-bootstrap build
... ...
@@ -41,8 +41,10 @@
41 41
 
42 42
 usage()
43 43
 {
44
-   cat <<EOF
45
-usage: <refresh|nonrecursive>
44
+   cat <<EOF >&2
45
+usage:
46
+   mulle-bootstrap <refresh|nonrecursive>
47
+
46 48
    refresh      : update settings, remove unused repositories (default)
47 49
    nonrecursive : ignore .bootstrap folders of fetched repositories
48 50
 EOF
... ...
@@ -41,8 +41,9 @@
41 41
 
42 42
 usage()
43 43
 {
44
-   cat <<EOF
45
-usage: tag [-f] <tag>
44
+   cat <<EOF >&2
45
+usage:
46
+   mulle-bootstrap tag [-f] <tag>
46 47
 
47 48
    -d           : delete tag
48 49
    -f           : force tag
... ...
@@ -43,8 +43,9 @@ fi
43 43
 
44 44
 usage()
45 45
 {
46
-   cat <<EOF
47
-xcode <add|remove> [xcodeproj]
46
+   cat <<EOF >&2
47
+usage:
48
+   mulle-bootstrap xcode <add|remove> [xcodeproj]
48 49
 
49 50
    add      : add settings to Xcode project (default)
50 51
    remove   : remove settings from Xcode project