gen_pack.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. # Version: 2.3
  3. # Date: 2022-09-28
  4. # This bash script generates a CMSIS Software Pack:
  5. #
  6. set -o pipefail
  7. # Set version of gen pack library
  8. REQUIRED_GEN_PACK_LIB="0.5.1"
  9. # Set default command line arguments
  10. DEFAULT_ARGS=(-c "v")
  11. # Pack warehouse directory - destination
  12. PACK_OUTPUT=./output
  13. # Temporary pack build directory
  14. PACK_BUILD=./build
  15. # Specify directory names to be added to pack base directory
  16. PACK_DIRS="
  17. documentation/html
  18. examples/common
  19. Helper
  20. Library
  21. tools
  22. "
  23. # Specify file names to be added to pack base directory
  24. PACK_BASE_FILES="
  25. documentation/index.html
  26. documentation/version.css
  27. documentation/version.js
  28. LICENSE
  29. README.md
  30. "
  31. # Specify file names to be deleted from pack build directory
  32. PACK_DELETE_FILES="
  33. Library/Include/__arm_2d_cde.h
  34. Library/Source/arm_2d_cde.c
  35. examples/common/platform
  36. examples/common/*.pack
  37. examples/common/asset/*.png
  38. examples/common/asset/*.PNG
  39. examples/common/asset/*.jpg
  40. "
  41. # Specify patches to be applied
  42. PACK_PATCH_FILES=""
  43. # Specify addition argument to packchk
  44. PACKCHK_ARGS=()
  45. # Specify additional dependencies for packchk
  46. PACKCHK_DEPS="
  47. ARM.CMSIS.pdsc
  48. "
  49. # custom pre-processing steps
  50. function preprocess() {
  51. ./documentation/gen_doc.sh
  52. }
  53. # custom post-processing steps
  54. function postprocess() {
  55. # add custom steps here to be executed
  56. # after populating the pack build folder
  57. # but before archiving the pack into output folder
  58. return 0
  59. }
  60. ############ DO NOT EDIT BELOW ###########
  61. function install_lib() {
  62. local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
  63. echo "Downloading gen-pack lib to '$2'"
  64. mkdir -p "$2"
  65. curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
  66. }
  67. function load_lib() {
  68. if [[ -d ${GEN_PACK_LIB} ]]; then
  69. . "${GEN_PACK_LIB}/gen-pack"
  70. return 0
  71. fi
  72. local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
  73. local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
  74. if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
  75. echo "Required gen_pack lib not found!" >&2
  76. install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
  77. fi
  78. if [[ -d "${GLOBAL_LIB}" ]]; then
  79. . "${GLOBAL_LIB}/gen-pack"
  80. elif [[ -d "${USER_LIB}" ]]; then
  81. . "${USER_LIB}/gen-pack"
  82. else
  83. echo "Required gen-pack lib is not installed!" >&2
  84. exit 1
  85. fi
  86. }
  87. load_lib
  88. gen_pack "${DEFAULT_ARGS[@]}" "$@"
  89. exit 0