Browse code

improvements in /usr/local treatment. Bugfixes of recently introduced of bootstrap_auto_update regresssions. Simplify build code a little bit

Nat! authored on 24-09-2016 17:35:40
Showing 11 changed files
... ...
@@ -1,4 +1,4 @@
1
-# mulle-bootstrap, cross platform dependency manager using bash and cmake
1
+# mulle-bootstrap, cross platform dependency manager using bash
2 2
 
3 3
 ... for Linux, OS X, FreeBSD, Windows
4 4
 
... ...
@@ -81,6 +81,9 @@ libraries into the `dependencies/lib`  and `dependencies/include` folders.
81 81
 * [mulle-bootstrap: Understanding mulle-bootstrap (I)](https://www.mulle-kybernetik.com/weblog/2016/mulle_bootstrap_how_it_works.html)
82 82
 * [mulle-bootstrap: Understanding mulle-bootstrap (II), Recursion](https://www.mulle-kybernetik.com/weblog/2016/mulle_bootstrap_recursion.html)
83 83
 
84
+If you want to hack on mulle-bootstrap, I'd recommend to get
85
+[Sublime Text](//www.sublimetext.com) and [install the linter plugin](//blog.codybunch.com/2016/01/25/Better-Bash-with-Sublime-Linter-and-ShellCheck/) to use [Shellcheck](//www.shellcheck.net). It
86
+simplifies shell scripting by an order of magnitude.
84 87
 
85 88
 ## GitHub and Mulle kybernetiK
86 89
 
... ...
@@ -1,6 +1,13 @@
1 1
 2.1
2 2
 ===
3 3
 
4
+This version has some additions, that enable a more flexible use of
5
+embedded repositories to "compose" source trees. It also now contains
6
+better fecth and build code, so that dependencies, that are installed in
7
+/usr/local already need not be fetched again. This can be helpful, when used
8
+to build brew packages (for example).
9
+
10
+
4 11
 **The changes should be transparent, but to be safe `mulle-bootstrap dist clean`
5 12
 your projects**
6 13
 
... ...
@@ -9,9 +16,11 @@ your projects**
9 16
 project tree
10 17
 * changes in deeply embedded repositories are now better tracked
11 18
 * fixed some as of yet unknown bugs, by improving some path functions
12
-* resurrected the clone command for **mulle-aba**
13
-* new --ignore-system switch to ignore /usr/local check for system libraries
14
-conveniently from the command line.
19
+* new -c switch to enable checking /usr/local/include for dependency libraries
20
+conveniently from the command line. Fix build to add /usr/local/include to
21
+build, if check_usr_local_include is YES.
22
+* allow build and fetch options to be passed to `bootstrap`
23
+
15 24
 
16 25
 2.0.1
17 26
 ===
... ...
@@ -180,7 +180,7 @@ Setting Name                      |  Description
180 180
 `absolute_symlinks`               | Use absolute symlinks instead of relatives    | NO
181 181
 `symlink_forbidden`               | mulle-bootstrap will not attempt to symlink   | NO (ignored on MINGW)
182 182
 `update_gitignore`                | add cleanable directories to .gitignore       | YES
183
-`check_usr_local_include`         | do not install, if a system header of same    |
183
+`check_usr_local_include`         | do not fetch, if a system header of same      |
184 184
                                   | is present in `/usr/local/include`            | NO
185 185
 
186 186
 Build Config Settings
... ...
@@ -25,7 +25,7 @@ fi
25 25
 
26 26
 fail()
27 27
 {
28
-   echo "${BOLD_RED}$*${C_RESET}" >&2
28
+   echo "${C_BR_RED}$*${C_RESET}" >&2
29 29
    exit 1
30 30
 }
31 31
 
... ...
@@ -119,7 +119,7 @@ get_sh_windows_path()
119 119
    local directory
120 120
 
121 121
    directory="`which sh`"
122
-   directory="`dirname -- "${directory}"`" 
122
+   directory="`dirname -- "${directory}"`"
123 123
    directory="`get_windows_path "${directory}"`"
124 124
 
125 125
    if [ -z "${directory}" ]
... ...
@@ -132,7 +132,7 @@ get_sh_windows_path()
132 132
 
133 133
 sed_mangle_escape_slashes()
134 134
 {
135
-   sed -e 's|/|\\\\|g'  
135
+   sed -e 's|/|\\\\|g'
136 136
 }
137 137
 
138 138
 
... ...
@@ -120,41 +120,24 @@ bootstrap_nomagic_main()
120 120
    . mulle-bootstrap-build.sh
121 121
    . mulle-bootstrap-warn-scripts.sh
122 122
 
123
-   if [ "${DONT_RECURSE}" = "" ]
123
+   # used for option handling only
124
+   MULLE_BOOTSTRAP_WILL_BUILD="YES"
125
+
126
+   if [ -z "${DONT_RECURSE}" ]
124 127
    then
125 128
       fetch_main "$@" || exit 1
126 129
       refresh_main    || exit 1
127
-  else
130
+   else
128 131
       fetch_main --non-recursive "$@" || exit 1
129 132
       refresh_main nonrecursive       || exit 1
130 133
    fi
131 134
 
132 135
    warn_scripts_main "${BOOTSTRAP_SUBDIR}" || exit 1
133 136
 
134
-   # do it again now!
135
-   build_main "$@" || exit 1
136
-}
137
-
138
-
139
-clone_main()
140
-{
141
-   local url
142
-
143
-   url="$1"
144
-   [ $# -ne 0 ] && shift
137
+   # used for option handling only
138
+   MULLE_BOOTSTRAP_DID_FETCH="YES"
145 139
 
146
-   name="`basename -- "${url}"`"
147
-   name="`basename -- "${name}" .git`"
148
-
149
-   if [ ! -e "${name}" ]
150
-   then
151
-      git clone ${GITFLAGS} "${url}" "${name}" || exit 1
152
-   else
153
-      log_info "Directory ${name} already exists."
154
-   fi
155
-
156
-   ( cd "${name}"; refresh_main ) || exit 1
157
-   ( cd "${name}"; bootstrap_nomagic_main "$@" ) || exit 1
140
+   build_main "$@" || exit 1
158 141
 }
159 142
 
160 143
 
... ...
@@ -393,7 +376,7 @@ bootstrap_main()
393 376
             refresh_main refresh_if_bare || exit 1
394 377
          ;;
395 378
 
396
-         update|refresh|clone)
379
+         update|refresh)
397 380
            . mulle-bootstrap-refresh.sh
398 381
 
399 382
            # 4 laters
... ...
@@ -402,10 +385,6 @@ bootstrap_main()
402 385
    fi
403 386
 
404 387
    case "${command}" in
405
-      clone)
406
-         clone_main "$@"
407
-      ;;
408
-
409 388
       bootstrap|nomagic)
