Browse code

only warn about tars, if there are tars. basename and dirname with "--" to protect some screwy filenames. Make embedded repositories work for bootstrapped repositories. Also try to manage CFLAGS, LDFLAGS like for cmake (experimental to say the lease)

Nat! authored on 21-10-2015 16:57:41
Showing 9 changed files
... ...
@@ -55,7 +55,7 @@ Install brew now (Linux or OS X should work) ? "
55 55
       fi
56 56
 
57 57
       log_fluff "Touching ${last_update}"
58
-      exekutor mkdir_if_missing "`dirname "${last_update}"`"
58
+      exekutor mkdir_if_missing "`dirname -- "${last_update}"`"
59 59
       exekutor touch "${last_update}"
60 60
       return 1
61 61
    fi
... ...
@@ -95,7 +95,7 @@ brew_update_if_needed()
95 95
       log_fluff "Updating brew, this can take some time..."
96 96
    	exekutor brew update
97 97
 
98
-	   mkdir_if_missing "`dirname "${last_update}"`"
98
+	   mkdir_if_missing "`dirname -- "${last_update}"`"
99 99
    	exekutor touch "${last_update}"
100 100
    fi
101 101
 }
... ...
@@ -162,7 +162,7 @@ collect_and_dispense_product()
162 162
       return 0
163 163
    fi
164 164
 
165
-   log_fluff "Collecting and dispensing \"${name}\" \"`basename "${subdir}"`\" products "
165
+   log_fluff "Collecting and dispensing \"${name}\" \"`basename -- "${subdir}"`\" products "
166 166
    #
167 167
    # probably should use install_name_tool to hack all dylib paths that contain .ref
168 168
    # (will this work with signing stuff ?)
... ...
@@ -915,6 +915,37 @@ ${info} in \"${builddir}\" ..."
915 915
       arguments="${arguments} -configuration \"${mapped}\""
916 916
    fi
917 917
 
918
+# an empty xcconfig is nice, because it acts as a reset for
919
+   local xcconfig
920
+
921
+   xcconfig=`read_repo_setting "${name}" "xcconfig"`
922
+   if [ ! -z "${xcconfig}" ]
923
+   then
924
+      arguments="${arguments} -xcconfig \"${xcconfig}\""
925
+   fi
926
+
927
+   local other_cflags
928
+   local other_cppflags
929
+   local other_ldflags
930
+
931
+   other_cflags="`gcc_cflags_value "${name}"`"
932
+   other_cppflags="`gcc_cppflags_value "${name}"`"
933
+   other_ldflags="`gcc_ldflags_value "${name}"`"
934
+
935
+   if [ ! -z "${other_cflags}" ]
936
+   then
937
+      other_cflags="OTHER_CFLAGS=${other_cflags}"
938
+   fi
939
+   if [ ! -z "${other_cppflags}" ]
940
+   then
941
+      other_cppflags="OTHER_CPPFLAGS=${other_cppflags}"
942
+   fi
943
+   if [ ! -z "${other_ldflags}" ]
944
+   then
945
+      other_ldflags="OTHER_LDFLAGS=${other_ldflags}"
946
+   fi
947
+
948
+
918 949
    create_dummy_dirs_against_warnings "${builddir}" "${configuration}" "${suffix}"
919 950
 
920 951
    owd=`pwd`
... ...
@@ -967,7 +998,6 @@ ${info} in \"${builddir}\" ..."
967 998
          dependencies_lib_search_path="${path} ${inherited}"
968 999
       fi
969 1000
 
970
-
971 1001
       inherited="`xcode_get_setting FRAMEWORK_SEARCH_PATHS ${arguments}`" || exit 1
