#!/bin/bash TARGET_DIR=$PWD/../unity_build BUILD_DIR=$TARGET_DIR/build SETUP=false UPDATE=false CLEAN=false NUM_JOBS=$(( `grep -c ^processor /proc/cpuinfo` + 1 )) LENSES="applications mockmusic mockvideos" # verified working revisions LIBUNITY_REV=215 UNITY_REV=3260 HUD_REV=252 usage() { echo "usage: build_unity [OPTIONS]\n" echo "Script to build Unity on Ubuntu 12.10.\n" echo "OPTIONS:" echo " -s, --setup Setup the build environment and branch Unity" echo " -u, --update Update Unity's source code" echo " -c, --clean Clean build trees before building" exit 1 } set -- `getopt -n$0 -u -a --longoptions="setup,update,clean,help" "such" "$@"` # FIXME: giving incorrect arguments does not call usage and exit while [ $# -gt 0 ] do case "$1" in -s|--setup) SETUP=true;; -u|--update) UPDATE=true;; -c|--clean) CLEAN=true;; -h|--help) usage;; --) shift;break;; esac shift done install_utils() { echo "Installing build utilities.." sudo apt-get install devscripts equivs || exit 4 } mk_build_deps() { echo "Installing build dependencies.." cd $TARGET_DIR sudo mk-build-deps -B -i $TARGET_DIR/libunity/debian/control || exit 5 sudo mk-build-deps -B -i $TARGET_DIR/unity/debian/control || exit 6 sudo mk-build-deps -B -i $TARGET_DIR/hud/debian/control || exit 7 } branch_libunity() { echo "Branching libunity.." bzr branch lp:libunity/phablet $TARGET_DIR/libunity || exit 8 } branch_unity() { echo "Branching Unity.." bzr branch lp:unity/phablet-mods $TARGET_DIR/unity || exit 9 } branch_hud() { echo "Branching hud.." bzr branch lp:hud $TARGET_DIR/hud || exit 10 } update_unity() { echo "Updating Unity.." bzr pull -d $TARGET_DIR/unity || exit 11 } update_libunity() { echo "Updating libunity.." bzr pull -d $TARGET_DIR/libunity || exit 12 } update_hud() { echo "Updating hud" bzr pull -d $TARGET_DIR/hud || exit 13 } compile_libunity() { echo "Configuring libunity.." if $CLEAN; then bzr clean-tree -d $TARGET_DIR/libunity --quiet --unknown --ignored --force; fi cd $TARGET_DIR/libunity bzr revert --quiet -r $LIBUNITY_REV || exit 14 mkdir $TARGET_DIR/libunity/build cd $TARGET_DIR/libunity/build ../autogen.sh --prefix $BUILD_DIR --disable-debug || exit 15 echo "Building libunity and installing in " $BUILD_DIR make -j$NUM_JOBS install || exit 16 } compile_unity_core() { echo "Configuring Unity.." if $CLEAN; then bzr clean-tree -d $TARGET_DIR/unity --quiet --unknown --ignored --force; fi cd $TARGET_DIR/unity bzr revert --quiet -r $UNITY_REV || exit 17 mkdir $TARGET_DIR/unity/build cd $TARGET_DIR/unity/build PKG_CONFIG_PATH=$BUILD_DIR/lib/pkgconfig:$PKG_CONFIG_PATH cmake $TARGET_DIR/unity -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$BUILD_DIR -DCOMPIZ_PLUGIN_INSTALL_TYPE=local -DGSETTINGS_LOCALINSTALL=ON || exit 18 echo "Building UnityCore and installing in " $BUILD_DIR cd UnityCore make -j$NUM_JOBS install || exit 19 } compile_hud() { echo "Configuring hud.." if $CLEAN; then bzr clean-tree -d $TARGET_DIR/hud --quiet --unknown --ignored --force; fi cd $TARGET_DIR/hud bzr revert -r $HUD_REV || exit 20 mkdir $TARGET_DIR/hud/build cd $TARGET_DIR/hud/build cmake $TARGET_DIR/hud/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$BUILD_DIR -DCMAKE_INSTALL_LIBDIR=lib -DLOCAL_INSTALL=ON -DENABLE_TESTS=OFF || exit 21 echo "Building hud and installing in " $BUILD_DIR make install || exit 22 } link_lenses() { echo "Linking system lenses.." mkdir -p $BUILD_DIR/share/unity/lenses/ for LENS in $LENSES; do [ -e $BUILD_DIR/share/unity/lenses/$LENS ] || ln -ivs /usr/share/unity/lenses/$LENS $BUILD_DIR/share/unity/lenses/$LENS done } if $SETUP; then echo "Setting up environment for building Unity.." install_utils mkdir -p $TARGET_DIR branch_libunity branch_unity branch_hud mk_build_deps elif $UPDATE; then update_libunity update_unity update_hud mk_build_deps else if $CLEAN; then rm -Rf $BUILD_DIR; fi mkdir -p $BUILD_DIR compile_libunity compile_unity_core compile_hud link_lenses fi