summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Baechle <dl9obn@darc.de>2013-10-08 10:54:45 (GMT)
committerDirk Baechle <dl9obn@darc.de>2013-10-08 10:54:45 (GMT)
commit3bebac3d0e8f24065ecda4abb2a2dad7b1d57164 (patch)
treeb2755eb58dbe9893e1d091b292b3a486fa6d7679
parent32676cbecfa28980b77426da56bfc1b8429ccb7d (diff)
downloadSCons-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
-rw-r--r--doc/generated/builders.gen21
-rw-r--r--doc/generated/builders.mod4
-rw-r--r--doc/generated/tools.gen7
-rw-r--r--doc/generated/variables.gen18
-rw-r--r--src/engine/SCons/Tool/gs.py31
-rw-r--r--src/engine/SCons/Tool/gs.xml38
-rw-r--r--test/Ghostscript/GS.py2
7 files changed, 95 insertions, 26 deletions
diff --git a/doc/generated/builders.gen b/doc/generated/builders.gen
index 3fdafb6..5cd92f2 100644
--- a/doc/generated/builders.gen
+++ b/doc/generated/builders.gen
@@ -397,6 +397,27 @@ env.DVI(target = 'ccc.dvi', source = 'ccc.latex')
</example_commands>
</listitem>
</varlistentry>
+ <varlistentry id="b-Gs">
+ <term>
+ <function>Gs()</function>
+ </term>
+ <term>
+ <function>env.Gs()</function>
+ </term>
+ <listitem>
+<para xmlns="http://www.scons.org/dbxsd/v1.0">
+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 xmlns="http://www.scons.org/dbxsd/v1.0">env = Environment(tools=['gs'])
+env.Gs('cover.jpg','scons-scons.pdf',
+ GSFLAGS='-dNOPAUSE -dBATCH -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -q')
+ )
+</example_commands>
+</listitem>
+ </varlistentry>
<varlistentry id="b-Install">
<term>
<function>Install()</function>
diff --git a/doc/generated/builders.mod b/doc/generated/builders.mod
index 59900cc..b8c7d80 100644
--- a/doc/generated/builders.mod
+++ b/doc/generated/builders.mod
@@ -21,6 +21,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT.
<!ENTITY b-DocbookXInclude "<function xmlns='http://www.scons.org/dbxsd/v1.0'>DocbookXInclude</function>">
<!ENTITY b-DocbookXslt "<function xmlns='http://www.scons.org/dbxsd/v1.0'>DocbookXslt</function>">
<!ENTITY b-DVI "<function xmlns='http://www.scons.org/dbxsd/v1.0'>DVI</function>">
+<!ENTITY b-Gs "<function xmlns='http://www.scons.org/dbxsd/v1.0'>Gs</function>">
<!ENTITY b-Install "<function xmlns='http://www.scons.org/dbxsd/v1.0'>Install</function>">
<!ENTITY b-InstallAs "<function xmlns='http://www.scons.org/dbxsd/v1.0'>InstallAs</function>">
<!ENTITY b-InstallVersionedLib "<function xmlns='http://www.scons.org/dbxsd/v1.0'>InstallVersionedLib</function>">
@@ -74,6 +75,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT.
<!ENTITY b-env-DocbookXInclude "<function xmlns='http://www.scons.org/dbxsd/v1.0'>env.DocbookXInclude</function>">
<!ENTITY b-env-DocbookXslt "<function xmlns='http://www.scons.org/dbxsd/v1.0'>env.DocbookXslt</function>">
<!ENTITY b-env-DVI "<function xmlns='http://www.scons.org/dbxsd/v1.0'>env.DVI</function>">
+<!ENTITY b-env-Gs "<function xmlns='http://www.scons.org/dbxsd/v1.0'>env.Gs</function>">
<!ENTITY b-env-Install "<function xmlns='http://www.scons.org/dbxsd/v1.0'>env.Install</function>">
<!ENTITY b-env-InstallAs "<function xmlns='http://www.scons.org/dbxsd/v1.0'>env.InstallAs</function>">
<!ENTITY b-env-InstallVersionedLib "<function xmlns='http://www.scons.org/dbxsd/v1.0'>env.InstallVersionedLib</function>">
@@ -137,6 +139,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT.
<!ENTITY b-link-DocbookXInclude "<link linkend='b-DocbookXInclude' xmlns='http://www.scons.org/dbxsd/v1.0'><function>DocbookXInclude</function></link>">
<!ENTITY b-link-DocbookXslt "<link linkend='b-DocbookXslt' xmlns='http://www.scons.org/dbxsd/v1.0'><function>DocbookXslt</function></link>">
<!ENTITY b-link-DVI "<link linkend='b-DVI' xmlns='http://www.scons.org/dbxsd/v1.0'><function>DVI</function></link>">
+<!ENTITY b-link-Gs "<link linkend='b-Gs' xmlns='http://www.scons.org/dbxsd/v1.0'><function>Gs</function></link>">
<!ENTITY b-link-Install "<link linkend='b-Install' xmlns='http://www.scons.org/dbxsd/v1.0'><function>Install</function></link>">
<!ENTITY b-link-InstallAs "<link linkend='b-InstallAs' xmlns='http://www.scons.org/dbxsd/v1.0'><function>InstallAs</function></link>">
<!ENTITY b-link-InstallVersionedLib "<link linkend='b-InstallVersionedLib' xmlns='http://www.scons.org/dbxsd/v1.0'><function>InstallVersionedLib</function></link>">
@@ -190,6 +193,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT.
<!ENTITY b-link-env-DocbookXInclude "<link linkend='b-DocbookXInclude' xmlns='http://www.scons.org/dbxsd/v1.0'><function>env.DocbookXInclude</function></link>">
<!ENTITY b-link-env-DocbookXslt "<link linkend='b-DocbookXslt' xmlns='http://www.scons.org/dbxsd/v1.0'><function>env.DocbookXslt</function></link>">
<!ENTITY b-link-env-DVI "<link linkend='b-DVI' xmlns='http://www.scons.org/dbxsd/v1.0'><function>env.DVI</function></link>">
+<!ENTITY b-link-env-Gs "<link linkend='b-Gs' xmlns='http://www.scons.org/dbxsd/v1.0'><function>env.Gs</function></link>">
<!ENTITY b-link-env-Install "<link linkend='b-Install' xmlns='http://www.scons.org/dbxsd/v1.0'><function>env.Install</function></link>">
<!ENTITY b-link-env-InstallAs "<link linkend='b-InstallAs' xmlns='http://www.scons.org/dbxsd/v1.0'><function>env.InstallAs</function></link>">
<!ENTITY b-link-env-InstallVersionedLib "<link linkend='b-InstallVersionedLib' xmlns='http://www.scons.org/dbxsd/v1.0'><function>env.InstallVersionedLib</function></link>">
diff --git a/doc/generated/tools.gen b/doc/generated/tools.gen
index 57bb0a2..7d75638 100644
--- a/doc/generated/tools.gen
+++ b/doc/generated/tools.gen
@@ -444,7 +444,12 @@ Set construction variables for GNU linker/loader.
<term>gs</term>
<listitem>
<para xmlns="http://www.scons.org/dbxsd/v1.0">
-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 (<link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="b-PDF"><function>PDF</function></link>), such that the conversion from
+PS/EPS to PDF happens automatically for the TeX/LaTeX toolchain.
+Finally, it adds an explicit Ghostscript Builder (<link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="b-Gs"><function>Gs</function></link>) to the
+environment.
</para>
<para>Sets: &cv-link-GS;, &cv-link-GSCOM;, &cv-link-GSFLAGS;.</para><para>Uses: &cv-link-GSCOMSTR;.</para></listitem>
</varlistentry>
diff --git a/doc/generated/variables.gen b/doc/generated/variables.gen
index 784cd28..ee5a0dd 100644
--- a/doc/generated/variables.gen
+++ b/doc/generated/variables.gen
@@ -2324,7 +2324,7 @@ described above.)
<term>GS</term>
<listitem>
<para xmlns="http://www.scons.org/dbxsd/v1.0">
-The Ghostscript program used to convert PostScript to PDF files.
+The Ghostscript program used, e.g. to convert PostScript to PDF files.
</para>
</listitem>
</varlistentry>
@@ -2332,7 +2332,8 @@ The Ghostscript program used to convert PostScript to PDF files.
<term>GSCOM</term>
<listitem>
<para xmlns="http://www.scons.org/dbxsd/v1.0">
-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>
</listitem>
</varlistentry>
@@ -2341,9 +2342,8 @@ The Ghostscript command line used to convert PostScript to PDF files.
<listitem>
<para xmlns="http://www.scons.org/dbxsd/v1.0">
The string displayed when
-Ghostscript is used to convert
-a PostScript file to a PDF file.
-If this is not set, then <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-GSCOM"><envar>$GSCOM</envar></link> (the command line) is displayed.
+Ghostscript is called for the conversion process.
+If this is not set (the default), then <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-GSCOM"><envar>$GSCOM</envar></link> (the command line) is displayed.
</para>
</listitem>
</varlistentry>
@@ -2351,8 +2351,9 @@ If this is not set, then <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="
<term>GSFLAGS</term>
<listitem>
<para xmlns="http://www.scons.org/dbxsd/v1.0">
-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>
</listitem>
</varlistentry>
@@ -3548,6 +3549,9 @@ See <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="t-msginit"><literal>m
Internal ``macro''. Computes locale (language) name based on target filename
(default: <literal>'${TARGET.filebase}' </literal>).
</para>
+<para xmlns="http://www.scons.org/dbxsd/v1.0">
+See <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="t-msginit"><literal>msginit</literal></link> tool and <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="b-POInit"><function>POInit</function></link> builder.
+</para>
</listitem>
</varlistentry>
<varlistentry id="cv-MSGMERGE">
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
diff --git a/test/Ghostscript/GS.py b/test/Ghostscript/GS.py
index 2cae8b8..daeea09 100644
--- a/test/Ghostscript/GS.py
+++ b/test/Ghostscript/GS.py
@@ -51,6 +51,7 @@ env = Environment(GS = r'%(_python_)s mygs.py',
GSCOM = r'$GS $TARGET $SOURCE',
tools=['gs'])
env.PDF(target = 'test1.pdf', source = 'test1.ps')
+env.Gs(target = 'test2.pdf', source = 'test1.ps')
""" % locals())
test.write('test1.ps', r"""This is a .ps test.
@@ -60,6 +61,7 @@ test.write('test1.ps', r"""This is a .ps test.
test.run(arguments = '.', stderr = None)
test.fail_test(test.read('test1.pdf') != "This is a .ps test.\n")
+test.fail_test(test.read('test2.pdf') != "This is a .ps test.\n")