~unity-team/unity/phablet.raring

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/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=214
UNITY_REV=3258
PEOPLE_LENS_REV=74
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_dependencies() {
    echo "Installing build dependencies.."
    sudo apt-get build-dep -y libunity unity || exit 4
    sudo apt-get install -y libgtest-dev gnome-common libfolks-dev libtelepathy-glib-dev || exit 5
    # HUD dependencies
    sudo apt-get install -y bamfdaemon debhelper dh-autoreconf gir1.2-dee-1.0 gnome-common gnome-doc-utils gobject-introspection gtk-doc-tools indicator-application indicator-appmenu indicator-appmenu-tools intltool libappindicator3-dev libbamf3-dev libdbusmenu-glib-dev libdbusmenu-gtk3-dev libdbusmenu-jsonloader-dev libdbustest1-dev libdee-dev libgirepository1.0-dev libgtk-3-dev libncurses5-dev libreadline-dev libsqlite3-dev metacity sqlite3 valac-0.18 libpocketsphinx-dev libsphinxbase-dev  || exit 6
}

branch_libunity() {
    echo "Branching libunity.."
    bzr branch lp:libunity/phablet $TARGET_DIR/libunity
}

branch_unity() {
    echo "Branching Unity.."
    bzr branch lp:unity/phablet-mods $TARGET_DIR/unity
}

branch_people_lens() {
    echo "Branching people lens.."
    bzr branch lp:unity-lens-people $TARGET_DIR/people_lens
}

branch_hud() {
    echo "Branching hud.."
    bzr branch lp:hud $TARGET_DIR/hud
}

update_unity() {
    echo "Updating Unity.."
    bzr pull -d $TARGET_DIR/unity
}

update_libunity() {
    echo "Updating libunity.."
    bzr pull -d $TARGET_DIR/libunity
}

update_people_lens() {
    echo "Updating people lens.."
    bzr pull -d $TARGET_DIR/people_lens
}

update_hud() {
    echo "Updating hud"
    bzr pull -d $TARGET_DIR/hud
}

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 8

    ./autogen.sh --prefix $BUILD_DIR --disable-debug

    echo "Building libunity and installing in " $BUILD_DIR
    make -j$NUM_JOBS install

}

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 9

    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

    echo "Building UnityCore and installing in " $BUILD_DIR
    cd UnityCore
    make -j$NUM_JOBS
    make install

}

compile_people_lens() {
    echo "Configuring people lens.."

    if $CLEAN; then bzr clean-tree -d $TARGET_DIR/people_lens --quiet --unknown --ignored --force; fi

    cd $TARGET_DIR/people_lens
    bzr revert --quiet -r $PEOPLE_LENS_REV || exit 10

    PKG_CONFIG_PATH=$BUILD_DIR/lib/pkgconfig:$PKG_CONFIG_PATH ./autogen.sh --prefix $BUILD_DIR --enable-localinstall

    echo "Building people lens and installing in " $BUILD_DIR
    MAINTAINER_VALAFLAGS="--vapidir=${BUILD_DIR}/share/vala/vapi" make -j$NUM_JOBS install

}

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 11

    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

    echo "Building hud and installing in " $BUILD_DIR
    make install

}

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_dependencies
    mkdir -p $TARGET_DIR
    branch_libunity
    branch_unity
    branch_people_lens
    branch_hud
elif $UPDATE; then
    update_libunity
    update_unity
    update_people_lens
    update_hud
else
    if $CLEAN; then rm -Rf $BUILD_DIR; fi
    mkdir -p $BUILD_DIR
    compile_libunity
    compile_unity_core
    compile_people_lens
    compile_hud
    link_lenses
fi