Modified tileset bundler to not rebuild bundles that are demonstrably up

to date (all files involved in the making of the bundle are older than the
built bundle file).


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2292 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-02-28 00:46:52 +00:00
parent 97c02d2a00
commit efec457ac7
2 changed files with 40 additions and 6 deletions
@@ -1,5 +1,5 @@
//
// $Id: TileSetBundler.java,v 1.13 2003/01/24 21:51:26 mdb Exp $
// $Id: TileSetBundler.java,v 1.14 2003/02/28 00:46:52 mdb Exp $
package com.threerings.media.tile.bundle.tools;
@@ -211,10 +211,13 @@ public class TileSetBundler
* file.
* @param target the tileset bundle file that will be created.
*
* @return true if the bundle was rebuilt, false if it was not because
* the bundle file was newer than all involved source files.
*
* @exception IOException thrown if an error occurs reading, writing
* or processing anything.
*/
public void createBundle (
public boolean createBundle (
TileSetIDBroker idBroker, final File bundleDesc, File target)
throws IOException
{
@@ -235,6 +238,11 @@ public class TileSetBundler
fin.close();
}
// we want to make sure that at least one of the tileset image
// files or the bundle definition file is newer than the bundle
// file, otherwise consider the bundle up to date
long newest = bundleDesc.lastModified();
// create a tileset bundle to hold our tilesets
TileSetBundle bundle = new TileSetBundle();
@@ -251,6 +259,21 @@ public class TileSetBundler
continue;
}
// make sure this tileset's image file exists and check
// it's last modified date
File tsfile = new File(bundleDesc.getParent(),
set.getImagePath());
if (!tsfile.exists()) {
System.err.println("Tile set missing image file " +
"[bundle=" + bundleDesc.getPath() +
", name=" + set.getName() +
", imgpath=" + tsfile.getPath() + "].");
continue;
}
if (tsfile.lastModified() > newest) {
newest = tsfile.lastModified();
}
// assign a tilset id to the tileset and bundle it
try {
int tileSetId = idBroker.getTileSetID(name);
@@ -277,6 +300,11 @@ public class TileSetBundler
}
}
// see if our newest file is newer than the tileset bundle
if (newest < target.lastModified()) {
return false;
}
// now we have to create the actual bundle file
FileOutputStream fout = new FileOutputStream(target);
Manifest manifest = new Manifest();
@@ -365,6 +393,8 @@ public class TileSetBundler
// finally close up the jar file and call ourself done
jar.close();
return true;
} catch (IOException ioe) {
// remove the incomplete jar file and rethrow the exception
fout.close();
@@ -1,5 +1,5 @@
//
// $Id: TileSetBundlerTask.java,v 1.5 2002/09/27 19:02:15 mdb Exp $
// $Id: TileSetBundlerTask.java,v 1.6 2003/02/28 00:46:52 mdb Exp $
package com.threerings.media.tile.bundle.tools;
@@ -90,9 +90,13 @@ public class TileSetBundlerTask extends Task
File bfile = new File(bpath);
// create the bundle
System.out.println(
"Creating bundle from '" + cpath + "'...");
bundler.createBundle(broker, cfile, bfile);
if (bundler.createBundle(broker, cfile, bfile)) {
System.out.println(
"Created bundle from '" + cpath + "'...");
} else {
System.out.println(
"Tileset bundle up to date '" + bpath + "'.");
}
}
}