~allanlesage/+junk/unity8-network-indicator

1 by Michał Sawicz
Inital unity8 commit.
1
#!/bin/sh
2
3
SETUP=false
4
CLEAN=false
5
NUM_JOBS=$(( `grep -c ^processor /proc/cpuinfo` + 1 ))
32.1.1 by Michał Sawicz
Drop build_unity that's not needed anymore and clean up build/run scripts.
6
CODE_DIR=$( dirname `readlink -f $0` )
1 by Michał Sawicz
Inital unity8 commit.
7
8
usage() {
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
16
}
17
18
ARGS=`getopt -n$0 -u -a --longoptions="setup,clean,help" -o "sch" -- "$@"`
19
[ $? -ne 0 ] && usage
20
eval set -- "$ARGS"
21
22
while [ $# -gt 0 ]
23
do
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
31
done
32
33
[ $# -gt 1 ] && usage
34
35
BUILD_TYPE="debug"
36
[ $# -eq 1 ] && BUILD_TYPE="$1"
37
38
install_dependencies() {
39
    sudo apt-get update || exit 4
3.1.1 by Michał Sawicz
Improve build scripts error reporting and interactivity.
40
    echo "Installing Unity 8 dependencies.."
32.1.2 by Michał Sawicz
add some readability
41
    sudo apt-get install devscripts \
42
                         equivs \
224.2.1 by Michał Sawicz
Fix runtime dependencies in build script.
43
                         gsettings-desktop-schemas \
2.6.2 by Michał Sawicz
Do not add PPAs anymore and clean up build scripts and CODING accordingly.
44
                         qmenumodel-qml \
224.2.1 by Michał Sawicz
Fix runtime dependencies in build script.
45
                         qtdeclarative5-dee-plugin \
46
                         qtdeclarative5-gsettings1.0 \
32.1.2 by Michał Sawicz
add some readability
47
                         qtdeclarative5-ubuntu-ui-toolkit-plugin \
224.2.2 by Michał Sawicz
Don't require a particular version of notifications-impl.
48
                         unity-notifications-impl \
224.2.1 by Michał Sawicz
Fix runtime dependencies in build script.
49
                         qtdeclarative5-xmllistmodel-plugin \
32.1.2 by Michał Sawicz
add some readability
50
                         ubuntu-mobile-icons \
51.4.3 by Kevin Gunn
update the build to install "recommends" for unity8
51
                         unity-scope-home \
52
                         unity-lens-applications \
32.1.2 by Michał Sawicz
add some readability
53
        || exit 5
32.1.1 by Michał Sawicz
Drop build_unity that's not needed anymore and clean up build/run scripts.
54
}
55
56
mk_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
1 by Michał Sawicz
Inital unity8 commit.
58
}
59
265.1.1 by Jussi Pakkanen
Use CCache if it exists.
60
if [ -f "/usr/bin/ccache" ] ; then
265.1.2 by Jussi Pakkanen
Use ccache only if compilers are not explicitly set.
61
  if [ "x$CC" = "x" ]; then
62
    export CC='ccache gcc'
63
  fi
64
  if [ "x$CXX" = "x" ] ; then
65
    export CXX='ccache g++'
66
  fi
265.1.1 by Jussi Pakkanen
Use CCache if it exists.
67
fi
68
1 by Michał Sawicz
Inital unity8 commit.
69
if [ -f "/usr/bin/ninja" ] ; then
70
  GENERATOR="-G Ninja"
242.1.1 by Jussi Pakkanen
Let Ninja parallelize itself.
71
  # Ninja does not need -j, it parallelizes automatically.
72
  BUILD_COMMAND="ninja"
1 by Michał Sawicz
Inital unity8 commit.
73
else
74
  GENERATOR=
75
  BUILD_COMMAND="make -j$NUM_JOBS"
76
fi
77
78
if $SETUP; then
79
    install_dependencies
80
else
81
    if $CLEAN; then rm -rf builddir; fi
82
    mkdir -p builddir
83
    cd builddir
32.1.1 by Michał Sawicz
Drop build_unity that's not needed anymore and clean up build/run scripts.
84
    mk_build_deps
85
    cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CODE_DIR ${GENERATOR} || exit 6
3.1.1 by Michał Sawicz
Improve build scripts error reporting and interactivity.
86
    ${BUILD_COMMAND} || exit 7
1 by Michał Sawicz
Inital unity8 commit.
87
fi