Browse code

kick mod_pbxproj as dependency, add mulle-xcode-settings

Nat! authored on 06-10-2015 18:02:19
Showing 8 changed files
... ...
@@ -1,2 +1 @@
1
-shellcheck
2
-
1
+mulle-xcode-settings
3 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+mulle-kybernetik/software
... ...
@@ -1,4 +1,5 @@
1 1
 SCRIPTS=install.sh \
2
+mulle-bootstrap-brew.sh \
2 3
 mulle-bootstrap-build.sh \
3 4
 mulle-bootstrap-clean.sh \
4 5
 mulle-bootstrap-fetch.sh \
... ...
@@ -198,6 +198,7 @@ main()
198 198
       *)
199 199
          usage >&2
200 200
          exit 1
201
+         ;;
201 202
       esac
202 203
 }
203 204
 
204 205
new file mode 100644
... ...
@@ -0,0 +1,101 @@
1
+#! /bin/sh
2
+#
3
+#   Copyright (c) 2015 Nat! - Mulle kybernetiK
4
+#   All rights reserved.
5
+#
6
+#   Redistribution and use in source and binary forms, with or without
7
+#   modification, are permitted provided that the following conditions are met:
8
+#
9
+#   Redistributions of source code must retain the above copyright notice, this
10
+#   list of conditions and the following disclaimer.
11
+#
12
+#   Redistributions in binary form must reproduce the above copyright notice,
13
+#   this list of conditions and the following disclaimer in the documentation
14
+#   and/or other materials provided with the distribution.
15
+#
16
+#   Neither the name of Mulle kybernetiK nor the names of its contributors
17
+#   may be used to endorse or promote products derived from this software
18
+#   without specific prior written permission.
19
+#
20
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+#   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
+#   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+#   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+#   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+#   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+#   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+#   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+#   POSSIBILITY OF SUCH DAMAGE.
31
+
32
+fetch_brew_if_needed()
33
+{
34
+   local last_update
35
+   local binary
36
+
37
+   last_update="${HOME}/.mulle-bootstrap/brew-update"
38
+
39
+   binary=`which brew`
40
+   if [ "${binary}" = "" ]
41
+   then
42
+      user_say_yes "Brew isn't installed on this system.
43
+Install brew now (Linux or OS X should work) ? "
44
+      if [ $? -ne 0 ]
45
+      then
46
+         return 1
47
+      fi
48
+      if [ "`uname`" = 'Darwin' ]
49
+      then
50
+         log_info "Installing OS X brew"
51
+         exekutor ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit 1
52
+      else
53
+         log_info "Installing Linux brew"
54
+         exekutor ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)" || exit 1
55
+      fi
56
+
57
+      log_fluff "Touching ${last_update}"
58
+      exekutor mkdir_if_missing "`dirname "${last_update}"`"
59
+      exekutor touch "${last_update}"
60
+      return 1
61
+   fi
62
+   return 0
63
+}
64
+
65
+
66
+brew_update_if_needed()
67
+{
68
+   local stale
69
+   local last_update
70
+   local what
71
+
72
+   what="$1"
73
+   last_update="${HOME}/.mulle-bootstrap/brew-update"
74
+
75
+   fetch_brew_if_needed
76
+   if [ $? -eq 1 ]
77
+  	then
78
+	  	return 0  ## just fetched it
79
+	fi
80
+
81
+   if [ -f "${last_update}" ]
82
+   then
83
+      stale="`find "${last_update}" -mtime +1 -type f -exec echo '{}' \;`"
84
+      if [ -f "${last_update}" -a "$stale" = "" ]
85
+      then
86
+         log_fluff "brew seems to be up to date"
87
+         return 0
88
+      fi
89
+   fi
90
+
91
+   user_say_yes "Should brew be updated before installing ${what} ?"
92
+
93
+   if [ $? -eq 0 ]
94
+   then
95
+      log_fluff "Updating brew, this can take some time..."
96
+   	exekutor brew update
97
+
98
+	   mkdir_if_missing "`dirname "${last_update}"`"
99
+   	exekutor touch "${last_update}"
100
+   fi
101
+}
... ...
@@ -37,6 +37,7 @@
37 37
 #