410 389
          bootstrap_nomagic_main "${command}" "$@"
411 390
       ;;
... ...
@@ -165,7 +165,7 @@ bootstrap_auto_update_repo_settings()
165 165
 
166 166
 
167 167
 #
168
-# return 0, if nothing changed
168
+# return 0, if something changed
169 169
 #
170 170
 bootstrap_auto_update()
171 171
 {
... ...
@@ -189,7 +189,7 @@ bootstrap_auto_update()
189 189
    if [ ! -d "${directory}/.bootstrap" ] # -a ! -L "${dst}" ]
190 190
    then
191 191
       log_fluff "No .bootstrap folder in \"${directory}\" found"
192
-      return 0
192
+      return 1
193 193
    fi
194 194
 
195 195
    log_verbose "Updating .bootstrap.auto with ${directory}"
... ...
@@ -204,7 +204,7 @@ bootstrap_auto_update()
204 204
    bootstrap_auto_update_repo_settings "${directory}"
205 205
 
206 206
    log_fluff "Acquisiton of \"${name}\" complete"
207
-   return 1
207
+   return 0
208 208
 }
209 209
 
210 210
 #
... ...
@@ -753,13 +753,10 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
753 753
 #   then
754 754
 #      rmdir_safer "${builddir}"
755 755
 #   fi
756
-
757 756
    mkdir_if_missing "${builddir}"
758 757
    exekutor cd "${builddir}" || fail "failed to enter ${builddir}"
759 758
 
760
-      #
761
-      # cmake doesn't seem to "get" CMAKE_CXX_FLAGS or -INCLUDE
762
-      #
759
+      # DONT READ CONFIG SETTING IN THIS INDENT
763 760
       set -f
764 761
 
765 762
       logfile1="${owd}/${logfile1}"
... ...
@@ -811,6 +808,12 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
811 808
       frameworklines="`add_path "${frameworklines}" "${nativewd}/${REFERENCE_DEPENDENCY_SUBDIR}/${FRAMEWORK_DIR_NAME}"`"
812 809
       frameworklines="`add_path "${frameworklines}" "${nativewd}/${REFERENCE_ADDICTION_SUBDIR}/${FRAMEWORK_DIR_NAME}"`"
813 810
 
811
+      if [ "${CHECK_USR_LOCAL_INCLUDE}" = "YES" ]
812
+      then
813
+         includelines="`add_path "${includelines}" "${USR_LOCAL_INCLUDE}"`"
814
+         librarylines="`add_path "${librarylines}" "${USR_LOCAL_LIB}"`"
815
+      fi
816
+
814 817
       local relative_srcdir
815 818
       local prefixbuild
816 819
       local dependenciesdir
... ...
@@ -1019,6 +1022,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
1019 1022
    mkdir_if_missing "${builddir}"
