4 # This bash script generates CMSIS-Driver Documentation:
7 # - bash shell (for Windows: install git for Windows)
13 DIRNAME=$(dirname $(realpath $0))
14 DOXYGEN=$(which doxygen)
15 REQ_DXY_VERSION="1.9.6"
16 REQUIRED_GEN_PACK_LIB="0.6.1"
18 ############ gen-pack library ###########
20 function install_lib() {
21 local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
22 echo "Downloading gen_pack lib to '$2'"
24 curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
28 if [[ -d ${GEN_PACK_LIB} ]]; then
29 . "${GEN_PACK_LIB}/gen-pack"
32 local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
33 local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
34 if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
35 echo "Required gen-pack lib not found!" >&2
36 install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
39 if [[ -d "${GLOBAL_LIB}" ]]; then
40 . "${GLOBAL_LIB}/gen-pack"
41 elif [[ -d "${USER_LIB}" ]]; then
42 . "${USER_LIB}/gen-pack"
44 echo "Required gen-pack lib is not installed!" >&2
52 #########################################
54 if [[ ! -f "${DOXYGEN}" ]]; then
55 echo "Doxygen not found!" >&2
56 echo "Did you miss to add it to PATH?"
59 version=$("${DOXYGEN}" --version | sed -E 's/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
60 echo "DOXYGEN is ${DOXYGEN} at version ${version}"
61 if [[ "${version}" != "${REQ_DXY_VERSION}" ]]; then
62 echo " >> Version is different from ${REQ_DXY_VERSION} !" >&2
66 if [ -z "$VERSION" ]; then
67 VERSION_FULL=$(git_describe)
68 VERSION=${VERSION_FULL%+*}
70 VERSION_FULL=${VERSION}
73 echo "Generating documentation ..."
75 pushd $DIRNAME > /dev/null
77 rm -rf ${DIRNAME}/../Documentation/html
78 sed -e "s/{projectNumber}/${VERSION}/" "${DIRNAME}/CMSIS_DV.dxy.in" \
79 > "${DIRNAME}/CMSIS_DV.dxy"
81 PACK_CHANGELOG_MODE="tag"
82 DEV=$(pdsc_release_desc "${DIRNAME}/../ARM.CMSIS-Driver_Validation.pdsc")
83 git_changelog -f html -d "${DEV}" > src/history.txt
85 echo "${DOXYGEN} CMSIS_DV.dxy"
86 "${DOXYGEN}" CMSIS_DV.dxy
89 if [[ $2 != 0 ]]; then
90 cp -f "${DIRNAME}/templates/search.css" "${DIRNAME}/../Documentation/html/search/"
93 projectName=$(grep -E "PROJECT_NAME\s+=" "${DIRNAME}/CMSIS_DV.dxy" | sed -r -e 's/[^"]*"([^"]+)"/\1/')
94 datetime=$(date -u +'%a %b %e %Y %H:%M:%S')
96 if [[ "${year}" != "2022" ]]; then
99 sed -e "s/{datetime}/${datetime}/" "${DIRNAME}/templates/footer.js.in" \
100 | sed -e "s/{year}/${year}/" \
101 | sed -e "s/{projectName}/${projectName}/" \
102 | sed -e "s/{projectNumber}/${VERSION}/" \
103 | sed -e "s/{projectNumberFull}/${VERSION_FULL}/" \
104 > "${DIRNAME}/../Documentation/html/footer.js"