38 38
 . mulle-bootstrap-warn-scripts.sh
39 39
 . mulle-bootstrap-local-environment.sh
40
+. mulle-bootstrap-brew.sh
40 41
 
41 42
 
42 43
 usage()
... ...
@@ -278,7 +279,7 @@ checkout()
278 279
             then
279 280
                user_say_yes "There is a ${found} folder in the parent
280 281
 directory of this project.
281
-Use it instead of cloning ${clone} ?"
282
+Use it ?"
282 283
                if [ $? -eq 0 ]
283 284
                then
284 285
                   srcname="${found}"
... ...
@@ -715,42 +716,6 @@ update_repositories()
715 716
 }
716 717
 
717 718
 
718
-brew_update_if_needed()
719
-{
720
-   local stale
721
-   local last_update
722
-   local what
723
-
724
-   what="$1"
725
-   last_update="${HOME}/.mulle-bootstrap/brew-update"
726
-
727
-   fetch_brew_if_needed
728
-   if [ $? -eq 1 ]
729
-  	then
730
-	  	return 0  ## just fetched it
731
-	fi
732
-
733
-   if [ -f "${last_update}" ]
734
-   then
735
-      stale="`find "${last_update}" -mtime +1 -type f -exec echo '{}' \;`"
736
-      if [ -f "${last_update}" -a "$stale" = "" ]
737
-      then
738
-         log_fluff "brew seems to be up to date"
739
-         return 0
740
-      fi
741
-   fi
742
-
743
-   user_say_yes "Should brew be updated before installing ${what} ?"
744
-
745
-   if [ $? -eq 0 ]
746
-   then
747
-      log_fluff "Updating brew, this can take some time..."
748
-   	exekutor brew update
749
-
750
-	   mkdir_if_missing "`dirname "${last_update}"`"
751
-   	exekutor touch "${last_update}"
752
-   fi
753
-}
754 719
 
755 720
 
756 721
 #
... ...
@@ -410,40 +410,6 @@ dir_has_files()
410 410
 }
411 411
 
412 412
 
413
-fetch_brew_if_needed()
414
-{
415
-   local last_update
416
-   local binary
417
-
418
-   last_update="${HOME}/.mulle-bootstrap/brew-update"
419
-
420
-   binary=`which brew`
421
-   if [ "${binary}" = "" ]
422
-   then
423
-      user_say_yes "Brew isn't installed on this system.
424
-Install brew now (Linux or OS X should work) ? "
425
-      if [ $? -ne 0 ]
426
-      then
427
-         return 1
428
-      fi
429
-      if [ "`uname`" = 'Darwin' ]
430
-      then
431
-         log_info "Installing OS X brew"
432
-         exekutor ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit 1
433
-      else
434
-         log_info "Installing Linux brew"
435
-         exekutor ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)" || exit 1
436
-      fi
437
-
438
-      log_fluff "Touching ${last_update}"
439
-      exekutor mkdir_if_missing "`dirname "${last_update}"`"
440
-      exekutor touch "${last_update}"
441
-      return 1
442
-   fi
443
-   return 0
444
-}
445
-
446
-
447 413
 #
448 414
 # first find a project with matching name, otherwise find
449 415
 # first nearest project
... ...
@@ -7,6 +7,7 @@
7 7
 #
8 8
 
9 9
 . mulle-bootstrap-local-environment.sh
10
+. mulle-bootstrap-brew.sh
10 11
 
11 12
 
12 13
 usage()
... ...
@@ -65,74 +66,27 @@ list_default_configuration()
65 66
 }
66 67
 
67 68
 
