You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by na...@apache.org on 2014/02/10 23:20:16 UTC
git commit: Upleveled amazon_fireos_parser. Making it at par with
android_parser.js
Updated Branches:
refs/heads/master 7f1b02fae -> 9539b4eb7
Upleveled amazon_fireos_parser. Making it at par with android_parser.js
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/9539b4eb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/9539b4eb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/9539b4eb
Branch: refs/heads/master
Commit: 9539b4eb7efba2ebd5b9e2173210fb0091a2fd2c
Parents: 7f1b02f
Author: Archana Naik <na...@lab126.com>
Authored: Fri Feb 7 14:08:27 2014 -0800
Committer: Archana Naik <na...@lab126.com>
Committed: Mon Feb 10 14:19:54 2014 -0800
----------------------------------------------------------------------
src/metadata/amazon_fireos_parser.js | 80 +++++++++----------------------
1 file changed, 23 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/9539b4eb/src/metadata/amazon_fireos_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/amazon_fireos_parser.js b/src/metadata/amazon_fireos_parser.js
index 2f1e2ab..b964450 100644
--- a/src/metadata/amazon_fireos_parser.js
+++ b/src/metadata/amazon_fireos_parser.js
@@ -45,48 +45,10 @@ module.exports = function android_parser(project) {
};
// Returns a promise.
+// Returns a promise.
module.exports.check_requirements = function(project_root) {
- events.emit('log', 'Checking Amazon FireOS requirements...');
- var command = 'android list target';
- events.emit('verbose', 'Running "' + command + '" (output to follow)');
- var d = Q.defer();
- child_process.exec(command, function(err, output, stderr) {
- events.emit('verbose', output);
- if (err) {
- d.reject(new Error('The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ' + output));
- } else {
- if (output.indexOf('android-17') == -1) {
- d.reject(new Error('Please install Android target 17 (the Android 4.2 SDK). Make sure you have the latest Android tools installed as well. Run `android` from your command-line to install/update any missing SDKs or tools.'));
- } else {
- var custom_path = project_config.has_custom_path(project_root, 'android');
- var framework_path;
- if (custom_path) {
- framework_path = path.resolve(path.join(custom_path, 'framework'));
- } else {
- framework_path = path.join(util.libDirectory, 'amazon-fireos', 'cordova', require('../../platforms').android.version, 'framework');
- }
- var cmd = 'android update project -p "' + framework_path + '" -t android-17';
- events.emit('verbose', 'Running "' + cmd + '" (output to follow)...');
- var d2 = Q.defer();
- child_process.exec(cmd, function(err, output, stderr) {
- events.emit('verbose', output + stderr);
- if (err) {
- d2.reject(new Error('Updating the Cordova library to work with your Android environment failed when running: "' + cmd + '", output: ' + output));
- } else {
- events.emit('log', 'Checking if ' + awv_interface + ' exists... in framework/libs folder');
- var awv_interface_expected_path=path.join(framework_path,'libs');
- if (!fs.existsSync(path.join(awv_interface_expected_path,awv_interface))) {
- d2.reject(new Error('awv_interface.jar not found in ' + awv_interface_expected_path +' folder. \nPlease download the AmazonWebView SDK from http://developer.amazon.com/sdk/fire/IntegratingAWV.html#installawv and copy the awv_interface.jar file to this folder:' + awv_interface_expected_path + ' and re-run cordova platform add amazon-fireos command.'));
- } else {
- d2.resolve();
- }
- }
- });
- d.resolve(d2.promise);
- }
- }
- });
- return d.promise;
+ // Rely on platform's bin/create script to check requirements.
+ return Q(true);
};
module.exports.prototype = {
@@ -116,7 +78,16 @@ module.exports.prototype = {
fs.writeFileSync(this.manifest, manifest.write({indent: 4}), 'utf-8');
var orig_pkgDir = path.join(this.path, 'src', path.join.apply(null, orig_pkg.split('.')));
- var orig_java_class = fs.readdirSync(orig_pkgDir).filter(function(f) {return f.indexOf('.svn') == -1;})[0];
+ var java_files = fs.readdirSync(orig_pkgDir).filter(function(f) {
+ return f.indexOf('.svn') == -1 && f.indexOf('.java') >= 0 && fs.readFileSync(path.join(orig_pkgDir, f), 'utf-8').match(/extends\s+CordovaActivity/);
+ });
+ if (java_files.length == 0) {
+ throw new Error('No Java files found which extend CordovaActivity.');
+ } else if(java_files.length > 1) {
+ events.emit('log', 'Multiple candidate Java files (.java files which extend CordovaActivity) found. Guessing at the first one, ' + java_files[0]);
+ }
+
+ var orig_java_class = java_files[0];
var pkgDir = path.join(this.path, 'src', path.join.apply(null, pkg.split('.')));
shell.mkdir('-p', pkgDir);
var orig_javs = path.join(orig_pkgDir, orig_java_class);
@@ -146,24 +117,19 @@ module.exports.prototype = {
return path.resolve(jsPath);
},
+ // Replace the www dir with contents of platform_www and app www.
update_www:function() {
var projectRoot = util.isCordova(this.path);
- var www = util.projectWww(projectRoot);
- var platformWww = path.join(this.path, 'assets');
- // remove stock platform assets
+ var app_www = util.projectWww(projectRoot);
+ var platform_www = path.join(this.path, 'platform_www');
+
+ // Clear the www dir
shell.rm('-rf', this.www_dir());
- // copy over all app www assets
- shell.cp('-rf', www, platformWww);
-
- // write out android lib's cordova.js
- var custom_path = project_config.has_custom_path(projectRoot, 'android');
- var jsPath;
- if (custom_path) {
- jsPath = path.resolve(path.join(custom_path, 'framework', 'assets', 'www', 'cordova.js'));
- } else {
- jsPath = path.join(util.libDirectory, 'amazon-fireos', 'cordova', require('../../platforms').android.version, 'framework', 'assets', 'www', 'cordova.js');
- }
- fs.writeFileSync(path.join(this.www_dir(), 'cordova.js'), fs.readFileSync(jsPath, 'utf-8'), 'utf-8');
+ shell.mkdir(this.www_dir());
+ // Copy over all app www assets
+ shell.cp('-rf', path.join(app_www, '*'), this.www_dir());
+ // Copy over stock platform www assets (cordova.js)
+ shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
},
// update the overrides folder into the www folder