6 ## This script is initiated by either xcodebuild or Xcode.app.
8 ## We must guarantee no jobserver is passed through since file-descriptors are
9 ## clobbered by Xcode. If this is not done then make allows unlimited jobs.
14 ## validate environment
15 case "$EXTERNAL_DRIVER" in
16 bootstrap
) ;; ## bootstrapping from terminal
17 terminal
) ;; ## building from terminal
18 xcode
) ;; ## building from Xcode.app
20 echo "ERROR: unexpected value for EXTERNAL_DRIVER: $EXTERNAL_DRIVER"
25 ## validate environment
26 for name
in EXTERNAL_BUILD EXTERNAL_JOBS EXTERNAL_SRC
; do
29 echo "ERROR: missing value for $name"
34 ## validate environment
35 archcount
=`echo $ARCHS | awk '{ print NF }'`
36 if [ "$archcount" -ne 1 ]; then
37 echo "*********************************************************************"
39 echo "*** ERROR: multiple architectures: $ARCHS"
41 echo "*** This build system does not support more than one (1)"
42 echo "*** simultaneous architecture setting."
44 echo "*********************************************************************"
50 ## compute goals; these correlate with TARGET_NAME and ACTION from Xcode
51 spec
="$TARGET_NAME:$ACTION"
52 echo "target specification: $spec"
55 if [ "$EXTERNAL_DRIVER" == "xcode" ]; then
56 ## driving build from Xcode.app do pristine clean
57 if [ -z "$EXTERNAL_BUILD" ]; then
58 echo "ERROR: unsafe rm -fr would result because EXTERNAL_BUILD is not defined"
61 if [ -d "$EXTERNAL_BUILD" ]; then
62 cmd
="/bin/rm -fr $EXTERNAL_BUILD/*"
65 [ $?
-ne 0 ] && exit 1
71 ## driving build from xcodebuild do xclean, preserving configuration
76 if [ -z "$EXTERNAL_GOALS" ]; then
79 goals
="$EXTERNAL_GOALS"
83 echo "ERROR: unexpected env specification: $spec"
88 ## compute if re/configure necessary
89 if [ ! -f $EXTERNAL_BUILD/GNUmakefile
]; then
90 reconfigure
="no configuration present"
91 elif [ $EXTERNAL_SRC/make
/configure.py
-nt $EXTERNAL_BUILD/GNUmakefile
]; then
92 reconfigure
="configure script was updated"
93 elif [ $EXTERNAL_DRIVER == "bootstrap" ]; then
94 reconfigure
="driver bootstrap"
99 ## perform re/configure
100 if [ -n "$reconfigure" ]; then
101 echo "reconfiguring ($reconfigure)"
103 if [ "$EXTERNAL_DRIVER" == "bootstrap" ]; then
104 driver
="--xcode-driver=terminal"
106 driver
="--xcode-driver=$EXTERNAL_DRIVER"
109 ## determine which compiler to use based on Xcode environment (project).
110 case "$GCC_VERSION" in
111 com.apple.compilers.llvmgcc42
)
112 gcc
="--gcc=`$DEVELOPER_BIN_DIR/xcodebuild -find-executable llvm-gcc-4.2`"
114 com.apple.compilers.llvm.clang
.1_0
)
115 gcc
="--gcc=`$DEVELOPER_BIN_DIR/xcodebuild -find-executable clang`"
118 echo "*********************************************************************"
120 echo "*** ERROR: unexpected value for GCC_VERSION: $GCC_VERSION"
122 echo "*********************************************************************"
127 if [ -n "$ARCHS" ]; then
133 case "$CONFIGURATION" in
135 debug
="--debug=std --optimize=none"
142 if [ -n "$SDKROOT" ]; then
143 sysroot
="--sysroot=$SDKROOT"
148 if [ -n "$MACOSX_DEPLOYMENT_TARGET" ]; then
149 minver
="--minver=$MACOSX_DEPLOYMENT_TARGET"
154 ## pickup user setting from Xcode IDE and avoid recursion
155 if [ -n "$EXTERNAL_CONFIGURE" ]; then
156 extconf
="$EXTERNAL_CONFIGURE"
162 ## invoke configure with (hidden) option which indicates conf performed by xcode
163 (set -ex; $EXTERNAL_SRC/configure
--force \
164 $EXTERNAL_CONF_ARGS \
165 --build="$EXTERNAL_BUILD" \
167 --xcode-symroot="$SYMROOT" \
168 --xcode-config="$EXTERNAL_XCCONFIG" \
169 $gcc $arch $debug $sysroot $minver $extconf)
170 [ $?
-ne 0 ] && exit 1
173 ## log environment as provided by Xcode
174 logdir
=$EXTERNAL_BUILD/log
175 if [ ! -d $logdir ]; then
178 env |
sort > $logdir/xcodemake.env.txt
180 [ $exit_post_log -ne 0 ] && exit 0
182 ## safeguard against passing blank value which would result in unlimited jobs
183 if [ -z "$EXTERNAL_JOBS" ]; then
185 elif [ "$EXTERNAL_JOBS" == "auto" ]; then
186 jobs=--jobs=`sysctl -n hw.activecpu`
188 jobs=--jobs=$EXTERNAL_JOBS
191 ## when driving from terminal; ensure $SYMROOT/external/ exists relative to SYMROOT
192 if [ "$EXTERNAL_DRIVER" == "terminal" -a ! -e "$SYMROOT/external" ]; then
193 ln -s "$EXTERNAL_BUILD" "$SYMROOT/external"
197 ## must set XCODE.driver to prevent inifinite recursion
199 exec make -C $EXTERNAL_BUILD XCODE.driver
=xcodemake
$jobs $goals $EXTERNAL_VARS