]> begriffs open source - cmsis/blob - gen_pack.sh
Updates for CMSIS 6
[cmsis] / gen_pack.sh
1 #!/bin/bash
2 # Version: 2.5
3 # Date: 2023-03-22
4 # This bash script generates a CMSIS Software Pack:
5 #
6
7 set -o pipefail
8
9 # Set version of gen pack library
10 REQUIRED_GEN_PACK_LIB="0.8.2"
11
12 # Set default command line arguments
13 DEFAULT_ARGS=(-c "v")
14
15 # Pack warehouse directory - destination
16 PACK_OUTPUT=./output
17
18 # Temporary pack build directory
19 PACK_BUILD=./build
20
21 # Specify directory names to be added to pack base directory
22 PACK_DIRS="
23   CMSIS/Core
24   CMSIS/Core_A
25   CMSIS/Documentation
26   CMSIS/Driver
27   CMSIS/RTOS2
28 "
29
30 # Specify file names to be added to pack base directory
31 PACK_BASE_FILES="
32   LICENSE.txt
33 "
34
35 # Specify file names to be deleted from pack build directory
36 PACK_DELETE_FILES=""
37
38 # Specify patches to be applied
39 PACK_PATCH_FILES=""
40
41 # Specify addition argument to packchk
42 PACKCHK_ARGS=(-x M353 -x M379 -x M336)
43
44 # Specify additional dependencies for packchk
45 PACKCHK_DEPS=""
46
47 # Optional: restrict fallback modes for changelog generation
48 # Default: full
49 # Values:
50 # - full      Tag annotations, release descriptions, or commit messages (in order)
51 # - release   Tag annotations, or release descriptions (in order)
52 # - tag       Tag annotations only
53 PACK_CHANGELOG_MODE="tag"
54
55 #
56 # custom pre-processing steps
57 #
58 # usage: preprocess <build>
59 #   <build>  The build folder
60 #
61 function preprocess() {
62   # add custom steps here to be executed
63   # before populating the pack build folder
64   ./CMSIS/DoxyGen/gen_doc.sh
65   return 0
66 }
67
68 #
69 # custom post-processing steps
70 #
71 # usage: postprocess <build>
72 #   <build>  The build folder
73 #
74 function postprocess() {
75   # add custom steps here to be executed
76   # after populating the pack build folder
77   # but before archiving the pack into output folder
78   return 0
79 }
80
81 ############ DO NOT EDIT BELOW ###########
82
83 function install_lib() {
84   local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
85   echo "Downloading gen-pack lib to '$2'"
86   mkdir -p "$2"
87   curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
88 }
89
90 function load_lib() {
91   if [[ -d ${GEN_PACK_LIB} ]]; then
92     . "${GEN_PACK_LIB}/gen-pack"
93     return 0
94   fi
95   local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
96   local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
97   if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
98     echo "Required gen_pack lib not found!" >&2
99     install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
100   fi
101
102   if [[ -d "${GLOBAL_LIB}" ]]; then
103     . "${GLOBAL_LIB}/gen-pack"
104   elif [[ -d "${USER_LIB}" ]]; then
105     . "${USER_LIB}/gen-pack"
106   else
107     echo "Required gen-pack lib is not installed!" >&2
108     exit 1
109   fi
110 }
111
112 load_lib
113 gen_pack "${DEFAULT_ARGS[@]}" "$@"
114
115 exit 0