Skip to content

Commit

Permalink
Merge pull request BoltsFramework#159 from BoltsFramework/nlutsenko.w…
Browse files Browse the repository at this point in the history
…atchOS.scripts

Add watchOS 2 to deployment.
  • Loading branch information
nlutsenko committed Sep 23, 2015
2 parents 6a3d62c + 6ff39e2 commit 7581f66
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 30 deletions.
122 changes: 96 additions & 26 deletions scripts/build_framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
# process options, valid arguments -c [Debug|Release] -n
BUILDCONFIGURATION=Debug
NOEXTRAS=1
while getopts ":ntc:" OPTNAME
WATCHOS=0
TVOS=0
while getopts ":ntc:-:" OPTNAME
do
case "$OPTNAME" in
"c")
Expand All @@ -34,11 +36,28 @@ do
"t")
NOEXTRAS=0
;;
-)
case "${OPTARG}" in
"with-watchos")
WATCHOS=1
;;
"with-tvos")
TVOS=1
;;
*)
# Should not occur
echo "Unknown error while processing options"
die
;;
esac
;;
"?")
echo "$0 -c [Debug|Release] -n"
echo "$0 -c [Debug|Release] -n --with-watchos --with-tvos"
echo " -c sets configuration (default=Debug)"
echo " -n no test run (default)"
echo " -t test run"
echo " --with-watchos Add watchOS framework"
echo " --with-tvos Add tvOS framework"
die
;;
":")
Expand All @@ -59,6 +78,7 @@ test -x "$LIPO" || die 'Could not find lipo in $PATH'
BOLTS_IOS_BINARY=$BOLTS_BUILD/${BUILDCONFIGURATION}-universal/Bolts.framework/Bolts
BOLTS_OSX_BINARY=$BOLTS_BUILD/${BUILDCONFIGURATION}/Bolts.framework
BOLTS_TVOS_BINARY=$BOLTS_BUILD/${BUILDCONFIGURATION}-appletv-universal/Bolts.framework/Bolts
BOLTS_WATCHOS_BINARY=$BOLTS_BUILD/${BUILDCONFIGURATION}-watch-universal/Bolts.framework/Bolts

# -----------------------------------------------------------------------------

Expand All @@ -79,15 +99,23 @@ test -d "$BOLTS_OSX_BUILD" \
|| mkdir -p "$BOLTS_OSX_BUILD" \
|| die "Could not create directory $BOLTS_OSX_BUILD"

test -d "$BOLTS_TVOS_BUILD" \
|| mkdir -p "$BOLTS_TVOS_BUILD" \
|| die "Could not create directory $BOLTS_TVOS_BUILD"
if [ $WATCHOS -eq 1 ]; then
test -d "$BOLTS_WATCHOS_BUILD" \
|| mkdir -p "$BOLTS_WATCHOS_BUILD" \
|| die "Could not create directory $BOLTS_WATCHOS_BUILD"
fi

if [ $TVOS -eq 1 ]; then
test -d "$BOLTS_TVOS_BUILD" \
|| mkdir -p "$BOLTS_TVOS_BUILD" \
|| die "Could not create directory $BOLTS_TVOS_BUILD"
fi

