doxygen.sh 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2014-2015, Marcus Rohrmoser mobile Software, http://mro.name/me
  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. PROJECT_BUNDLE_ID="name.mro.rdf.sqlite"
  70. PROJECT_NAME="Redland RDF SQLite Storage"
  71. PROJECT_VERSION="0.5"
  72. PROJECT_SOURCE="."
  73. cd "$(dirname "$0")/.."
  74. if [ "" = "$PROJECT_NAME" ] ; then
  75. PROJECT_NAME="$(basename "$(pwd)")"
  76. fi
  77. # set up some paths
  78. BUILD_DIR=./build
  79. DOXYGEN_DIR="$BUILD_DIR"/doxygen
  80. DOXYGEN_CFG="tools/doxygen.config"
  81. DOXYGEN_CFG_GENERATED="$BUILD_DIR/doxygen/doxygen.config.generated"
  82. echo copying "$DOXYGEN_CFG" to "$DOXYGEN_CFG_GENERATED"
  83. mkdir -p `dirname "$DOXYGEN_CFG_GENERATED"` 2> /dev/null
  84. cp "$DOXYGEN_CFG" "$DOXYGEN_CFG_GENERATED"
  85. echo inject settings into "$DOXYGEN_CFG_GENERATED"
  86. sed -i '' -e "s|DOT_PATH *=.*|DOT_PATH = $DOT_PATH|g" "$DOXYGEN_CFG_GENERATED"
  87. sed -i '' -e "s|HAVE_DOT *=.*|HAVE_DOT = YES|g" "$DOXYGEN_CFG_GENERATED"
  88. sed -i '' -e "s/PROJECT_NUMBER *=.*/PROJECT_NUMBER = \"$PROJECT_VERSION\"/g" "$DOXYGEN_CFG_GENERATED"
  89. sed -i '' -e "s/PROJECT_NAME *=.*/PROJECT_NAME = \"$PROJECT_NAME\"/g" "$DOXYGEN_CFG_GENERATED"
  90. sed -i '' -e "s|INPUT *=.*|INPUT = $PROJECT_SOURCE|g" "$DOXYGEN_CFG_GENERATED"
  91. sed -i '' -e "s|OUTPUT_DIRECTORY *=.*|OUTPUT_DIRECTORY = \"$DOXYGEN_DIR\"|g" "$DOXYGEN_CFG_GENERATED"
  92. sed -i '' -e "s|DOCSET_BUNDLE_ID *=.*|DOCSET_BUNDLE_ID = $PROJECT_BUNDLE_ID|g" "$DOXYGEN_CFG_GENERATED"
  93. sed -i '' -e "s|DOCSET_FEEDNAME *=.*|DOCSET_FEEDNAME = $PROJECT_BUNDLE_ID|g" "$DOXYGEN_CFG_GENERATED"
  94. echo running doxygen with "$DOXYGEN_CFG_GENERATED"
  95. "$DOXYGEN" "$DOXYGEN_CFG_GENERATED"
  96. # size_before=$(du -kc "$DOXYGEN_DIR"/*.png | tail -1)
  97. # time (ls "$DOXYGEN_DIR"/*.png | xargs -L 5 -P 16 optipng -o 7)
  98. # echo before: $size_before
  99. # echo after : $(du -kc "$DOXYGEN_DIR"/*.png | tail -1)
  100. echo launch browser with "$DOXYGEN_DIR/./index.html"
  101. open "$DOXYGEN_DIR/./index.html"