Skip to content

Instantly share code, notes, and snippets.

@mrackwitz
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrackwitz/198a767dda18a924ca79 to your computer and use it in GitHub Desktop.
Save mrackwitz/198a767dda18a924ca79 to your computer and use it in GitHub Desktop.
Script for iOS Projects to build and cache Facebook SDK when included as submodule/subtree
#!/bin/sh
# buildFacebookSdk.sh
#
# This can be included as a build phase in Xcode.
# It will ensure that the Facebook-SDK is built, when your project was
# originally checked out and whenever the commit pointer was changed.
# Furthermore you can use it with your CI. It will integrate seamlessly with
# the xctool output.
#
# Created by Marius Rackwitz on 09.01.14.
# Copyright (c) 2013 Marius Rackwitz.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
FACEBOOK_SDK_DIR='Libs/FacebookSDK'
##
# Print a line across the entire width of the terminal
# or of 80 char length if we are on dumb term (Xcode)
#
# @link http://wiki.bash-hackers.org/snipplets/print_horizontal_line
#
# @param length - enforce a line length
function printSeparator {
if [[ ! $1 && $TERM != 'dumb' ]]; then
LENGTH=$(tput cols)
else
LENGTH=${1:-80}
fi
if [[ $TERM != 'dumb' && ! $CI ]]; then
CHAR=━
else
CHAR=-
fi
printf '%*s\n' "${COLUMNS:-$LENGTH}" '' | tr ' ' $CHAR
}
echo "Build FacebookSDK"
cd $FACEBOOK_SDK_DIR
REV_FILE_PATH='build/.last-build-rev'
CURRENT_REV=`git rev-parse HEAD`
if [ "$CURRENT_REV" != "`cat $REV_FILE_PATH 2> /dev/null`" ]; then
STDERR=$(scripts/build_framework.sh 2>&1 > /dev/null)
if [[ $? == 0 ]]; then
printf "\033[1;32m✓\033[0m Current HEAD was built.\n"
git rev-parse HEAD > $REV_FILE_PATH
else
printf "\033[1;31m✗\033[0m Built failed with output:\n"
printf "\033[0;37m"
printSeparator $2
echo "$STDERR"
printSeparator $2
printf "\033[0m"
fi
else
printf "\033[1;32m✓\033[0m Current HEAD is already built. (Use \`\033[0;37mrm $FACEBOOK_SDK_DIR/$REV_FILE_PATH\033[0m\` to rebuild.)\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment