gen_pack.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/usr/bin/env bash
  2. # Version: 3.0
  3. # Date: 2024-01-09
  4. # This bash script generates a CMSIS-NN Software Pack:
  5. #
  6. set -o pipefail
  7. # Set version of gen pack library
  8. # For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags.
  9. # Use the tag name without the prefix "v", e.g., 0.7.0
  10. REQUIRED_GEN_PACK_LIB="0.9.1"
  11. # Set default command line arguments
  12. DEFAULT_ARGS=(-c "v")
  13. # Pack warehouse directory - destination
  14. # Default: ./output
  15. #
  16. # PACK_OUTPUT=./output
  17. # Temporary pack build directory,
  18. # Default: ./build
  19. #
  20. # PACK_BUILD=./build
  21. # Specify directory names to be added to pack base directory
  22. # An empty list defaults to all folders next to this script.
  23. # Default: empty (all folders)
  24. #
  25. PACK_DIRS="
  26. Documentation
  27. Include
  28. Source
  29. "
  30. # Specify file names to be added to pack base directory
  31. # Default: empty
  32. #
  33. PACK_BASE_FILES="
  34. LICENSE
  35. README.md
  36. "
  37. # Specify file names to be deleted from pack build directory
  38. # Default: empty
  39. #
  40. PACK_DELETE_FILES="
  41. Documentation/Doxygen
  42. Documentation/README.md
  43. "
  44. # Specify patches to be applied
  45. # Default: empty
  46. #
  47. # PACK_PATCH_FILES=""
  48. # Specify addition argument to packchk
  49. # Default: empty
  50. #
  51. # PACKCHK_ARGS=()
  52. # Specify additional dependencies for packchk
  53. # Default: empty
  54. #
  55. PACKCHK_DEPS="
  56. ARM.CMSIS.pdsc
  57. "
  58. # Optional: restrict fallback modes for changelog generation
  59. # Default: full
  60. # Values:
  61. # - full Tag annotations, release descriptions, or commit messages (in order)
  62. # - release Tag annotations, or release descriptions (in order)
  63. # - tag Tag annotations only
  64. #
  65. PACK_CHANGELOG_MODE="tag"
  66. # custom pre-processing steps
  67. #
  68. # usage: preprocess <build>
  69. # <build> The build folder
  70. #
  71. function preprocess() {
  72. # add custom steps here to be executed
  73. # before populating the pack build folder
  74. ./Documentation/Doxygen/gen_doc.sh
  75. return 0
  76. }
  77. # custom post-processing steps
  78. #
  79. # usage: postprocess <build>
  80. # <build> The build folder
  81. #
  82. function postprocess() {
  83. # Set component version to match pack version
  84. VERSION=$(git_describe "${CHANGELOG}" | sed -e "s/+g.*$//")
  85. sed -i -e "s/Cgroup=\"NN Lib\" Cversion=\"[^\"]*\"/Cgroup=\"NN Lib\" Cversion=\"${VERSION}\"/" ${PACK_BUILD}/ARM.CMSIS-NN.pdsc
  86. }
  87. ############ DO NOT EDIT BELOW ###########
  88. # Set GEN_PACK_LIB_PATH to use a specific gen-pack library root
  89. # ... instead of bootstrap based on REQUIRED_GEN_PACK_LIB
  90. if [[ -f "${GEN_PACK_LIB_PATH}/gen-pack" ]]; then
  91. . "${GEN_PACK_LIB}/gen-pack"
  92. else
  93. . <(curl -sL "https://raw.githubusercontent.com/Open-CMSIS-Pack/gen-pack/main/bootstrap")
  94. fi
  95. gen_pack "${DEFAULT_ARGS[@]}" "$@"
  96. exit 0