<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>alan.lamielle.net &#187; tex</title>
	<atom:link href="http://alan.lamielle.net/tags/tex/feed" rel="self" type="application/rss+xml" />
	<link>http://alan.lamielle.net</link>
	<description>Alan LaMielle</description>
	<lastBuildDate>Fri, 16 Sep 2011 16:50:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Using waf to build LaTeX Documents</title>
		<link>http://alan.lamielle.net/2009/09/29/using-waf-to-build-latex-documents</link>
		<comments>http://alan.lamielle.net/2009/09/29/using-waf-to-build-latex-documents#comments</comments>
		<pubDate>Tue, 29 Sep 2009 19:47:44 +0000</pubDate>
		<dc:creator>Alan LaMielle</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[build system]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[makefile]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[tex]]></category>
		<category><![CDATA[waf]]></category>

		<guid isPermaLink="false">http://alan.lamielle.net/?p=508</guid>
		<description><![CDATA[I&#8217;ve finally made the migration away from make and the horrible system of autofoo and Makefiles.  A few years ago I discovered a build system called waf that does everything make can do, only better! Waf is a Python based build system (or more generally a task execution system).  Directly from the site: Waf is a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally made the migration away from <code>make</code> and the horrible system of <code>autofoo</code> and <code>Makefiles</code>.  A few years ago I discovered a build system called <code>waf</code> that does everything <code>make</code> can do, only better!</p>
<p><span id="more-508"></span></p>
<p><a href="http://code.google.com/p/waf/">Waf</a> is a Python based build system (or more generally a task execution system).  Directly from the site:</p>
<blockquote><p>Waf is a Python-based framework for configuring, compiling and installing applications. It derives from the concepts of other build tools such as Scons, Autotools, CMake or Ant.</p></blockquote>
<p>Just like <code>make</code>, <code>waf</code> is a quasi-declarative build system.  You define the tasks and results you require, and <code>waf</code> determines dependences and executes the tasks (in a valid order) necessary to produce the desired output.  However, <code>waf</code> differs from <code>make</code> in that <strong>waf actually uses a real programming language</strong> for declaring tasks and developing the build system (in case it wasn&#8217;t obvious, the language I&#8217;m referring to is Python).  This single fact alone is enough for me to want to move away from <code>make</code> completely.  However, <code>waf</code> also offers a whole slew of other extremely nice features that make it very powerful.  See the project site for more details.</p>
<p>Until now I&#8217;ve been using <code>make</code> to build my <code>LaTeX</code> documents.  However, I&#8217;ve finally taken the time to discover how to do this with <code>waf</code>.  The following script (really just two functions), named <code>wscript</code> in the directory with the <code>LaTeX</code> source, is the result:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">srcdir=<span style="color: #483d8b;">'.'</span>
blddir=<span style="color: #483d8b;">'build'</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> configure<span style="color: black;">&#40;</span>conf<span style="color: black;">&#41;</span>:
   conf.<span style="color: black;">check_tool</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'tex'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> build<span style="color: black;">&#40;</span>bld<span style="color: black;">&#41;</span>:
   obj=bld.<span style="color: black;">new_task_gen</span><span style="color: black;">&#40;</span>features=<span style="color: #483d8b;">'tex'</span><span style="color: black;">&#41;</span>
   obj.<span style="color: black;">source</span>=<span style="color: #483d8b;">'source_tex_file.tex'</span>
   bld.<span style="color: black;">install_files</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'${PREFIX}'</span>,<span style="color: #483d8b;">'output_pdf_file.pdf'</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>The first two lines define the source directory (the current directory is denoted by the &#8216;.&#8217;) and the name of the build directory (where all the temporary files will be stored).  The <code>configure</code> function simply tells <code>waf</code>, using the <code>check_tool</code> call, to ensure that the tools necessary for building <code>LaTeX</code> documents are present on the system.  The <code>build</code> function defines that we want to create a PDF document from the file <code>source_tex_file.tex</code> using the <code>tex</code> <code>waf</code> tool.  And that&#8217;s it&#8230; seriously.</p>
<p>My workflow with this setup is basically edit <code>LaTeX</code> file, call <code>./waf build install</code>, check the output PDF, repeat.  Easy as pie.</p>
<p>So, if you&#8217;re looking for a fabulous alternative to <code>make</code>, check out <code>waf</code>, I&#8217;m sure you&#8217;ll be impressed.</p>
]]></content:encoded>
			<wfw:commentRss>http://alan.lamielle.net/2009/09/29/using-waf-to-build-latex-documents/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

