diff --git a/src/tools/fop.jam b/src/tools/fop.jam index ed0255502..c24b8725f 100644 --- a/src/tools/fop.jam +++ b/src/tools/fop.jam @@ -6,100 +6,64 @@ # This module defines rules to handle generation of PDF and # PostScript files from XSL Formatting Objects via Apache FOP -import os ; import generators ; import common ; -import errors ; import boostbook ; generators.register-standard fop.render.pdf : FO : PDF ; generators.register-standard fop.render.ps : FO : PS ; +# Initializes the fop toolset. +# rule init ( fop-command ? : java-home ? : java ? ) { - fop-command = [ common.get-invocation-command fop : fop : $(fop-command) - : [ modules.peek : FOP_DIR ] ] ; - - .FOP_COMMAND = $(fop-command) ; - .FOP_SETUP = ; - - # JAVA_HOME is the location that java was installed to. - - if $(java-home) + local has-command = $(.has-command) ; + + if $(fop-command) { - .FOP_SETUP += [ common.variable-setting-command JAVA_HOME : $(java-home) ] ; + .has-command = true ; } - # JAVACMD is the location that of the java executable, useful for a - # non-standard java installation, where the executable isn't at - # $JAVA_HOME/bin/java. - - if $(java) + if $(fop-command) || ! $(has-command) { - .FOP_SETUP += [ common.variable-setting-command JAVACMD : $(java) ] ; + fop-command = [ common.get-invocation-command fop : fop : $(fop-command) + : [ modules.peek : FOP_DIR ] ] ; } - # Make sure the fop command is executed from within the directory where it's located. - - # DPG: I can't see how this could ever be correct, because it - # messes up path names that are used in the command. - - # if $(.FOP_COMMAND:D) - # { - # .FOP_SETUP = $(.FOP_SETUP)" -# cd "$(.FOP_COMMAND:D) ; - # } - -} - -local rule find-by-absolute-path ( target ) -{ - # Mask off any vars by these names that may be hanging around in - # outer dynamic scopes. - local LOCATE SEARCH ; - - # simulate the target binding process to find the target - - local found = [ on $(target) GLOB $(LOCATE) (SEARCH) : $(target:G=) ] ; - - if $(found) + if $(fop-command) { - # Re-LOCATE the target with an absolute path if it isn't - # already absolute. - local found-dir = $(found[1]:D) ; - local cwd = [ PWD ] ; - local absolute-dir = $(found-dir:R=$(cwd)) ; - - # Translate cygwin paths to Windows iff the user is running on - # cygwin but using a Windows FOP. We detect a Windows FOP by - # looking to see if FOP_COMMAND ends with ".bat" - if [ os.name ] = CYGWIN && [ MATCH .*\\.([Bb][Aa][Tt])$ : $(.FOP_COMMAND) ] + .FOP_COMMAND = $(fop-command) ; + } + + if $(java-home) || $(java) + { + .FOP_SETUP = ; + + + # JAVA_HOME is the location that java was installed to. + + if $(java-home) { - absolute-dir = "`cygpath --windows '$(absolute-dir)'`" ; + .FOP_SETUP += [ common.variable-setting-command JAVA_HOME : $(java-home) ] ; + } + + # JAVACMD is the location that of the java executable, useful for a + # non-standard java installation, where the executable isn't at + # $JAVA_HOME/bin/java. + + if $(java) + { + .FOP_SETUP += [ common.variable-setting-command JAVACMD : $(java) ] ; } - LOCATE on $(target) = $(absolute-dir) ; } } -rule render.pdf ( source : target : properties * ) -{ - find-by-absolute-path $(source) ; - find-by-absolute-path $(target) ; -} - -rule render.ps ( source : target : properties * ) -{ - find-by-absolute-path $(source) ; - find-by-absolute-path $(target) ; -} - - actions render.pdf { - $(.FOP_SETUP) $(.FOP_COMMAND) $(>) $(<) + $(.FOP_SETUP) $(.FOP_COMMAND:E=fop) $(>) $(<) } actions render.ps { - $(.FOP_SETUP) $(.FOP_COMMAND) $(>) -ps $(<) + $(.FOP_SETUP) $(.FOP_COMMAND:E=fop) $(>) -ps $(<) }