You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/12/24 04:21:41 UTC

[2/2] git commit: CB-5701 Reference custom frameworks usinexecHelperrelative paths

CB-5701 Reference custom frameworks usinexecHelperrelative paths

Also changed where the frameworks are copied to. They now live within
the plugin's subdirectory (beside its source files) instead of at the
top of the 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/6d8c1c77
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/6d8c1c77
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/6d8c1c77

Branch: refs/heads/master
Commit: 6d8c1c77747b17105212d71addbb301e7e658f9c
Parents: ad07294
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Dec 23 22:20:12 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Dec 23 22:20:12 2013 -0500

----------------------------------------------------------------------
 package.json               |  4 +++-
 spec/platforms/ios.spec.js | 25 ++++++++++++-------------
 src/install.js             |  2 +-
 src/platforms/ios.js       | 20 +++++++++++---------
 src/uninstall.js           |  2 +-
 5 files changed, 28 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6d8c1c77/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 1f366ef..20c6d4a 100644
--- a/package.json
+++ b/package.json
@@ -16,11 +16,13 @@
     "node": ">=0.9.9"
   },
   "engineStrict":true,
+  "//": ["Can remove node-xcode git dependency once pull request is merged:",
+         "https://github.com/alunny/node-xcode/pull/25"],
   "dependencies": {
     "nopt": "1.0.x",
     "glob": "3.2.x",
     "elementtree": "0.1.5",
-    "xcode": "0.6.3",
+    "xcode": "git+https://github.com/kronenthaler/node-xcode.git",
     "plist": "0.4.x",
     "bplist-parser": "0.0.x",
     "shelljs": "0.1.x",

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6d8c1c77/spec/platforms/ios.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/ios.spec.js b/spec/platforms/ios.spec.js
index 2346c5c..f49db9f 100644
--- a/spec/platforms/ios.spec.js
+++ b/spec/platforms/ios.spec.js
@@ -249,30 +249,29 @@ describe('ios project handler', function() {
             it('should throw if framework src cannot be found', function() {
                 var frameworks = copyArray(invalid_custom_frameworks);
                 expect(function() {
-                    ios['framework'].install(frameworks[0], faultyplugin, temp, proj_files);
+                    ios['framework'].install(frameworks[0], faultyplugin, temp, dummy_id, proj_files);
                 }).toThrow('cannot find "' + path.resolve(faultyplugin, 'src/ios/NonExistantCustomFramework.framework') + '" ios <framework>');
             });
             it('should throw if framework target already exists', function() {
                 var frameworks = copyArray(valid_custom_frameworks);
-                var target = path.join(temp, 'Custom.framework');
-                shell.mkdir('-p', path.dirname(target));
-                fs.writeFileSync(target, 'some bs', 'utf-8');
+                var target = path.join(temp, 'SampleApp/Plugins/com.phonegap.plugins.dummyplugin/Custom.framework');
+                shell.mkdir('-p', target);
                 expect(function() {
-                    ios['framework'].install(frameworks[0], dummyplugin, temp, proj_files);
+                    ios['framework'].install(frameworks[0], dummyplugin, temp, dummy_id, proj_files);
                 }).toThrow('target destination "' + target + '" already exists');
             });
             it('should call into xcodeproj\'s addFramework', function() {
                 var frameworks = copyArray(valid_custom_frameworks);
                 var spy = spyOn(proj_files.xcode, 'addFramework');
-                ios['framework'].install(frameworks[0], dummyplugin, temp, proj_files);
-                expect(spy).toHaveBeenCalledWith(path.join(temp, 'Custom.framework'), {customFramework:true});
+                ios['framework'].install(frameworks[0], dummyplugin, temp, dummy_id, proj_files);
+                expect(spy).toHaveBeenCalledWith('SampleApp/Plugins/com.phonegap.plugins.dummyplugin/Custom.framework', {customFramework:true});
             });
             it('should cp the file to the right target location', function() {
                 var frameworks = copyArray(valid_custom_frameworks);
                 var spy = spyOn(shell, 'cp');
-                ios['framework'].install(frameworks[0], dummyplugin, temp, proj_files);
+                ios['framework'].install(frameworks[0], dummyplugin, temp, dummy_id, proj_files);
                 expect(spy).toHaveBeenCalledWith('-R', path.join(dummyplugin, 'src', 'ios', 'Custom.framework'),
-                                                 temp);
+                                                 path.join(temp, 'SampleApp/Plugins/com.phonegap.plugins.dummyplugin'));
             });
         });
     });