1020 1023
    exekutor cd "${builddir}" || fail "failed to enter ${builddir}"
1021 1024
 
1025
+      # DONT READ CONFIG SETTING IN THIS INDENT
1022 1026
        set -f
1023 1027
 
1024 1028
       logfile1="${owd}/${logfile1}"
... ...
@@ -1070,6 +1074,12 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
1070 1074
       frameworklines="`add_path "${frameworklines}" "${nativewd}/${REFERENCE_DEPENDENCY_SUBDIR}/${FRAMEWORK_DIR_NAME}"`"
1071 1075
       frameworklines="`add_path "${frameworklines}" "${nativewd}/${REFERENCE_ADDICTION_SUBDIR}/${FRAMEWORK_DIR_NAME}"`"
1072 1076
 
1077
+      if [ "${CHECK_USR_LOCAL_INCLUDE}" = "YES" ]
1078
+      then
1079
+         includelines="`add_path "${includelines}" "${USR_LOCAL_INCLUDE}"`"
1080
+         librarylines="`add_path "${librarylines}" "${USR_LOCAL_LIB}"`"
1081
+      fi
1082
+
1073 1083
       local prefixbuild
1074 1084
       local dependenciesdir
1075 1085
       #local linker
... ...
@@ -1088,7 +1098,6 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
1088 1098
          ;;
1089 1099
       esac
1090 1100
 
1091
-
1092 1101
       # assemble -I /I and -L /LIBPATH:
1093 1102
 
1094 1103
       local memo
... ...
@@ -1360,7 +1369,6 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1360 1369
 
1361 1370
    local toolname
1362 1371
 
1363
-
1364 1372
    #
1365 1373
    # xctool needs schemes, these are often autocreated, which xctool cant do
1366 1374
    # xcodebuild can just use a target
... ...
@@ -1404,10 +1412,10 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1404 1412
       command=install
1405 1413
    fi
1406 1414
 
1407
-      #
1408
-      # headers are complicated, the preference is to get it uniform into
1409
-      # dependencies/include/libraryname/..
1410
-      #
1415
+   #
1416
+   # headers are complicated, the preference is to get it uniform into
1417
+   # dependencies/include/libraryname/..
1418
+   #
1411 1419
 
1412 1420
    local public_headers
1413 1421
    local private_headers
... ...
@@ -1480,11 +1488,10 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1480 1488
       other_ldflags="OTHER_LDFLAGS=${other_ldflags}"
1481 1489
    fi
1482 1490
 
1483
-
1484 1491
    owd=`pwd`
1485 1492
    exekutor cd "${srcdir}" || exit 1
1486 1493
 
1487
-
1494
+      # DONT READ CONFIG SETTING IN THIS INDENT
1488 1495
       logfile="${owd}/${logfile}"
1489 1496
 
1490 1497
       if [ "${MULLE_BOOTSTRAP_VERBOSE_BUILD}" = "YES" ]
... ...
@@ -1537,6 +1544,12 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1537 1544
          dependencies_lib_search_path="${path} ${inherited}"
1538 1545
       fi
1539 1546
 
1547
+      if [ "${CHECK_USR_LOCAL_INCLUDE}" = "YES" ]
1548
+      then
1549
+         dependencies_header_search_path="${path} ${USR_LOCAL_INCLUDE}"
1550
+         dependencies_lib_search_path="${path} ${USR_LOCAL_LIB}"
1551
+      fi
1552
+
1540 1553
       inherited="`xcode_get_setting FRAMEWORK_SEARCH_PATHS ${arguments}`" || exit 1
