Permalink
Browse files

Merge pull request #569 from AnalyticalGraphicsInc/buildSpeed

Build speed improvements.
  • Loading branch information...
2 parents f60bdfd + 1a34434 commit 2fb7aea9bef4080650b9b53a61e6f41986cd8e68 @pjcozzi pjcozzi committed Mar 18, 2013
@@ -1,50 +1,35 @@
/*global importClass,project,attributes,elements,java,Packages*/
-/*jshint multistr:true*/
-importClass(java.io.File); /*global File*/
-importClass(java.io.FileReader); /*global FileReader*/
-importClass(java.io.FileWriter); /*global FileWriter*/
-importClass(Packages.org.apache.tools.ant.util.FileUtils); /*global FileUtils*/
+/*jshint strict:false,multistr:true*/
+
+importClass(Packages.org.mozilla.javascript.tools.shell.Main); /*global Main*/
+Main.exec(['-e', '{}']);
+var load = Main.global.load;
+
+load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,File,FileReader,FileWriter,FileUtils*/
var moduleIds = [];
var parameters = [];
var assignments = [];
var nonIdentifierRegexp = /[^0-9a-zA-Z_$]/g;
-var sourceFilesets = elements.get('sourcefiles');
-for ( var i = 0, len = sourceFilesets.size(); i < len; ++i) {
- var sourceFileset = sourceFilesets.get(i);
- var basedir = sourceFileset.getDir(project);
- var sourceFilenames = sourceFileset.getDirectoryScanner(project).getIncludedFiles();
-
- for ( var j = 0; j < sourceFilenames.length; ++j) {
- var relativePath = sourceFilenames[j];
- var file = new File(basedir, relativePath);
-
- var moduleId = relativePath.replace('\\', '/');
- moduleId = moduleId.substring(0, moduleId.lastIndexOf('.'));
+forEachFile('sourcefiles', function(relativePath, file) {
+ var moduleId = relativePath.replace('\\', '/');
+ moduleId = moduleId.substring(0, moduleId.lastIndexOf('.'));
- var baseName = file.getName();
- var assignmentName = baseName.substring(0, baseName.lastIndexOf('.'));
- assignmentName = String(assignmentName).replace(nonIdentifierRegexp, '_');
- if (/Shaders\//.test(moduleId)) {
- assignmentName = '_shaders.' + assignmentName;
- }
-
- var parameterName = String(moduleId).replace(nonIdentifierRegexp, '_');
-
- moduleIds.push("'" + moduleId + "'");
- parameters.push(parameterName);
- assignments.push('Cesium.' + assignmentName + ' = ' + parameterName + ';');
+ var baseName = file.getName();
+ var assignmentName = baseName.substring(0, baseName.lastIndexOf('.'));
+ assignmentName = String(assignmentName).replace(nonIdentifierRegexp, '_');
+ if (/Shaders\//.test(moduleId)) {
+ assignmentName = '_shaders.' + assignmentName;
}
-}
-var output = attributes.get('output');
-if (new File(output).exists()) {
- var reader = new FileReader(output);
- var oldContents = String(FileUtils.readFully(reader));
- reader.close();
-}
+ var parameterName = String(moduleId).replace(nonIdentifierRegexp, '_');
+
+ moduleIds.push("'" + moduleId + "'");
+ parameters.push(parameterName);
+ assignments.push('Cesium.' + assignmentName + ' = ' + parameterName + ';');
+});
var contents = '\
/*global define*/\n\
@@ -57,8 +42,4 @@ define([' + moduleIds.join(', ') + '], function(' + parameters.join(', ') + ') {
return Cesium;\n\
});';
-if (oldContents !== contents) {
- var writer = new FileWriter(output);
- writer.write(contents);
- writer.close();
-}
+writeFileContents(attributes.get('output'), contents);
@@ -1,51 +1,32 @@
/*global importClass,project,attributes,elements,java,Packages*/
-/*jshint multistr:true*/
-importClass(java.io.File); /*global File*/
-importClass(java.io.FileReader); /*global FileReader*/
-importClass(java.io.FileWriter); /*global FileWriter*/
-importClass(Packages.org.apache.tools.ant.util.FileUtils); /*global FileUtils*/
+/*jshint strict:false,multistr:true*/
+
+importClass(Packages.org.mozilla.javascript.tools.shell.Main); /*global Main*/
+Main.exec(['-e', '{}']);
+var load = Main.global.load;
+
+load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,File,FileReader,FileWriter,FileUtils*/
var demos = [];
-var demoFilesets = elements.get('demos');
-for ( var i = 0, len = demoFilesets.size(); i < len; ++i) {
- var demoFileset = demoFilesets.get(i);
- var basedir = demoFileset.getDir(project);
- var demoFilenames = demoFileset.getDirectoryScanner(project).getIncludedFiles();
-
- for ( var j = 0, len2 = demoFilenames.length; j < len2; ++j) {
- var relativePath = demoFilenames[j];
- var demo = relativePath.substring(0, relativePath.lastIndexOf('.')).replace('\\', '/');
- var thumbnail = '';
- if (new File(basedir, demo + '.jpg').exists()) {
- thumbnail = "'img' : '" + demo + ".jpg',";
- }
- var fileDate = new File(basedir, demo + '.html').lastModified().toString();
- var demoContent = "\
- {\n\
- 'name' : '" + demo + "',\n\
- " + thumbnail + "\n\
- 'date' : " + fileDate + '\n\
- }';
- demos.push(demoContent);
+forEachFile('demos', function(relativePath, file) {
+ var demo = relativePath.substring(0, relativePath.lastIndexOf('.')).replace('\\', '/');
+ var demoObject = {
+ name : String(demo),
+ date : file.lastModified()
+ };
+
+ if (new File(file.getParent(), demo + '.jpg').exists()) {
+ demoObject.img = demo + '.jpg';
}
-}
-var output = attributes.get("output");
-if (new File(output).exists()) {
- var reader = new FileReader(output);
- var oldContents = String(FileUtils.readFully(reader));
- reader.close();
-}
+ demos.push(JSON.stringify(demoObject, null, 2));
+});
var contents = '\
// This file is automatically rebuilt by the Cesium build process.\n\
var gallery_demos = [\n\
' + demos.join(',\n') + '\n\
];';
-if (oldContents !== contents) {
- var writer = new FileWriter(output);
- writer.write(contents);
- writer.close();
-}
+writeFileContents(attributes.get('output'), contents);
@@ -1,26 +1,17 @@
/*global importClass,project,attributes,elements,java,Packages*/
-/*jshint multistr:true,evil:true*/
-importClass(java.io.File); /*global File*/
-importClass(java.io.FileReader); /*global FileReader*/
-importClass(java.io.FileWriter); /*global FileWriter*/
-importClass(Packages.org.apache.tools.ant.util.FileUtils); /*global FileUtils*/
+/*jshint strict:false,multistr:true,evil:true*/
+
+importClass(Packages.org.mozilla.javascript.tools.shell.Main); /*global Main*/
+Main.exec(['-e', '{}']);
+var load = Main.global.load;
+
+load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,File,FileReader,FileWriter,FileUtils*/
var jsHintOptions = eval('({' + attributes.get('jshintoptions') + '})');
jsHintOptions.predef = ['require', 'console', 'Sandcastle', 'Cesium'];
-var output = attributes.get("output");
-if (new File(output).exists()) {
- var reader = new FileReader(output);
- var oldContents = String(FileUtils.readFully(reader));
- reader.close();
-}
-
var contents = '\
// This file is automatically rebuilt by the Cesium build process.\n\
var sandcastleJsHintOptions = ' + JSON.stringify(jsHintOptions, null, 2) + ';';
-if (oldContents !== contents) {
- var writer = new FileWriter(output);
- writer.write(contents);
- writer.close();
-}
+writeFileContents(attributes.get('output'), contents);
@@ -1,36 +1,19 @@
/*global importClass,project,attributes,elements,java,Packages*/
-/*jshint multistr:true*/
-importClass(java.io.File); /*global File*/
-importClass(java.io.FileReader); /*global FileReader*/
-importClass(java.io.FileWriter); /*global FileWriter*/
-importClass(Packages.org.apache.tools.ant.util.FileUtils); /*global FileUtils*/
+/*jshint strict:false,multistr:true*/
-var specs = [];
+importClass(Packages.org.mozilla.javascript.tools.shell.Main); /*global Main*/
+Main.exec(['-e', '{}']);
+var load = Main.global.load;
-var specFilesets = elements.get('specs');
-for ( var i = 0, len = specFilesets.size(); i < len; ++i) {
- var specFileset = specFilesets.get(i);
- var basedir = specFileset.getDir(project);
- var specFilenames = specFileset.getDirectoryScanner(project).getIncludedFiles();
+load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,File,FileReader,FileWriter,FileUtils*/
- for ( var j = 0, len2 = specFilenames.length; j < len2; ++j) {
- var relativePath = specFilenames[j];
- var spec = relativePath.substring(0, relativePath.lastIndexOf('.')).replace('\\', '/');
- specs.push("'Specs/" + spec + "'");
- }
-}
+var specs = [];
-var output = attributes.get('output');
-if (new File(output).exists()) {
- var reader = new FileReader(output);
- var oldContents = String(FileUtils.readFully(reader));
- reader.close();
-}
+forEachFile('specs', function(relativePath, file) {
+ var spec = relativePath.substring(0, relativePath.lastIndexOf('.')).replace('\\', '/');
+ specs.push("'Specs/" + spec + "'");
+});
var contents = 'var specs = [' + specs.join(',') + '];';
-if (oldContents !== contents) {
- var writer = new FileWriter(output);
- writer.write(contents);
- writer.close();
-}
+writeFileContents(attributes.get('output'), contents);
@@ -1,36 +1,21 @@
/*global importClass,project,attributes,elements,java,Packages*/
-/*jshint multistr:true*/
-importClass(java.io.File); /*global File*/
-importClass(java.io.FileReader); /*global FileReader*/
-importClass(java.io.FileWriter); /*global FileWriter*/
-importClass(Packages.org.apache.tools.ant.util.FileUtils); /*global FileUtils*/
+/*jshint strict:false,multistr:true*/
-var glslFilesets = elements.get('glslfiles');
-for ( var i = 0, len = glslFilesets.size(); i < len; ++i) {
- var glslFileset = glslFilesets.get(i);
- var basedir = glslFileset.getDir(project);
- var glslFilenames = glslFileset.getDirectoryScanner(project).getIncludedFiles();
+importClass(Packages.org.mozilla.javascript.tools.shell.Main); /*global Main*/
+Main.exec(['-e', '{}']);
+var load = Main.global.load;
- var glslDocComments = '';
+load(project.getProperty('tasksDirectory') + '/shared.js'); /*global forEachFile,readFileContents,writeFileContents,File,FileReader,FileWriter,FileUtils*/
- for ( var j = 0; j < glslFilenames.length; j++) {
- var glslFilename = glslFilenames[j];
+var glslDocComments = [];
+forEachFile('glslfiles', function(relativePath, file) {
+ var contents = readFileContents(file);
+ contents = contents.replace(/\r\n/gm, '\n');
- var glslFile = new File(basedir, glslFilename);
- var reader = new FileReader(glslFile);
- var contents = String(FileUtils.readFully(reader));
- reader.close();
-
- contents = contents.replace(/\r\n/gm, '\n');
-
- var docComments = contents.match(/\/\*\*[\s\S]*?\*\//gm);
- if (docComments) {
- glslDocComments += docComments.join('\n') + '\n';
- }
+ var docComments = contents.match(/\/\*\*[\s\S]*?\*\//gm);
+ if (docComments) {
+ glslDocComments.push(docComments.join('\n'));
}
+});
- var glslDocFile = new File(basedir, 'glslComments.js');
- var glslDocWriter = new FileWriter(glslDocFile);
- glslDocWriter.write(glslDocComments);
- glslDocWriter.close();
-}
+writeFileContents(attributes.get('output'), glslDocComments.join('\n'));
Oops, something went wrong.

0 comments on commit 2fb7aea

Please sign in to comment.