Manuel Pégourié-Gonnard | 63e7eba | 2015-07-28 14:17:48 +0200 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | set -eu |
| 4 | |
| 5 | TREE=.. |
| 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 |
| 12 | if [ -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 |
| 18 | fi |
| 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 |
| 22 | TMP=$DEST-tmp |
| 23 | rm -rf $TMP |
| 24 | |
| 25 | mkdir -p $TMP/mbedtls $TMP/source |
| 26 | cp $TREE/include/mbedtls/*.h $TMP/mbedtls |
| 27 | cp $TREE/library/*.c $TMP/source |
| 28 | |
| 29 | # temporary, should depend on external module later |
| 30 | cp data/entropy_hardware_poll.c $TMP/source |
| 31 | cp data/target_config.h $TMP/mbedtls |
| 32 | |
| 33 | data/adjust-config.sh $TREE/scripts/config.pl $TMP/mbedtls/config.h |
| 34 | |
| 35 | mkdir -p $TMP/test |
| 36 | cp -r data/example-* $TMP/test |
| 37 | # later we should have the generated test suites here too |
| 38 | |
| 39 | cp data/module.json $TMP |
| 40 | cp data/README.md $TMP |
| 41 | |
| 42 | mkdir -p $DEST |
| 43 | rsync -cr --delete --exclude build --exclude yotta_\* $TMP/ $DEST/ |
| 44 | rm -rf $TMP |
| 45 | |
| 46 | echo "mbed TLS yotta module created in '$DEST'." |
| 47 | |
| 48 | test_build() |
| 49 | { |
| 50 | TARGET=$1 |
| 51 | echo; echo "*** Doing a test build for $TARGET ***" |
| 52 | ( cd $DEST && yt target $TARGET && yt build ) |
| 53 | } |
| 54 | |
| 55 | if [ $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 |
| 66 | fi |