diff options
author | Dirk Baechle <dl9obn@darc.de> | 2013-10-08 10:54:45 (GMT) |
---|---|---|
committer | Dirk Baechle <dl9obn@darc.de> | 2013-10-08 10:54:45 (GMT) |
commit | 3bebac3d0e8f24065ecda4abb2a2dad7b1d57164 (patch) | |
tree | b2755eb58dbe9893e1d091b292b3a486fa6d7679 /src | |
parent | 32676cbecfa28980b77426da56bfc1b8429ccb7d (diff) | |
download | SCons-3bebac3d0e8f24065ecda4abb2a2dad7b1d57164.zip SCons-3bebac3d0e8f24065ecda4abb2a2dad7b1d57164.tar.gz SCons-3bebac3d0e8f24065ecda4abb2a2dad7b1d57164.tar.bz2 |
- added an explicit Gs() Builder to the gs.py Tool
- updated documentation accordingly and added a (very) simple test
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Tool/gs.py | 31 | ||||
-rw-r--r-- | src/engine/SCons/Tool/gs.xml | 38 |
2 files changed, 51 insertions, 18 deletions
diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py index ada169a..a8fddde 100644 --- a/src/engine/SCons/Tool/gs.py +++ b/src/engine/SCons/Tool/gs.py @@ -34,6 +34,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Action +import SCons.Builder import SCons.Platform import SCons.Util @@ -52,17 +53,27 @@ GhostscriptAction = None def generate(env): """Add Builders and construction variables for Ghostscript to an Environment.""" - global GhostscriptAction - if GhostscriptAction is None: - GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR') - - import pdf - pdf.generate(env) - - bld = env['BUILDERS']['PDF'] - bld.add_action('.ps', GhostscriptAction) - + # The following try-except block enables us to use the Tool + # in standalone mode (without the accompanying pdf.py), + # whenever we need an explicit call of gs via the Gs() + # Builder ... + try: + if GhostscriptAction is None: + GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR') + + import pdf + pdf.generate(env) + + bld = env['BUILDERS']['PDF'] + bld.add_action('.ps', GhostscriptAction) + except ImportError, e: + pass + + gsbuilder = SCons.Builder.Builder(action = SCons.Action.Action('$GSCOM', '$GSCOMSTR'), + env = env) + env['BUILDERS']['Gs'] = gsbuilder + env['GS'] = gs env['GSFLAGS'] = SCons.Util.CLVar('-dNOPAUSE -dBATCH -sDEVICE=pdfwrite') env['GSCOM'] = '$GS $GSFLAGS -sOutputFile=$TARGET $SOURCES' diff --git a/src/engine/SCons/Tool/gs.xml b/src/engine/SCons/Tool/gs.xml index c34f004..3fe5165 100644 --- a/src/engine/SCons/Tool/gs.xml +++ b/src/engine/SCons/Tool/gs.xml @@ -26,7 +26,12 @@ See its __doc__ string for a discussion of the format. <tool name="gs"> <summary> <para> -Set construction variables for Ghostscript. +This Tool sets the required construction variables for working with +the Ghostscript command. It also registers an appropriate Action +with the PDF Builder (&b-link-PDF;), such that the conversion from +PS/EPS to PDF happens automatically for the TeX/LaTeX toolchain. +Finally, it adds an explicit Ghostscript Builder (&b-link-Gs;) to the +environment. </para> </summary> <sets> @@ -42,7 +47,7 @@ Set construction variables for Ghostscript. <cvar name="GS"> <summary> <para> -The Ghostscript program used to convert PostScript to PDF files. +The Ghostscript program used, e.g. to convert PostScript to PDF files. </para> </summary> </cvar> @@ -50,7 +55,8 @@ The Ghostscript program used to convert PostScript to PDF files. <cvar name="GSCOM"> <summary> <para> -The Ghostscript command line used to convert PostScript to PDF files. +The full Ghostscript command line used for the conversion process. Its default +value is <quote><literal>$GS $GSFLAGS -sOutputFile=$TARGET $SOURCES</literal></quote>. </para> </summary> </cvar> @@ -59,9 +65,8 @@ The Ghostscript command line used to convert PostScript to PDF files. <summary> <para> The string displayed when -Ghostscript is used to convert -a PostScript file to a PDF file. -If this is not set, then &cv-link-GSCOM; (the command line) is displayed. +Ghostscript is called for the conversion process. +If this is not set (the default), then &cv-link-GSCOM; (the command line) is displayed. </para> </summary> </cvar> @@ -69,10 +74,27 @@ If this is not set, then &cv-link-GSCOM; (the command line) is displayed. <cvar name="GSFLAGS"> <summary> <para> -General options passed to the Ghostscript program -when converting PostScript to PDF files. +General options passed to the Ghostscript program, +when converting PostScript to PDF files for example. Its default value +is <quote><literal>-dNOPAUSE -dBATCH -sDEVICE=pdfwrite</literal></quote> </para> </summary> </cvar> +<builder name="Gs"> +<summary> +<para> +A Builder for explicitly calling the <literal>gs</literal> executable. +Depending on the underlying OS, the different names <literal>gs</literal>, +<literal>gsos2</literal> and <literal>gswin32c</literal> +are tried. +</para> +<example_commands>env = Environment(tools=['gs']) +env.Gs('cover.jpg','scons-scons.pdf', + GSFLAGS='-dNOPAUSE -dBATCH -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -q') + ) +</example_commands> +</summary> +</builder> + </sconsdoc>
\ No newline at end of file |