1541 1554
       path=`combined_escaped_search_path \
1542 1555
 "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}${mappedsubdir}/${FRAMEWORK_DIR_NAME}" \
... ...
@@ -1698,9 +1711,6 @@ build_script()
1698 1711
    local builddir
1699 1712
    local name
1700 1713
    local sdk
1701
-   local project
1702
-   local schemename
1703
-   local targetname
1704 1714
 
1705 1715
    configuration="$1"
1706 1716
    srcdir="$2"
... ...
@@ -1708,6 +1718,9 @@ build_script()
1708 1718
    name="$4"
1709 1719
    sdk="$5"
1710 1720
 
1721
+   local project
1722
+   local schemename
1723
+   local targetname
1711 1724
    local logfile
1712 1725
 
1713 1726
    mkdir_if_missing "${BUILDLOG_SUBDIR}"
... ...
@@ -1770,6 +1783,122 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1770 1783
 }
1771 1784
 
1772 1785
 
1786
+build_with_configuration_sdk_preferences()
1787
+{
1788
+   local name
1789
+   local configuration
1790
+   local sdk
1791
+   local preferences
1792
+
1793
+   name="$1"
1794
+   [ $# -ne 0 ] && shift
1795
+   configuration="$1"
1796
+   [ $# -ne 0 ] && shift
1797
+   sdk="$1"
1798
+   [ $# -ne 0 ] && shift
1799
+   preferences="$1"
1800
+   [ $# -ne 0 ] && shift
1801
+
1802
+   if [ "/${configuration}" = "/${LIBRARY_DIR_NAME}" -o "/${configuration}" = "${HEADER_DIR_NAME}" -o "/${configuration}" = "${FRAMEWORK_DIR_NAME}" ]
1803
+   then
1804
+      fail "You are just asking for trouble naming your configuration \"${configuration}\"."
1805
+   fi
1806
+
1807
+   if [ "${configuration}" = "lib" -o "${configuration}" = "include" -o "${configuration}" = "Frameworks" ]
1808
+   then
1809
+      fail "You are just asking for major trouble naming your configuration \"${configuration}\"."
1810
+   fi
1811
+
1812
+   local builddir
1813
+
1814
+   builddir="${CLONESBUILD_SUBDIR}/${configuration}/${name}"
1815
+
1816
+   if [ -d "${builddir}" -a "${CLEAN_BEFORE_BUILD}" = "YES" ]
1817
+   then
1818
+      log_fluff "Cleaning build directory \"${builddir}\""
1819
+      rmdir_safer "${builddir}"
1820
+   fi
1821
+
1822
+   #
1823
+   # execute pre-build script (f.e. for libcurl)
1824
+   #
1825
+   local script
1826
+
1827
+   script="`find_build_setting_file "${name}" "bin/pre-build.sh"`"
1828
+   if [ -x "${script}" ]
1829
+   then
1830
+      build_script "${script}" "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}" || exit 1
1831
+   fi
1832
+
1833
+   local project
1834
+
1835
+   for preference in ${preferences}
1836
+   do
1837
+      case "${preference}" in
1838
+         script)
1839
+            script="`find_build_setting_file "${name}" "bin/build.sh"`"
1840
+            if [ -x "${script}" ]
1841
+            then
1842
+               build_script "${script}" "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}" || exit 1
1843
+               return 0
1844
+            else
1845
+               [ ! -e "${script}" ] || fail "script ${script} is not executable"
1846
+            fi
1847
+         ;;
1848
+
1849
+         xcodebuild)
1850
+            if [ ! -z "${XCODEBUILD}" ]
1851
+            then
1852
+               project=`(cd "${srcdir}" ; find_xcodeproj "${name}")`
1853
+
1854
+               if [ ! -z "$project" ]
1855
+               then
1856
+                  build_xcodebuild_schemes_or_target "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}" "${project}"  || exit 1
1857
+                  return 0
1858
+               fi
1859
+            fi
1860
+         ;;
1861
+
1862
+         configure)
1863
+            if [ ! -f "${srcdir}/configure" ]
1864
+            then
1865
+               # try for autogen if installed (not coded yet)
1866
+               :
1867
+            fi
1868
+            if [ -x "${srcdir}/configure" ]
1869
+            then
1870
+               if [ -z "${MAKE}" ]
1871
+               then
1872
+                  log_warning "Found a configure, but make is not installed"
1873
+               else
1874
+                  build_configure "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}"  || exit 1
1875
+                  return 0
1876
+               fi
1877
+            fi
1878
+         ;;
1879
+
1880
+         cmake)
1881
+            if [ -f "${srcdir}/CMakeLists.txt" ]
1882
+            then
1883
+               if [ -z "${CMAKE}" ]
1884
+               then
1885
+                  log_warning "Found a CMakeLists.txt, but cmake is not installed"
1886
+               else
1887
+                  build_cmake "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}"  || exit 1
1888
+                  return 0
1889
+               fi
1890
+            fi
1891
+         ;;
1892
+
1893
+         *)
1894
+            fail "unknown build preference $1"
1895
+         ;;
1896
+      esac
1897
+   done
1898
+
1899
+   return 1
1900
+}
1901
+
1773 1902
 
1774 1903
 build()
1775 1904
 {
... ...
@@ -1813,20 +1942,15 @@ configure"`"
1813 1942
       esac
1814 1943
    fi
1815 1944
 
1816
-   local sdk
1945
+   local configurations
1946
+   local configuration
1817 1947
    local sdks
1948
+   local sdk
1818 1949
 
1819 1950
    # need uniform SDK for our builds
1820 1951
    sdks=`read_build_root_setting "sdks" "Default"`
1821 1952
    [ ! -z "${sdks}" ] || fail "setting \"sdks\" must at least contain \"Default\" to build anything"
1822 1953
 
1823
-
1824
-   local builddir
1825
-   local hasbuilt
1826
-   local configuration
1827
-   local preference
1828
-   local configurations
1829
-
1830 1954
    # settings can override the commandline default
1831 1955
    configurations="`read_repo_setting "${name}" "configurations" "${CONFIGURATIONS}"`"
1832 1956
 
