]> begriffs open source - cmsis-freertos/blob - gen_pack.sh
Updates for FreeRTOS-Kernel v10.6.1
[cmsis-freertos] / gen_pack.sh
1 #!/usr/bin/env bash
2 # Version: 2.7
3 # Date: 2023-08-30
4 # This bash script generates a CMSIS Software Pack: CMSIS-FreeRTOS
5 #
6
7 set -o pipefail
8
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.3"
13
14 # Set default command line arguments
15 DEFAULT_ARGS=(-c "v")
16
17 # Pack warehouse directory - destination
18 # Default: ./output
19 #
20 # PACK_OUTPUT=./output
21
22 # Temporary pack build directory,
23 # Default: ./build
24 #
25 # PACK_BUILD=./build
26
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)
30 #
31 PACK_DIRS="
32   CMSIS
33   Config
34   Documentation
35   Source
36 "
37
38 # Specify file names to be added to pack base directory
39 # Default: empty
40 #
41 PACK_BASE_FILES="
42   LICENSE
43 "
44
45 # Specify file names to be deleted from pack build directory
46 # Default: empty
47 #
48 # PACK_DELETE_FILES=""
49
50 # Specify patches to be applied
51 # Default: empty
52 #
53 # PACK_PATCH_FILES=""
54
55 # Specify addition argument to packchk
56 # Default: empty
57 #
58 # PACKCHK_ARGS=()
59
60 # Specify additional dependencies for packchk
61 # Default: empty
62 #
63 PACKCHK_DEPS="
64   ARM.CMSIS.pdsc
65 "
66
67 # Optional: restrict fallback modes for changelog generation
68 # Default: full
69 # Values:
70 # - full      Tag annotations, release descriptions, or commit messages (in order)
71 # - release   Tag annotations, or release descriptions (in order)
72 # - tag       Tag annotations only
73 #
74 PACK_CHANGELOG_MODE="full"
75
76 #
77 # custom pre-processing steps
78 #
79 # usage: preprocess <build>
80 #   <build>  The build folder
81 #
82 function preprocess() {
83   # add custom steps here to be executed
84   # before populating the pack build folder
85   ./DoxyGen/gen_doc.sh
86   return 0
87 }
88
89 #
90 # custom post-processing steps
91 #
92 # usage: postprocess <build>
93 #   <build>  The build folder
94 #
95 function postprocess() {
96   # add custom steps here to be executed
97   # after populating the pack build folder
98   # but before archiving the pack into output folder
99   return 0
100 }
101
102 ############ DO NOT EDIT BELOW ###########
103
104 function install_lib() {
105   local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
106   local STATUS=$(curl -sLI "${URL}" | grep "^HTTP" | tail -n 1 | cut -d' ' -f2 || echo "$((600+$?))")
107   if [[ $STATUS -ge 400 ]]; then
108     echo "Wrong/unavailable gen-pack lib version '$1'!" >&2
109     echo "Check REQUIRED_GEN_PACK_LIB variable."  >&2
110     echo "For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags." >&2
111     exit 1
112   fi
113   echo "Downloading gen-pack lib version '$1' to '$2' ..."
114   mkdir -p "$2"
115   curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
116 }
117
118 function load_lib() {
119   if [[ -d ${GEN_PACK_LIB} ]]; then
120     . "${GEN_PACK_LIB}/gen-pack"
121     return 0
122   fi
123   local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
124   local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
125   if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
126     echo "Required gen_pack lib not found!" >&2
127     install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
128   fi
129
130   if [[ -d "${GLOBAL_LIB}" ]]; then
131     . "${GLOBAL_LIB}/gen-pack"
132   elif [[ -d "${USER_LIB}" ]]; then
133     . "${USER_LIB}/gen-pack"
134   else
135     echo "Required gen-pack lib is not installed!" >&2
136     exit 1
137   fi
138 }
139
140 load_lib
141 gen_pack "${DEFAULT_ARGS[@]}" "$@"
142
143 exit 0