4 # This bash script generates a CMSIS Software Pack:
9 # Set version of gen pack library
10 # For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags.
11 # Use the tag name without the prefix "v", e.g., 0.7.0
12 REQUIRED_GEN_PACK_LIB="0.8.5"
14 # Set default command line arguments
17 # Pack warehouse directory - destination
20 # PACK_OUTPUT=./output
22 # Temporary pack build directory,
27 # Specify directory names to be added to pack base directory
28 # An empty list defaults to all folders next to this script.
29 # Default: empty (all folders)
38 # Specify file names to be added to pack base directory
45 # Specify file names to be deleted from pack build directory
49 CMSIS/Documentation/Doxygen
50 CMSIS/Documentation/README.md
53 # Specify patches to be applied
58 # Specify addition argument to packchk
61 PACKCHK_ARGS=(-x M336)
63 # Specify additional dependencies for packchk
68 # Optional: restrict fallback modes for changelog generation
71 # - full Tag annotations, release descriptions, or commit messages (in order)
72 # - release Tag annotations, or release descriptions (in order)
73 # - tag Tag annotations only
75 PACK_CHANGELOG_MODE="tag"
78 # custom pre-processing steps
80 # usage: preprocess <build>
81 # <build> The build folder
83 function preprocess() {
84 # add custom steps here to be executed
85 # before populating the pack build folder
86 ./CMSIS/Documentation/Doxygen/gen_doc.sh
91 # custom post-processing steps
93 # usage: postprocess <build>
94 # <build> The build folder
96 function postprocess() {
97 # add custom steps here to be executed
98 # after populating the pack build folder
99 # but before archiving the pack into output folder
103 ############ DO NOT EDIT BELOW ###########
105 function install_lib() {
106 local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
107 local STATUS=$(curl -sLI "${URL}" | grep "^HTTP" | tail -n 1 | cut -d' ' -f2 || echo "$((600+$?))")
108 if [[ $STATUS -ge 400 ]]; then
109 echo "Wrong/unavailable gen-pack lib version '$1'!" >&2
110 echo "Check REQUIRED_GEN_PACK_LIB variable." >&2
111 echo "For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags." >&2
114 echo "Downloading gen-pack lib version '$1' to '$2' ..."
116 curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
119 function load_lib() {
120 if [[ -d ${GEN_PACK_LIB} ]]; then
121 . "${GEN_PACK_LIB}/gen-pack"
124 local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
125 local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
126 if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
127 echo "Required gen_pack lib not found!" >&2
128 install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
131 if [[ -d "${GLOBAL_LIB}" ]]; then
132 . "${GLOBAL_LIB}/gen-pack"
133 elif [[ -d "${USER_LIB}" ]]; then
134 . "${USER_LIB}/gen-pack"
136 echo "Required gen-pack lib is not installed!" >&2
142 gen_pack "${DEFAULT_ARGS[@]}" "$@"