cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject git commit: CB-5238 adding custom frameworks
Date Thu, 21 Nov 2013 03:12:08 GMT
Updated Branches:
  refs/heads/frameworks [created] 64fea2c87


CB-5238 adding custom frameworks


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

Branch: refs/heads/frameworks
Commit: 64fea2c878c3a03f37496af1c946c715aac11136
Parents: 4414a43
Author: Anis Kadri <anis@apache.org>
Authored: Wed Nov 20 19:11:54 2013 -0800
Committer: Anis Kadri <anis@apache.org>
Committed: Wed Nov 20 19:11:54 2013 -0800

----------------------------------------------------------------------
 spec/platforms/ios.spec.js                      | 54 ++++++++++++++++++++
 spec/plugins/ChildBrowser/plugin.xml            |  1 +
 spec/plugins/DummyPlugin/plugin.xml             |  1 +
 .../src/ios/Custom.framework/someFheader.h      |  0
 .../src/ios/Custom.framework/somebinlib         |  0
 spec/plugins/FaultyPlugin/plugin.xml            |  1 +
 spec/util/config-changes.spec.js                |  2 +
 src/install.js                                  |  5 ++
 src/platforms/ios.js                            | 19 +++++++
 src/uninstall.js                                |  6 +++
 src/util/config-changes.js                      | 28 +++++-----
 11 files changed, 105 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/spec/platforms/ios.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/ios.spec.js b/spec/platforms/ios.spec.js
index cb7460d..07b24f6 100644
--- a/spec/platforms/ios.spec.js
+++ b/spec/platforms/ios.spec.js
@@ -30,6 +30,7 @@ var valid_source = platformTag.findall('./source-file'),
     valid_assets = plugin_et.findall('./asset'),
     valid_headers = platformTag.findall('./header-file'),
     valid_resources = platformTag.findall('./resource-file'),
+    valid_custom_frameworks = platformTag.findall('./framework[@custom="true"]'),
     valid_frameworks = platformTag.findall('./framework'),
     plist_els = platformTag.findall('./plugins-plist'),
     dummy_configs = platformTag.findall('./config-file');
@@ -52,6 +53,7 @@ var invalid_assets = plugin_et.findall('./asset');
 var invalid_source = platformTag.findall('./source-file');
 var invalid_headers = platformTag.findall('./header-file');
 var invalid_resources = platformTag.findall('./resource-file');
+var invalid_custom_frameworks = platformTag.findall('./framework[@custom="true"]');
 var invalid_frameworks = platformTag.findall('./framework');
 
 xml_path = path.join(plistplugin, 'plugin.xml');
@@ -240,6 +242,39 @@ describe('ios project handler', function() {
                 expect(spy).toHaveBeenCalledWith('-R', path.join(dummyplugin, 'src', 'ios',
'DummyPlugin.bundle'), path.join(temp, 'SampleApp', 'Resources'));
             });
         });
+        describe('of <framework custom="true"> elements', function() {
+            beforeEach(function() {
+                shell.cp('-rf', ios_config_xml_project, temp);
+            });
+            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);
+                }).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');
+                expect(function() {
+                    ios['framework'].install(frameworks[0], dummyplugin, temp, 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});
+            });
+            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);
+                expect(spy).toHaveBeenCalledWith('-R', path.join(dummyplugin, 'src', 'ios',
'Custom.framework'),
+                                                 path.join(temp, 'Custom.framework'));
+            });
+        });
     });
 
     describe('uninstallation', function() {
@@ -331,5 +366,24 @@ describe('ios project handler', function() {
                 expect(spy).toHaveBeenCalledWith('-rf', path.join(temp, 'SampleApp', 'Resources',
'DummyPlugin.bundle'));
             });
         });
+        describe('of <framework custom="true"> elements', function() {
+            beforeEach(function() {
+                shell.cp('-rf', ios_config_xml_project, temp);
+            });
+            it('should call into xcodeproj\'s removeFramework', 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});
+            });
+            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'));
+            });
+        });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/spec/plugins/ChildBrowser/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/ChildBrowser/plugin.xml b/spec/plugins/ChildBrowser/plugin.xml
index 512c02f..2dfd692 100644
--- a/spec/plugins/ChildBrowser/plugin.xml
+++ b/spec/plugins/ChildBrowser/plugin.xml
@@ -105,6 +105,7 @@
         <framework src="libsqlite3.dylib" />
         <framework src="social.framework" weak="true" />
         <framework src="music.framework" weak="rabbit" />
