aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2017-03-09 21:08:57 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-16 17:10:40 +0100
commit7735f7d8603859431af40702f3e274c5e1d90e5c (patch)
tree156a323fda2174bb641403ff5096258659379963
parent935dfd3dc3a74a3d9a49cb25f68ef78e4573626a (diff)
add a helper script to build, can be use by VS2017.
Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
-rwxr-xr-xbuild.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..a51da1b
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+function build {
+ echo "ACTION: build"
+ source ~/agl/sdk/porter/environment*
+ if [ ! -d "$1/$2" ]; then
+ echo "INFO: build dir ($1/$2) doesn't exist, created it!"
+ mkdir -p "$1/$2"
+ fi
+ pushd "$1/$2"
+ #cd "$1/$2"
+ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$3 $1
+ make
+ popd
+}
+
+function clean {
+ echo "ACTION: clean"
+ if [ -d "$1/$2" ]; then
+ rm -vrf "$1/$2"
+ fi
+}
+
+function rebuild {
+ build $1 $2 $3
+ clean $1 $2
+}
+
+function printhelp {
+ echo "Usage: build.sh <action> <subdir> [config]"
+ echo " action: can be one of the following"
+ echo " build: build this project."
+ echo " rebuild: rebuild this project."
+ echo " clean: clean the previous build."
+ echo " install: install the build result."
+ echo " subdir: the subdir into which the build is done."
+ echo " config: can be Debug or Release. Ignored if the action is 'clean'."
+}
+
+function checkparams {
+ if [ "$#" -ne "$(($1+1))" ]; then
+ echo "ERROR: Wrong number of parameters, expected $1 but got $(($#-1))"
+ printhelp
+ exit 1
+ fi
+}
+
+function main {
+ CURRENT_DIR=$( dirname "$(readlink -f "$0")" )
+ echo "Current script: $CURRENT_DIR"
+
+ if [ "$#" -lt "1" ]; then
+ echo "ERROR: At least <action> must be specified!"
+ exit 1
+ fi
+
+ case "$1" in
+ "build")
+ checkparams 3 $*
+ build $CURRENT_DIR $2 $3
+ ;;
+ "rebuild")
+ checkparams 3 $*
+ rebuild $CURRENT_DIR $2 $3
+ ;;
+ "clean")
+ checkparams 2 $*
+ clean $CURRENT_DIR $2
+ ;;
+ "install")
+ checkparams 3 $*
+ echo "ERROR: Not implemented yet!"
+ ;;
+ *)
+ echo "ERROR: Unknown action '$3'!"
+ exit 1
+ ;;
+ esac
+}
+
+main $*
+