... ...
@@ -1840,100 +1964,8 @@ configure"`"
1840 1964
 
1841 1965
       for configuration in ${configurations}
1842 1966
       do
1843
-         if [ "/${configuration}" = "/${LIBRARY_DIR_NAME}" -o "/${configuration}" = "${HEADER_DIR_NAME}" -o "/${configuration}" = "${FRAMEWORK_DIR_NAME}" ]
1844
-         then
1845
-            fail "You are just asking for trouble naming your configuration \"${configuration}\"."
1846
-         fi
1847
-
1848
-         if [ "${configuration}" = "lib" -o "${configuration}" = "include" -o "${configuration}" = "Frameworks" ]
1849
-         then
1850
-            fail "You are just asking for major trouble naming your configuration \"${configuration}\"."
1851
-         fi
1852
-
1853
-         builddir="${CLONESBUILD_SUBDIR}/${configuration}/${name}"
1854
-
1855
-         if [ -d "${builddir}" -a "${CLEAN_BEFORE_BUILD}" = "YES" ]
1856
-         then
1857
-            log_fluff "Cleaning build directory \"${builddir}\""
1858
-            rmdir_safer "${builddir}"
1859
-         fi
1860
-
1861
-         #
1862
-         # execute pre-build script (f.e. for libcurl)
1863
-         #
1864
-         local script
1865
-
1866
-         script="`find_build_setting_file "${name}" "bin/pre-build.sh"`"
1867
-         if [ -x "${script}" ]
1868
-         then
1869
-            build_script "${script}" "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}" || exit 1
1870
-         fi
1871
-
1872
-         hasbuilt=no
1873
-         for preference in ${preferences}
1874
-         do
1875
-            if [ "${preference}" = "script" ]
1876
-            then
1877
-               script="`find_build_setting_file "${name}" "bin/build.sh"`"
1878
-               if [ -x "${script}" ]
1879
-               then
1880
-                  build_script "${script}" "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}" || exit 1
1881
-                  hasbuilt=yes
1882
-                  break
1883
-               else
1884
-                  [ ! -e "${script}" ] || fail "script ${script} is not executable"
1885
-               fi
1886
-            fi
1887
-
1888
-            if [ "${preference}" = "xcodebuild" -a ! -z "${XCODEBUILD}" ]
1889
-            then
1890
-               project=`(cd "${srcdir}" ; find_xcodeproj "${name}")`
1891
-
1892
-               if [ "$project" != "" ]
1893
-               then
1894
-                  build_xcodebuild_schemes_or_target "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}" "${project}"  || exit 1
1895
-                  hasbuilt=yes
1896
-                  break
1897
-               fi
1898
-            fi
1899
-
1900
-            if [ "${preference}" = "configure" ]
1901
-            then
1902
-               if [ ! -f "${srcdir}/configure" ]
1903
-               then
1904
-                  # try for autogen if installed (not coded yet)
1905
-                  :
1906
-               fi
1907
-               if [ -x "${srcdir}/configure" ]
1908
-               then
1909
-                  if [ -z "${MAKE}" ]
1910
-                  then
1911
-                     log_warning "Found a configure, but make is not installed"
1912
-                  else
1913
-                     build_configure "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}"  || exit 1
1914
-                     hasbuilt=yes
1915
-                     break
1916
-                  fi
1917
-               fi
1918
-            fi
1919
-
1920
-            if [ "${preference}" = "cmake" ]
1921
-            then
1922
-               if [ -f "${srcdir}/CMakeLists.txt" ]
1923
-               then
1924
-                  if [ -z "${CMAKE}" ]
1925
-                  then
1926
-                     log_warning "Found a CMakeLists.txt, but cmake is not installed"
1927
-                  else
1928
-                     build_cmake "${configuration}" "${srcdir}" "${builddir}" "${name}" "${sdk}"  || exit 1
1929
-                     hasbuilt=yes
1930
-                     break
1931
-                  fi
1932
-               fi
1933
-            fi
1934
-         done
1935
-
1936
-         if [ "$hasbuilt" != "yes" ]
1967
+         build_with_configuration_sdk_preferences "${name}" "${configuration}" "${sdk}" "${preferences}"
1968
+         if [ $? -ne 0 ]
1937 1969
          then
1938 1970
             fail "Don't know how to build ${name}"
1939 1971
          fi
... ...
@@ -2175,22 +2207,26 @@ build_main()
2175 2207
 
2176 2208
    [ -z "${MULLE_BOOTSTRAP_BUILD_ENVIRONMENT_SH}" ] && . mulle-bootstrap-build-environment.sh
2177 2209
 
2210
+   #
2211
+   # it is useful, that fetch understands build options and
2212
+   # ignores them
2213
+   #
2178 2214
    while [ $# -ne 0 ]
2179 2215
    do
2180 2216
       case "$1" in
2181
-         -K)
2217
+         -K|--clean)
2182 2218
             CLEAN_BEFORE_BUILD="YES"
