on c5e376f help sign in
unity8/build_unity
158 lines 4.0 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 ))
10# verified working revisions
11LIBUNITY_REV=228
12UNITY_REV=3343
13HUD_REV=252
15usage() {
16 echo "usage: build_unity [OPTIONS]\n"
17 echo "Script to build Unity on Ubuntu 12.10.\n"
18 echo "OPTIONS:"
19 echo " -s, --setup Setup the build environment and branch Unity"
20 echo " -u, --update Update Unity's source code"
21 echo " -c, --clean Clean build trees before building"
22 exit 1
25set -- `getopt -n$0 -u -a --longoptions="setup,update,clean,help" "such" "$@"`
27# FIXME: giving incorrect arguments does not call usage and exit
28while [ $# -gt 0 ]
29do
30 case "$1" in
31 -s|--setup) SETUP=true;;
32 -u|--update) UPDATE=true;;
33 -c|--clean) CLEAN=true;;
34 -h|--help) usage;;
35 --) shift;break;;
36 esac
37 shift
38done
40install_utils() {
41 echo "Installing build utilities.."
42 sudo apt-get install devscripts equivs || exit 4
45mk_build_deps() {
46 echo "Installing build dependencies.."
47 cd $TARGET_DIR
48 sudo mk-build-deps -B -i $TARGET_DIR/libunity/debian/control || exit 5
49 sudo mk-build-deps -B -i $TARGET_DIR/unity/debian/control || exit 6
50 sudo mk-build-deps -B -i $TARGET_DIR/hud/debian/control || exit 7
53branch_libunity() {
54 echo "Branching libunity.."
55 bzr branch lp:libunity $TARGET_DIR/libunity || exit 8
58branch_unity() {
59 echo "Branching Unity.."
60 bzr branch lp:unity $TARGET_DIR/unity || exit 9
63branch_hud() {
64 echo "Branching hud.."
65 bzr branch lp:hud $TARGET_DIR/hud || exit 10
68update_unity() {
69 echo "Updating Unity.."
70 bzr pull -d $TARGET_DIR/unity || exit 11
73update_libunity() {
74 echo "Updating libunity.."
75 bzr pull -d $TARGET_DIR/libunity || exit 12
78update_hud() {
79 echo "Updating hud"
80 bzr pull -d $TARGET_DIR/hud || exit 13
83compile_libunity() {
84 echo "Configuring libunity.."
86 if $CLEAN; then bzr clean-tree -d $TARGET_DIR/libunity --quiet --unknown --ignored --force; fi
88 cd $TARGET_DIR/libunity
89 bzr revert --quiet -r $LIBUNITY_REV || exit 14
91 mkdir $TARGET_DIR/libunity/build
92 cd $TARGET_DIR/libunity/build
94 ../autogen.sh --prefix $BUILD_DIR --disable-debug --with-pygi-overrides-dir=$BUILD_DIR/gi-overrides || exit 15
96 echo "Building libunity and installing in " $BUILD_DIR
97 make -j$NUM_JOBS install || exit 16
101compile_unity_core() {
102 echo "Configuring Unity.."
104 if $CLEAN; then bzr clean-tree -d $TARGET_DIR/unity --quiet --unknown --ignored --force; fi
106 cd $TARGET_DIR/unity
107 bzr revert --quiet -r $UNITY_REV || exit 17
109 mkdir $TARGET_DIR/unity/build
110 cd $TARGET_DIR/unity/build
112 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
114 echo "Building UnityCore and installing in " $BUILD_DIR
115 cd UnityCore
116 make -j$NUM_JOBS install || exit 19
120compile_hud() {
121 echo "Configuring hud.."
123 if $CLEAN; then bzr clean-tree -d $TARGET_DIR/hud --quiet --unknown --ignored --force; fi
125 cd $TARGET_DIR/hud
126 bzr revert -r $HUD_REV || exit 20
128 mkdir $TARGET_DIR/hud/build
129 cd $TARGET_DIR/hud/build
131 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
133 echo "Building hud and installing in " $BUILD_DIR
134 make install || exit 22
138if $SETUP; then
139 echo "Setting up environment for building Unity.."
140 install_utils
141 mkdir -p $TARGET_DIR
142 branch_libunity
143 branch_unity
144 branch_hud
145 mk_build_deps
146elif $UPDATE; then
147 update_libunity
148 update_unity
149 update_hud
150 mk_build_deps
151else
152 if $CLEAN; then rm -Rf $BUILD_DIR; fi
153 mkdir -p $BUILD_DIR
154 compile_libunity
155 compile_unity_core
156 compile_hud
157fi