Add uncommited generation checking to all the gen tasks.

If checking="true" on them, they generate their code to a String instead of a file, and compare that
against existing output.  If any generation would produce changes, the build is failed.

As a side effect, generation will now only write files if it's going to modify them, which should
eliminate some spurious compiling.



git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6349 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Charlie Groves
2010-12-09 07:43:18 +00:00
parent 0b77c89fa7
commit 39405136e9
19 changed files with 190 additions and 169 deletions
@@ -27,8 +27,8 @@ import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import com.google.common.collect.Lists;
@@ -129,11 +129,11 @@ public class SourceFile
* @param fsection the new "generated fields" to write to the file, or null.
* @param msection the new "generated methods" to write to the file, or null.
*/
public void writeTo (File dest, String fsection, String msection)
public String generate (String fsection, String msection)
throws IOException
{
BufferedWriter bout = new BufferedWriter(new FileWriter(dest));
StringWriter writer = new StringWriter();
BufferedWriter bout = new BufferedWriter(writer);
addOrRemoveGeneratedImport(StringUtil.deNull(fsection).contains("@Generated(") ||
StringUtil.deNull(msection).contains("@Generated("));
@@ -180,6 +180,7 @@ public class SourceFile
writeln(bout, _lines.get(ii));
}
bout.close();
return writer.toString();
}
/** Helper function for sanity checking marker existence. */