setup.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env bash
  2. # this script deploys wolfssl and wolfcrypto source code to the mynewt project.
  3. # run as bash "mynewt project root directory path"
  4. set -e
  5. SCRIPTDIR=`dirname $0`
  6. SCRIPTDIR=`cd $SCRIPTDIR && pwd -P`
  7. WOLFSSL_MYNEWTDIR=${SCRIPTDIR}
  8. WOLFSSL_MYNEWTDIR=`cd $WOLFSSL_MYNEWTDIR && pwd -P`
  9. BASEDIR=${SCRIPTDIR}/../..
  10. BASEDIR=`cd ${BASEDIR} && pwd -P`
  11. if [ $# -ne 1 ]; then
  12. echo "Usage: $0 'mynewt project root directory path'" 1>&2
  13. exit 1
  14. fi
  15. MYNEWT_PROJECT=$1
  16. if [ ! -d $MYNEWT_PROJECT ] || [ ! -f $MYNEWT_PROJECT/project.yml ]; then
  17. echo "target directory is not mynewt project.: $MYNEWT_PROJECT"
  18. exit 1
  19. fi
  20. # create wolfssl pkgs to mynewt project
  21. pushd $MYNEWT_PROJECT > /dev/null
  22. echo "create crypto/wolfssl pkg"
  23. /bin/rm -rf crypto/wolfssl
  24. newt pkg new crypto/wolfssl
  25. /bin/rm -rf crypto/wolfssl/include
  26. /bin/mkdir -p crypto/wolfssl/include
  27. /bin/rm -rf crypto/wolfssl/src
  28. /bin/mkdir -p crypto/wolfssl/src
  29. echo "create apps/wolfcrypttest pkg"
  30. /bin/rm -rf apps/wolfcrypttest
  31. newt pkg new -t app apps/wolfcrypttest
  32. /bin/rm -rf apps/wolfcrypttest/include
  33. /bin/rm -rf apps/wolfcrypttest/src
  34. /bin/mkdir -p apps/wolfcrypttest/src
  35. popd > /dev/null # $MYNEWT_PROJECT
  36. # deploy source files and pkg
  37. pushd $BASEDIR > /dev/null
  38. # deploy to crypto/wolfssl
  39. echo "deploy wolfssl sources to crypto/wolfssl"
  40. /bin/cp $WOLFSSL_MYNEWTDIR/crypto.wolfssl.pkg.yml $MYNEWT_PROJECT/crypto/wolfssl/pkg.yml
  41. /bin/cp $WOLFSSL_MYNEWTDIR/crypto.wolfssl.syscfg.yml $MYNEWT_PROJECT/crypto/wolfssl/syscfg.yml
  42. /bin/mkdir -p $MYNEWT_PROJECT/crypto/wolfssl/src/src
  43. /bin/cp ./src/*.c $MYNEWT_PROJECT/crypto/wolfssl/src/src
  44. /bin/mkdir -p $MYNEWT_PROJECT/crypto/wolfssl/src/wolfcrypt/src
  45. /bin/cp ./wolfcrypt/src/*.asm $MYNEWT_PROJECT/crypto/wolfssl/src/wolfcrypt/src
  46. /bin/cp ./wolfcrypt/src/*.c $MYNEWT_PROJECT/crypto/wolfssl/src/wolfcrypt/src
  47. /bin/mkdir -p $MYNEWT_PROJECT/crypto/wolfssl/src/wolfcrypt/src/port/mynewt
  48. /bin/cp ./wolfcrypt/src/port/mynewt/* $MYNEWT_PROJECT/crypto/wolfssl/src/wolfcrypt/src/port/mynewt
  49. /bin/mkdir -p $MYNEWT_PROJECT/crypto/wolfssl/include/wolfssl
  50. /bin/cp -r wolfssl/* $MYNEWT_PROJECT/crypto/wolfssl/include/wolfssl/
  51. # deploy to apps/wolfcrypttest
  52. echo "deploy unit test sources to apps/wolfcrypttest"
  53. /bin/cp $WOLFSSL_MYNEWTDIR/apps.wolfcrypttest.pkg.yml $MYNEWT_PROJECT/apps/wolfcrypttest/pkg.yml
  54. /bin/mkdir -p $MYNEWT_PROJECT/apps/wolfcrypttest/include/wolfcrypt/test
  55. /bin/cp -r wolfcrypt/test/test.h $MYNEWT_PROJECT/apps/wolfcrypttest/include/wolfcrypt/test/
  56. /bin/mkdir -p $MYNEWT_PROJECT/apps/wolfcrypttest/src
  57. /bin/cp wolfcrypt/test/test.c $MYNEWT_PROJECT/apps/wolfcrypttest/src/main.c
  58. popd > /dev/null # $BASEDIR