You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2016/12/23 11:09:26 UTC
cordova-windows git commit: CB-12189: Add support for WinMD and DLL
combination
Repository: cordova-windows
Updated Branches:
refs/heads/master 1cf27a9db -> ae433f675
CB-12189: Add support for WinMD and DLL combination
This closes #219
Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/ae433f67
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/ae433f67
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/ae433f67
Branch: refs/heads/master
Commit: ae433f67579d7ca4dbec8d0da419b66b2a9bccf5
Parents: 1cf27a9
Author: Vladimir <ko...@gmail.com>
Authored: Fri Dec 23 14:02:45 2016 +0300
Committer: Vladimir <ko...@gmail.com>
Committed: Fri Dec 23 14:06:12 2016 +0300
----------------------------------------------------------------------
.../testProj/plugins/testPlugin/plugin.xml | 12 +++++
.../plugins/testPlugin/src/deps/ARM/arm.dll | 0
.../plugins/testPlugin/src/deps/ARM/arm.winmd | 0
.../plugins/testPlugin/src/deps/x64/x64.UWP.dll | 0
.../plugins/testPlugin/src/deps/x64/x64.winmd | 0
.../plugins/testPlugin/src/deps/x86/x86.dll | 0
.../plugins/testPlugin/src/deps/x86/x86.winmd | 0
spec/unit/pluginHandler/windows.spec.js | 50 ++++++++++++++++++++
template/cordova/lib/JsprojManager.js | 9 +++-
template/cordova/lib/PluginHandler.js | 6 ++-
template/cordova/lib/PluginInfo.js | 29 +++++++++++-
11 files changed, 103 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/spec/unit/fixtures/testProj/plugins/testPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/unit/fixtures/testProj/plugins/testPlugin/plugin.xml b/spec/unit/fixtures/testProj/plugins/testPlugin/plugin.xml
new file mode 100644
index 0000000..c1e813d
--- /dev/null
+++ b/spec/unit/fixtures/testProj/plugins/testPlugin/plugin.xml
@@ -0,0 +1,12 @@
+<?xml version='1.0' encoding='utf-8'?>
+<plugin id="testPlugin" version="0.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+ <name>testPlugin</name>
+ <js-module name="testPlugin" src="www/testPlugin.js">
+ <clobbers target="cordova.plugins.testPlugin" />
+ </js-module>
+ <platform name="windows">
+ <framework src="src/deps/x86/x86.winmd" target-dir="x86" arch="x86" custom="true" versions="10.*" implementation="src/deps/x86/x86.dll"/>
+ <framework src="src/deps/x64/x64.winmd" target-dir="x64" arch="x64" custom="true" versions="10.*" implementation="src/deps/x64/x64.UWP.dll" />
+ <framework src="src/deps/ARM/arm.winmd" target-dir="ARM" arch="ARM" custom="true" versions="10.*" implementation="src/deps/ARM/arm.dll"/>
+ </platform>
+</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/ARM/arm.dll
----------------------------------------------------------------------
diff --git a/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/ARM/arm.dll b/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/ARM/arm.dll
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/ARM/arm.winmd
----------------------------------------------------------------------
diff --git a/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/ARM/arm.winmd b/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/ARM/arm.winmd
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x64/x64.UWP.dll
----------------------------------------------------------------------
diff --git a/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x64/x64.UWP.dll b/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x64/x64.UWP.dll
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x64/x64.winmd
----------------------------------------------------------------------
diff --git a/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x64/x64.winmd b/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x64/x64.winmd
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x86/x86.dll
----------------------------------------------------------------------
diff --git a/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x86/x86.dll b/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x86/x86.dll
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x86/x86.winmd
----------------------------------------------------------------------
diff --git a/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x86/x86.winmd b/spec/unit/fixtures/testProj/plugins/testPlugin/src/deps/x86/x86.winmd
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/spec/unit/pluginHandler/windows.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/pluginHandler/windows.spec.js b/spec/unit/pluginHandler/windows.spec.js
index 161f6f5..8793c3c 100644
--- a/spec/unit/pluginHandler/windows.spec.js
+++ b/spec/unit/pluginHandler/windows.spec.js
@@ -27,17 +27,22 @@ var rewire = require('rewire');
var PluginHandler = rewire('../../../template/cordova/lib/PluginHandler');
var JsprojManager = require('../../../template/cordova/lib/JsprojManager');
var cordovaProjectDir = path.join(os.tmpdir(), 'plugman');
+var testProjectWindowsPlatformDir = path.join(__dirname, '../fixtures/testProj', 'platforms', 'windows');
var cordovaProjectWindowsPlatformDir = path.join(cordovaProjectDir, 'platforms', 'windows');
var cordovaProjectPluginsDir = path.join(cordovaProjectDir, 'plugins');
var PluginInfo = require('cordova-common').PluginInfo;
+var pluginInfo = require('../../../template/cordova/lib/PluginInfo').PluginInfo;
var dummyplugin = path.join(__dirname, '../fixtures/testProj/plugins/org.test.plugins.dummyplugin');
+var testPlugin = path.join(__dirname, '../fixtures/testProj/plugins/testPlugin');
var dummyPluginInfo = new PluginInfo(dummyplugin);
+var testPluginInfo = new pluginInfo(testPlugin);
var valid_source = dummyPluginInfo.getSourceFiles('windows');
var valid_resourceFiles = dummyPluginInfo.getResourceFiles('windows');
var valid_libfiles = dummyPluginInfo.getLibFiles('windows');
var valid_frameworks = dummyPluginInfo.getFrameworks('windows');
+var test_frameworks = testPluginInfo.getFrameworks('windows');
var faultyplugin = path.join(__dirname, '../fixtures/org.test.plugins.faultyplugin');
var faultyPluginInfo = new PluginInfo(faultyplugin);
@@ -304,6 +309,51 @@ describe('windows project handler', function () {
xpath = 'Reference[@Include="dummy6"]/HintPath';
validateInstalledProjects('framework', frameworks[5], xpath, ['windows', 'windows10', 'phone']);
});
+
+ it('with .winmd and .dll files', function() {
+ var frameworks = copyArray(test_frameworks);
+ var install = PluginHandler.getInstaller('framework');
+ var uninstall = PluginHandler.getUninstaller('framework');
+ var testProject = JsprojManager.getProject(testProjectWindowsPlatformDir);
+
+ frameworks.forEach(function(framework) {
+ install(framework, testPluginInfo, testProject);
+ var dest = path.join('plugins', 'testPlugin', framework.targetDir || '', path.basename(framework.src));
+ if (framework.implementation) {
+ expect(copyFileSpy).toHaveBeenCalledWith(testPlugin, framework.implementation, testProjectWindowsPlatformDir, path.join(path.dirname(dest), path.basename(framework.implementation)));
+ }
+ });
+
+ var jsProjFileFromPlatform = path.join(testProjectWindowsPlatformDir, 'CordovaApp.Windows10.jsproj');
+ var searchProjects = testProject._projects.filter(function(project) {
+ return path.normalize(project.location) === jsProjFileFromPlatform;
+ });
+
+ expect(searchProjects.length).toBe(1);
+ var projectXmlTree = searchProjects[0].xml;
+
+ var refHintPaths = projectXmlTree.findall('./ItemGroup/Reference/HintPath');
+ var pathsEqual = refHintPaths.every(function(hintPath, index) {
+ return path.basename(hintPath.text) === path.basename(frameworks[index].src);
+ });
+
+ expect(pathsEqual).toBeTruthy();
+
+ var refWinMdStatus = projectXmlTree.findall('./ItemGroup/Reference/IsWinMDFile');
+ var allReferencesHaveMetadata = refWinMdStatus.every(function(isWinMd) {
+ return isWinMd.text === 'true';
+ });
+
+ expect(allReferencesHaveMetadata).toBeTruthy();
+
+ var refImplements = projectXmlTree.findall('./ItemGroup/Reference/Implementation');
+ expect(refImplements.length).toBe(1);
+ expect(refImplements[0].text).toBe(path.basename(frameworks[1].implementation));
+
+ frameworks.forEach(function(framework) {
+ uninstall(framework, testPluginInfo, testProject);
+ });
+ });
});
describe('of <framework> elements of type \'projectReference\'', function () {
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/template/cordova/lib/JsprojManager.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/JsprojManager.js b/template/cordova/lib/JsprojManager.js
index 21ee808..2a93fc1 100644
--- a/template/cordova/lib/JsprojManager.js
+++ b/template/cordova/lib/JsprojManager.js
@@ -134,7 +134,7 @@ jsprojManager.prototype = {
});
},
- addReference: function (relPath, targetConditions) {
+ addReference: function (relPath, targetConditions, implPath) {
events.emit('verbose', 'jsprojManager.addReference(incText: ' + relPath + ', targetConditions: ' + JSON.stringify(targetConditions) + ')');
// add hint path with full path
@@ -149,6 +149,13 @@ jsprojManager.prototype = {
children.push(mdFileTag);
}
+ // We only need to add <Implementation> tag when dll base name differs from winmd name
+ if (implPath && path.basename(relPath, '.winmd') !== path.basename(implPath, '.dll')) {
+ var implementTag = new et.Element('Implementation');
+ implementTag.text = path.basename(implPath);
+ children.push(implementTag);
+ }
+
var item = createItemGroupElement('ItemGroup/Reference', path.basename(relPath, extName), targetConditions, children);
this._getMatchingProjects(targetConditions).forEach(function (project) {
project.appendToRoot(item);
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/template/cordova/lib/PluginHandler.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/PluginHandler.js b/template/cordova/lib/PluginHandler.js
index e2511f6..0ba69cf 100644
--- a/template/cordova/lib/PluginHandler.js
+++ b/template/cordova/lib/PluginHandler.js
@@ -86,6 +86,7 @@ var handlers = {
var dest = src;
var type = obj.type;
var targetDir = obj.targetDir || '';
+ var implementPath = obj.implementation;
if(type === 'projectReference') {
dest = path.join(path.relative(project.projectFolder, plugin.dir), targetDir, src);
@@ -94,7 +95,10 @@ var handlers = {
// path.join ignores empty paths passed so we don't check whether targetDir is not empty
dest = path.join('plugins', plugin.id, targetDir, path.basename(src));
copyFile(plugin.dir, src, project.root, dest);
- project.addReference(dest, getTargetConditions(obj));
+ if (implementPath) {
+ copyFile(plugin.dir, implementPath, project.root, path.join(path.dirname(dest), path.basename(implementPath)));
+ }
+ project.addReference(dest, getTargetConditions(obj), implementPath);
}
},
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/ae433f67/template/cordova/lib/PluginInfo.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/PluginInfo.js b/template/cordova/lib/PluginInfo.js
index a45ee07..b0af399 100644
--- a/template/cordova/lib/PluginInfo.js
+++ b/template/cordova/lib/PluginInfo.js
@@ -97,7 +97,7 @@ function createReplacement(manifestFile, originalChange) {
/*
A class for holidng the information currently stored in plugin.xml
It's inherited from cordova-common's PluginInfo class
-In addition it overrides getConfigFiles method to use windows-specific logic
+In addition it overrides getConfigFiles, getEditConfigs, getFrameworks methods to use windows-specific logic
*/
function PluginInfo(dirname) {
// We're not using `util.inherit' because original PluginInfo defines
@@ -115,6 +115,33 @@ function PluginInfo(dirname) {
var configFiles = parentGetConfigFiles(platform);
return processChanges(configFiles);
};
+
+ this.getFrameworks = function(platform) {
+ return _getTags(this._et, 'framework', platform, function(el) {
+ var ret = {
+ itemType: 'framework',
+ type: el.attrib.type,
+ parent: el.attrib.parent,
+ custom: String(el.attrib.custom).toLowerCase() == 'true',
+ src: el.attrib.src,
+ versions: el.attrib.versions,
+ targetDir: el.attrib['target-dir'],
+ deviceTarget: el.attrib['device-target'] || el.attrib.target,
+ arch: el.attrib.arch,
+ implementation: el.attrib.implementation
+ };
+ return ret;
+ });
+ };
+}
+
+function _getTags(pelem, tag, platform, transform) {
+ var platformTag = pelem.find('./platform[@name="' + platform + '"]');
+ var tagsInPlatform = platformTag ? platformTag.findall(tag) : [];
+ if ( typeof transform === 'function' ) {
+ tagsInPlatform = tagsInPlatform.map(transform);
+ }
+ return tagsInPlatform;
}
exports.PluginInfo = PluginInfo;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org