2183 2219
          ;;
2184 2220
 
2185
-         -k)
2221
+         -k|--no-clean)
2186 2222
             CLEAN_BEFORE_BUILD=
2187 2223
          ;;
2188 2224
 
2189
-         -f)
2225
+         -f|--force)
2190 2226
             MULLE_BOOTSTRAP_DIRTY_HARRY="NO"
2191 2227
          ;;
2192 2228
 
2193
-         -j)
2229
+         -j|--cores)
2194 2230
             case "${UNAME}" in
2195 2231
                mingw)
2196 2232
                   build_usage
... ...
@@ -2203,13 +2239,22 @@ build_main()
2203 2239
             CORES="$1"
2204 2240
             ;;
2205 2241
 
2206
-         -c)
2242
+         -c|--configuration)
2207 2243
             shift
2208 2244
             [ $# -ne 0 ] || fail "configuration names missing"
2209 2245
 
2210 2246
             CONFIGURATIONS="`printf "%s" "$1" | tr ',' '\012'`"
2211 2247
             ;;
2212 2248
 
2249
+         # fetch options
2250
+         -nr|--no-recursion|-e|--embedded-only|-u|--update-symlinks)
2251
+            if [ -z "${MULLE_BOOTSTRAP_DID_FETCH}" ]
2252
+            then
2253
+               log_error "unknown option $1"
2254
+               ${USAGE}
2255
+            fi
2256
+         ;;
2257
+
2213 2258
          -*)
2214 2259
             log_error "unknown option $1"
2215 2260
             build_usage
... ...
@@ -2239,6 +2284,8 @@ build_main()
2239 2284
    [ -z "${MULLE_BOOTSTRAP_GCC_SH}" ] && . mulle-bootstrap-gcc.sh
2240 2285
    [ -z "${MULLE_BOOTSTRAP_SCRIPTS_SH}" ] && . mulle-bootstrap-scripts.sh
2241 2286
 
2287
+   CHECK_USR_LOCAL_INCLUDE="`read_config_setting "check_usr_local_include" "NO"`"
2288
+
2242 2289
    if [ $# -eq 0 ]
2243 2290
    then
2244 2291
       log_fluff "Setting up dependencies directory as \"${DEPENDENCY_SUBDIR}\""
... ...
@@ -48,6 +48,7 @@ usage:
48 48
       -f    :  override dirty harry check
49 49
       -u    :  try to update symlinked folders as well (not recommended)
50 50
       -nr   :  ignore .bootstrap folders of fetched repositories
51
+      -e    :  fetch embedded repositories only
51 52
 
52 53
    install  :  clone or symlink non-exisiting repositories and other resources
53 54
    update   :  execute a "pull" in fetched repositories
... ...
@@ -670,7 +671,7 @@ did_clone_repository()
670 671
 # checked out already it will use it, or ask
671 672
 # convention: .git suffix == repo to clone
672 673
 #          no .git suffix, try to symlink
673
-# return value 1 means: reread repositories, as it may have changed
674
+# return value 0 means: reread repositories, as it may have changed
674 675
 #
675 676
 checkout_repository()
676 677
 {
... ...
@@ -688,7 +689,8 @@ checkout_repository()
688 689
    local run_script
689 690
 
690 691
    run_script=-1
691
-   flag=0
692
+
693
+   stop=1
692 694
 
693 695
    if [ -e "${dstdir}" ]
694 696
    then
... ...
@@ -705,8 +707,10 @@ checkout_repository()
705 707
          checkout "$@"
706 708
          run_script=0  # yes, run it
707 709
 
708
-         bootstrap_auto_update "${name}" "${url}" "${dstdir}"
709
-         flag=$?
710
+         if bootstrap_auto_update "${name}" "${url}" "${dstdir}"
711
+         then
712
+            stop=0
713
+         fi
710 714
       fi
711 715
    fi
712 716
 
... ...
@@ -726,7 +730,7 @@ checkout_repository()
726 730
       fetch__run_build_settings_script "${name}" "${url}" "${dstdir}" "post-${COMMAND}" "$@"
727 731
    fi
728 732
 
729
-   return $flag
733
+   return $stop
730 734
 }
731 735
 
732 736
 
... ...
@@ -744,7 +748,6 @@ clone_repository()
744 748
 
745 749
    local tag
746 750
    local dstdir
747
-   local flag
748 751
    local doit
749 752
 
750 753
    log_verbose "Clone ${name} if needed ..."
... ...
@@ -759,7 +762,9 @@ clone_repository()
759 762
       doit=$?
760 763
    fi
761 764
 
762
-   flag=0
765
+   local stop
766
+
767
+   stop=1
763 768
 
764 769
    if [ $doit -ne 0 ]
765 770
    then
... ...
@@ -770,15 +775,17 @@ clone_repository()
770 775
 
771 776
       create_file_if_missing "${CLONESFETCH_SUBDIR}/.fetch_update_started"
772 777
 
773
-      checkout_repository "${name}" "${url}" "${dstdir}" "${branch}" "${tag}" "${scm}"
774
-      flag=$?
778
+      if checkout_repository "${name}" "${url}" "${dstdir}" "${branch}" "${tag}" "${scm}"
779
+      then
780
+         stop=0
781
+      fi
775 782
 
776 783
       remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_update_started"
777 784
    else
778 785
       log_info "${C_MAGENTA}${C_BOLD}${name}${C_INFO} is a system library, so not fetching it"
779 786
    fi
780 787
 
781
-   return $flag
788
+   return $stop
782 789
 }
