4 # This bash script generates CMSIS-FreeRTOS documentation
7 # - bash shell (for Windows: install git for Windows)
12 # Set version of gen pack library
13 REQUIRED_GEN_PACK_LIB="0.6.0"
15 DIRNAME=$(dirname $(readlink -f $0))
16 DOXYGEN=$(which doxygen 2>/dev/null)
17 REQ_DXY_VERSION="1.9.2"
19 if [[ ! -f "${DOXYGEN}" ]]; then
20 echo "Doxygen not found!" >&2
21 echo "Did you miss to add it to PATH?"
24 version=$("${DOXYGEN}" --version | sed -E 's/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
25 echo "Doxygen is ${DOXYGEN} at version ${version}"
26 if [[ "${version}" != "${REQ_DXY_VERSION}" ]]; then
27 echo "Doxygen required to be at version ${REQ_DXY_VERSION}!" >&2
32 ############ DO NOT EDIT BELOW ###########
34 function install_lib() {
35 local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz"
36 echo "Downloading gen_pack lib to '$2'"
38 curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1
42 if [[ -d ${GEN_PACK_LIB} ]]; then
43 . "${GEN_PACK_LIB}/gen-pack"
46 local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
47 local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}"
48 if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then
49 echo "Required gen-pack lib not found!" >&2
50 install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}"
53 if [[ -d "${GLOBAL_LIB}" ]]; then
54 . "${GLOBAL_LIB}/gen-pack"
55 elif [[ -d "${USER_LIB}" ]]; then
56 . "${USER_LIB}/gen-pack"
58 echo "Required gen-pack lib is not installed!" >&2
66 if [ -z $VERSION ]; then
67 VERSION_FULL=$(git_describe "v")
68 VERSION=${VERSION_FULL%+*}
71 pushd "${DIRNAME}" > /dev/null
73 echo "Generating documentation ..."
75 sed -e "s/{projectNumber}/${VERSION}/" freertos.dxy.in > freertos.dxy
77 git_changelog -f html -p "v" > src/history.txt
79 echo "\"${DOXYGEN}\" freertos.dxy"
80 "${DOXYGEN}" freertos.dxy
82 if [[ $2 != 0 ]]; then
83 mkdir -p "${DIRNAME}/../Documentation/html/search/"
84 cp -f "${DIRNAME}/templates/search.css" "${DIRNAME}/../Documentation/html/search/"
87 projectName=$(grep -E "PROJECT_NAME\s+=" freertos.dxy | sed -r -e 's/[^"]*"([^"]+)".*/\1/')
88 datetime=$(date -u +'%a %b %e %Y %H:%M:%S')
90 sed -e "s/{datetime}/${datetime}/" "${DIRNAME}/templates/footer.js.in" \
91 | sed -e "s/{year}/${year}/" \
92 | sed -e "s/{projectName}/${projectName}/" \
93 | sed -e "s/{projectNumber}/${VERSION}/" \
94 | sed -e "s/{projectNumberFull}/${VERSION_FULL}/" \
95 > "${DIRNAME}/../Documentation/html/footer.js"