on 3b92eca help sign in
unity8/build_unity
168 lines 4.3 kB history raw
1#!/bin/bash
3TARGET_DIR=$PWD/../unity_build
4BUILD_DIR=$TARGET_DIR/build
5SETUP=false
6UPDATE=false
7CLEAN=false
8NUM_JOBS=$(( `grep -c ^processor /proc/cpuinfo` + 1 ))
9LENSES="applications mockmusic mockvideos"
11# verified working revisions
12LIBUNITY_REV=215
13UNITY_REV=3260
14HUD_REV=252
16usage() {
17 echo "usage: build_unity [OPTIONS]\n"
18 echo "Script to build Unity on Ubuntu 12.10.\n"
19 echo "OPTIONS:"
20 echo " -s, --setup Setup the build environment and branch Unity"
21 echo " -u, --update Update Unity's source code"
22 echo " -c, --clean Clean build trees before building"
23 exit 1
26set -- `getopt -n$0 -u -a --longoptions="setup,update,clean,help" "such" "$@"`
28# FIXME: giving incorrect arguments does not call usage and exit
29while [ $# -gt 0 ]
30do
31 case "$1" in
32 -s|--setup) SETUP=true;;
33 -u|--update) UPDATE=true;;
34 -c|--clean) CLEAN=true;;
35 -h|--help) usage;;
36 --) shift;break;;
37 esac
38 shift
39done
41install_utils() {
42 echo "Installing build utilities.."
43 sudo apt-get install devscripts equivs || exit 4
46mk_build_deps() {
47 echo "Installing build dependencies.."
48 cd $TARGET_DIR
49 sudo mk-build-deps -B -i $TARGET_DIR/libunity/debian/control || exit 5
50 sudo mk-build-deps -B -i $TARGET_DIR/unity/debian/control || exit 6
51 sudo mk-build-deps -B -i $TARGET_DIR/hud/debian/control || exit 7
54branch_libunity() {
55 echo "Branching libunity.."
56 bzr branch lp:libunity/phablet $TARGET_DIR/libunity || exit 8
59branch_unity() {
60 echo "Branching Unity.."
61 bzr branch lp:unity/phablet-mods $TARGET_DIR/unity || exit 9
64branch_hud() {
65 echo "Branching hud.."
66 bzr branch lp:hud $TARGET_DIR/hud || exit 10
69update_unity() {
70 echo "Updating Unity.."
71 bzr pull -d $TARGET_DIR/unity || exit 11
74update_libunity() {
75 echo "Updating libunity.."
76 bzr pull -d $TARGET_DIR/libunity || exit 12
79update_hud() {
80 echo "Updating hud"
81 bzr pull -d $TARGET_DIR/hud || exit 13
84compile_libunity() {
85 echo "Configuring libunity.."
87 if $CLEAN; then bzr clean-tree -d $TARGET_DIR/libunity --quiet --unknown --ignored --force; fi
89 cd $TARGET_DIR/libunity
90 bzr revert --quiet -r $LIBUNITY_REV || exit 14
92 mkdir $TARGET_DIR/libunity/build
93 cd $TARGET_DIR/libunity/build
95 ../autogen.sh --prefix $BUILD_DIR --disable-debug || exit 15
97 echo "Building libunity and installing in " $BUILD_DIR
98 make -j$NUM_JOBS install || exit 16
102compile_unity_core() {
103 echo "Configuring Unity.."
105 if $CLEAN; then bzr clean-tree -d $TARGET_DIR/unity --quiet --unknown --ignored --force; fi
107 cd $TARGET_DIR/unity
108 bzr revert --quiet -r $UNITY_REV || exit 17
110 mkdir $TARGET_DIR/unity/build
111 cd $TARGET_DIR/unity/build
113 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
115 echo "Building UnityCore and installing in " $BUILD_DIR
116 cd UnityCore
117 make -j$NUM_JOBS install || exit 19
121compile_hud() {
122 echo "Configuring hud.."
124 if $CLEAN; then bzr clean-tree -d $TARGET_DIR/hud --quiet --unknown --ignored --force; fi
126 cd $TARGET_DIR/hud
127 bzr revert -r $HUD_REV || exit 20
129 mkdir $TARGET_DIR/hud/build
130 cd $TARGET_DIR/hud/build
132 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
134 echo "Building hud and installing in " $BUILD_DIR
135 make install || exit 22
139link_lenses() {
140 echo "Linking system lenses.."
141 mkdir -p $BUILD_DIR/share/unity/lenses/
142 for LENS in $LENSES; do
143 [ -e $BUILD_DIR/share/unity/lenses/$LENS ] || ln -ivs /usr/share/unity/lenses/$LENS $BUILD_DIR/share/unity/lenses/$LENS
144 done
147if $SETUP; then
148 echo "Setting up environment for building Unity.."
149 install_utils
150 mkdir -p $TARGET_DIR
151 branch_libunity
152 branch_unity
153 branch_hud
154 mk_build_deps
155elif $UPDATE; then
156 update_libunity
157 update_unity
158 update_hud
159 mk_build_deps
160else
161 if $CLEAN; then rm -Rf $BUILD_DIR; fi
162 mkdir -p $BUILD_DIR
163 compile_libunity
164 compile_unity_core
165 compile_hud
166 link_lenses
167fi