Skip to content

Commit

Permalink
Merge pull request #5196 from cb1kenobi/timob-16151
Browse files Browse the repository at this point in the history
[TIMOB-16151] Fixed bug with Titanium symbols not being scanned for emul...
  • Loading branch information
ayeung committed Jan 9, 2014
2 parents 98ddc66 + acac086 commit bc3744a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 52 deletions.
56 changes: 29 additions & 27 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2276,7 +2276,9 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {
htmlJsFiles[file] = 1;
});

copyFile.call(_t, from, to, next);
_t.cli.createHook('build.android.copyResource', _t, function (from, to, cb) {
copyFile.call(_t, from, to, cb);
})(from, to, next);
break;

case 'js':
Expand All @@ -2300,8 +2302,10 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {

case 'xml':
if (_t.xmlMergeRegExp.test(filename)) {
_t.writeXmlFile(from, to);
next();
_t.cli.createHook('build.android.copyResource', _t, function (from, to, cb) {
_t.writeXmlFile(from, to);
cb();
})(from, to, next);
break;
}

Expand Down Expand Up @@ -2461,35 +2465,33 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {
}
delete this.lastBuildFiles[to];

// if we're not minifying the JavaScript and we're not forcing all
// Titanium Android modules to be included, then parse the AST and detect
// all Titanium symbols
if (this.minifyJS || !this.includeAllTiModules) {
try {
var r = jsanalyze.analyzeJsFile(from, { minify: this.minifyJS });
try {
// parse the AST
var r = jsanalyze.analyzeJsFile(from, { minify: this.minifyJS });

// we want to sort by the "to" filename so that we correctly handle file overwriting
this.tiSymbols[to] = r.symbols;
// we want to sort by the "to" filename so that we correctly handle file overwriting
this.tiSymbols[to] = r.symbols;

this.logger.debug(this.minifyJS
? __('Copying and minifying %s => %s', from.cyan, to.cyan)
: __('Copying %s => %s', from.cyan, to.cyan));
this.cli.createHook('build.android.copyResource', this, function (from, to, cb) {
var dir = path.dirname(to);
fs.existsSync(dir) || wrench.mkdirSyncRecursive(dir);

if (this.minifyJS) {
this.logger.debug(__('Copying and minifying %s => %s', from.cyan, to.cyan));

this.cli.createHook('build.android.compileJsFile', this, function (r, from, to, cb2) {
fs.writeFile(to, r.contents, cb2);
})(r, from, to, cb);
} else {
this.logger.debug(__('Copying %s => %s', from.cyan, to.cyan));

this.cli.createHook('build.android.compileJsFile', this, function (r, from, to, cb) {
var dir = path.dirname(to);
fs.existsSync(dir) || wrench.mkdirSyncRecursive(dir);
fs.writeFile(to, r.contents, cb);
})(r, from, to, done);
} catch (ex) {
ex.message.split('\n').forEach(this.logger.error);
this.logger.log();
process.exit(1);
}
} else {
// no need to parse the AST, so just copy the file
this.cli.createHook('build.android.copyResource', this, function (from, to, cb) {
copyFile.call(this, from, to, cb);
}
})(from, to, done);
} catch (ex) {
ex.message.split('\n').forEach(this.logger.error);
this.logger.log();
process.exit(1);
}
};
}), function () {
Expand Down
1 change: 1 addition & 0 deletions android/cli/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
"Forcing rebuild: Android activites in tiapp.xml changed since last build": "Forcing rebuild: Android activites in tiapp.xml changed since last build",
"Forcing rebuild: Android services in tiapp.xml SDK changed since last build": "Forcing rebuild: Android services in tiapp.xml SDK changed since last build",
"Forcing rebuild: One or more JSS files changed since last build": "Forcing rebuild: One or more JSS files changed since last build",
"Forcing rebuild: mergeCustomAndroidManifest config has changed since last build": "Forcing rebuild: mergeCustomAndroidManifest config has changed since last build",
"Symlinking %s => %s": "Symlinking %s => %s",
"Copying %s => %s": "Copying %s => %s",
"Ignoring %s": "Ignoring %s",
Expand Down
50 changes: 27 additions & 23 deletions iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2731,7 +2731,9 @@ iOSBuilder.prototype.copyResources = function copyResources(finished) {
htmlJsFiles[file] = 1;
});

copyFile.call(_t, from, to, next);
_t.cli.createHook('build.ios.copyResource', _t, function (from, to, cb) {
copyFile.call(_t, from, to, cb);
})(from, to, next);
break;

case 'js':
Expand Down Expand Up @@ -2849,6 +2851,7 @@ iOSBuilder.prototype.copyResources = function copyResources(finished) {
series(this, tasks, function (err, results) {
// copy js files into assets directory and minify if needed
this.logger.info(__('Processing JavaScript files'));

series(this, Object.keys(jsFiles).map(function (id) {
return function (done) {
var from = jsFiles[id],
Expand All @@ -2869,32 +2872,33 @@ iOSBuilder.prototype.copyResources = function copyResources(finished) {
jsFilesToEncrypt.push(id);
}

// if we're not minifying the JavaScript and we're not forcing all
// Titanium modules to be included, then parse the AST and detect
// all Titanium symbols
if (this.minifyJS || !this.includeAllTiModules) {
try {
var r = jsanalyze.analyzeJsFile(from, { minify: this.minifyJS });
try {
// parse the AST
var r = jsanalyze.analyzeJsFile(from, { minify: this.minifyJS });

// we want to sort by the "to" filename so that we correctly handle file overwriting
this.tiSymbols[to] = r.symbols;
// we want to sort by the "to" filename so that we correctly handle file overwriting
this.tiSymbols[to] = r.symbols;

this.logger.debug(__('Copying and minifying %s => %s', from.cyan, to.cyan));
this.cli.createHook('build.ios.compileJsFile', this, function (r, from, to, cb) {
var dir = path.dirname(to);
fs.existsSync(dir) || wrench.mkdirSyncRecursive(dir);
fs.writeFile(to, r.contents, cb);
})(r, from, to, done);
} catch (ex) {
ex.message.split('\n').forEach(this.logger.error);
this.logger.log();
process.exit(1);
}
} else {
// no need to parse the AST, so just copy the file
this.cli.createHook('build.ios.copyResource', this, function (from, to, cb) {
copyFile.call(this, from, to, cb);
var dir = path.dirname(to);
fs.existsSync(dir) || wrench.mkdirSyncRecursive(dir);

if (this.minifyJS) {
this.logger.debug(__('Copying and minifying %s => %s', from.cyan, to.cyan));

this.cli.createHook('build.ios.compileJsFile', this, function (r, from, to, cb2) {
fs.writeFile(to, r.contents, cb2);
})(r, from, to, cb);
} else {
this.logger.debug(__('Copying %s => %s', from.cyan, to.cyan));

fs.writeFile(to, r.contents, cb);
}
})(from, to, done);
} catch (ex) {
ex.message.split('\n').forEach(this.logger.error);
this.logger.log();
process.exit(1);
}
};
}), function () {
Expand Down
2 changes: 1 addition & 1 deletion node_modules/titanium-sdk/lib/jsanalyze.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/titanium-sdk/locales/en.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bc3744a

Please sign in to comment.