cd "$BOLTS_SRC"
function xcode_build_target() {
echo "Compiling for platform: ${1}."
$XCODEBUILD \
-target "${3}Bolts" \
-target "${3}" \
-sdk $1 \
-configuration "${2}" \
SYMROOT="$BOLTS_BUILD" \
Expand All @@ -96,31 +124,54 @@ function xcode_build_target() {
|| die "Xcode build failed for platform: ${1}."
}

xcode_build_target "iphonesimulator" "${BUILDCONFIGURATION}"
xcode_build_target "iphoneos" "${BUILDCONFIGURATION}"
xcode_build_target "macosx" "${BUILDCONFIGURATION}" "Mac"
xcode_build_target "appletvsimulator" "${BUILDCONFIGURATION}" "TV"
xcode_build_target "appletvos" "${BUILDCONFIGURATION}" "TV"
xcode_build_target "iphonesimulator" "${BUILDCONFIGURATION}" "Bolts"
xcode_build_target "iphoneos" "${BUILDCONFIGURATION}" "Bolts"
xcode_build_target "macosx" "${BUILDCONFIGURATION}" "MacBolts"
if [ $WATCHOS -eq 1 ]; then
xcode_build_target "watchsimulator" "${BUILDCONFIGURATION}" "Bolts-watchOS"
xcode_build_target "watchos" "${BUILDCONFIGURATION}" "Bolts-watchOS"
fi
if [ $TVOS -eq 1 ]; then
xcode_build_target "appletvsimulator" "${BUILDCONFIGURATION}" "TVBolts"
xcode_build_target "appletv" "${BUILDCONFIGURATION}" "TVBolts"
fi

# -----------------------------------------------------------------------------
# Merge lib files for different platforms into universal binary
#
progress_message "Building Bolts univeral library using lipo."

mkdir -p "$(dirname "$BOLTS_IOS_BINARY")"
mkdir -p "$(dirname "$BOLTS_TVOS_BINARY")"

if [ $WATCHOS -eq 1 ]; then
mkdir -p "$(dirname "$BOLTS_WATCHOS_BINARY")"
fi

if [ $TVOS -eq 1 ]; then
mkdir -p "$(dirname "$BOLTS_TVOS_BINARY")"
fi

# Copy/Paste iOS Framework to get structure/resources/etc
cp -av \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-iphoneos/Bolts.framework" \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-universal"
rm "$BOLTS_BUILD/${BUILDCONFIGURATION}-universal/Bolts.framework/Bolts"

# Copy/Paste AppleTV framework to get structure/resources/etc
cp -av \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-appletvos/Bolts.framework" \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-appletv-universal"
rm "$BOLTS_BUILD/${BUILDCONFIGURATION}-appletv-universal/Bolts.framework/Bolts"
if [ $WATCHOS -eq 1 ]; then
# Copy/Paste watchOS framework to get structure/resources/etc
cp -av \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-watchos/Bolts.framework" \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-watch-universal"
rm "$BOLTS_BUILD/${BUILDCONFIGURATION}-watch-universal/Bolts.framework/Bolts"
fi

if [ $TVOS -eq 1 ]; then
# Copy/Paste tvOS framework to get structure/resources/etc
cp -av \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-appletvos/Bolts.framework" \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-appletv-universal"
rm "$BOLTS_BUILD/${BUILDCONFIGURATION}-appletv-universal/Bolts.framework/Bolts"
fi

# Combine iOS/Simulator binaries into a single universal binary.
$LIPO \
Expand All @@ -130,22 +181,41 @@ $LIPO \
-output "$BOLTS_IOS_BINARY" \
|| die "lipo failed - could not create universal static library"

# Combine AppleTV/Simulator binaries into a single universal binary.
$LIPO \
-create \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-appletvsimulator/Bolts.framework/Bolts" \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-appletvos/Bolts.framework/Bolts" \
-output "$BOLTS_TVOS_BINARY" \
|| die "lipo failed - could not create universal static library"
if [ $WATCHOS -eq 1 ]; then
# Combine watchOS/Simulator binaries into a single universal binary.
$LIPO \
-create \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-watchsimulator/Bolts.framework/Bolts" \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-watchos/Bolts.framework/Bolts" \
-output "$BOLTS_WATCHOS_BINARY" \
|| die "lipo failed - could not create universal static library"
fi

if [ $TVOS -eq 1 ]; then
# Combine tvOS/Simulator binaries into a single universal binary.
$LIPO \
-create \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-appletvsimulator/Bolts.framework/Bolts" \
"$BOLTS_BUILD/${BUILDCONFIGURATION}-appletvos/Bolts.framework/Bolts" \
-output "$BOLTS_TVOS_BINARY" \
|| die "lipo failed - could not create universal static library"
fi

# Copy/Paste created iOS Framework to final location
cp -av "$(dirname "$BOLTS_IOS_BINARY")" $BOLTS_IOS_FRAMEWORK

# Copy/Paste OSX framework, as this is already built for us
cp -av "$BOLTS_OSX_BINARY" $BOLTS_OSX_FRAMEWORK

# Copy/Paste TVOS Framework
cp -av "$(dirname "$BOLTS_TVOS_BINARY")" $BOLTS_TVOS_FRAMEWORK
if [ $WATCHOS -eq 1 ]; then
# Copy/Paste watchOS Framework
cp -av "$(dirname "$BOLTS_WATCHOS_BINARY")" $BOLTS_WATCHOS_FRAMEWORK
fi

if [ $TVOS -eq 1 ]; then
# Copy/Paste tvOS Framework
cp -av "$(dirname "$BOLTS_TVOS_BINARY")" $BOLTS_TVOS_FRAMEWORK
fi

# -----------------------------------------------------------------------------
# Run unit tests
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
# -----------------------------------------------------------------------------
# Call out to build .framework
#
. $BOLTS_SCRIPT/build_framework.sh -c Release
. $BOLTS_SCRIPT/build_framework.sh --with-watchos -c Release

cd $BOLTS_BUILD
zip -r --symlinks $BOLTS_DISTRIBUTION_ARCHIVE ios/ osx/
zip -r --symlinks $BOLTS_DISTRIBUTION_ARCHIVE ios/ osx/ watchOS/

common_success
6 changes: 4 additions & 2 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ if [ -z "$BOLTS_SCRIPT" ]; then
BOLTS_BUILD=$BOLTS_ROOT/build
BOLTS_IOS_BUILD=$BOLTS_ROOT/build/ios
BOLTS_OSX_BUILD=$BOLTS_ROOT/build/osx
BOLTS_TVOS_BUILD=$BOLTS_ROOT/build/tvos
BOLTS_WATCHOS_BUILD=$BOLTS_ROOT/build/watchOS
BOLTS_TVOS_BUILD=$BOLTS_ROOT/build/tvOS
BOLTS_BUILD_LOG=$BOLTS_BUILD/build.log

# The name of the Bolts framework
Expand All @@ -57,7 +58,8 @@ if [ -z "$BOLTS_SCRIPT" ]; then
# The path to the built Bolts .framework file
BOLTS_IOS_FRAMEWORK=$BOLTS_IOS_BUILD/$BOLTS_FRAMEWORK_NAME
BOLTS_OSX_FRAMEWORK=$BOLTS_OSX_BUILD/$BOLTS_FRAMEWORK_NAME
BOLTS_TVOS_FRAMEWORK=$BOLTS_TVOS_BUILD/$BOLTS_FRAMEWORK_NAME
BOLTS_WATCHOS_FRAMEWORK=$BOLTS_WATCHOS_BUILD/$BOLTS_FRAMEWORK_NAME
BOLTS_TVOS_FRAMEWORK=$BOLTS_WATCHOS_BUILD/$BOLTS_FRAMEWORK_NAME

# The name of the docset
BOLTS_DOCSET_NAME=Bolts.docset
Expand Down

0 comments on commit 7581f66

Please sign in to comment.