blob: 73dc925210273c497eeda913e745790da5f07455 [file] [log] [blame]
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +02001#!/bin/sh
2
3set -eu
4
5TREE=..
6
7# default values, can be overriden by the environment
8: ${DEST:=module}
9: ${BUILD:=1}
10
11# make sure we're running in our own directory
12if [ -f create-module.sh ]; then :; else
13 cd $( dirname $0 )
14 if [ -f create-module.sh ]; then :; else
15 echo "Please run the script from is directory." >&2
16 exit 1
17 fi
18fi
19
20# use a temporary directory to build the module, then rsync to DEST
21# this allows touching only new files, for more efficient re-builds
22TMP=$DEST-tmp
23rm -rf $TMP
24
25mkdir -p $TMP/mbedtls $TMP/source
26cp $TREE/include/mbedtls/*.h $TMP/mbedtls
27cp $TREE/library/*.c $TMP/source
28
29# temporary, should depend on external module later
30cp data/entropy_hardware_poll.c $TMP/source
31cp data/target_config.h $TMP/mbedtls
32
33data/adjust-config.sh $TREE/scripts/config.pl $TMP/mbedtls/config.h
34
35mkdir -p $TMP/test
36cp -r data/example-* $TMP/test
37# later we should have the generated test suites here too
38
39cp data/module.json $TMP
40cp data/README.md $TMP
41
42mkdir -p $DEST
43rsync -cr --delete --exclude build --exclude yotta_\* $TMP/ $DEST/
44rm -rf $TMP
45
46echo "mbed TLS yotta module created in '$DEST'."
47
48test_build()
49{
50 TARGET=$1
51 echo; echo "*** Doing a test build for $TARGET ***"
52 ( cd $DEST && yt target $TARGET && yt build )
53}
54
55if [ $BUILD -eq 1 ]; then
56 if uname -a | grep 'Linux.*x86' >/dev/null; then
57 test_build x86-linux-native
58 fi
59
60 if uname -a | grep 'Darwin.*x86' >/dev/null; then
61 test_build x86-osx-native
62 fi
63
64 # do that one last so that it remains the target
65 test_build frdm-k64f-gcc
66fi