mkconfigvars.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #!/usr/bin/env bash
  2. # tools/mkconfivars.sh
  3. #
  4. # Copyright (C) 2013 Gregory Nutt. All rights reserved.
  5. # Author: Gregory Nutt <gnutt@nuttx.org>
  6. #
  7. # Redistribution and use in source and binary forms, with or without
  8. # modification, are permitted provided that the following conditions
  9. # are met:
  10. #
  11. # 1. Redistributions of source code must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. # 2. Redistributions in binary form must reproduce the above copyright
  14. # notice, this list of conditions and the following disclaimer in
  15. # the documentation and/or other materials provided with the
  16. # distribution.
  17. # 3. Neither the name NuttX nor the names of its contributors may be
  18. # used to endorse or promote products derived from this software
  19. # without specific prior written permission.
  20. #
  21. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. # POSSIBILITY OF SUCH DAMAGE.
  33. #
  34. USAGE="USAGE: $0 [-d|h] [-v <major.minor.patch>]"
  35. ADVICE="Try '$0 -h' for more information"
  36. unset VERSION
  37. while [ ! -z "$1" ]; do
  38. case $1 in
  39. -v )
  40. shift
  41. VERSION=$1
  42. ;;
  43. -d )
  44. set -x
  45. ;;
  46. -h )
  47. echo "$0 is a tool for generation of configuration variable documentation"
  48. echo ""
  49. echo $USAGE
  50. echo ""
  51. echo "Where:"
  52. echo " -v <major.minor.patch>"
  53. echo " The NuttX version number expressed as a major, minor and patch number separated"
  54. echo " by a period"
  55. echo " -d"
  56. echo " Enable script debug"
  57. echo " -h"
  58. echo " show this help message and exit"
  59. exit 0
  60. ;;
  61. * )
  62. echo "Unrecognized option: ${1}"
  63. echo $USAGE
  64. echo $ADVICE
  65. exit 1
  66. ;;
  67. esac
  68. shift
  69. done
  70. # Find the directory we were executed from and were we expect to
  71. # see the directories to tar up
  72. MYNAME=`basename $0`
  73. KCONFIG2HTML_TARGET=kconfig2html
  74. KCONFIG2HTML1=tools/kconfig2html
  75. KCONFIG2HTML2=tools/kconfig2html.exe
  76. KCONFIG2MAKEFILE=Makefile.host
  77. KCONFIG2MAKEDIR=tools
  78. HTMLFILE=Documentation/NuttXConfigVariables.html
  79. BKUPFILE=Documentation/NuttXConfigVariables.bkp
  80. if [ -x ./${MYNAME} ] ; then
  81. cd .. || { echo "ERROR: cd .. failed" ; exit 1 ; }
  82. fi
  83. if [ ! -x tools/${MYNAME} ] ; then
  84. echo "ERROR: This file must be executed from the top-level NuttX directory: $PWD"
  85. exit 1
  86. fi
  87. WD=${PWD}
  88. # Find the application directory
  89. if [ -d ../apps ]; then
  90. APPSDIR="../apps"
  91. else
  92. if [ -d "../apps-${VERSION}" ]; then
  93. APPSDIR="../apps-${VERSION}"
  94. else
  95. echo "ERROR: Cannot find the application directory"
  96. exit 1
  97. fi
  98. fi
  99. # If the kconfig2html executable does not exist, then build it
  100. if [ -x ${KCONFIG2HTML1} ]; then
  101. KCONFIG2HTML=${KCONFIG2HTML1}
  102. else
  103. if [ -x ${KCONFIG2HTML2} ]; then
  104. KCONFIG2HTML=${KCONFIG2HTML2}
  105. else
  106. make -C ${KCONFIG2MAKEDIR} -f ${KCONFIG2MAKEFILE} ${KCONFIG2HTML_TARGET} 1>/dev/null || \
  107. { echo "ERROR: make ${KCONFIG2HTML1} failed" ; exit 1 ; }
  108. fi
  109. fi
  110. if [ -x ${KCONFIG2HTML1} ]; then
  111. KCONFIG2HTML=${KCONFIG2HTML1}
  112. else
  113. if [ -x ${KCONFIG2HTML2} ]; then
  114. KCONFIG2HTML=${KCONFIG2HTML2}
  115. else
  116. echo "ERROR: Failed to create ${KCONFIG2HTML1}"
  117. exit 1
  118. fi
  119. fi
  120. # Keep a backup of the previous HTML file. This is usefully primarily
  121. # for testing the effects of changes.
  122. if [ -e "${HTMLFILE}" ]; then
  123. rm -f ${BKUPFILE} || { echo "ERROR: Failed to remove ${BKUPFILE}" ; exit 1 ; }
  124. mv ${HTMLFILE} ${BKUPFILE} || { echo "ERROR: Failed to move ${HTMLFILE}" ; exit 1 ; }
  125. fi
  126. # Now re-create the configuration variable document
  127. ${KCONFIG2HTML} -a "${APPSDIR}" -o ${HTMLFILE}