Skip to content
Browse files

Run asc.jar in optimization mode; change .gitignore

  • Loading branch information...
1 parent 2d0f92b commit 0a428c490a35728f6c9b17556b29f722af69d8e9 @yurydelendik yurydelendik committed Feb 6, 2014
Showing with 38 additions and 10 deletions.
  1. +2 −0 .gitignore
  2. +36 −10 utils/playerGlobal-new/build.js
View
2 .gitignore
@@ -18,6 +18,8 @@ src/avm2/utils/js
src/flash/playerglobal.js
src/flash/playerglobal.abc
+src/flash/playerglobal-new.js
+src/flash/playerglobal-new.abc
node_modules/
View
46 utils/playerGlobal-new/build.js
@@ -20,7 +20,11 @@ var fs = require('fs');
var spawn = require('child_process').spawn;
// simple args parsing
-var rebuild = false, buildThreadsCount = 1;
+var rebuild = false;
+var buildThreadsCount = 1;
+var dependenciesRecursionLevel = 1;
+var optimize = true;
+var debugInfo = false;
for (var i = 2; i < process.argv.length;) {
var cmd = process.argv[i++];
switch (cmd) {
@@ -32,6 +36,10 @@ for (var i = 2; i < process.argv.length;) {
case '-r':
rebuild = true;
break;
+ case '-d':
+ debugInfo = true;
+ optimize = false;
+ break;
default:
throw new Error('Bad argument: ' + cmd);
}
@@ -117,9 +125,15 @@ function runAsc(threadId, outputPath, files, callback) {
}
var args = ['-ea', '-DAS3', '-DAVMPLUS', '-classpath', ascjar,
- 'macromedia.asc.embedding.ScriptCompiler', '-builtin',
- '-import', buildasc, '-outdir', outputDir,
- '-out', outputName].concat(files);
+ 'macromedia.asc.embedding.ScriptCompiler', '-builtin'];
+ if (debugInfo) {
+ args.push('-d');
+ }
+ if (optimize) {
+ args.push('-optimize');
+ }
+ args = args.concat(['-import', buildasc, '-outdir', outputDir,
+ '-out', outputName]).concat(files);
var proc = spawn('java', args, {stdio: 'inherit'} );
proc.on('close', function (code) {
if (!fs.existsSync(outputPath)) {
@@ -130,6 +144,15 @@ function runAsc(threadId, outputPath, files, callback) {
});
}
+var ignoreDependenciesErrors = {
+ 'flash.utils.Dictionary': true,
+ 'flash.utils.ByteArray': true,
+ 'flash.utils.escapeMultiByte': true,
+ 'flash.utils.unescapeMultiByte': true,
+ 'flash.utils.IDataInput': true,
+ // add more ..
+};
+
function getDependencies(files) {
var tmp = {}, tmpErr = {}, queue = [];
files.forEach(function (file) {
@@ -146,10 +169,11 @@ function getDependencies(files) {
if (fs.existsSync(path)) {
if (!tmp[path]) {
tmp[path] = true;
- // uncomment to do recursive search of dependencies
- // queue.push(path);
+ if (dependenciesRecursionLevel >= 2) {
+ queue.push(path);
+ }
}
- } else if (!tmpErr[m[0]]) {
+ } else if (!tmpErr[m[0]] && !ignoreDependenciesErrors[m[1]]) {
console.log('Dependency file for \"' + m[0] + '\" was not found');
tmpErr[m[0]] = true;
}
@@ -162,8 +186,9 @@ function getDependencies(files) {
var path = file.substring(0, file.lastIndexOf('/') + 1) + m[1] + '.as';
if (fs.existsSync(path)) {
tmp[path] = true;
- // uncomment to do recursive search of dependencies
- // queue.push(path);
+ if (dependenciesRecursionLevel >= 2) {
+ queue.push(path);
+ }
}
}
}
@@ -187,7 +212,8 @@ function buildNext(threadId) {
throw new Error('Build returned error code: ' + code);
}
- item.dependencies = getDependencies(item.files);
+ item.dependencies = dependenciesRecursionLevel < 1 ? items.files :
+ getDependencies(item.files);
pending--;
if (buildQueue.length === 0) {

0 comments on commit 0a428c4

Please sign in to comment.
Something went wrong with that request. Please try again.