~pete-woods/hud/13.10-lp1238420

« back to all changes in this revision

Viewing changes to build.sh

  • Committer: Pete Woods
  • Date: 2013-08-20 17:10:44 UTC
  • mto: This revision was merged to the branch mainline in revision 312.
  • Revision ID: pete.woods@canonical.com-20130820171044-qcq61kf5mz1xfgql
Debugging changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/bash
2
2
set -e
3
3
 
4
 
mkdir -p build
 
4
ECLIPSE=false
 
5
CLEAN=false
 
6
SOURCEDIR="$PWD"
 
7
BRANCHNAME=`basename $SOURCEDIR`
 
8
BUILDDIR="$SOURCEDIR/../$BRANCHNAME-build"
 
9
 
 
10
usage() {
 
11
    echo "usage: $0 [OPTIONS] [BUILD_TYPE]\n" >&2
 
12
    echo "Script to build hud. If BUILD_TYPE is not specified, it defaults to \"Debug\".\n" >&2
 
13
    echo "OPTIONS:" >&2
 
14
    echo " -e, --eclipse Generate Eclipse projects" >&2
 
15
    echo " -c, --clean Clean the build tree before building" >&2
 
16
    echo >&2
 
17
    exit 1
 
18
}
 
19
 
 
20
ARGS=`getopt -n$0 -u -a --longoptions="eclipse,clean,help" -o "sch" -- "$@"`
 
21
[ $? -ne 0 ] && usage
 
22
eval set -- "$ARGS"
 
23
 
 
24
while [ $# -gt 0 ]
 
25
do
 
26
    case "$1" in
 
27
       -e|--eclipse) ECLIPSE=true;;
 
28
       -c|--clean)   CLEAN=true;;
 
29
       -h|--help)    usage;;
 
30
       --)           shift;break;;
 
31
    esac
 
32
    shift
 
33
done
 
34
 
 
35
[ $# -gt 1 ] && usage
 
36
 
 
37
BUILD_TYPE="Debug"
 
38
[ $# -eq 1 ] && BUILD_TYPE="$1"
5
39
 
6
40
if [ -f "/usr/bin/ninja" ] ; then
7
 
  EXTRA_ARGS="-G Ninja"
 
41
  if $ECLIPSE; then
 
42
    GENERATOR="Eclipse CDT4 - Ninja"
 
43
  else
 
44
    GENERATOR="Ninja"
 
45
  fi
8
46
  BUILD_COMMAND="ninja"
9
47
else
 
48
  if $ECLIPSE; then
 
49
    GENERATOR="Eclipse CDT4 - Unix Makefiles"
 
50
  else
 
51
    GENERATOR="Unix Makefiles"
 
52
  fi
10
53
  BUILD_COMMAND="make"
11
54
fi
12
55
 
13
56
echo "Using $BUILD_COMMAND to build"
 
57
 
 
58
if $CLEAN; then
 
59
  rm -rf $BUILDDIR
 
60
fi
 
61
 
 
62
mkdir -p $BUILDDIR
14
63
(
15
 
  cd build
16
 
  cmake .. $EXTRA_ARGS -DCMAKE_INSTALL_PREFIX=../../install -DLOCAL_INSTALL=ON -DCMAKE_BUILD_TYPE=Debug
 
64
  cd $BUILDDIR
 
65
  cmake "$SOURCEDIR" -G "$GENERATOR" \
 
66
    -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
 
67
    -DLOCAL_INSTALL=ON \
 
68
    -DCMAKE_INSTALL_PREFIX="$SOURCEDIR/../$BRANCHNAME-install"
17
69
  $BUILD_COMMAND
18
70
)