68
-check_for_python()
69
-{
70
-   local python
71
-
72
-   python="`which python`"
73
-   if [ "$python" = "" ]
74
-   then
75
-      echo "Need to install python with pip to install mod_pbxproj." >&2
76
-      echo "The author suggests you install phyton with brew (http://brew.sh)" >&2
77
-      user_say_yes "Install brew now ?"
78
-      [ $? -eq 0 ] || exit 1
79
-
80
-      fetch_brew_if_needed
81
-      executor brew install python  || exit 1
82
-   fi
83
-}
84
-
85
-
86
-check_for_pip()
87
-{
88
-   local pip
89
-
90
-   pip="`which pip`"
91
-   if [ "$pip" = "" ]
92
-   then
93
-      echo "Need to install python with pip to install mod_pbxproj. You have only python." >&2
94
-      echo "The author suggests you install phyton with brew (http://brew.sh)" >&2
95
-      user_say_yes "Install python now ?"
96
-      [ $? -eq 0 ] || exit 1
97
-
98
-      fetch_brew_if_needed
99
-      executor brew install python || exit 1
100
-   fi
101
-}
102
-
103
-
104
-check_for_mod_pbxproj()
69
+check_for_mulle_xcode_settings()
105 70
 {
106 71
    local installed
107 72
 
108
-   check_for_python
109
-
110 73
    #
111 74
    # OK
112 75
    #
113
-   installed=`python -m mod_pbxproj 2>&1 | grep usage`
76
+   installed=`which mulle-xcode-settings`
114 77
    if [ "$installed" = "" ]
115 78
    then
116
-      user_say_yes "Need to install mod_pbxproj (as sudo)
117
-   Install mod_pbxproj now ?"
79
+      user_say_yes "Need to install mulle-xcode-settings (via brew)
80
+   Install mulle-xcode-settings now ?"
118 81
       [ $? -eq 0 ] || exit 1
119 82
 
120
-      check_for_pip
121
-
122
-      echo "pip needs to run as sudo, and may ask you for your password." >&2
123
-      sudo pip install mod_pbxproj
124
-      if [ $? -ne 0 ]
125
-      then
126
-         echo "Pip didn't work. )Pip is part of python)" >&2
127
-         echo "Maybe it's too old." >&2
83
+      brew_update_if_needed
128 84
 
129
-         user_say_yes "Try to upgrade pip ?"
130
-         [ $? -eq 0 ] || exit 1
85
+      log_info "Tapping mulle-kybernetik/software"
86
+      brew tap "mulle-kybernetik/software"
131 87
 
132
-         echo "pip needs to run as sudo, and may ask you for your password." >&2
133
-         executor sudo pip install --upgrade pip setuptools
134
-         executor sudo pip install mod_pbxproj
135
-      fi
88
+      log_info "Installing mulle-xcode-settings"
89
+      brew install "mulle-xcode-settings" || fail "failed to install \"mulle-xcode-settings\""
136 90
    fi
137 91
 }
138 92
 
... ...
@@ -184,8 +138,6 @@ map_configuration()
184 138
 }
185 139
 
186 140
 
187
-
188
-
189 141
 patch_library_configurations()
190 142
 {
191 143
    local xcode_configurations
... ...
@@ -206,13 +158,7 @@ patch_library_configurations()
206 158
    for i in ${xcode_configurations}
207 159
    do
208 160
       mapped=`map_configuration "${configurations}" "${i}"`
209
-      if [ "${i}" = "Debug" -o "${i}" = "Release" ]
210
-      then
211
-         exekutor python -m mod_pbxproj -b "${flag}" 'LIBRARY_CONFIGURATION='"${mapped}" "${project}" "${i}" || exit 1
212
-      else
213
-         echo "${C_RED}You need to edit ${C_CYAN}LIBRARY_CONFIGURATION=${C_RED} \
214
-for ${C_CYAN}$i${C_RED} manually, sorry${C_RESET}" 2>&1
215
-      fi
161
+      exekutor mulle-xcode-settings -configuration "${i}" "${flag}" "LIBRARY_CONFIGURATION" "${mapped}" "${project}" || exit 1
216 162
    done
217 163
    IFS="${old}"
218 164
 }
