doxygen.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2010-2015, Marcus Rohrmoser mobile Software
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without modification, are permitted
  7. # provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of source code must retain the above copyright notice, this list of conditions
  10. # and the following disclaimer.
  11. #
  12. # 2. The software must not be used for military or intelligence or related purposes nor
  13. # anything that's in conflict with human rights as declared in http://www.un.org/en/documents/udhr/ .
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  18. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  22. # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. #
  24. # I suggest to use doxygen 1.5.9 as it works fine whereas later versions
  25. # might choke on categories.
  26. # https://bugzilla.gnome.org/show_bug.cgi?id=655941
  27. # http://stackoverflow.com/questions/2042595/doxygen-and-objective-c-categories
  28. if [ ! -e "$DOXYGEN" ] ; then
  29. DOXYGEN=/Applications/Doxygen.app/Contents/Resources/doxygen
  30. fi
  31. if [ ! -e "$DOXYGEN" ] ; then
  32. # use most recent
  33. DOXYGEN=$(ls -t /Applications/Doxygen*/Contents/Resources/doxygen | head -n 1)
  34. fi
  35. if [ ! -e "$DOXYGEN" ] ; then
  36. echo "I cannot find doxygen. Please install doxygen from" >&2
  37. # echo "\n http://www.stack.nl/~dimitri/doxygen/download.html#latestsrc" >&2
  38. echo "\n ftp://ftp.stack.nl/pub/users/dimitri/Doxygen-1.5.9.dmg" >&2
  39. echo "\ninto 'Applications', or set" >&2
  40. echo "\n export DOXYGEN=..." >&2
  41. echo "\nto point to the location you installed it to." >&2
  42. exit 1
  43. fi
  44. echo "Found doxygen $($DOXYGEN --version) at $DOXYGEN" >&2
  45. if [ ! -e "$DOT_PATH"/dot ] ; then
  46. # use packaged with doxygen
  47. DOT_PATH=$(dirname "$DOXYGEN")
  48. fi
  49. if [ ! -e "$DOT_PATH"/dot ] ; then
  50. # search in path
  51. DOT_PATH=$(which dot | head -n 1)
  52. DOT_PATH=$(dirname "$DOT_PATH")
  53. fi
  54. if [ ! -e "$DOT_PATH"/dot ] ; then
  55. # search in /usr/local
  56. DOT_PATH=$(find /usr/local -maxdepth 4 -type f -name dot | head -n 1)
  57. DOT_PATH=$(dirname "$DOT_PATH")
  58. fi
  59. if [ ! -e "$DOT_PATH"/dot ] ; then
  60. echo "I cannot find graphviz. I could run without, but that's only half the fun. So please install graphviz from" >&2
  61. echo "\n http://www.ryandesign.com/graphviz/" >&2
  62. echo "\nsomewhere in \$PATH or under /usr/local, or set" >&2
  63. echo "\n export DOT_PATH=..." >&2
  64. echo "\nto point to the directory you installed dot into." >&2
  65. exit 2
  66. fi
  67. echo "Found $("$DOT_PATH"/dot -V 2>&1) at $DOT_PATH/dot" >&2
  68. echo "Found mscgen $(mscgen -l | head -2 | tail -1) at $(which mscgen)" >&2
  69. PLANTUML=$(which plantuml 2>/dev/null)
  70. if [ $? -eq 0 ] && [ -x "$PLANTUML" ] ; then
  71. echo "Found $("$PLANTUML" -version | head -n 1) at $PLANTUML" >&2
  72. else
  73. echo "!!! Cannot find plantuml - so no UML diagrams." >&2
  74. fi
  75. PROJECT_BUNDLE_ID="name.mro.MROGeometry"
  76. PROJECT_NAME="MROGeometry"
  77. PROJECT_VERSION="0.1"
  78. PROJECT_SOURCE="MROGeometry"
  79. cd `dirname $0`/..
  80. if [[ "$PROJECT_NAME" == "" ]] ; then
  81. tmp=`pwd`
  82. PROJECT_NAME=`basename "$tmp"`
  83. fi
  84. # set up some paths
  85. BUILD_DIR=./build
  86. DOXYGEN_DIR="$BUILD_DIR"/doxygen
  87. DOXYGEN_CFG="tools/doxygen.config"
  88. DOXYGEN_CFG_GENERATED="$BUILD_DIR/doxygen/doxygen.config.generated"
  89. echo copying "$DOXYGEN_CFG" to "$DOXYGEN_CFG_GENERATED"
  90. mkdir -p `dirname "$DOXYGEN_CFG_GENERATED"` 2> /dev/null
  91. cp "$DOXYGEN_CFG" "$DOXYGEN_CFG_GENERATED"
  92. echo inject settings into "$DOXYGEN_CFG_GENERATED"
  93. sed -i '' -e "s|DOT_PATH *=.*|DOT_PATH = $DOT_PATH|g" "$DOXYGEN_CFG_GENERATED"
  94. sed -i '' -e "s|HAVE_DOT *=.*|HAVE_DOT = YES|g" "$DOXYGEN_CFG_GENERATED"
  95. sed -i '' -e "s/PROJECT_NUMBER *=.*/PROJECT_NUMBER = \"$PROJECT_VERSION\"/g" "$DOXYGEN_CFG_GENERATED"
  96. sed -i '' -e "s/PROJECT_NAME *=.*/PROJECT_NAME = \"$PROJECT_NAME\"/g" "$DOXYGEN_CFG_GENERATED"
  97. sed -i '' -e "s|INPUT *=.*|INPUT = $PROJECT_SOURCE|g" "$DOXYGEN_CFG_GENERATED"
  98. sed -i '' -e "s|OUTPUT_DIRECTORY *=.*|OUTPUT_DIRECTORY = \"$DOXYGEN_DIR\"|g" "$DOXYGEN_CFG_GENERATED"
  99. sed -i '' -e "s|DOCSET_BUNDLE_ID *=.*|DOCSET_BUNDLE_ID = $PROJECT_BUNDLE_ID|g" "$DOXYGEN_CFG_GENERATED"
  100. sed -i '' -e "s|DOCSET_FEEDNAME *=.*|DOCSET_FEEDNAME = $PROJECT_BUNDLE_ID|g" "$DOXYGEN_CFG_GENERATED"
  101. if [ -x "$PLANTUML" ] ; then
  102. echo running plantuml
  103. mkdir -p "$BUILD_DIR/plantuml-images" 2> /dev/null
  104. # echo "\"$PLANTUML\"" -tsvg -charset UTF8 -o "\"$(pwd)/$BUILD_DIR/plantuml-images\"" "\"MROGeometry/**.(c|m|h)\"" >&2
  105. "$PLANTUML" -tsvg -charset UTF8 -o "$(pwd)/$BUILD_DIR/plantuml-images" "MROGeometry/**.(c|m|h)" >&2
  106. fi
  107. echo running doxygen with "$DOXYGEN_CFG_GENERATED"
  108. "$DOXYGEN" "$DOXYGEN_CFG_GENERATED"
  109. # size_before=$(du -kc "$DOXYGEN_DIR"/*.png | tail -1)
  110. # time (ls "$DOXYGEN_DIR"/*.png | xargs -L 5 -P 16 optipng -o 7)
  111. # echo before: $size_before
  112. # echo after : $(du -kc "$DOXYGEN_DIR"/*.png | tail -1)
  113. echo launch browser with "$DOXYGEN_DIR/./index.html"
  114. open "$DOXYGEN_DIR/./index.html"