async-check.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. # async-check.sh
  3. # This script creates symbolic links to the required asynchronous
  4. # file for using the asynchronous simulator and make check
  5. #
  6. # $ ./async-check [keep|clean|setup]
  7. #
  8. # - keep: (default off) ./async and links kept around for inspection
  9. # - clean: (default off) only cleanup existing ./async and links
  10. # - setup: (default off) only setup ./async and links but don't run config
  11. # or make
  12. #
  13. ASYNC_REPO=https://github.com/wolfSSL/wolfAsyncCrypt.git
  14. function Usage() {
  15. printf '\n%s\n\n' "Usage: $0 [keep|clean|setup]"
  16. printf '%s\n' "Where \"keep\" means keep (default off) async files around for inspection"
  17. printf '%s\n' "Where \"clean\" means only clean (default off) the async files"
  18. printf '%s\n\n' "Where \"setup\" means only setup (default off) the async files"
  19. printf '%s\n' "EXAMPLE:"
  20. printf '%s\n' "---------------------------------"
  21. printf '%s\n' "./async-check.sh keep"
  22. printf '%s\n' "./async-check.sh clean"
  23. printf '%s\n' "./async-check.sh setup"
  24. printf '%s\n\n' "---------------------------------"
  25. }
  26. function CleanUp() {
  27. unlink ./wolfcrypt/src/async.c
  28. unlink ./wolfssl/wolfcrypt/async.h
  29. unlink ./wolfcrypt/src/port/intel/quickassist.c
  30. unlink ./wolfcrypt/src/port/intel/quickassist_mem.c
  31. unlink ./wolfcrypt/src/port/intel/README.md
  32. unlink ./wolfssl/wolfcrypt/port/intel/quickassist.h
  33. unlink ./wolfssl/wolfcrypt/port/intel/quickassist_mem.h
  34. unlink ./wolfcrypt/src/port/cavium/cavium_nitrox.c
  35. unlink ./wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h
  36. unlink ./wolfcrypt/src/port/cavium/README.md
  37. rm -rf ./async
  38. # restore original README.md files
  39. git checkout -- wolfcrypt/src/port/cavium/README.md
  40. git checkout -- wolfcrypt/src/port/intel/README.md
  41. }
  42. function LinkFiles() {
  43. # link files
  44. ln -s -f ../../async/wolfcrypt/src/async.c ./wolfcrypt/src/async.c
  45. ln -s -f ../../async/wolfssl/wolfcrypt/async.h ./wolfssl/wolfcrypt/async.h
  46. ln -s -f ../../../../async/wolfcrypt/src/port/intel/quickassist.c ./wolfcrypt/src/port/intel/quickassist.c
  47. ln -s -f ../../../../async/wolfcrypt/src/port/intel/quickassist_mem.c ./wolfcrypt/src/port/intel/quickassist_mem.c
  48. ln -s -f ../../../../async/wolfcrypt/src/port/intel/README.md ./wolfcrypt/src/port/intel/README.md
  49. ln -s -f ../../../../async/wolfssl/wolfcrypt/port/intel/quickassist.h ./wolfssl/wolfcrypt/port/intel/quickassist.h
  50. ln -s -f ../../../../async/wolfssl/wolfcrypt/port/intel/quickassist_mem.h ./wolfssl/wolfcrypt/port/intel/quickassist_mem.h
  51. ln -s -f ../../../../async/wolfcrypt/src/port/cavium/cavium_nitrox.c ./wolfcrypt/src/port/cavium/cavium_nitrox.c
  52. ln -s -f ../../../../async/wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h ./wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h
  53. ln -s -f ../../../../async/wolfcrypt/src/port/cavium/README.md ./wolfcrypt/src/port/cavium/README.md
  54. }
  55. if [ "$#" -gt 1 ]; then
  56. Usage
  57. exit 1
  58. fi
  59. KEEP=no
  60. ONLY_SETUP=no
  61. case "x$1" in
  62. "xkeep")
  63. KEEP=yes
  64. ;;
  65. "xclean")
  66. CleanUp
  67. exit 0
  68. ;;
  69. "xsetup")
  70. ONLY_SETUP=yes
  71. ;;
  72. *)
  73. Usage
  74. exit 1
  75. ;;
  76. esac
  77. # Fail on any error in script from now on
  78. set -e
  79. if [ -d ./async ];
  80. then
  81. echo "\n\nUsing existing async repo\n\n"
  82. else
  83. # make a clone of the wolfAsyncCrypt repository
  84. git clone --depth 1 $ASYNC_REPO async
  85. fi
  86. # setup auto-conf
  87. ./autogen.sh
  88. LinkFiles
  89. if [ "x$ONLY_SETUP" == "xno" ];
  90. then
  91. ./configure --enable-asynccrypt --enable-all
  92. make check
  93. # Clean up
  94. if [ "x$KEEP" == "xno" ];
  95. then
  96. CleanUp
  97. fi
  98. fi