From efec457ac7c1ffc6909306acd3d60c9c3cccc4c5 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 28 Feb 2003 00:46:52 +0000 Subject: [PATCH] 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 --- .../tile/bundle/tools/TileSetBundler.java | 34 +++++++++++++++++-- .../tile/bundle/tools/TileSetBundlerTask.java | 12 ++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java index e8da9452d..cb31a1cca 100644 --- a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java +++ b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java @@ -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(); diff --git a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundlerTask.java b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundlerTask.java index cd6ff6241..a7c43b40b 100644 --- a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundlerTask.java +++ b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundlerTask.java @@ -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 + "'."); + } } }