Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 64 additions & 171 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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."

Expand Down