4 # This bash script generates CMSIS-Core documentation
7 # - bash shell (for Windows: install git for Windows)
13 # Set version of gen pack library
14 # For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags.
15 # Use the tag name without the prefix "v", e.g., 0.7.0
16 REQUIRED_GEN_PACK_LIB="0.8.4"
18 DIRNAME=$(dirname $(readlink -f $0))
19 GENDIR=../Documentation
20 REQ_DXY_VERSION="1.9.6"
21 REQ_MSCGEN_VERSION="0.20"
23 ############ DO NOT EDIT BELOW ###########
25 function install_lib() {
26 local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
27 local STATUS=$(curl -sLI "${URL}" | grep "^HTTP" | tail -n 1 | cut -d' ' -f2 || echo "$((600+$?))")
28 if [[ $STATUS -ge 400 ]]; then
29 echo "Wrong/unavailable gen-pack lib version '$1'!" >&2
30 echo "Check REQUIRED_GEN_PACK_LIB variable." >&2
31 echo "For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags." >&2
34 echo "Downloading gen-pack lib version '$1' to '$2' ..."
36 curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
40 if [[ -d ${GEN_PACK_LIB} ]]; then
41 . "${GEN_PACK_LIB}/gen-pack"
44 local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
45 local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
46 if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
47 echo "Required gen-pack lib not found!" >&2
48 install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
51 if [[ -d "${GLOBAL_LIB}" ]]; then
52 . "${GLOBAL_LIB}/gen-pack"
53 elif [[ -d "${USER_LIB}" ]]; then
54 . "${USER_LIB}/gen-pack"
56 echo "Required gen-pack lib is not installed!" >&2
63 find_doxygen "${REQ_DXY_VERSION}"
64 find_utility "mscgen" "-l | grep 'Mscgen version' | sed -r -e 's/Mscgen version ([^,]+),.*/\1/'" "${REQ_MSCGEN_VERSION}"
66 if [ -z "${VERSION_FULL}" ]; then
67 VERSION_FULL=$(git_describe "v")
70 pushd "${DIRNAME}" > /dev/null
72 echo "Generating documentation ..."
77 projectName=$(grep -E "PROJECT_NAME\s+=" $1.dxy.in | sed -r -e 's/[^"]*"([^"]+)".*/\1/')
78 projectNumberFull="$2"
79 if [ -z "${projectNumberFull}" ]; then
80 projectNumberFull=$(grep -E "PROJECT_NUMBER\s+=" $1.dxy.in | sed -r -e 's/[^"]*"[^0-9]*(([0-9]+\.[0-9]+(\.[0-9]+)?(-.+)?)?)".*/\1/')
82 if [ -z "${projectNumberFull}" ]; then
83 projectNumberFull="$(git rev-parse --short HEAD)"
85 projectNumber="${projectNumberFull%+*}"
86 datetime=$(date -u +'%a %b %e %Y %H:%M:%S')
89 sed -e "s/{projectNumber}/${projectNumber}/" $1.dxy.in > $1.dxy
91 # git_changelog -f html -p "v" > src/history.txt
93 echo "\"${UTILITY_DOXYGEN}\" $1.dxy"
94 "${UTILITY_DOXYGEN}" $1.dxy
96 mkdir -p "${DIRNAME}/${GENDIR}/$1/html/search/"
97 cp -f "${DIRNAME}/Doxygen_Templates/search.css" "${DIRNAME}/${GENDIR}/$1/html/search/"
98 cp -f "${DIRNAME}/Doxygen_Templates/navtree.js" "${DIRNAME}/${GENDIR}/$1/html/"
100 sed -e "s/{datetime}/${datetime}/" "${DIRNAME}/Doxygen_Templates/footer.js.in" \
101 | sed -e "s/{year}/${year}/" \
102 | sed -e "s/{projectName}/${projectName}/" \
103 | sed -e "s/{projectNumber}/${projectNumber}/" \
104 | sed -e "s/{projectNumberFull}/${projectNumberFull}/" \
105 > "${DIRNAME}/${GENDIR}/$1/html/footer.js"
110 generate "General" "${VERSION_FULL}"