cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject git commit: add ubuntu platform
Date Wed, 27 Nov 2013 23:40:49 GMT
Updated Branches:
  refs/heads/ubuntu [created] d7312d82d


add ubuntu platform


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/d7312d82
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/d7312d82
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/d7312d82

Branch: refs/heads/ubuntu
Commit: d7312d82db3e7a5ea2cf42fac7a6cca7b23f7983
Parents: f617176
Author: Maxim Ermilov <maxim.ermilov@canonical.com>
Authored: Wed Nov 27 19:46:02 2013 +0400
Committer: Maxim Ermilov <maxim.ermilov@canonical.com>
Committed: Wed Nov 27 19:46:02 2013 +0400

----------------------------------------------------------------------
 src/platforms.js           |   3 +-
 src/platforms/ubuntu.js    | 107 ++++++++++++++++++++++++++++++++++++++++
 src/util/config-changes.js |   4 +-
 3 files changed, 112 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d7312d82/src/platforms.js
----------------------------------------------------------------------
diff --git a/src/platforms.js b/src/platforms.js
index bcd2613..795fad3 100644
--- a/src/platforms.js
+++ b/src/platforms.js
@@ -5,5 +5,6 @@ module.exports = {
     'wp7': require('./platforms/wp7'),
     'wp8': require('./platforms/wp8'),
     'windows8' : require('./platforms/windows8'),
-    'firefoxos': require('./platforms/firefoxos')
+    'firefoxos': require('./platforms/firefoxos'),
+    'ubuntu': require('./platforms/ubuntu')
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d7312d82/src/platforms/ubuntu.js
----------------------------------------------------------------------
diff --git a/src/platforms/ubuntu.js b/src/platforms/ubuntu.js
new file mode 100644
index 0000000..884b542
--- /dev/null
+++ b/src/platforms/ubuntu.js
@@ -0,0 +1,107 @@
+/*
+ *
+ * Copyright 2013 Canonical Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+function replaceAt(str, index, char) {
+    return str.substr(0, index) + char + str.substr(index + char.length);
+}
+
+function toCamelCase(str) {
+    return str.split('-').map(function(str) {
+        return replaceAt(str, 0, str[0].toUpperCase());
+    }).join('');
+}
+
+var fs = require('fs')
+   , path = require('path')
+   , xml_helpers = require(path.join(__dirname, '..', 'util', 'xml-helpers'));
+
+module.exports = {
+    www_dir:function(project_dir) {
+        return path.join(project_dir, 'www');
+    },
+
+    package_name:function (project_dir) {
+        var config_path = path.join(project_dir, 'config.xml');
+        var widget_doc = xml_helpers.parseElementtreeSync(config_path);
+        return widget_doc._root.attrib['id'];
+    },
+    "source-file":{
+        install:function(source_el, plugin_dir, project_dir, plugin_id) {
+            var shell = require('shelljs');
+            var dest = path.join(project_dir, "build", "src", "plugins", plugin_id);
+            shell.mkdir(dest);
+            shell.cp(path.join(plugin_dir, source_el.attrib.src), dest);
+
+            shell.exec('touch ' + path.join(project_dir, "CMakeLists.txt"))
+        },
+        uninstall:function(source_el, project_dir, plugin_id) {
+            var shell = require('shelljs');
+
+            var dest = path.join(project_dir, "build", "src", "plugins", plugin_id);
+            shell.rm(path.join(dest, path.basename(source_el.attrib.src)));
+        }
+    },
+    "header-file":{
+        install:function(source_el, plugin_dir, project_dir, plugin_id) {
+            var shell = require('shelljs');
+            var dest = path.join(project_dir, "build", "src", "plugins", plugin_id);
+            shell.mkdir(dest);
+            shell.cp(path.join(plugin_dir, source_el.attrib.src), dest);
+
+            var plugins = path.join(project_dir, "build", "src", "coreplugins.cpp");
+            src = String(fs.readFileSync(plugins));
+
+            src = src.replace('INSERT_HEADER_HERE', '#include "plugins/' + plugin_id + "/"
+ path.basename(source_el.attrib.src) +'"\nINSERT_HEADER_HERE');
+            var class_name = plugin_id.match(/\.[^.]+$/)[0].substr(1);
+            class_name = toCamelCase(class_name);
+            src = src.replace('INSERT_PLUGIN_HERE', 'INIT_PLUGIN(' + class_name + ');INSERT_PLUGIN_HERE');
+
+            fs.writeFileSync(plugins, src);
+        },
+        uninstall:function(source_el, project_dir, plugin_id) {
+            var shell = require('shelljs');
+            var dest = path.join(project_dir, "build", "src", "plugins", plugin_id);
+            shell.rm(path.join(dest, path.basename(source_el.attrib.src)));
+
+            var plugins = path.join(project_dir, "build", "src", "coreplugins.cpp");
+            src = String(fs.readFileSync(plugins));
+
+            src = src.replace('#include "plugins/' + plugin_id + "/" + path.basename(source_el.attrib.src)
+'"', '');
+            var class_name = plugin_id.match(/\.[^.]+$/)[0].substr(1);
+            class_name = toCamelCase(class_name);
+            src = src.replace('INIT_PLUGIN(' + class_name + ');', '');
+
+            fs.writeFileSync(plugins, src);
+        }
+    },
+    "resource-file":{
+        install:function(source_el, plugin_dir, project_dir, plugin_id) {
+            var shell = require('shelljs');
+            var dest = path.join(project_dir, "qml");
+            shell.mkdir(dest);
+            shell.cp(path.join(plugin_dir, source_el.attrib.src), dest);
+        },
+        uninstall:function(source_el, project_dir, plugin_id) {
+            var shell = require('shelljs');
+
+            var dest = path.join(project_dir, "qml");
+            shell.rm(path.join(dest, path.basename(source_el.attrib.src)));
+        }
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d7312d82/src/util/config-changes.js
----------------------------------------------------------------------
diff --git a/src/util/config-changes.js b/src/util/config-changes.js
index c9f625b..5fa9983 100644
--- a/src/util/config-changes.js
+++ b/src/util/config-changes.js
@@ -460,7 +460,9 @@ function resolveConfigFilePath(project_dir, platform, file) {
     } else {
         // special-case config.xml target that is just "config.xml". this should be resolved
to the real location of the file.
         if (file == 'config.xml') {
-            if (platform == 'android') {
+            if (platform == 'ubuntu') {
+                filepath = path.join(project_dir, 'config.xml');
+            } else if (platform == 'android') {
                 filepath = path.join(project_dir, 'res', 'xml', 'config.xml');
             } else {
                 var matches = glob.sync(path.join(project_dir, '**', 'config.xml'));


Mime
View raw message