Skip to content

Commit

Permalink
Update objc-build-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jspahrsummers committed Nov 11, 2013
1 parent c03669e commit 94ef093
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 9 deletions.
74 changes: 68 additions & 6 deletions script/README.md
@@ -1,20 +1,82 @@
These scripts are primarily meant to support the use of # objc-build-scripts
[Janky](https://github.com/github/janky). To use them, read the contents of this
repository into a `script` folder: This project is a collection of scripts created with two goals:

1. To standardize how Objective-C projects are bootstrapped after cloning
1. To easily build Objective-C projects on continuous integration servers

## Scripts

Right now, there are two important scripts: [`bootstrap`](#bootstrap) and
[`cibuild`](#cibuild). Both are Bash scripts, to maximize compatibility and
eliminate pesky system configuration issues (like setting up a working Ruby
environment).

The structure of the scripts on disk is meant to follow that of a typical Ruby
project:

```
script/
bootstrap
cibuild
```

### bootstrap

This script is responsible for bootstrapping (initializing) your project after
it's been checked out. Here, you should install or clone any dependencies that
are required for a working build and development environment.

By default, the script will verify that [xctool][] is installed, then initialize
and update submodules recursively. If any submodules contain `script/bootstrap`,
that will be run as well.

To check that other tools are installed, you can set the `REQUIRED_TOOLS`
environment variable before running `script/bootstrap`, or edit it within the
script directly. Note that no installation is performed automatically, though
this can always be added within your specific project.

### cibuild

This script is responsible for building the project, as you would want it built
for continuous integration. This is preferable to putting the logic on the CI
server itself, since it ensures that any changes are versioned along with the
source.

By default, the script will run [`bootstrap`](#bootstrap), look for any Xcode
workspace or project in the working directory, then build all targets/schemes
(as found by `xcodebuild -list`) using [xctool][].

You can also specify the schemes to build by passing them into the script:

```sh
script/cibuild ReactiveCocoa-Mac ReactiveCocoa-iOS
```

As with the `bootstrap` script, there are several environment variables that can
be used to customize behavior. They can be set on the command line before
invoking the script, or the defaults changed within the script directly.

## Getting Started

To add the scripts to your project, read the contents of this repository into
a `script` folder:


``` ```
$ git remote add objc-build-scripts https://github.com/jspahrsummers/objc-build-scripts.git $ git remote add objc-build-scripts https://github.com/jspahrsummers/objc-build-scripts.git
$ git fetch objc-build-scripts $ git fetch objc-build-scripts
$ git read-tree --prefix=script/ -u objc-build-scripts/master $ git read-tree --prefix=script/ -u objc-build-scripts/master
``` ```


Then commit the changes to incorporate the scripts into your own repository's Then commit the changes, to incorporate the scripts into your own repository's
history. You can also freely tweak the scripts for your specific project's history. You can also freely tweak the scripts for your specific project's
needs. needs.


To bring in upstream changes later: To merge in upstream changes later:


``` ```
$ git fetch -p objc-build-scripts $ git fetch -p objc-build-scripts
$ git merge -Xsubtree=script objc-build-scripts/master $ git merge --ff --squash -Xsubtree=script objc-build-scripts/master
``` ```

[xctool]: https://github.com/facebook/xctool
15 changes: 12 additions & 3 deletions script/cibuild
Expand Up @@ -113,17 +113,26 @@ build_scheme ()
echo "*** Building and testing $scheme..." echo "*** Building and testing $scheme..."
echo echo


# Determine whether this target needs to be built using the iOS simulator SDK.
local sdkflag= local sdkflag=
local action=test local action=test

# Determine whether we can run unit tests for this target.
run_xctool -scheme "$scheme" run-tests | parse_build run_xctool -scheme "$scheme" run-tests | parse_build


if [ "$?" -eq "1" ] local awkstatus=$?

if [ "$awkstatus" -ne "0" ]
then then
sdkflag="-sdk iphonesimulator" # Unit tests aren't supported.
action=build action=build
fi fi


if [ "$awkstatus" -eq "1" ]
then
# Build for iOS.
sdkflag="-sdk iphonesimulator"
fi

run_xctool $sdkflag -scheme "$scheme" $action run_xctool $sdkflag -scheme "$scheme" $action
} }


Expand Down
5 changes: 5 additions & 0 deletions script/xctool.awk
Expand Up @@ -2,6 +2,7 @@
# #
# 0 - No errors found. # 0 - No errors found.
# 1 - Wrong SDK. Retry with SDK `iphonesimulator`. # 1 - Wrong SDK. Retry with SDK `iphonesimulator`.
# 2 - Missing target.


BEGIN { BEGIN {
status = 0; status = 0;
Expand All @@ -15,6 +16,10 @@ BEGIN {
status = 1; status = 1;
} }


/does not contain a target named/ {
status = 2;
}

END { END {
exit status; exit status;
} }

0 comments on commit 94ef093

Please sign in to comment.