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:
@@ -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;
|
package com.threerings.media.tile.bundle.tools;
|
||||||
|
|
||||||
@@ -211,10 +211,13 @@ public class TileSetBundler
|
|||||||
* file.
|
* file.
|
||||||
* @param target the tileset bundle file that will be created.
|
* @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
|
* @exception IOException thrown if an error occurs reading, writing
|
||||||
* or processing anything.
|
* or processing anything.
|
||||||
*/
|
*/
|
||||||
public void createBundle (
|
public boolean createBundle (
|
||||||
TileSetIDBroker idBroker, final File bundleDesc, File target)
|
TileSetIDBroker idBroker, final File bundleDesc, File target)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
@@ -235,6 +238,11 @@ public class TileSetBundler
|
|||||||
fin.close();
|
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
|
// create a tileset bundle to hold our tilesets
|
||||||
TileSetBundle bundle = new TileSetBundle();
|
TileSetBundle bundle = new TileSetBundle();
|
||||||
|
|
||||||
@@ -251,6 +259,21 @@ public class TileSetBundler
|
|||||||
continue;
|
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
|
// assign a tilset id to the tileset and bundle it
|
||||||
try {
|
try {
|
||||||
int tileSetId = idBroker.getTileSetID(name);
|
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
|
// now we have to create the actual bundle file
|
||||||
FileOutputStream fout = new FileOutputStream(target);
|
FileOutputStream fout = new FileOutputStream(target);
|
||||||
Manifest manifest = new Manifest();
|
Manifest manifest = new Manifest();
|
||||||
@@ -365,6 +393,8 @@ public class TileSetBundler
|
|||||||
// finally close up the jar file and call ourself done
|
// finally close up the jar file and call ourself done
|
||||||
jar.close();
|
jar.close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
// remove the incomplete jar file and rethrow the exception
|
// remove the incomplete jar file and rethrow the exception
|
||||||
fout.close();
|
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;
|
package com.threerings.media.tile.bundle.tools;
|
||||||
|
|
||||||
@@ -90,9 +90,13 @@ public class TileSetBundlerTask extends Task
|
|||||||
File bfile = new File(bpath);
|
File bfile = new File(bpath);
|
||||||
|
|
||||||
// create the bundle
|
// create the bundle
|
||||||
System.out.println(
|
if (bundler.createBundle(broker, cfile, bfile)) {
|
||||||
"Creating bundle from '" + cpath + "'...");
|
System.out.println(
|
||||||
bundler.createBundle(broker, cfile, bfile);
|
"Created bundle from '" + cpath + "'...");
|
||||||
|
} else {
|
||||||
|
System.out.println(
|
||||||
|
"Tileset bundle up to date '" + bpath + "'.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user