972 1002
       path=`combined_escaped_search_path \
973 1003
 "${owd}/${REFERENCE_DEPENDENCY_SUBDIR}/${FRAMEWORK_DIR_NAME}/${mapped}" \
... ...
@@ -1002,6 +1032,9 @@ SYMROOT='${owd}/${builddir}/' \
1002 1032
 OBJROOT='${owd}/${builddir}/obj' \
1003 1033
 ONLY_ACTIVE_ARCH=NO \
1004 1034
 ${skip_install} \
1035
+${other_cflags} \
1036
+${other_cppflags} \
1037
+${other_ldflags} \
1005 1038
 HEADER_SEARCH_PATHS='${dependencies_header_search_path}' \
1006 1039
 LIBRARY_SEARCH_PATHS='${dependencies_lib_search_path}' \
1007 1040
 FRAMEWORK_SEARCH_PATHS='${dependencies_framework_search_path}'"
... ...
@@ -1337,7 +1370,7 @@ build_if_alive()
1337 1370
    local xdone
1338 1371
    local zombie
1339 1372
 
1340
-   zombie="`dirname "${srcdir}"`/.zombies/${name}"
1373
+   zombie="`dirname -- "${srcdir}"`/.zombies/${name}"
1341 1374
    if [ -e "${zombie}" ]
1342 1375
    then
1343 1376
       log_warning "Ignoring zombie repo ${name} as \"${zombie}${C_WARNING} exists"
... ...
@@ -1447,6 +1480,13 @@ build_clones()
1447 1480
 }
1448 1481
 
1449 1482
 
1483
+have_tars()
1484
+{
1485
+   tarballs=`read_fetch_setting "tarballs"`
1486
+   [ "${tarballs}" != "" ]
1487
+}
1488
+
1489
+
1450 1490
 install_tars()
1451 1491
 {
1452 1492
    local tarballs
... ...
@@ -1512,7 +1552,10 @@ main()
1512 1552
       exekutor ln -s "usr/local/include" "${DEPENDENCY_SUBDIR}/include" || fail "failed to symlink future usr/local/include"
1513 1553
       install_tars "$@"
1514 1554
    else
1515
-      log_warning "Tars have not been installed, as \"${DEPENDENCY_SUBDIR}\" already exists."
1555
+      if have_tars
1556
+      then
1557
+         log_warning "Tars have not been installed, as \"${DEPENDENCY_SUBDIR}\" already exists."
1558
+      fi
1516 1559
    fi
1517 1560
 
1518 1561
    build_clones "$@"
... ...
@@ -139,7 +139,7 @@ clean_parent_folders_if_empty()
139 139
       parent="${dir}"
140 140
       while :
141 141
       do
142
-         parent="`dirname "${parent}"`"
142
+         parent="`dirname -- "${parent}"`"
143 143
          if [ "${parent}" = "." -o "${parent}" = "${stop}" ]
144 144
          then
145 145
              break
... ...
@@ -272,7 +272,7 @@ link_command()
272 272
    tag="$3"
273 273
 
274 274
    local dstdir
275
-   dstdir="`dirname "${dst}"`"
275
+   dstdir="`dirname -- "${dst}"`"
276 276
 
277 277
    if [ ! -e "${dstdir}/${src}" ]
278 278
    then
... ...
@@ -300,7 +300,7 @@ link_command()
300 300
       then
301 301
          local name
302 302
 
303
-         name="`basename "${dst}"`"
303
+         name="`basename -- "${dst}"`"
304 304
          log_warning "tag ${tag} will be ignored, due to symlink" >&2
305 305
          log_warning "if you want to checkout this tag do:" >&2
306 306
          log_warning "${C_RESET}(cd .repos/${name}; git ${GITFLAGS} checkout \"${tag}\" )${C_WARNING}" >&2
... ...
@@ -419,9 +419,9 @@ bootstrap_auto_update()
419 419
       dstfile="${BOOTSTRAP_SUBDIR}.auto/${i}"
420 420
       if [ -f "${srcfile}" ]
421 421
       then
422
-         log_fluff "Inheriting \"`basename ${i}`\" from \"${srcfile}\""
422
+         log_fluff "Inheriting \"`basename -- ${i}`\" from \"${srcfile}\""
423 423
 
424
-         mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/`dirname "${i}"`"
424
+         mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/`dirname -- "${i}"`"
425 425
          if [ -f "${BOOTSTRAP_SUBDIR}.auto/${i}" ]
426 426
          then
427 427
             local tmpfile
... ...
@@ -506,7 +506,7 @@ mark_all_zombies()
506 506
       do
507 507
          if [ -d "${i}" -o -L "${i}" ]
508 508
          then
509
-            name="`basename "${i}"`"
509
+            name="`basename -- "${i}"`"
510 510
             exekutor touch "${CLONES_FETCH_SUBDIR}/.zombies/${name}"
511 511
          fi
512 512
       done
... ...
@@ -524,7 +524,7 @@ mark_alive()
524 524
 
525 525
    local zombie
526 526
 
527
-   zombie="`dirname "${dstdir}"`/.zombies/${name}"
527
+   zombie="`dirname -- "${dstdir}"`/.zombies/${name}"
528 528
 
529 529
    # mark as alive
530 530
    if [ -d "${dstdir}" -o -L "${dstdir}" ]
... ...
@@ -583,13 +583,13 @@ checkout()
583 583
    local relative
584 584
    local name2
585 585
 
586
-   relative="`dirname "${dstdir}"`"
586
+   relative="`dirname -- "${dstdir}"`"
587 587
    relative="`compute_relative "${relative}"`"
588 588
    if [ ! -z "${relative}" ]
589 589
    then
590 590
       relative="${relative}/"
591 591
    fi
592
-   name2="`basename "${url}"`"  # only works for git really
592
+   name2="`basename -- "${url}"`"  # only works for git really
593 593
 
594 594
    #
595 595
    # this implicitly ensures, that these folders are
... ...
@@ -721,6 +721,14 @@ checkout_repository()
721 721
 
722 722
       if [ "${COMMAND}" = "install" -a "${DONT_RECURSE}" = "" ]
723 723
       then
724
+         local old
725
+
726
+         old="${BOOTSTRAP_SUBDIR}"
727
+
728
+         BOOTSTRAP_SUBDIR="${dstdir}/.bootstrap"
729
+         install_embedded_repositories "${dstdir}/"
730
+         BOOTSTRAP_SUBDIR="${old}"
731
+
724 732
          bootstrap_auto_update "${name}" "${url}" "${dstdir}"
725 733
          flag=$?
726 734
       fi
... ...
@@ -837,11 +845,16 @@ clone_repositories()
837 845
 
838 846
 install_embedded_repositories()
839 847
 {
848
+   local dstprefix
849
+
850
+   dstprefix="$1"
851
+
840 852
    local clones
841 853
    local clone
842 854
    local old
843 855
    local name
844 856
    local url
857
+   local dstdir
845 858
 
846 859
    old="${IFS:-" "}"
847 860
 
... ...
@@ -857,7 +870,7 @@ install_embedded_repositories()
857 870
          url="`url_from_clone "${clone}"`"
858 871
 
859 872
          tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
860
-         dstdir="${name}"
873
+         dstdir="${dstprefix}${name}"
861 874
          log_fetch_action "${name}" "${dstdir}"
862 875
 
863 876
          if [ ! -d "${dstdir}" ]
... ...
@@ -964,6 +977,17 @@ update_repository()
964 977
    log_fetch_action "${url}" "${dstdir}"
965 978
 
966 979
    update "${name}" "${url}" "${dstdir}" "${tag}"
980
+
981
+   if [ "${DONT_RECURSE}" = "" ]
982
+   then
983
+      local old
984
+
985
+      old="${BOOTSTRAP_SUBDIR}"
986
+
987
+      BOOTSTRAP_SUBDIR="${dstdir}/.bootstrap"
988
+      update_embedded_repositories "${dstdir}/"
989
+      BOOTSTRAP_SUBDIR="${old}"
990
+   fi
967 991
 }
968 992
 
969 993
 
... ...
@@ -1052,6 +1076,10 @@ update_repositories()
1052 1076
 
1053 1077
 update_embedded_repositories()
1054 1078
 {
1079
+   local dstprefix
1080
+
1081
+   dstprefix="$1"
1082
+
1055 1083
    local clones
1056 1084
    local clone
1057 1085
    local old
... ...
@@ -1072,7 +1100,7 @@ update_embedded_repositories()
1072 1100
          url="`url_from_clone "${clone}"`"
1073 1101
 
1074 1102
          tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
1075
-         dstdir="${name}"
1103
+         dstdir="${dstprefix}${name}"
1076 1104
          log_fetch_action "${name}" "${dstdir}"
1077 1105
 
1078 1106
          update "${name}" "${url}" "${dstdir}" "${tag}"
... ...
@@ -209,7 +209,7 @@ path_depth()
209 209
    then
210 210
       while [ "$name" != "." ]
211 211
       do
212
-         name=`dirname "$name"`
212
+         name=`dirname -- "$name"`
213 213
          depth=`expr $depth + 1`
214 214
       done
215 215
    fi
... ...
@@ -221,7 +221,7 @@ extension_less_basename()
221 221
 {
222 222
    local  file
223 223
 
224
-   file="`basename "$1"`"
224
+   file="`basename -- "$1"`"
225 225
    echo "${file%.*}"
226 226
 }
227 227
 
... ...
@@ -251,7 +251,7 @@ resolve_symlinks()
251 251
    path="`readlink "$1"`"
252 252
    if [ $? -eq 0 ]
253 253
    then
254
-      dir_context=`dirname "$1"`
254
+      dir_context=`dirname -- "$1"`
255 255
       resolve_symlinks "`_prepend_path_if_relative "$dir_context" "$path"`"
256 256
    else
257 257
       echo "$1"
... ...
@@ -270,7 +270,7 @@ _canonicalize_file_path()
270 270
     local dir file
271 271
 
272 272
     dir="` dirname "$1"`"
273
-    file="`basename "$1"`"
273
+    file="`basename -- "$1"`"
274 274
     (cd "${dir}" 2>/dev/null && echo "`pwd -P`/${file}")
275 275
 }
276 276
 
... ...
@@ -335,7 +335,7 @@ remove_absolute_path_prefix_up_to()
335 335
    s="$1"
336 336
    prefix="$2"
337 337
 
338
-   if [ "`basename "${s}"`" = "${prefix}" ]
338
+   if [ "`basename -- "${s}"`" = "${prefix}" ]
339 339
    then
340 340
       return 0
341 341
    fi
... ...
@@ -486,7 +486,7 @@ find_xcodeproj()
486 486
 
487 487
    for i in `find . -name "*.xcodeproj" -print`
488 488
    do
489
-      match=`basename "${i}" .xcodeproj`
489
+      match=`basename -- "${i}" .xcodeproj`
490 490
       if [ "$match" = "$expect" ]
491 491
       then
492 492
          echo "$i"
... ...
@@ -44,7 +44,7 @@ git_checkout_tag()
44 44
    then
45 45
       log_error "Checkout failed, moving ${C_CYAN}${dst}${C_ERROR} to {C_CYAN}${dst}.failed${C_ERROR}"
46 46
       log_error "You need to fix this manually and then move it back."
47
-      log_info "Hint: check ${BOOTSTRAP_SUBDIR}/`basename "${dst}"`/TAG" >&2
47
+      log_info "Hint: check ${BOOTSTRAP_SUBDIR}/`basename -- "${dst}"`/TAG" >&2
48 48
 
49 49
       rmdir_safer "${dst}.failed"
50 50
       exekutor mv "${dst}" "${dst}.failed"
... ...
@@ -39,7 +39,7 @@ warn_user_setting()
39 39
    file="$1"
40 40
    if [ "$MULLE_BOOTSTRAP_NO_WARN_USER_SETTINGS" != "YES" ]
41 41
    then
42
-      log_warning "Using `dirname "${file}"` for `basename "${file}"`"
42
+      log_warning "Using `dirname -- "${file}"` for `basename -- "${file}"`"
43 43
    fi
44 44
 }
45 45
 
... ...
@@ -51,7 +51,7 @@ warn_local_setting()
51 51
    file="$1"
52 52
    if [ "$MULLE_BOOTSTRAP_NO_WARN_LOCAL_SETTINGS" != "YES" ]
53 53
    then
54
-      log_warning "Using `dirname "${file}"` for `basename "${file}"`"
54
+      log_warning "Using `dirname -- "${file}"` for `basename -- "${file}"`"
55 55
    fi
56 56
 }
57 57
 
... ...
@@ -112,7 +112,7 @@ _read_setting()
112 112
       then
113 113
          local os
114 114
          os="`uname`"
115
-         log_fluff "${C_MAGENTA}`basename "${file}" ".${os}"`${C_FLUFF} found as \"${file}\""
115
+         log_fluff "${C_MAGENTA}`basename -- "${file}" ".${os}"`${C_FLUFF} found as \"${file}\""
116 116
       fi
117 117
    else
118 118
       value=`egrep -v '^#|^[ ]*$' "${file}"`
... ...
@@ -120,7 +120,7 @@ _read_setting()
120 120
       then
121 121
          local os
122 122
          os="`uname`"
123
-         log_fluff "Setting ${C_MAGENTA}`basename "${file}" ".${os}"`${C_FLUFF} found in \"${file}\" as ${C_MAGENTA}${value}${C_FLUFF}"
123
+         log_fluff "Setting ${C_MAGENTA}`basename -- "${file}" ".${os}"`${C_FLUFF} found in \"${file}\" as ${C_MAGENTA}${value}${C_FLUFF}"
124 124
       fi
125 125
    fi
126 126
 
... ...
@@ -39,7 +39,7 @@
39 39
 . mulle-bootstrap-scripts.sh
40 40
 
41 41
 
42
-name=`basename "${PWD}"`
42
+name=`basename -- "${PWD}"`
43 43
 
44 44
 
45 45
 usage()
... ...
@@ -70,7 +70,7 @@ AGVTAG=
70 70
 if [ "${project}" != "" ]
71 71
 then
72 72
    log_fluff "Trying agvtool to figure out current version"
73
-   dir=`dirname "${project}"`
73
+   dir=`dirname -- "${project}"`
74 74
    [ -x "${dir}" ] || fail "${dir} is not accesible"
75 75
 
76 76
    AGVTAG=`(cd "${dir}" ; agvtool what-version -terse ) 2> /dev/null`
... ...
@@ -98,7 +98,7 @@ if [ -z "${VENDOR_TAG}" -o "${VENDOR_TAG}" = "-" ]
98 98
 then
99 99
    if [ -z "${VENDOR_PREFIX}" ]
100 100
    then
101
-      VENDOR_PREFIX=`basename "${PWD}"`
101
+      VENDOR_PREFIX=`basename -- "${PWD}"`
102 102
       VENDOR_PREFIX="${VENDOR_PREFIX%%.*}"  # remove vile extension :)
103 103
    fi
104 104
 
... ...
@@ -173,7 +173,7 @@ tag()
173 173
    then
174 174
       run_script "$script" "${TAG}" "${REPO}" || exit 1
175 175
    else
176
-      log_info "Tagging \"`basename "${REPO}"`\" with \"${TAG}\""
176
+      log_info "Tagging \"`basename -- "${REPO}"`\" with \"${TAG}\""
177 177
       ( cd "${REPO}" ; exekutor git tag "${TAG}" ) || exit 1
178 178
 
179 179
       if  dir_has_files "${CLONES_SUBDIR}"
... ...
@@ -184,7 +184,7 @@ tag()
184 184
             then
185 185
                if [ -d "${i}/.git" -o -d "${i}/refs" ]
186 186
                then
187
-                  log_info "Tagging \"`basename "${i}"`\" with \"${VENDOR_TAG}\""
187
+                  log_info "Tagging \"`basename -- "${i}"`\" with \"${VENDOR_TAG}\""
188 188
                   (cd "$i" ; exekutor git tag "${VENDOR_TAG}" ) || fail "tag failed"
189 189
                fi
190 190
             fi
... ...
@@ -202,7 +202,7 @@ main()
202 202
 
203 203
    ensure_repos_clean
204 204
 
205
-   echo "Will tag `basename "${PWD}"` with ${TAG}" >&2
205
+   echo "Will tag `basename -- "${PWD}"` with ${TAG}" >&2
206 206
    if  dir_has_files "${CLONES_SUBDIR}"
207 207
    then
208 208
       echo "Will tag clones with ${VENDOR_TAG}" >&2
... ...
@@ -213,7 +213,7 @@ patch_xcode_project()
213 213
    read_yes_no_config_setting "terse" "NO"
214 214
    terse=$?
215 215
 
216
-   name=`basename "${PWD}"`
216
+   name=`basename -- "${PWD}"`
217 217
 
218 218
    if [ ! -z "${PROJECT}" ]
219 219
    then
... ...
@@ -227,7 +227,7 @@ patch_xcode_project()
227 227
       fi
228 228
    fi
229 229
 
230
-   projectname="`basename "${project}"`"
230
+   projectname="`basename -- "${project}"`"
231 231
 
232 232
    # mod_pbxproj can only do Debug/Release/All...
233 233
 
... ...
@@ -283,7 +283,7 @@ Release"
283 283
    local relative_subdir
284 284
 
285 285
    absolute="`realpath "${project}"`"
286
-   absolute="`dirname "${absolute}"`"
286
+   absolute="`dirname -- "${absolute}"`"
287 287
    absolute2="`pwd -P`/${DEPENDENCY_SUBDIR}"
288 288
    relative_subdir="`relative_path_between "${absolute2}" "${absolute}" `"
289 289