@@ -374,15 +373,15 @@ describe('ios project handler', function() {
                 var frameworks = copyArray(valid_custom_frameworks);
                 var spy = spyOn(proj_files.xcode, 'removeFramework');
 
-                ios['framework'].uninstall(frameworks[0], temp, proj_files);
-                expect(spy).toHaveBeenCalledWith(path.join(temp, 'Custom.framework'), {customFramework:true});
+                ios['framework'].uninstall(frameworks[0], temp, dummy_id, proj_files);
+                expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp/Plugins/com.phonegap.plugins.dummyplugin/Custom.framework'), {customFramework:true});
             });
             it('should rm the file from the right target location', function(){
                 var frameworks = copyArray(valid_custom_frameworks);
                 var spy = spyOn(shell, 'rm');
 
-                ios['framework'].uninstall(frameworks[0], temp, proj_files);
-                expect(spy).toHaveBeenCalledWith('-rf', path.join(temp, 'Custom.framework'));
+                ios['framework'].uninstall(frameworks[0], temp, dummy_id, proj_files);
+                expect(spy).toHaveBeenCalledWith('-rf', path.join(temp, 'SampleApp/Plugins/com.phonegap.plugins.dummyplugin/Custom.framework'));
             });
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6d8c1c77/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 5d931e4..6b09434 100644
--- a/src/install.js
+++ b/src/install.js
@@ -362,7 +362,7 @@ function handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plu
         });
         // CB-5238 custom frameworks only 
         frameworkFiles && frameworkFiles.forEach(function(framework) {
-            actions.push(actions.createAction(handler["framework"].install, [framework, plugin_dir, project_dir], handler["framework"].uninstall, [framework, project_dir]));
+            actions.push(actions.createAction(handler["framework"].install, [framework, plugin_dir, project_dir, plugin_id], handler["framework"].uninstall, [framework, project_dir]));
         });
 
         libFiles && libFiles.forEach(function(lib) {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6d8c1c77/src/platforms/ios.js
----------------------------------------------------------------------
diff --git a/src/platforms/ios.js b/src/platforms/ios.js
index 550f973..83f159c 100644
--- a/src/platforms/ios.js
+++ b/src/platforms/ios.js
@@ -116,22 +116,24 @@ module.exports = {
         }
     },
     "framework":{ // CB-5238 custom frameworks only
-        install:function(framework_el, plugin_dir, project_dir, project) {
+        install:function(framework_el, plugin_dir, project_dir, plugin_id, project) {
             var src = framework_el.attrib['src'],
                 custom = framework_el.attrib['custom'],
                 srcFile = path.resolve(plugin_dir, src),
-                destFile = path.resolve(project_dir, path.basename(src));
+                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(destFile)) throw new Error('target destination "' + destFile + '" already exists');
-            shell.cp('-R', srcFile, project_dir); // frameworks are directories
-            project.xcode.addFramework(destFile, {customFramework: true});
+            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);
+            project.xcode.addFramework(project_relative, {customFramework: true});
         },
-        uninstall:function(framework_el, project_dir, project) {
+        uninstall:function(framework_el, project_dir, plugin_id, project) {
             var src = framework_el.attrib['src'],
-                destFile = path.resolve(project_dir, path.basename(src));
-            project.xcode.removeFramework(destFile, {customFramework: true});
-            shell.rm('-rf', destFile);
+                targetDir = path.resolve(project.plugins_dir, plugin_id, path.basename(src));
+            project.xcode.removeFramework(targetDir, {customFramework: true});
+            shell.rm('-rf', targetDir);
         }
     },
     parseProjectFile:function(project_dir) {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6d8c1c77/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index 085923e..4bc8a23 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -168,7 +168,7 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir, w
         
         // CB-5238 custom frameworks only 
         frameworkFiles && frameworkFiles.forEach(function(framework) {
-            actions.push(actions.createAction(handler["framework"].uninstall, [framework, project_dir], handler["framework"].install, [framework, plugin_dir, project_dir]));
+            actions.push(actions.createAction(handler["framework"].uninstall, [framework, project_dir, plugin_id], handler["framework"].install, [framework, plugin_dir, project_dir]));
         });
 
         libFiles && libFiles.forEach(function(source) {