]> begriffs open source - cmsis-driver-validation/blob - gen_pack.sh
Update GitHub Actions runner to ubuntu-22.04 (#18)
[cmsis-driver-validation] / gen_pack.sh
1 #!/bin/bash
2 # Version: 2.3
3 # Date: 2022-09-28
4 # This bash script generates a CMSIS-Driver Software Pack
5 #
6
7 set -o pipefail
8
9 # Set version of gen pack library
10 REQUIRED_GEN_PACK_LIB="0.6.1"
11
12 # Set default command line arguments
13 DEFAULT_ARGS=(-c "")
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   Boards
24   Config
25   Documentation
26   Include
27   Scripts
28   Source
29   Tools
30 "
31
32 # Specify file names to be added to pack base directory
33 PACK_BASE_FILES="
34   LICENSE.txt
35   README.md
36 "
37
38 # Specify file names to be deleted from pack build directory
39 PACK_DELETE_FILES=""
40
41 # Specify patches to be applied
42 PACK_PATCH_FILES=""
43
44 # Specify addition argument to packchk
45 PACKCHK_ARGS=()
46
47 # Specify additional dependencies for packchk
48 PACKCHK_DEPS="
49   ARM.CMSIS.pdsc
50   ARM.CMSIS-RTX.pdsc
51   Keil.STM32F2xx_DFP.pdsc
52   Keil.STM32F4xx_DFP.pdsc
53   Keil.STM32F7xx_DFP.pdsc
54   Keil.B-L475E-IOT01A_BSP.pdsc
55   Infineon.XMC4000_DFP.pdsc
56   NXP.LPCXpresso55S69_BSP.pdsc
57   NXP.EVK-MIMXRT1064_BSP.pdsc
58 "
59
60 # Optional: restrict fallback modes for changelog generation
61 # Default: full
62 # Values:
63 # - full      Tag annotations, release descriptions, or commit messages (in order)
64 # - release   Tag annotations, or release descriptions (in order)
65 # - tag       Tag annotations only
66 PACK_CHANGELOG_MODE="tag"
67
68 # custom preprocessing steps
69 function preprocess() {
70   ./DoxyGen/gen_doc.sh
71 }
72
73 # custom post-processing steps
74 # function postprocess() {
75 # }
76
77 ############ DO NOT EDIT BELOW ###########
78
79 function install_lib() {
80   local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
81   echo "Downloading gen-pack lib to '$2'"
82   mkdir -p "$2"
83   curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
84 }
85
86 function load_lib() {
87   if [[ -d ${GEN_PACK_LIB} ]]; then
88     . "${GEN_PACK_LIB}/gen-pack"
89     return 0
90   fi
91   local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
92   local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
93   if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
94     echo "Required gen_pack lib not found!" >&2
95     install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
96   fi
97
98   if [[ -d "${GLOBAL_LIB}" ]]; then
99     . "${GLOBAL_LIB}/gen-pack"
100   elif [[ -d "${USER_LIB}" ]]; then
101     . "${USER_LIB}/gen-pack"
102   else
103     echo "Required gen-pack lib is not installed!" >&2
104     exit 1
105   fi
106 }
107
108 load_lib
109 gen_pack "${DEFAULT_ARGS[@]}" "$@"
110
111 exit 0