cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [01/13] git commit: wip implementing reading guid from 'framework' project
Date Thu, 06 Mar 2014 00:13:28 GMT
Repository: cordova-plugman
Updated Branches:
  refs/heads/master cc51a5f10 -> 172a4dec2


wip implementing reading guid from 'framework' project


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

Branch: refs/heads/master
Commit: 83aa57fb05e6ca378dc401c94887389e8af68086
Parents: f0a339f
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Tue Feb 4 02:37:28 2014 -0800
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Tue Feb 4 02:37:28 2014 -0800

----------------------------------------------------------------------
 src/platforms/windows8.js | 50 ++++++++++++++++++++++++++++++++++++++++--
 src/util/w8jsproj.js      | 21 +++++++++++++++++-
 2 files changed, 68 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/83aa57fb/src/platforms/windows8.js
----------------------------------------------------------------------
diff --git a/src/platforms/windows8.js b/src/platforms/windows8.js
index bd25562..65a1445 100644
--- a/src/platforms/windows8.js
+++ b/src/platforms/windows8.js
@@ -20,8 +20,10 @@
 var common = require('./common'),
     path = require('path'),
     glob = require('glob'),
-    w8jsproj = require('../util/w8jsproj');
-    xml_helpers = require('../util/xml-helpers');
+    shell = require('shelljs'),
+    fs   = require('fs');
+var w8jsproj = require('../util/w8jsproj');
+var xml_helpers = require('../util/xml-helpers');
 
 
 module.exports = {
@@ -64,5 +66,49 @@ module.exports = {
         },
         uninstall:function(el, project_dir) {
         }
+    },
+    "framework":{ // CB-5238 custom frameworks only
+        install:function(framework_el, plugin_dir, project_dir, plugin_id, project) {
+            // console.log("framework install called with framework_el:: " + framework_el);
+            // console.log("framework install called with plugin_dir:: " + plugin_dir );
+            // console.log("framework install called with project_dir:: " + project_dir);
+            // console.log("framework install called with plugin_id:: " + plugin_id);
+            // console.log("framework install called with project::" + project);
+
+            // console.log("project.plugins_dir " + project.plugins_dir);
+
+            // framework_el attributes : src, custom
+            var src = framework_el.attrib['src'];
+            console.log("src = " + src);
+
+            var custom = framework_el.attrib['custom'];
+
+            var srcFile = path.resolve(plugin_dir, src);
+
+            console.log("path.basename(src) = " + path.basename(src));
+
+            console.log("srcFile = " + srcFile);
+
+            var targetDir = path.resolve(project.plugins_dir, plugin_id, path.basename(src));
+
+            if (!custom) throw new Error('cannot add non custom frameworks.');
+            if (!fs.existsSync(srcFile)) throw new Error('cannot find "' + srcFile + '" ios
<framework>');
+            if (fs.existsSync(targetDir)) throw new Error('target destination "' + targetDir
+ '" already exists');
+            shell.mkdir('-p', path.dirname(targetDir));
+            shell.cp('-R', srcFile, path.dirname(targetDir)); // frameworks are directories
+            var project_relative = path.relative(project_dir, targetDir);
+            
+            console.log("project_relative = " + project_relative);
+            project.addProjectReference(project_relative);
+            //project.xcode.addFramework(project_relative, {customFramework: true});
+        },
+        uninstall:function(framework_el, project_dir, plugin_id, project) {
+            var src = framework_el.attrib['src'],
+                baseDir = path.resolve(project.plugins_dir, plugin_id),
+                targetDir = path.resolve(baseDir, path.basename(src));
+            project.removeProjectReference(targetDir);
+            shell.rm('-rf', baseDir);
+
+        }
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/83aa57fb/src/util/w8jsproj.js
----------------------------------------------------------------------
diff --git a/src/util/w8jsproj.js b/src/util/w8jsproj.js
index bd5dd41..10c5b7b 100644
--- a/src/util/w8jsproj.js
+++ b/src/util/w8jsproj.js
@@ -5,7 +5,9 @@
 
 var xml_helpers = require('./xml-helpers'),
     et = require('elementtree'),
-    fs = require('fs');
+    fs = require('fs'),
+    shell = require('shelljs'),
+    path = require('path');
 
 function jsproj(location) {
     require('../../plugman').emit('verbose','creating jsproj from project at : ' + location);
@@ -17,6 +19,7 @@ function jsproj(location) {
 jsproj.prototype = {
     location:null,
     xml:null,
+    plugins_dir:"Plugins",
     write:function() {
         fs.writeFileSync(this.location, this.xml.write({indent:4}), 'utf-8');
     },
@@ -30,6 +33,22 @@ jsproj.prototype = {
             item.append(content);
         this.xml.getroot().append(item);
     },
+    addProjectReference:function(relative_path) {
+        require('../../plugman').emit('verbose','adding project reference to ' + relative_path);
+        // read the guid from the project
+
+        // could be a .csproj, or ???
+        var projectFullPath = shell.ls(path.join(relative_path,"*.*proj"));
+        var pluginProjectXML = xml_helpers.parseElementtreeSync(".\\" + projectFullPath);
+        var guidNode = pluginProjectXML.findall("PropertyGroup/ProjectGuid")[0];
+        var projectGuid = guidNode.text;
+        console.log("Project guid = " + projectGuid);
+
+
+    },
+    removeProjectReference:function(relative_path) {
+        require('../../plugman').emit('verbose','removing project reference to ' + relative_path);
+    },
     removeSourceFile:function(relative_path) {
         relative_path = relative_path.split('/').join('\\');
         var item_groups = this.xml.findall('ItemGroup');


Mime
View raw message