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
7set -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
12REQUIRED_GEN_PACK_LIB="0.9.1"
13
14# Set default command line arguments
15DEFAULT_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#
31PACK_DIRS="
32  Documentation
33  Include
34  Source
35"
36
37# Specify file names to be added to pack base directory
38# Default: empty
39#
40PACK_BASE_FILES="
41  LICENSE
42  README.md
43"
44
45# Specify file names to be deleted from pack build directory
46# Default: empty
47#
48PACK_DELETE_FILES="
49  Documentation/Doxygen
50  Documentation/README.md
51"
52
53# Specify patches to be applied
54# Default: empty
55#
56# PACK_PATCH_FILES=""
57
58# Specify addition argument to packchk
59# Default: empty
60#
61# PACKCHK_ARGS=()
62
63# Specify additional dependencies for packchk
64# Default: empty
65#
66PACKCHK_DEPS="
67  ARM.CMSIS.pdsc
68"
69
70# Optional: restrict fallback modes for changelog generation
71# Default: full
72# Values:
73# - full      Tag annotations, release descriptions, or commit messages (in order)
74# - release   Tag annotations, or release descriptions (in order)
75# - tag       Tag annotations only
76#
77PACK_CHANGELOG_MODE="tag"
78# custom pre-processing steps
79#
80# usage: preprocess <build>
81#   <build>  The build folder
82#
83function preprocess() {
84  # add custom steps here to be executed
85  # before populating the pack build folder
86  ./Documentation/Doxygen/gen_doc.sh
87  return 0
88}
89# custom post-processing steps
90#
91# usage: postprocess <build>
92#   <build>  The build folder
93#
94function postprocess() {
95  # Set component version to match pack version
96  VERSION=$(git_describe "${CHANGELOG}" | sed -e "s/+g.*$//")
97  sed -i -e "s/Cgroup=\"NN Lib\" Cversion=\"[^\"]*\"/Cgroup=\"NN Lib\" Cversion=\"${VERSION}\"/" ${PACK_BUILD}/ARM.CMSIS-NN.pdsc
98}
99
100############ DO NOT EDIT BELOW ###########
101
102# Set GEN_PACK_LIB_PATH to use a specific gen-pack library root
103# ... instead of bootstrap based on REQUIRED_GEN_PACK_LIB
104if [[ -f "${GEN_PACK_LIB_PATH}/gen-pack" ]]; then
105  . "${GEN_PACK_LIB}/gen-pack"
106else
107  . <(curl -sL "https://raw.githubusercontent.com/Open-CMSIS-Pack/gen-pack/main/bootstrap")
108fi
109
110gen_pack "${DEFAULT_ARGS[@]}" "$@"
111
112exit 0
113