783 790
 
784 791
 
... ...
@@ -831,9 +838,7 @@ ${clone}"
831 838
 
832 839
                __parse_expanded_clone "${clone}"
833 840
 
834
-               clone_repository "${name}" "${url}" "${branch}" "${scm}"
835
-
836
-               if [ $? -eq 1 ]
841
+               if clone_repository "${name}" "${url}" "${branch}" "${scm}"
837 842
                then
838 843
                   stop=0
839 844
                   break
... ...
@@ -1356,6 +1361,10 @@ update_embedded_repositories()
1356 1361
 
1357 1362
 _common_main()
1358 1363
 {
1364
+   #
1365
+   # it is useful, that fetch understands build options and
1366
+   # ignores them
1367
+   #
1359 1368
    while [ $# -ne 0 ]
1360 1369
    do
1361 1370
       case "$1" in
... ...
@@ -1367,6 +1376,10 @@ _common_main()
1367 1376
             DONT_RECURSE="YES"
1368 1377
          ;;
1369 1378
 
1379
+         -e|--embedded-only)
1380
+            EMBEDDED_ONLY="YES"
1381
+         ;;
1382
+
1370 1383
          -f)
1371 1384
             MULLE_BOOTSTRAP_DIRTY_HARRY="NO"
1372 1385
          ;;
... ...
@@ -1375,10 +1388,18 @@ _common_main()
1375 1388
             MULLE_BOOTSTRAP_UPDATE_SYMLINKS="YES"
1376 1389
          ;;
1377 1390
 
1391
+         # build options
1392
+         -K|--clean|-k|--no-clean|-j|--cores|-c|--configuration)
1393
+            if [ -z "${MULLE_BOOTSTRAP_WILL_BUILD}" ]
1394
+            then
1395
+               log_error "unknown option $1"
1396
+               ${USAGE}
1397
+            fi
1398
+         ;;
1399
+
1378 1400
          -*)
1379 1401
             log_error "unknown option $1"
1380 1402
             ${USAGE}
1381
-
1382 1403
          ;;
1383 1404
 
1384 1405
          *)
... ...
@@ -1435,7 +1456,10 @@ _common_main()
1435 1456
 #      install_gems
1436 1457
 #      install_pips
1437 1458
 
1438
-      clone_repositories
1459
+      if [ -z "${EMBEDDED_ONLY}" ]
1460
+      then
1461
+         clone_repositories
1462
+      fi
1439 1463
       clone_embedded_repositories
1440 1464
 
1441 1465
       # install brews again, in case we inherited some in the meantime
... ...
@@ -1445,7 +1469,10 @@ _common_main()
1445 1469
    else
1446 1470
       if dir_has_files "${CLONESFETCH_SUBDIR}"
1447 1471
       then
1448
-         update_repositories "$@"
1472
+         if [ -z "${EMBEDDED_ONLY}" ]
1473
+         then
1474
+            update_repositories "$@"
1475
+         fi
1449 1476
          update_embedded_repositories
1450 1477
       else
1451 1478
          log_info "Nothing to update, fetch first"
... ...
@@ -93,11 +93,6 @@ local_environment_initialize()
93 93
    DEPENDENCY_SUBDIR="${RELATIVE_ROOT}dependencies"
94 94
    ADDICTION_SUBDIR="${RELATIVE_ROOT}addictions"
95 95
 
96
-   #
97
-   # simplify UNAME from MINGW64_NT-10.0 to MINGW
98
-   # others should be ok
99
-   #
100
-
101 96
    log_fluff "${UNAME} detected"
102 97
    case "${UNAME}" in
103 98
       mingw)
... ...
@@ -113,6 +108,8 @@ local_environment_initialize()
113 108
          fi
114 109
 
115 110
          PATH_SEPARATOR=';'
111
+         USR_LOCAL_LIB=~/lib
112
+         USR_LOCAL_INCLUDE=~/include
116 113
       ;;
117 114
 
118 115
       "")
... ...
@@ -121,6 +118,8 @@ local_environment_initialize()
121 118
 
