From c6de94ebf96cc219dfd0f5dc4a8cbfcb8c8e27e5 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 26 May 2010 18:06:16 +0000 Subject: [PATCH] Handle cygwin vs. windows paths for doxygen [SVN r62247] --- src/tools/doxygen.jam | 82 ++++++++++++++++++- .../doxygen/windows-paths-check.doxyfile | 3 + src/tools/doxygen/windows-paths-check.hpp | 0 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 src/tools/doxygen/windows-paths-check.doxyfile create mode 100644 src/tools/doxygen/windows-paths-check.hpp diff --git a/src/tools/doxygen.jam b/src/tools/doxygen.jam index 0c6682958..a443d8fe8 100644 --- a/src/tools/doxygen.jam +++ b/src/tools/doxygen.jam @@ -37,6 +37,7 @@ import alias ; import common ; import modules ; import project ; +import utility ; # Use to specify extra configuration paramters. These get translated @@ -140,6 +141,11 @@ rule init ( name ? ) ECHO "notice:" using doxygen ":" $(.doxygen) ; } + if [ .is-cygwin ] + { + .is-cygwin = true ; + } + .doxproc = [ modules.binding $(__name__) ] ; .doxproc = $(.doxproc:D)/doxproc.py ; @@ -170,6 +176,22 @@ rule name ( ) return $(.doxygen) ; } +rule .is-cygwin ( ) +{ + if [ os.on-windows ] + { + local file = [ path.make [ modules.binding $(__name__) ] ] ; + local dir = [ path.native + [ path.join [ path.parent $(file) ] doxygen ] ] ; + local command = + "cd \"$(dir)\" && \"$(.doxygen)\" windows-paths-check.doxyfile 2>&1" ; + result = [ SHELL $(command) ] ; + if [ MATCH "(Parsing file /)" : $(result) ] + { + return true ; + } + } +} # Runs Doxygen on the given Doxygen configuration file (the source) to generate # the Doxygen files. The output is dumped according to the settings in the @@ -192,6 +214,48 @@ actions doxproc } +rule translate-path ( path ) +{ + if [ os.on-windows ] + { + if [ os.name ] = CYGWIN + { + if $(.is-cygwin) + { + return $(path) ; + } + else + { + return $(path:W) ; + } + } + else + { + if $(.is-cygwin) + { + match = [ MATCH ^(.):(.*) : $(path) ] ; + if $(match) + { + return /cygdrive/$(match[1])$(match[2]:T) ; + } + else + { + return $(path:T) ; + } + } + else + { + return $(path) ; + } + } + } + else + { + return $(path) ; + } +} + + # Generates a doxygen configuration file (doxyfile) given a set of C++ sources # and a property list that may contain features. # @@ -205,20 +269,30 @@ rule headers-to-doxyfile ( target : sources * : properties * ) for local param in [ feature.get-values : $(properties) ] { local namevalue = [ regex.match ([^=]*)=(.*) : $(param) ] ; - text += "$(namevalue[1]) = $(namevalue[2])" ; if $(namevalue[1]) = OUTPUT_DIRECTORY { - output-dir = "$(namevalue[2])" ; + output-dir = [ translate-path + [ utility.unquote $(namevalue[2]) ] ] ; + text += "OUTPUT_DIRECTORY = \"$(output-dir)\"" ; + } + else + { + text += "$(namevalue[1]) = $(namevalue[2])" ; } } if ! $(output-dir) { - output-dir = [ on $(target) return $(LOCATE) ] ; + output-dir = [ translate-path [ on $(target) return $(LOCATE) ] ] ; text += "OUTPUT_DIRECTORY = \"$(output-dir)\"" ; } - local headers = \"$(sources:G=)\" ; + local headers = ; + for local header in $(sources:G=) + { + header = [ translate-path $(header) ] ; + headers += \"$(header)\" ; + } # Doxygen generates LaTex by default. So disable it unconditionally, or at # least until someone needs, and hence writes support for, LaTex output. diff --git a/src/tools/doxygen/windows-paths-check.doxyfile b/src/tools/doxygen/windows-paths-check.doxyfile new file mode 100644 index 000000000..9b969df9c --- /dev/null +++ b/src/tools/doxygen/windows-paths-check.doxyfile @@ -0,0 +1,3 @@ +INPUT = windows-paths-check.hpp +GENERATE_HTML = NO +GENERATE_LATEX = NO diff --git a/src/tools/doxygen/windows-paths-check.hpp b/src/tools/doxygen/windows-paths-check.hpp new file mode 100644 index 000000000..e69de29bb