on 8.15+17.04.20161129-0ubuntu1 help sign in
unity8/build.sh
66 lines 1.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 " -c, --clean Clean the build tree before building" >&2
13 echo >&2
14 exit 1
17ARGS=`getopt -n$0 -u -a --longoptions="setup,clean,help" -o "sch" -- "$@"`
18[ $? -ne 0 ] && usage
19eval set -- "$ARGS"
21while [ $# -gt 0 ]
22do
23 case "$1" in
24 -c|--clean) CLEAN=true;;
25 -h|--help) usage;;
26 --) shift;break;;
27 esac
28 shift
29done
31[ $# -gt 1 ] && usage
33BUILD_TYPE="debug"
34[ $# -eq 1 ] && BUILD_TYPE="$1"
36mk_build_deps() {
37 if [ ! -f control -o $CODE_DIR/debian/control -nt control ]; then
38 sed 's/\:native//g' $CODE_DIR/debian/control > control
39 mk-build-deps --install --root-cmd sudo control
40 fi
43if [ -f "/usr/bin/ccache" ] ; then
44 if [ "x$CC" = "x" ]; then
45 export CC='ccache gcc'
46 fi
47 if [ "x$CXX" = "x" ] ; then
48 export CXX='ccache g++'
49 fi
50fi
52if [ -f "/usr/bin/ninja" ] ; then
53 GENERATOR="-G Ninja"
54 # Ninja does not need -j, it parallelizes automatically.
55 BUILD_COMMAND="ninja"
56else
57 GENERATOR=
58 BUILD_COMMAND="make -j$NUM_JOBS"
59fi
61if $CLEAN; then rm -rf builddir; fi
62mkdir -p builddir
63cd builddir
64mk_build_deps
65cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CODE_DIR ${GENERATOR} || exit 6
66${BUILD_COMMAND} || exit 7