4 # This bash script generates CMSIS-View documentation
7 # - bash shell (for Windows: install git for Windows)
13 # Set version of gen pack library
14 REQUIRED_GEN_PACK_LIB="0.8.3"
16 DIRNAME=$(dirname $(readlink -f $0))
17 GENDIR=../Documentation
18 REQ_DXY_VERSION="1.9.6"
19 REQ_MSCGEN_VERSION="0.20"
21 ############ DO NOT EDIT BELOW ###########
23 function install_lib() {
24 local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
25 local STATUS=$(curl -sLI "${URL}" | grep "^HTTP" | tail -n 1 | cut -d' ' -f2 || echo "$((600+$?))")
26 if [[ $STATUS -ge 400 ]]; then
27 echo "Wrong/unavailable gen-pack lib version '$1'!" >&2
28 echo "Check REQUIRED_GEN_PACK_LIB variable." >&2
29 echo "For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags." >&2
32 echo "Downloading gen-pack lib version '$1' to '$2' ..."
34 curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
38 if [[ -d ${GEN_PACK_LIB} ]]; then
39 . "${GEN_PACK_LIB}/gen-pack"
42 local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
43 local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
44 if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
45 echo "Required gen-pack lib not found!" >&2
46 install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
49 if [[ -d "${GLOBAL_LIB}" ]]; then
50 . "${GLOBAL_LIB}/gen-pack"
51 elif [[ -d "${USER_LIB}" ]]; then
52 . "${USER_LIB}/gen-pack"
54 echo "Required gen-pack lib is not installed!" >&2
61 find_doxygen "${REQ_DXY_VERSION}"
62 find_utility "mscgen" "-l | grep 'Mscgen version' | sed -r -e 's/Mscgen version ([^,]+),.*/\1/'" "${REQ_MSCGEN_VERSION}"
64 if [ -z "${VERSION_FULL}" ]; then
65 VERSION_FULL=$(git_describe "v")
68 pushd "${DIRNAME}" > /dev/null
70 echo "Generating documentation ..."
75 projectName=$(grep -E "PROJECT_NAME\s+=" $1.dxy.in | sed -r -e 's/[^"]*"([^"]+)".*/\1/')
76 projectNumberFull="$2"
77 if [ -z "${projectNumberFull}" ]; then
78 projectNumberFull=$(grep -E "PROJECT_NUMBER\s+=" $1.dxy.in | sed -r -e 's/[^"]*"[^0-9]*([0-9]+\.[0-9]+(\.[0-9]+)?(-.+)?)".*/\1/')
80 projectNumber="${projectNumberFull%+*}"
81 datetime=$(date -u +'%a %b %e %Y %H:%M:%S')
84 sed -e "s/{projectNumber}/${projectNumber}/" $1.dxy.in > $1.dxy
86 # git_changelog -f html -p "v" > src/history.txt
88 echo "\"${UTILITY_DOXYGEN}\" $1.dxy"
89 "${UTILITY_DOXYGEN}" $1.dxy
91 mkdir -p "${DIRNAME}/${GENDIR}/$1/html/search/"
92 cp -f "${DIRNAME}/Doxygen_Templates/search.css" "${DIRNAME}/${GENDIR}/$1/html/search/"
93 cp -f "${DIRNAME}/Doxygen_Templates/navtree.js" "${DIRNAME}/${GENDIR}/$1/html/"
95 sed -e "s/{datetime}/${datetime}/" "${DIRNAME}/Doxygen_Templates/footer.js.in" \
96 | sed -e "s/{year}/${year}/" \
97 | sed -e "s/{projectName}/${projectName}/" \
98 | sed -e "s/{projectNumber}/${projectNumber}/" \
99 | sed -e "s/{projectNumberFull}/${projectNumberFull}/" \
100 > "${DIRNAME}/${GENDIR}/$1/html/footer.js"
105 generate "General" "${VERSION_FULL}"