Support (but don't require) compiling to a custom destination directory.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@150 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -35,36 +35,40 @@ import com.jme.util.LoggingSystem;
|
||||
import com.jmex.model.XMLparser.Converters.DummyDisplaySystem;
|
||||
|
||||
/**
|
||||
* An ant task for compiling 3D models defined in XML to fast-loading binary
|
||||
* files.
|
||||
* An ant task for compiling 3D models defined in XML to fast-loading binary files.
|
||||
*/
|
||||
public class CompileModelTask extends Task
|
||||
{
|
||||
public void setDest (File dest)
|
||||
{
|
||||
_dest = dest;
|
||||
}
|
||||
|
||||
public void addFileset (FileSet set)
|
||||
{
|
||||
_filesets.add(set);
|
||||
}
|
||||
|
||||
|
||||
public void init () throws BuildException
|
||||
{
|
||||
// create a dummy display system
|
||||
new DummyDisplaySystem();
|
||||
LoggingSystem.getLogger().setLevel(Level.WARNING);
|
||||
}
|
||||
|
||||
|
||||
public void execute ()
|
||||
throws BuildException
|
||||
{
|
||||
for (int ii = 0, nn = _filesets.size(); ii < nn; ii++) {
|
||||
FileSet fs = _filesets.get(ii);
|
||||
String baseDir = getProject().getBaseDir().getPath();
|
||||
for (FileSet fs : _filesets) {
|
||||
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
|
||||
File fromDir = fs.getDir(getProject());
|
||||
String[] srcFiles = ds.getIncludedFiles();
|
||||
|
||||
for (int f = 0; f < srcFiles.length; f++) {
|
||||
File source = new File(fromDir, srcFiles[f]);
|
||||
for (String file : ds.getIncludedFiles()) {
|
||||
File source = new File(fromDir, file);
|
||||
File destDir = (_dest == null) ? source.getParentFile() :
|
||||
new File(source.getParent().replaceAll(baseDir, _dest.getPath()));
|
||||
try {
|
||||
CompileModel.compile(source);
|
||||
CompileModel.compile(source, destDir);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error compiling " + source + ": " + e);
|
||||
}
|
||||
@@ -72,6 +76,10 @@ public class CompileModelTask extends Task
|
||||
}
|
||||
}
|
||||
|
||||
/** The directory in which we will generate our model output (in a directory tree mirroring the
|
||||
* source files. */
|
||||
protected File _dest;
|
||||
|
||||
/** A list of filesets that contain XML models. */
|
||||
protected ArrayList<FileSet> _filesets = new ArrayList<FileSet>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user