I followed my own advice on
code generation, and found that my build
file didn't scale at all to a larger project, taking about a minute to run the codegen task on a couple hundred files. I guessed that
most of the time was being spent in the
exec task,
which was instantiating the python interpreter, and that just seemed like a lot of overhead. Lucky for me,
Ned is a smart guy, and one of
Cog's options is
to take a file containing a list of files to process. So, now I can iterate over my project, make a text file (fileList.txt) containing the path to each file
I want to run the codegen for, and then pass that fileList.txt to Cog at the end, only having to exec python once. That reduced the build time from
64.7s to 3.2s. Not to shabby for 10 minutes worth of work.
Here's the updated
codegen nant target. The rest of the build file remains the same.
<target name="codegen">
<!-- if there's an old one, delete it.-->
<delete file="fileList.txt" if="${file::exists('fileList.txt')}"/>
<!-- generate the new file list -->
<foreach item="File" property="filename">
<in>
<items>
<include name="**.cs" />
<include name="**.js" />
<include name="**.xul" />
</items>
</in>
<do>
<echo file="fileList.txt" message="${filename}" append="true"/>
</do>
</foreach>
<!-- pass the file list to Cog -->
<exec program="python">
<arg value="cog.py" />
<arg value="-r" />
<arg value="@fileList.txt" />
</exec>
<!-- clean up -->
<delete file="fileList.txt" failonerror="true"/>
</target>
I'm digging into this stuff in earnest starting this week, so I'll post again when I find the next naive mistake.