Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-16151] Fixed bug with Titanium symbols not being scanned for emul... #5197

Merged
merged 2 commits into from
Jan 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 29 additions & 27 deletions android/cli/commands/_build.js
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
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
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.