on 3f5d08f help sign in
unity8/build
77 lines 2.5 kB history raw
1#!/bin/sh
3SETUP=false
4CLEAN=false
5NUM_JOBS=$(( `grep -c ^processor /proc/cpuinfo` + 1 ))
6CODE_DIR=$( dirname `readlink -f $0` )
8usage() {
9 echo "usage: build [OPTIONS] [BUILD_TYPE]\n" >&2
10 echo "Script to build the shell. If BUILD_TYPE is not specified, it defaults to \"debug\".\n" >&2
11 echo "OPTIONS:" >&2
12 echo " -s, --setup Setup the build environment and branch Unity" >&2
13 echo " -c, --clean Clean the build tree before building" >&2
14 echo >&2
15 exit 1
18ARGS=`getopt -n$0 -u -a --longoptions="setup,clean,help" -o "sch" -- "$@"`
19[ $? -ne 0 ] && usage
20eval set -- "$ARGS"
22while [ $# -gt 0 ]
23do
24 case "$1" in
25 -s|--setup) SETUP=true;;
26 -c|--clean) CLEAN=true;;
27 -h|--help) usage;;
28 --) shift;break;;
29 esac
30 shift
31done
33[ $# -gt 1 ] && usage
35BUILD_TYPE="debug"
36[ $# -eq 1 ] && BUILD_TYPE="$1"
38install_dependencies() {
39 [ -f /etc/apt/sources.list.d/phablet-team-desktop-deps-${DISTRIB_CODENAME}.list ] || sudo add-apt-repository ppa:phablet-team/desktop-deps || exit 1
40 [ -f /etc/apt/sources.list.d/canonical-qt5-edgers-qt5-proper-${DISTRIB_CODENAME}.list ] || sudo add-apt-repository ppa:canonical-qt5-edgers/qt5-proper || exit 2;
41 [ -f /etc/apt/sources.list.d/ubuntu-sdk-team-ppa-${DISTRIB_CODENAME}.list ] || sudo add-apt-repository ppa:ubuntu-sdk-team/ppa || exit 3
42 sudo apt-get update || exit 4
43 echo "Installing Unity 8 dependencies.."
44 sudo apt-get install devscripts \
45 equivs \
46 qmenumodel-qml \
47 qtdeclarative5-ubuntu-ui-toolkit-plugin \
48 qtdeclarative5-dee-plugin \
49 ubuntu-mobile-icons \
50 unity-notifications-impl-1 \
51 unity-scope-home \
52 unity-lens-applications \
53 || exit 5
56mk_build_deps() {
57 [ ! -f unity8-build-deps*deb -o $CODE_DIR/debian/control -nt unity8-build-deps*deb ] && mk-build-deps --install --root-cmd sudo $CODE_DIR/debian/control
60if [ -f "/usr/bin/ninja" ] ; then
61 GENERATOR="-G Ninja"
62 BUILD_COMMAND="ninja -j$NUM_JOBS"
63else
64 GENERATOR=
65 BUILD_COMMAND="make -j$NUM_JOBS"
66fi
68if $SETUP; then
69 install_dependencies
70else
71 if $CLEAN; then rm -rf builddir; fi
72 mkdir -p builddir
73 cd builddir
74 mk_build_deps
75 cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CODE_DIR ${GENERATOR} || exit 6
76 ${BUILD_COMMAND} || exit 7
77fi