external/busybox
Revision | 25b92aa06ee1d76d778dbd8341129bcfdacfe97c (tree) |
---|---|
Time | 2014-09-02 13:52:32 |
Author | Diogo Ferreira <defer@cyng...> |
Commiter | Tanguy Pruvot |
busybox: Use 'gsed' in Mac builds
Mac builds were broken because its sed implementation is not compatible
with some of the features used in this script. We already require gsed
for the Android build on Mac so this changes the script to take that
into account.
Change-Id: I37c10f8c543bdaf2c84409dacfaeccd24eb152d7
@@ -17,6 +17,20 @@ status() { printf ' %-8s%s\n' "$1" "$2"; } | ||
17 | 17 | gen() { status "GEN" "$@"; } |
18 | 18 | chk() { status "CHK" "$@"; } |
19 | 19 | |
20 | +# On OSX the sed implementation is not compatible with some of the | |
21 | +# features in this script, so this uses gsed and warns the user if | |
22 | +# it does not exist. | |
23 | +UNAME=$(uname -sm) | |
24 | +if [[ $UNAME == *Darwin* ]] || [[ $UNAME == *Macintosh* ]]; then | |
25 | + SED_IMPL=$(which gsed) | |
26 | + if [ $? != 0 ]; then | |
27 | + echo "GNU sed is required for Darwin builds, please install and add 'gsed' to the path" | |
28 | + exit 1; | |
29 | + fi | |
30 | +else | |
31 | + SED_IMPL=sed | |
32 | +fi | |
33 | + | |
20 | 34 | generate() |
21 | 35 | { |
22 | 36 | # NB: data to be inserted at INSERT line is coming on stdin |
@@ -27,11 +41,11 @@ generate() | ||
27 | 41 | # rules re handling of "\n" in echo params. |
28 | 42 | printf "%s\n" "${header}" |
29 | 43 | # print everything up to INSERT line |
30 | - sed -n '/^INSERT$/ q; p' "${src}" | |
44 | + $SED_IMPL -n '/^INSERT$/ q; p' "${src}" | |
31 | 45 | # copy stdin to stdout |
32 | 46 | cat |
33 | 47 | # print everything after INSERT line |
34 | - sed -n '/^INSERT$/ { :l; n; p; bl }' "${src}" | |
48 | + $SED_IMPL -n '/^INSERT$/ { :l; n; p; bl }' "${src}" | |
35 | 49 | } >"${dst}.tmp" |
36 | 50 | if ! cmp -s "${dst}" "${dst}.tmp"; then |
37 | 51 | gen "${dst}" |
@@ -42,7 +56,7 @@ generate() | ||
42 | 56 | } |
43 | 57 | |
44 | 58 | # (Re)generate include/applets.h |
45 | -sed -n 's@^//applet:@@p' "$srctree"/*/*.c "$srctree"/*/*/*.c \ | |
59 | +$SED_IMPL -n 's@^//applet:@@p' "$srctree"/*/*.c "$srctree"/*/*/*.c \ | |
46 | 60 | | generate \ |
47 | 61 | "$srctree/include/applets.src.h" \ |
48 | 62 | "include/applets.h" \ |
@@ -52,7 +66,7 @@ sed -n 's@^//applet:@@p' "$srctree"/*/*.c "$srctree"/*/*/*.c \ | ||
52 | 66 | # We add line continuation backslash after each line, |
53 | 67 | # and insert empty line before each line which doesn't start |
54 | 68 | # with space or tab |
55 | -sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\@p' \ | |
69 | +$SED_IMPL -n -e 's@^//usage:\([ \t].*\)$@\1 \\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\@p' \ | |
56 | 70 | "$srctree"/*/*.c "$srctree"/*/*/*.c \ |
57 | 71 | | generate \ |
58 | 72 | "$srctree/include/usage.src.h" \ |
@@ -70,7 +84,7 @@ sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\ | ||
70 | 84 | if test -f "$src"; then |
71 | 85 | mkdir -p -- "$d" 2>/dev/null |
72 | 86 | |
73 | - sed -n 's@^//kbuild:@@p' "$srctree/$d"/*.c \ | |
87 | + $SED_IMPL -n 's@^//kbuild:@@p' "$srctree/$d"/*.c \ | |
74 | 88 | | generate \ |
75 | 89 | "${src}" "${dst}" \ |
76 | 90 | "# DO NOT EDIT. This file is generated from Kbuild.src" |
@@ -81,7 +95,7 @@ sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\ | ||
81 | 95 | if test -f "$src"; then |
82 | 96 | mkdir -p -- "$d" 2>/dev/null |
83 | 97 | |
84 | - sed -n 's@^//config:@@p' "$srctree/$d"/*.c \ | |
98 | + $SED_IMPL -n 's@^//config:@@p' "$srctree/$d"/*.c \ | |
85 | 99 | | generate \ |
86 | 100 | "${src}" "${dst}" \ |
87 | 101 | "# DO NOT EDIT. This file is generated from Config.src" |