... ...
@@ -237,7 +183,7 @@ patch_xcode_project()
237 183
 
238 184
    # mod_pbxproj can only do Debug/Release/All...
239 185
 
240
-   check_for_mod_pbxproj
186
+   check_for_mulle_xcode_settings
241 187
 
242 188
    configurations=`read_build_root_setting "configurations" "Debug
243 189
 Release"`
... ...
@@ -258,15 +204,15 @@ Release"
258 204
 
259 205
    if [ "$COMMAND" = "add" ]
260 206
    then
261
-      flag="-af"
207
+      flag="add"
262 208
       #     012345678901234567890123456789012345678901234567890123456789
263
-      echo "${C_WHITE}Settings will be added to ${C_MAGENTA}${projectname}${C_WHITE} and each contained target." >&2
209
+      echo "${C_WHITE}Settings will be added to ${C_MAGENTA}${projectname}${C_WHITE}." >&2
264 210
       echo "In the long term it may be more useful to copy/paste the following" >&2
265
-      echo "xcconfig lines into local .xcconfig files.${C_RESET}" >&2
211
+      echo "lines into a local .xcconfig file, that is inherited by all configurations.${C_RESET}" >&2
266 212
    else
267
-      flag="-rf"
213
+      flag="remove"
268 214
       #     012345678901234567890123456789012345678901234567890123456789
269
-      echo "${C_WHITE}Settings will be removed from ${projectname} and each contained target." >&2
215
+      echo "${C_WHITE}Settings will be removed from ${projectname}." >&2
270 216
       echo "You may want to check afterwards, that this has worked out OK :).${C_RESET}" >&2
271 217
    fi
272 218
 
... ...
@@ -354,10 +300,10 @@ Release"
354 300
 
355 301
    patch_library_configurations "${xcode_configurations}" "${configurations}" "${project}" "${flag}"
356 302
 
357
-   exekutor python -m mod_pbxproj -b "${flag}" "DEPENDENCIES_DIR=${dependencies_dir}" "${project}" "All" || exit 1
358
-   exekutor python -m mod_pbxproj -b "${flag}" "HEADER_SEARCH_PATHS=${header_search_paths}" "${project}" "All" || exit 1
359
-   exekutor python -m mod_pbxproj -b "${flag}" "LIBRARY_SEARCH_PATHS=${library_search_paths}" "${project}" "All" || exit 1
360
-   exekutor python -m mod_pbxproj -b "${flag}" "FRAMEWORK_SEARCH_PATHS=${framework_search_paths}" "${project}" "All" || exit 1
303
+   exekutor mulle-xcode-settings "${flag}" "DEPENDENCIES_DIR" "${dependencies_dir}" "${project}"  || exit 1
304
+   exekutor mulle-xcode-settings "${flag}" "HEADER_SEARCH_PATHS" "${header_search_paths}" "${project}"  || exit 1
305
+   exekutor mulle-xcode-settings "${flag}" "LIBRARY_SEARCH_PATHS" "${library_search_paths}" "${project}"  || exit 1
306
+   exekutor mulle-xcode-settings "${flag}" "FRAMEWORK_SEARCH_PATHS" "${framework_search_paths}" "${project}" || exit 1
361 307
 
362 308
 
363 309
    if [ "$COMMAND" = "add" ]
... ...
@@ -365,9 +311,6 @@ Release"
365 311
       #     012345678901234567890123456789012345678901234567890123456789
366 312
       echo "${C_WHITE}"
367 313
       echo "Hint:"
368
-      echo "You may want to delete the target settings, which have been" >&2
369
-      echo "(redundantly) added by mod_pbxproj. The project settings suffice." >&2
370
-      echo "" >&2
371 314
       echo "If you add a configuration to your project, remember to edit" >&2
372 315
       echo "the LIBRARY_CONFIGURATION setting for that configuration." >&2
373 316
       echo "" >&2