blob: 8df000385e171891351d92102965680a1d1daf3f [file] [log] [blame]
Jonatan Antonie73f32f2021-05-05 18:19:03 +02001#!/bin/bash
2# Version: 1.0
3# Date: 2021-05-05
4# This bash script generates CMSIS Documentation:
5#
6# Pre-requisites:
7# - bash shell (for Windows: install git for Windows)
8# - doxygen 1.8.6
9# - mscgen 0.20
10
11set -o pipefail
12
13DIRNAME=$(dirname $(readlink -f $0))
14DOXYGEN=$(which doxygen)
15MSCGEN=$(which mscgen)
16REGEN=0
17ALLPARTS=($(find ${DIRNAME} -mindepth 1 -maxdepth 1 -type d -exec basename {} \;))
18PARTS=()
19
20if [[ -z "$*" ]]; then
21 REGEN=1
22else
23 for part in "$*"; do
24 if [[ " ${ALLPARTS[@]} " =~ " $part " ]]; then
25 PARTS+=($part)
26 fi
27 done
28fi
29
30if [[ ! -f "${DOXYGEN}" ]]; then
31 echo "Doxygen not found!" >&2
32 echo "Did you miss to add it to PATH?"
33 exit 1
34else
35 version=$("${DOXYGEN}" --version)
36 echo "DOXYGEN is ${DOXYGEN} at version ${version}"
37 if [[ "${version}" != "1.8.6" ]]; then
38 echo " >> Version is different from 1.8.6 !" >&2
39 fi
40fi
41
42if [[ ! -f "${MSCGEN}" ]]; then
43 echo "mscgen not found!" >&2
44 echo "Did you miss to add it to PATH?"
45 exit 1
46else
47 version=$("${MSCGEN}" 2>/dev/null | grep "Mscgen version" | sed -r -e 's/Mscgen version ([^,]+),.*/\1/')
48 echo "MSCGEN is ${MSCGEN} at version ${version}"
49 if [[ "${version}" != "0.20" ]]; then
50 echo " >> Version is different from 0.20 !" >&2
51 fi
52fi
53
54function doxygen {
55 partname=$(basename $(dirname $1))
56 if [[ $REGEN != 0 ]] || [[ " ${PARTS[@]} " =~ " ${partname} " ]]; then
57 pushd "$(dirname $1)" > /dev/null
58 echo "${DOXYGEN} $1"
59 "${DOXYGEN}" $(basename "$1")
60 popd > /dev/null
61
62 if [[ $2 != 0 ]]; then
63 cp -f "${DIRNAME}/Doxygen_Templates/search.css" "${DIRNAME}/../Documentation/${partname}/html/search/"
64 fi
65
66 projectName=$(grep -E "PROJECT_NAME\s+=" $1 | sed -r -e 's/[^"]*"([^"]+)"/\1/')
67 projectNumber=$(grep -E "PROJECT_NUMBER\s+=" $1 | sed -r -e 's/[^"]*"([^"]+)"/\1/')
68 datetime=$(date -u +'%a %b %e %Y %H:%M:%S')
69 sed -e "s/{datetime}/${datetime}/" "${DIRNAME}/Doxygen_Templates/cmsis_footer.js" \
70 | sed -e "s/{projectName}/${projectName}/" \
71 | sed -e "s/{projectNumber}/${projectNumber}/" \
72 > "${DIRNAME}/../Documentation/${partname}/html/cmsis_footer.js"
73 fi
74}
75
76if [[ $REGEN != 0 ]]; then
77 echo "Cleaning existing documentation ..."
78 find "${DIRNAME}/../Documentation/" -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} +
79fi
80
81echo "Generating documentation ..."
Vladimir Marchenko1b7e0ce2022-04-14 17:30:30 +020082echo "Copying Build html"
83mkdir -p "${DIRNAME}/../Documentation/Build/"
84cp -r "${DIRNAME}/Build/html/" "${DIRNAME}/../Documentation/Build/"
Jonatan Antonie73f32f2021-05-05 18:19:03 +020085doxygen "${DIRNAME}/Core/core.dxy" 1
86doxygen "${DIRNAME}/Core_A/core_A.dxy" 1
87doxygen "${DIRNAME}/DAP/dap.dxy" 1
88doxygen "${DIRNAME}/Driver/Driver.dxy" 1
89doxygen "${DIRNAME}/DSP/dsp.dxy" 1
90doxygen "${DIRNAME}/General/general.dxy" 0
91doxygen "${DIRNAME}/DAP/dap.dxy" 1
92doxygen "${DIRNAME}/NN/nn.dxy" 1
Vladimir Marchenko1b7e0ce2022-04-14 17:30:30 +020093echo "Copying Pack html"
Jonatan Antonicdd6f012022-04-14 14:25:21 +020094mkdir -p "${DIRNAME}/../Documentation/Pack/"
95cp -r "${DIRNAME}/Pack/html" "${DIRNAME}/../Documentation/Pack/"
Jonatan Antonie73f32f2021-05-05 18:19:03 +020096doxygen "${DIRNAME}/RTOS/rtos.dxy" 1
97doxygen "${DIRNAME}/RTOS2/rtos.dxy" 1
98doxygen "${DIRNAME}/SVD/svd.dxy" 0
99doxygen "${DIRNAME}/Zone/zone.dxy" 1
100
101exit 0