-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_doc.sh
executable file
·99 lines (80 loc) · 2.98 KB
/
gen_doc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
# Version: 2.8
# Date: 2023-06-06
# This bash script generates CMSIS-myswcomp documentation
#
# Pre-requisites:
# - bash shell (for Windows: install git for Windows)
# - doxygen 1.9.6
# - mscgen 0.20
set -o pipefail
# Set version of gen pack library
# For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags.
# Use the tag name without the prefix "v", e.g., 0.7.0
REQUIRED_GEN_PACK_LIB="0.8.3"
DIRNAME=$(dirname $(readlink -f $0))
GENDIR=${DIRNAME}/../Documentation/html
REQ_DXY_VERSION="1.9.6"
REQ_MSCGEN_VERSION="0.20"
############ DO NOT EDIT BELOW ###########
function install_lib() {
local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
local STATUS=$(curl -sLI "${URL}" | grep "^HTTP" | tail -n 1 | cut -d' ' -f2 || echo "$((600+$?))")
if [[ $STATUS -ge 400 ]]; then
echo "Wrong/unavailable gen-pack lib version '$1'!" >&2
echo "Check REQUIRED_GEN_PACK_LIB variable." >&2
echo "For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags." >&2
exit 1
fi
echo "Downloading gen-pack lib version '$1' to '$2' ..."
mkdir -p "$2"
curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
}
function load_lib() {
if [[ -d ${GEN_PACK_LIB} ]]; then
. "${GEN_PACK_LIB}/gen-pack"
return 0
fi
local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
echo "Required gen-pack lib not found!" >&2
install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
fi
if [[ -d "${GLOBAL_LIB}" ]]; then
. "${GLOBAL_LIB}/gen-pack"
elif [[ -d "${USER_LIB}" ]]; then
. "${USER_LIB}/gen-pack"
else
echo "Required gen-pack lib is not installed!" >&2
exit 1
fi
}
load_lib
find_git
find_doxygen "${REQ_DXY_VERSION}"
find_utility "mscgen" "-l | grep 'Mscgen version' | sed -r -e 's/Mscgen version ([^,]+),.*/\1/'" "${REQ_MSCGEN_VERSION}"
if [ -z "${VERSION_FULL}" ]; then
VERSION_FULL=$(git_describe "v")
fi
pushd "${DIRNAME}" > /dev/null
echo "Generating documentation ..."
projectName=$(grep -E "PROJECT_NAME\s+=" myswcomp.dxy.in | sed -r -e 's/[^"]*"([^"]+)".*/\1/')
projectNumberFull="${VERSION_FULL}"
projectNumber="${projectNumberFull%+*}"
datetime=$(date -u +'%a %b %e %Y %H:%M:%S')
year=$(date -u +'%Y')
sed -e "s/{projectNumber}/${projectNumber}/" myswcomp.dxy.in > myswcomp.dxy
# git_changelog -f html -p "v" > src/history.txt
echo "\"${UTILITY_DOXYGEN}\" myswcomp.dxy"
"${UTILITY_DOXYGEN}" myswcomp.dxy
mkdir -p "${GENDIR}/search"
cp -f "${DIRNAME}/Doxygen_Templates/search.css" "${GENDIR}/search"
sed -e "s/{datetime}/${datetime}/" "${DIRNAME}/Doxygen_Templates/footer.js.in" \
| sed -e "s/{year}/${year}/" \
| sed -e "s/{projectName}/${projectName}/" \
| sed -e "s/{projectNumber}/${projectNumber}/" \
| sed -e "s/{projectNumberFull}/${projectNumberFull}/" \
> "${GENDIR}/footer.js"
popd > /dev/null
exit 0