+        <framework src="Custom.framework" custom="true" />
     </platform>
     <!-- wp7 -->
     <platform name="wp7">

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/spec/plugins/DummyPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/DummyPlugin/plugin.xml b/spec/plugins/DummyPlugin/plugin.xml
index fad5072..ef7fe8d 100644
--- a/spec/plugins/DummyPlugin/plugin.xml
+++ b/spec/plugins/DummyPlugin/plugin.xml
@@ -105,6 +105,7 @@
         <!-- framework for testing (not actual dependency of DummyPlugin -->
         <framework src="src/ios/libsqlite3.dylib" />
         <framework src="src/ios/libsqlite3.dylib" weak="true" />
+        <framework src="src/ios/Custom.framework" custom="true" />
     </platform>
 
     <!-- wp7 -->

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/spec/plugins/DummyPlugin/src/ios/Custom.framework/someFheader.h
----------------------------------------------------------------------
diff --git a/spec/plugins/DummyPlugin/src/ios/Custom.framework/someFheader.h b/spec/plugins/DummyPlugin/src/ios/Custom.framework/someFheader.h
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/spec/plugins/DummyPlugin/src/ios/Custom.framework/somebinlib
----------------------------------------------------------------------
diff --git a/spec/plugins/DummyPlugin/src/ios/Custom.framework/somebinlib b/spec/plugins/DummyPlugin/src/ios/Custom.framework/somebinlib
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/spec/plugins/FaultyPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/FaultyPlugin/plugin.xml b/spec/plugins/FaultyPlugin/plugin.xml
index 30af6e7..33c4493 100644
--- a/spec/plugins/FaultyPlugin/plugin.xml
+++ b/spec/plugins/FaultyPlugin/plugin.xml
@@ -77,6 +77,7 @@
         <source-file src="src/ios/FaultyPluginCommand.m" />
         <resource-file src="src/ios/IDontExist.bundle" />
         <framework src="src/ios/Nopers.lib" />
+        <framework src="src/ios/NonExistantCustomFramework.framework" custom="true" />
     </platform>
     <platform name="blackberry10">
         <config-file target="config.xml" parent="/widget">

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/spec/util/config-changes.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/config-changes.spec.js b/spec/util/config-changes.spec.js
index 5e46b69..9848813 100644
--- a/spec/util/config-changes.spec.js
+++ b/spec/util/config-changes.spec.js
@@ -214,6 +214,7 @@ describe('config-changes module', function() {
                 expect(munge['framework']['libsqlite3.dylib']['false']).toBeDefined();
                 expect(munge['framework']['social.framework']['true']).toBeDefined();
                 expect(munge['framework']['music.framework']['false']).toBeDefined();
+                expect(munge['framework']['Custom.framework']).not.toBeDefined();
             });
         });
     });
