diff --git a/build.sh b/build.sh index 0dda011eb2..87423af3c2 100755 --- a/build.sh +++ b/build.sh @@ -2,17 +2,64 @@ PLATFORM="platform=iOS Simulator,name=iPhone 7" SDK="iphonesimulator" +DERIVED_DATA_PATH="~/ASDKDerivedData" # It is pitch black. set -e -function trap_handler() { +function trap_handler { echo -e "\n\nOh no! You walked directly into the slavering fangs of a lurking grue!" echo "**** You have died ****" exit 255 } trap trap_handler INT TERM EXIT +# Derived data handling +[ -d DERIVED_DATA_PATH ] || mkdir DERIVED_DATA_PATH +function clean_derived_data { + eval find $DERIVED_DATA_PATH -mindepth 1 -delete +} + +# Build example +function build_example { + example="$1" + + clean_derived_data + + if [ -f "${example}/Podfile" ]; then + echo "Using CocoaPods" + if [ -f "${example}/Podfile.lock" ]; then + rm "$example/Podfile.lock" + fi + rm -rf "$example/Pods" + pod install --project-directory=$example + + set -o pipefail && xcodebuild \ + -workspace "${example}/Sample.xcworkspace" \ + -scheme Sample \ + -sdk "$SDK" \ + -destination "$PLATFORM" \ + -derivedDataPath "$DERIVED_DATA_PATH" \ + build | xcpretty $FORMATTER + elif [ -f "${example}/Cartfile" ]; then + echo "Using Carthage" + local_repo=`pwd` + current_branch=`git rev-parse --abbrev-ref HEAD` + cd $example + + echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile" + carthage update --platform iOS + + set -o pipefail && xcodebuild \ + -project "Sample.xcodeproj" \ + -scheme Sample \ + -sdk "$SDK" \ + -destination "$PLATFORM" \ + build | xcpretty $FORMATTER + + cd ../.. + fi +} MODE="$1" @@ -56,44 +103,7 @@ if [ "$MODE" = "examples" ]; then for example in examples/*/; do echo "Building (examples) $example." - rm -rf ~/ModuleCache - rm -rf ~/Build - rm -rf ~/Info.plist - rm -rf ~/Logs - - if [ -f "${example}/Podfile" ]; then - echo "Using CocoaPods" - if [ -f "${example}/Podfile.lock" ]; then - rm "$example/Podfile.lock" - fi - rm -rf "$example/Pods" - pod install --project-directory=$example - - set -o pipefail && xcodebuild \ - -workspace "${example}/Sample.xcworkspace" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - -derivedDataPath ~/ \ - clean build | xcpretty $FORMATTER - elif [ -f "${example}/Cartfile" ]; then - echo "Using Carthage" - local_repo=`pwd` - current_branch=`git rev-parse --abbrev-ref HEAD` - cd $example - - echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile" - carthage update --platform iOS - - set -o pipefail && xcodebuild \ - -project "Sample.xcodeproj" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - build | xcpretty $FORMATTER - - cd ../.. - fi + build_example $example done trap - EXIT exit 0 @@ -107,39 +117,7 @@ if [ "$MODE" = "examples-pt1" ]; then for example in $((find ./examples -type d -maxdepth 1 \( ! -iname ".*" \)) | head -6 | head); do echo "Building (examples-pt1) $example." - if [ -f "${example}/Podfile" ]; then - echo "Using CocoaPods" - if [ -f "${example}/Podfile.lock" ]; then - rm "$example/Podfile.lock" - fi - rm -rf "$example/Pods" - pod install --project-directory=$example - - set -o pipefail && xcodebuild \ - -workspace "${example}/Sample.xcworkspace" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - -derivedDataPath ~/ \ - build | xcpretty $FORMATTER - elif [ -f "${example}/Cartfile" ]; then - echo "Using Carthage" - local_repo=`pwd` - current_branch=`git rev-parse --abbrev-ref HEAD` - cd $example - - echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile" - carthage update --platform iOS - - set -o pipefail && xcodebuild \ - -project "Sample.xcodeproj" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - build | xcpretty $FORMATTER - - cd ../.. - fi + build_example $example done trap - EXIT exit 0 @@ -153,39 +131,7 @@ if [ "$MODE" = "examples-pt2" ]; then for example in $((find ./examples -type d -maxdepth 1 \( ! -iname ".*" \)) | head -12 | tail -6 | head); do echo "Building $example (examples-pt2)." - if [ -f "${example}/Podfile" ]; then - echo "Using CocoaPods" - if [ -f "${example}/Podfile.lock" ]; then - rm "$example/Podfile.lock" - fi - rm -rf "$example/Pods" - pod install --project-directory=$example - - set -o pipefail && xcodebuild \ - -workspace "${example}/Sample.xcworkspace" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - -derivedDataPath ~/ \ - build | xcpretty $FORMATTER - elif [ -f "${example}/Cartfile" ]; then - echo "Using Carthage" - local_repo=`pwd` - current_branch=`git rev-parse --abbrev-ref HEAD` - cd $example - - echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile" - carthage update --platform iOS - - set -o pipefail && xcodebuild \ - -project "Sample.xcodeproj" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - build | xcpretty $FORMATTER - - cd ../.. - fi + build_example $example done trap - EXIT exit 0 @@ -199,39 +145,7 @@ if [ "$MODE" = "examples-pt3" ]; then for example in $((find ./examples -type d -maxdepth 1 \( ! -iname ".*" \)) | head -7 | head); do echo "Building $example (examples-pt3)." - if [ -f "${example}/Podfile" ]; then - echo "Using CocoaPods" - if [ -f "${example}/Podfile.lock" ]; then - rm "$example/Podfile.lock" - fi - rm -rf "$example/Pods" - pod install --project-directory=$example - - set -o pipefail && xcodebuild \ - -workspace "${example}/Sample.xcworkspace" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - -derivedDataPath ~/ \ - build | xcpretty $FORMATTER - elif [ -f "${example}/Cartfile" ]; then - echo "Using Carthage" - local_repo=`pwd` - current_branch=`git rev-parse --abbrev-ref HEAD` - cd $example - - echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile" - carthage update --platform iOS - - set -o pipefail && xcodebuild \ - -project "Sample.xcodeproj" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - build | xcpretty $FORMATTER - - cd ../.. - fi + build_example $example done trap - EXIT exit 0 @@ -245,44 +159,23 @@ if [ "$MODE" = "examples-extra" ]; then for example in $((find ./examples_extra -type d -maxdepth 1 \( ! -iname ".*" \)) | head -7 | head); do echo "Building $example (examples-extra)." - if [ -f "${example}/Podfile" ]; then - echo "Using CocoaPods" - if [ -f "${example}/Podfile.lock" ]; then - rm "$example/Podfile.lock" - fi - rm -rf "$example/Pods" - pod install --project-directory=$example - - set -o pipefail && xcodebuild \ - -workspace "${example}/Sample.xcworkspace" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - -derivedDataPath ~/ \ - build | xcpretty $FORMATTER - elif [ -f "${example}/Cartfile" ]; then - echo "Using Carthage" - local_repo=`pwd` - current_branch=`git rev-parse --abbrev-ref HEAD` - cd $example - - echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile" - carthage update --platform iOS - - set -o pipefail && xcodebuild \ - -project "Sample.xcodeproj" \ - -scheme Sample \ - -sdk "$SDK" \ - -destination "$PLATFORM" \ - build | xcpretty $FORMATTER - - cd ../.. - fi + build_example $example done trap - EXIT exit 0 fi +# Support building a specific example: sh build.sh example examples/ASDKLayoutTransition +if [ "$MODE" = "example" ]; then + echo "Verifying that all AsyncDisplayKit examples compile." + #Update cocoapods repo + pod repo update master + + build_example $2 + trap - EXIT + exit 0 +fi + if [ "$MODE" = "life-without-cocoapods" ]; then echo "Verifying that AsyncDisplayKit functions as a static library."