mkconfigvars.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #!/usr/bin/env bash
  2. # tools/mkconfivars.sh
  3. #
  4. # Licensed to the Apache Software Foundation (ASF) under one or more
  5. # contributor license agreements. See the NOTICE file distributed with
  6. # this work for additional information regarding copyright ownership. The
  7. # ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance with the
  9. # License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. # License for the specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. USAGE="USAGE: $0 [-d|h] [-v <major.minor.patch>]"
  20. ADVICE="Try '$0 -h' for more information"
  21. unset VERSION
  22. while [ ! -z "$1" ]; do
  23. case $1 in
  24. -v )
  25. shift
  26. VERSION=$1
  27. ;;
  28. -d )
  29. set -x
  30. ;;
  31. -h )
  32. echo "$0 is a tool for generation of configuration variable documentation"
  33. echo ""
  34. echo $USAGE
  35. echo ""
  36. echo "Where:"
  37. echo " -v <major.minor.patch>"
  38. echo " The NuttX version number expressed as a major, minor and patch number separated"
  39. echo " by a period"
  40. echo " -d"
  41. echo " Enable script debug"
  42. echo " -h"
  43. echo " show this help message and exit"
  44. exit 0
  45. ;;
  46. * )
  47. echo "Unrecognized option: ${1}"
  48. echo $USAGE
  49. echo $ADVICE
  50. exit 1
  51. ;;
  52. esac
  53. shift
  54. done
  55. # Find the directory we were executed from and were we expect to
  56. # see the directories to tar up
  57. MYNAME=`basename $0`
  58. KCONFIG2HTML_TARGET=kconfig2html
  59. KCONFIG2HTML1=tools/kconfig2html
  60. KCONFIG2HTML2=tools/kconfig2html.exe
  61. KCONFIG2MAKEFILE=Makefile.host
  62. KCONFIG2MAKEDIR=tools
  63. HTMLFILE=Documentation/NuttXConfigVariables.html
  64. BKUPFILE=Documentation/NuttXConfigVariables.bkp
  65. if [ -x ./${MYNAME} ] ; then
  66. cd .. || { echo "ERROR: cd .. failed" ; exit 1 ; }
  67. fi
  68. if [ ! -x tools/${MYNAME} ] ; then
  69. echo "ERROR: This file must be executed from the top-level NuttX directory: $PWD"
  70. exit 1
  71. fi
  72. WD=${PWD}
  73. # Find the application directory
  74. if [ -d ../apps ]; then
  75. APPSDIR="../apps"
  76. else
  77. if [ -d "../apps-${VERSION}" ]; then
  78. APPSDIR="../apps-${VERSION}"
  79. else
  80. echo "ERROR: Cannot find the application directory"
  81. exit 1
  82. fi
  83. fi
  84. # If the kconfig2html executable does not exist, then build it
  85. if [ -x ${KCONFIG2HTML1} ]; then
  86. KCONFIG2HTML=${KCONFIG2HTML1}
  87. else
  88. if [ -x ${KCONFIG2HTML2} ]; then
  89. KCONFIG2HTML=${KCONFIG2HTML2}
  90. else
  91. make -C ${KCONFIG2MAKEDIR} -f ${KCONFIG2MAKEFILE} ${KCONFIG2HTML_TARGET} 1>/dev/null || \
  92. { echo "ERROR: make ${KCONFIG2HTML1} failed" ; exit 1 ; }
  93. fi
  94. fi
  95. if [ -x ${KCONFIG2HTML1} ]; then
  96. KCONFIG2HTML=${KCONFIG2HTML1}
  97. else
  98. if [ -x ${KCONFIG2HTML2} ]; then
  99. KCONFIG2HTML=${KCONFIG2HTML2}
  100. else
  101. echo "ERROR: Failed to create ${KCONFIG2HTML1}"
  102. exit 1
  103. fi
  104. fi
  105. # Keep a backup of the previous HTML file. This is usefully primarily
  106. # for testing the effects of changes.
  107. if [ -e "${HTMLFILE}" ]; then
  108. rm -f ${BKUPFILE} || { echo "ERROR: Failed to remove ${BKUPFILE}" ; exit 1 ; }
  109. mv ${HTMLFILE} ${BKUPFILE} || { echo "ERROR: Failed to move ${HTMLFILE}" ; exit 1 ; }
  110. fi
  111. # Now re-create the configuration variable document
  112. ${KCONFIG2HTML} -a "${APPSDIR}" -o ${HTMLFILE}