summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Tool
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Tool')
-rw-r--r--src/engine/SCons/Tool/gs.py31
-rw-r--r--src/engine/SCons/Tool/gs.xml38
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