@@ -313,6 +314,7 @@ describe('config-changes module', function() {
                     expect(xcode_add).toHaveBeenCalledWith('libsqlite3.dylib', {weak:false});
                     expect(xcode_add).toHaveBeenCalledWith('social.framework', {weak:true});
                     expect(xcode_add).toHaveBeenCalledWith('music.framework', {weak:false});
+                    expect(xcode_add).not.toHaveBeenCalledWith('Custom.framework');
                 });
             });
             describe('of <plugins-plist> elements', function() {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index c0a4de9..f91034a 100644
--- a/src/install.js
+++ b/src/install.js
@@ -344,6 +344,7 @@ function handleInstall(actions, plugin_id, plugin_et, platform, project_dir,
plu
         var sourceFiles = platformTag.findall('./source-file'),
             headerFiles = platformTag.findall('./header-file'),
             resourceFiles = platformTag.findall('./resource-file'),
+            frameworkFiles = platformTag.findall('./framework-file[@custom="true"]'), //
CB-5238 adding only custom frameworks
             libFiles = platformTag.findall('./lib-file');
         assets = assets.concat(platformTag.findall('./asset'));
         
@@ -359,6 +360,10 @@ function handleInstall(actions, plugin_id, plugin_et, platform, project_dir,
plu
         resourceFiles && resourceFiles.forEach(function(resource) {
             actions.push(actions.createAction(handler["resource-file"].install, [resource,
plugin_dir, project_dir], handler["resource-file"].uninstall, [resource, project_dir]));
         });
+        // 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]));
+        });
 
         libFiles && libFiles.forEach(function(lib) {
             actions.push(actions.createAction(handler["lib-file"].install, [lib, plugin_dir,
project_dir], handler["lib-file"].uninstall, [lib, project_dir]));

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/src/platforms/ios.js
----------------------------------------------------------------------
diff --git a/src/platforms/ios.js b/src/platforms/ios.js
index 065c4a7..be2b4da 100644
--- a/src/platforms/ios.js
+++ b/src/platforms/ios.js
@@ -115,6 +115,25 @@ module.exports = {
             shell.rm('-rf', destFile);
         }
     },
+    "framework":{ // CB-5238 custom frameworks only
+        install:function(framework_el, plugin_dir, project_dir, 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));
+            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, destFile);
+            project.xcode.addFramework(destFile, {customFramework: true});
+        },
+        uninstall:function(framework_el, project_dir, 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);
+        }
+    },
     parseProjectFile:function(project_dir) {
         // grab and parse pbxproj
         // we don't want CordovaLib's xcode project

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index 11ff7fb..8f5f0c8 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -150,6 +150,7 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir,
w
             headerFiles = platformTag.findall('./header-file'),
             libFiles = platformTag.findall('./lib-file'),
             resourceFiles = platformTag.findall('./resource-file');
+            frameworkFiles = platformTag.findall('./framework[@custom="true"]');
         assets = assets.concat(platformTag.findall('./asset'));
 
         // queue up native stuff
@@ -164,6 +165,11 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir,
w
         resourceFiles && resourceFiles.forEach(function(resource) {
             actions.push(actions.createAction(handler["resource-file"].uninstall, [resource,
project_dir], handler["resource-file"].install, [resource, plugin_dir, project_dir]));
         });
+        
+        // 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]));
+        });
 
         libFiles && libFiles.forEach(function(source) {
             actions.push(actions.createAction(handler["lib-file"].uninstall, [source, project_dir,
plugin_id], handler["lib-file"].install, [source, plugin_dir, project_dir, plugin_id]));

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/64fea2c8/src/util/config-changes.js
----------------------------------------------------------------------
diff --git a/src/util/config-changes.js b/src/util/config-changes.js
index 0239b61..c9f625b 100644
--- a/src/util/config-changes.js
+++ b/src/util/config-changes.js
@@ -124,21 +124,25 @@ module.exports = {
                 }
             });
             // note down pbxproj framework munges in special section of munge obj
+            // CB-5238 this is only for systems frameworks
             var frameworks = platformTag.findall('framework');
             frameworks.forEach(function(f) {
-                if (!munge['framework']) {
-                    munge['framework'] = {};
+                var custom = f.attrib['custom'];
+                if(!custom) {
+                  if (!munge['framework']) {
+                      munge['framework'] = {};
+                  }
+                  var file = f.attrib['src'];
+                  var weak = f.attrib['weak'];
+                  weak = (weak == undefined || weak == null || weak != 'true' ? 'false' :
'true');
+                  if (!munge['framework'][file]) {
+                      munge['framework'][file] = {};
+                  }
+                  if (!munge['framework'][file][weak]) {
+                      munge['framework'][file][weak] = 0;
+                  }
+                  munge['framework'][file][weak] += 1;
                 }
-                var file = f.attrib['src'];
-                var weak = f.attrib['weak'];
-                weak = (weak == undefined || weak == null || weak != 'true' ? 'false' : 'true');
-                if (!munge['framework'][file]) {
-                    munge['framework'][file] = {};
-                }
-                if (!munge['framework'][file][weak]) {
-                    munge['framework'][file][weak] = 0;
-                }
-                munge['framework'][file][weak] += 1;
             });
         }
 


Mime
View raw message