122 119
       *)
123 120
          PATH_SEPARATOR=':'
121
+         USR_LOCAL_LIB=/usr/local/lib
122
+         USR_LOCAL_INCLUDE=/usr/local/include
124 123
       ;;
125 124
    esac
126 125
 }
... ...
@@ -85,59 +85,57 @@ refresh_repositories_settings()
85 85
             match="`echo "${refreshed}" | grep -x "${clone}"`"
86 86
             # could remove prefixes here https:// http://
87 87
 
88
-            if [ "${match}" != "${clone}" ]
88
+            if [ "${match}" = "${clone}" ]
89 89
             then
90
-               refreshed="${refreshed}
90
+               continue
91
+            fi
92
+
93
+            refreshed="${refreshed}
91 94
 ${clone}"
92 95
 
93
-               local branch
94
-               local dstdir
95
-               local flag
96
-               local name
97
-               local scm
98
-               local tag
99
-               local url
96
+            local branch
97
+            local dstdir
98
+            local name
99
+            local scm
100
+            local tag
101
+            local url
100 102
 
101
-               __parse_expanded_clone "${clone}"
103
+            __parse_expanded_clone "${clone}"
102 104
 
103
-               dstdir="${CLONESFETCH_SUBDIR}/${name}"
104
-               if [ ! -d "${dstdir}" ]
105
-               then
106
-                  log_fluff "${name} has not been fetched yet"
107
-                  continue
108
-               fi
105
+            dstdir="${CLONESFETCH_SUBDIR}/${name}"
106
+            if [ ! -d "${dstdir}" ]
107
+            then
108
+               log_fluff "${name} has not been fetched yet"
109
+               continue
110
+            fi
109 111
 
110
-               #
111
-               # dependency management, it could be nicer, but isn't.
112
-               # Currently matches only URLs
113
-               #
114
-               local sub_repos
115
-               local filename
112
+            #
113
+            # dependency management, it could be nicer, but isn't.
114
+            # Currently matches only URLs
115
+            #
116
+            local sub_repos
117
+            local filename
116 118
 
117
-               filename="${dstdir}/${BOOTSTRAP_SUBDIR}/repositories"
118
-               if [ -f "${filename}" ]
119
+            filename="${dstdir}/${BOOTSTRAP_SUBDIR}/repositories"
120
+            if [ -f "${filename}" ]
121
+            then
122
+               sub_repos="`_read_setting "${filename}"`"
123
+               if [ ! -z "${sub_repos}" ]
119 124
                then
120
-                  sub_repos="`_read_setting "${filename}"`"
121
-                  if [ ! -z "${sub_repos}" ]
125
+                  dependency_map="`dependency_add "${dependency_map}" "__ROOT__" "${url}"`"
126
+                  dependency_map="`dependency_add_array "${dependency_map}" "${url}" "${sub_repos}"`"
127
+                  if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
122 128
                   then
123
-                     dependency_map="`dependency_add "${dependency_map}" "__ROOT__" "${url}"`"
124
-                     dependency_map="`dependency_add_array "${dependency_map}" "${url}" "${sub_repos}"`"
125
-                     if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
126
-                     then
127
-                        log_trace2 "add \"${sub_repos}\" for ${url} to ${dependency_map}"
128
-                     fi
129
+                     log_trace2 "add \"${sub_repos}\" for ${url} to ${dependency_map}"
129 130
                   fi
130
-               else
131
-                  log_fluff "${name} has no repositories"
132 131
                fi
132
+            else
133
+               log_fluff "${name} has no repositories"
134
+            fi
133 135
 
134
-               bootstrap_auto_update "${name}" "${url}" "${dstdir}"
135
-               flag=$?
136
-
137
-               if [ $flag -eq 0 ]
138
-               then
139
-                  stop=0
140
-               fi
136
+            if bootstrap_auto_update "${name}" "${url}" "${dstdir}"
137
+            then
138
+               stop=0
141 139
             fi
142 140
          done
143 141
       fi
... ...
@@ -210,7 +210,7 @@ run_build_settings_script()
210 210
    # can happen, if system libs override
211 211
    if [ ! -e "$srcdir" ]
212 212
    then
213
-      log_verbose "script \${script}\" not executed, because ${srcdir} does not exist"
213
+      log_verbose "script \"${script}\" not executed, because ${srcdir} does not exist"
214 214
       return 0
215 215
    fi
216 216
 
... ...
@@ -281,7 +281,7 @@ fetch__run_build_settings_script()
281 281
    # can happen, if system libs override
282 282
    if [ ! -e "$srcdir" ]
283 283
    then
284
-      log_verbose "script \${script}\" not executed, because ${srcdir} does not exist"
284
+      log_verbose "script \"${script}\" not executed, because ${srcdir} does not exist"
285 285
       return 0
286 286
    fi
287 287