1#!/bin/bash
2#
3# Integration build test script for all components
4#
5#  * Build all components using example platform of the SyS-T library.
6#  * Run the "hello" example and feed it's output into the printer.
7#
8#  The script will end with printing "Hello SyS-T" on success.
9set -e
10SELF_DIR="$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)"
11
12#BUILDMODE=Debug
13BUILDMODE=MinSizeRel
14BLD_ROOT=${BLD_ROOT:="$SELF_DIR/build"}
15DEPLOY_DIR="$BLD_ROOT/sdk"
16mkdir -p $DEPLOY_DIR
17
18echo
19echo ----- Building SyS-T library ... ----------------------------------------
20echo
21
22mkdir -p $BLD_ROOT/lib
23pushd $BLD_ROOT/lib
24cmake \
25    -DSYST_BUILD_TEST=ON \
26    -DSYST_BUILD_DOC=ON \
27    -DSYST_BUILD_PLATFORM_NAME=example \
28    -DCMAKE_INSTALL_PREFIX="$DEPLOY_DIR" \
29    -DCMAKE_BUILD_TYPE=$BUILDMODE \
30    "$SELF_DIR/../../library"
31
32cmake --build . --target install
33cmake --build . --target RUN_TEST_VERBOSE
34pushd
35
36echo
37echo ----- Building Examples ... ---------------------------------------------
38echo
39
40mkdir -p $BLD_ROOT/examples
41pushd $BLD_ROOT/examples
42
43cmake \
44    -DCMAKE_INSTALL_PREFIX="$DEPLOY_DIR" \
45    -DSYST_SDK="$DEPLOY_DIR" \
46    -DCMAKE_BUILD_TYPE=$BUILDMODE \
47    "$SELF_DIR/.."
48
49cmake --build . --target install
50pushd
51
52echo
53echo ----- Building printer ... ----------------------------------------------
54echo
55
56mkdir -p $BLD_ROOT/printer
57pushd $BLD_ROOT/printer
58
59cmake \
60    -DCMAKE_INSTALL_PREFIX="$DEPLOY_DIR" \
61    -DCMAKE_BUILD_TYPE=$BUILDMODE \
62    "$SELF_DIR/../../printer"
63
64cmake --build . --target install
65cmake --build . --target RUN_TEST_VERBOSE
66pushd
67
68
69echo
70echo ----- Running the SyS-T 'hello world' example  --------------------------
71echo
72pushd "$DEPLOY_DIR/bin" > /dev/null
73echo "$PWD/hello | $PWD/systprint -p -"
74echo
75./hello | ./systprint -p -
76popd > /dev/null
77exit 0
78