setup.sh 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/usr/bin/env bash
  2. # check if IDF_PATH is set
  3. if [ -z "$IDF_PATH" ]; then
  4. echo "Please follows the instruction of ESP-IDF installation and set IDF_PATH."
  5. exit 1
  6. fi
  7. RMDCMD='/bin/rm -rf'
  8. MKDCMD='/bin/mkdir'
  9. CPDCMD='/bin/cp'
  10. SCRIPTDIR=`dirname $0`
  11. SCRIPTDIR=`cd $SCRIPTDIR && pwd -P`
  12. WOLFSSL_ESPIDFDIR=${SCRIPTDIR}
  13. WOLFSSL_ESPIDFDIR=`cd $WOLFSSL_ESPIDFDIR && pwd -P`
  14. BASEDIR=${SCRIPTDIR}/../../../
  15. BASEDIR=`cd ${BASEDIR} && pwd -P`
  16. # echo $WOLFSSL_ESPIDFDIR
  17. WOLFSSLLIB_TRG_DIR=${IDF_PATH}/components/wolfssl
  18. WOLFSSLEXP_TRG_DIR=${IDF_PATH}/examples/protocols
  19. if [ "$1" == "--verbose" ]; then
  20. WOLFSSL_SETUP_VERBOSE=true
  21. fi
  22. if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then
  23. echo Verbose mode on!
  24. echo BASEDIR=${BASEDIR}
  25. echo SCRIPTDIR=${SCRIPTDIR}
  26. echo WOLFSSL_ESPIDFDIR=${WOLFSSL_ESPIDFDIR}
  27. echo WOLFSSLLIB_TRG_DIR=${WOLFSSLLIB_TRG_DIR}
  28. echo WOLFSSLEXP_TRG_DIR=${WOLFSSLEXP_TRG_DIR}
  29. echo ""
  30. fi
  31. if [ ! -d $IDF_PATH ]; then
  32. echo "ESP-IDF Development Framework doesn't exist.: $IDF_PATH"
  33. exit 1
  34. fi
  35. # Copy files into ESP-IDF development framework
  36. pushd $IDF_PATH > /dev/null
  37. echo "Copy files into $IDF_PATH"
  38. # Remove/Create directories
  39. if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then
  40. echo "Remove/Create directories..."
  41. fi
  42. ${RMDCMD} ${WOLFSSLLIB_TRG_DIR}/
  43. ${MKDCMD} ${WOLFSSLLIB_TRG_DIR}/
  44. ${MKDCMD} ${WOLFSSLLIB_TRG_DIR}/src
  45. ${MKDCMD} ${WOLFSSLLIB_TRG_DIR}/wolfcrypt
  46. ${MKDCMD} ${WOLFSSLLIB_TRG_DIR}/wolfcrypt/src
  47. ${MKDCMD} ${WOLFSSLLIB_TRG_DIR}/wolfssl
  48. ${MKDCMD} ${WOLFSSLLIB_TRG_DIR}/wolfssl/openssl
  49. ${MKDCMD} ${WOLFSSLLIB_TRG_DIR}/test
  50. ${MKDCMD} ${WOLFSSLLIB_TRG_DIR}/include
  51. popd > /dev/null # $WOLFSSL_ESPIDFDIR
  52. pushd ${BASEDIR} > /dev/null # WOLFSSL TOP DIR
  53. # copying ... files in src/ into $WOLFSSLLIB_TRG_DIR/src
  54. if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then
  55. echo "Copying ... files in src/ into \$WOLFSSLLIB_TRG_DIR/srcs ..."
  56. fi
  57. ${CPDCMD} ./src/*.c ${WOLFSSLLIB_TRG_DIR}/src/
  58. ${CPDCMD} -r ./wolfcrypt/src/*.{c,i} ${WOLFSSLLIB_TRG_DIR}/wolfcrypt/src/
  59. ${CPDCMD} -r ./wolfcrypt/src/port ${WOLFSSLLIB_TRG_DIR}/wolfcrypt/src/port/
  60. ${CPDCMD} -r ./wolfcrypt/test ${WOLFSSLLIB_TRG_DIR}/wolfcrypt/
  61. # Copy dummy test_paths.h to handle the case configure hasn't yet executed
  62. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/dummy_test_paths.h ${WOLFSSLLIB_TRG_DIR}/wolfcrypt/test/test_paths.h
  63. ${CPDCMD} -r ./wolfcrypt/benchmark ${WOLFSSLLIB_TRG_DIR}/wolfcrypt/
  64. ${CPDCMD} -r ./wolfssl/*.h ${WOLFSSLLIB_TRG_DIR}/wolfssl/
  65. ${CPDCMD} -r ./wolfssl/openssl/*.h ${WOLFSSLLIB_TRG_DIR}/wolfssl/openssl/
  66. ${CPDCMD} -r ./wolfssl/wolfcrypt ${WOLFSSLLIB_TRG_DIR}/wolfssl/
  67. # user_settings.h
  68. if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then
  69. echo "Copying user_settings.h to ${WOLFSSLLIB_TRG_DIR}/include/"
  70. fi
  71. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/user_settings.h ${WOLFSSLLIB_TRG_DIR}/include/
  72. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/dummy_config_h ${WOLFSSLLIB_TRG_DIR}/include/config.h
  73. # unit test app
  74. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/test/* ${WOLFSSLLIB_TRG_DIR}/test/
  75. popd > /dev/null #
  76. ${CPDCMD} ./libs/CMakeLists.txt ${WOLFSSLLIB_TRG_DIR}/
  77. ${CPDCMD} ./libs/component.mk ${WOLFSSLLIB_TRG_DIR}/
  78. pushd ${BASEDIR} > /dev/null # WOLFSSL TOP DIR
  79. # Benchmark program
  80. if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then
  81. echo ""
  82. fi
  83. ${RMDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_benchmark/
  84. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_benchmark/
  85. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_benchmark/main/
  86. ${CPDCMD} -r ./wolfcrypt/benchmark/benchmark.c ${WOLFSSLEXP_TRG_DIR}/wolfssl_benchmark/main/
  87. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_benchmark/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_benchmark/
  88. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_benchmark/main/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_benchmark/main/
  89. # Crypt Test program
  90. if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then
  91. echo "Copying wolfssl_test to ${WOLFSSLEXP_TRG_DIR}/wolfssl_test/main/"
  92. fi
  93. ${RMDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_test/
  94. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_test/
  95. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_test/main/
  96. ${CPDCMD} -r ./wolfcrypt/test/test.c ${WOLFSSLEXP_TRG_DIR}/wolfssl_test/main/
  97. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_test/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_test/
  98. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_test/main/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_test/main/
  99. # TLS Client program
  100. if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then
  101. echo "Copying TLS Client program to ${WOLFSSLEXP_TRG_DIR}/wolfssl_client/..."
  102. fi
  103. ${RMDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_client/
  104. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_client/
  105. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_client/main/
  106. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_client/main/include
  107. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_client/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_client/
  108. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_client/main/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_client/main/
  109. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_client/main/include/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_client/main/include/
  110. # TLS Server program
  111. if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then
  112. echo "Copying TLS Server program to ${WOLFSSLEXP_TRG_DIR}/wolfssl_server/..."
  113. fi
  114. ${RMDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_server/
  115. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_server/
  116. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_server/main/
  117. ${MKDCMD} ${WOLFSSLEXP_TRG_DIR}/wolfssl_server/main/include
  118. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_server/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_server/
  119. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_server/main/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_server/main/
  120. ${CPDCMD} -r ${WOLFSSL_ESPIDFDIR}/examples/wolfssl_server/main/include/* ${WOLFSSLEXP_TRG_DIR}/wolfssl_server/main/include/
  121. popd > /dev/null #
  122. if [ "${WOLFSSL_SETUP_VERBOSE}" == "true" ]; then
  123. echo "Copy complete!"
  124. fi
  125. exit 1