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 2015/09/16 14:06:12 UTC
[1/3] cordova-lib git commit: CB-8615 (Windows) .winmd files with the
same names are not added properly when using framework tag with target
attribute
Repository: cordova-lib
Updated Branches:
refs/heads/master 9b476c988 -> d146af3c5
CB-8615 (Windows) .winmd files with the same names are not added properly when using framework tag with target attribute
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/ccdf9a65
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/ccdf9a65
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/ccdf9a65
Branch: refs/heads/master
Commit: ccdf9a653b6518bdff6bca6d785b776ee40b7b2e
Parents: 9b476c9
Author: sgrebnov <v-...@microsoft.com>
Authored: Thu Sep 3 19:19:28 2015 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Wed Sep 16 14:57:03 2015 +0300
----------------------------------------------------------------------
cordova-lib/src/PluginInfo.js | 1 +
cordova-lib/src/plugman/platforms/windows.js | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ccdf9a65/cordova-lib/src/PluginInfo.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/PluginInfo.js b/cordova-lib/src/PluginInfo.js
index 1802f24..78f07f7 100644
--- a/cordova-lib/src/PluginInfo.js
+++ b/cordova-lib/src/PluginInfo.js
@@ -305,6 +305,7 @@ function PluginInfo(dirname) {
src: el.attrib.src,
weak: isStrTrue(el.attrib.weak),
versions: el.attrib.versions,
+ targetDir: el.attrib['target-dir'],
deviceTarget: el.attrib['device-target'] || el.attrib.target,
arch: el.attrib.arch
};
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ccdf9a65/cordova-lib/src/plugman/platforms/windows.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/windows.js b/cordova-lib/src/plugman/platforms/windows.js
index 22d86ea..dd8aa07 100644
--- a/cordova-lib/src/plugman/platforms/windows.js
+++ b/cordova-lib/src/plugman/platforms/windows.js
@@ -118,7 +118,9 @@ module.exports = {
}
else {
// if(isCustom) {}
- dest = path.join('plugins', plugin_id, path.basename(src));
+ var targetDir = obj.targetDir || '';
+ // 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));
common.copyFile(plugin_dir, src, project_dir, dest);
project_file.addReference(dest, getTargetConditions(obj));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[3/3] cordova-lib git commit: CB-9588 Plugman. Add support for
on Windows
Posted by an...@apache.org.
CB-9588 Plugman. Add support for <resource-file> on Windows
* Also includes corresponding unit tests.
This closes #301
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/d146af3c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/d146af3c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/d146af3c
Branch: refs/heads/master
Commit: d146af3c5646272ca9d115ee9174f3a1becee21d
Parents: eefd7af
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Wed Sep 16 15:03:06 2015 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Wed Sep 16 15:03:41 2015 +0300
----------------------------------------------------------------------
.../spec-plugman/platforms/windows.spec.js | 87 ++++++++++++++++++--
.../org.test.plugins.dummyplugin/plugin.xml | 5 ++
.../src/windows/text_sample1.txt | 0
.../src/windows/text_sample2.txt | 0
.../src/windows/text_sample3.txt | 0
.../src/windows/text_sample4.txt | 0
.../org.test.plugins.faultyplugin/plugin.xml | 4 +
.../src/windows/text_sample1.txt | 0
.../src/windows/text_sample2.txt | 0
.../src/windows/text_sample3.txt | 0
cordova-lib/src/PluginInfo.js | 7 +-
cordova-lib/src/plugman/platforms/windows.js | 9 +-
cordova-lib/src/util/windows/jsprojManager.js | 52 +++++++++---
13 files changed, 143 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/platforms/windows.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/windows.spec.js b/cordova-lib/spec-plugman/platforms/windows.spec.js
index f9fe6cb..785f5b3 100644
--- a/cordova-lib/spec-plugman/platforms/windows.spec.js
+++ b/cordova-lib/spec-plugman/platforms/windows.spec.js
@@ -35,12 +35,14 @@ var PluginInfo = require('../../src/PluginInfo');
var dummyPluginInfo = new PluginInfo(dummyplugin);
var dummy_id = dummyPluginInfo.id;
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 faultyPluginInfo = new PluginInfo(faultyplugin);
var faulty_id = faultyPluginInfo.id;
var invalid_source = faultyPluginInfo.getSourceFiles('windows');
+var invalid_resourceFiles = faultyPluginInfo.getResourceFiles('windows');
var invalid_libfiles = faultyPluginInfo.getLibFiles('windows');
function copyArray(arr) {
@@ -146,15 +148,25 @@ beforeEach(function () {
expect(copiedSuccessfully).toBe(true);
};
+ // Check that resource file was copied to correct path
+ var checkInstalledResourcePath = function (resource) {
+ var dest = path.join(cordovaProjectWindowsPlatformDir, resource.target);
+ var copiedSuccessfully = fs.existsSync(path.resolve(dest));
+ expect(copiedSuccessfully).toBe(true);
+ };
+
var appendToRootFake = function (itemGroup) {
- expect(itemGroup).toContainXmlPath(xpath);
// In case we install framework with 'custom' attribute set to 'true'
// we verify that file is copied to correct dir and reference is added properly.
// This is not required in case of 'projectReference' attribute is used.
if (tag === 'framework' && elementToInstall.type !== 'projectReference') {
checkInstalledFrameworkReference(tag, elementToInstall, itemGroup);
checkInstalledFrameworkPath(elementToInstall);
+ return;
+ } else if (tag === 'resource-file') {
+ checkInstalledResourcePath(elementToInstall);
}
+ expect(itemGroup).toContainXmlPath(xpath);
};
var projectsAddedToSpies = [];
@@ -211,6 +223,41 @@ beforeEach(function () {
});
});
+ describe('of <resource-file> elements', function () {
+ var resourceFiles = copyArray(valid_resourceFiles);
+ var invalidResourceFiles = copyArray(invalid_resourceFiles);
+
+ // This could be separated into individual specs, but that results in a lot of copying and deleting the
+ // project files, which is not needed.
+ it('should write to correct project files when conditions are specified', function () {
+ var xpath = 'Content[@Include="' + resourceFiles[0].target + '"][@Condition="\'$(Platform)\'==\'x86\'"]';
+ validateInstalledProjects('resource-file', resourceFiles[0], xpath, ['all']);
+
+ xpath = 'Content[@Include="' + resourceFiles[1].target + '"]';
+ validateInstalledProjects('resource-file', resourceFiles[1], xpath, ['windows', 'phone', 'windows10']);
+
+ xpath = 'Content[@Include="' + resourceFiles[2].target + '"]';
+ validateInstalledProjects('resource-file', resourceFiles[2], xpath, ['phone']);
+
+ xpath = 'Content[@Include="' + resourceFiles[3].target + '"][@Condition="\'$(Platform)\'==\'x64\'"]';
+ validateInstalledProjects('resource-file', resourceFiles[3], xpath, ['windows8']);
+ });
+
+ it('should throw if conditions are invalid', function () {
+ expect(function () {
+ windows['resource-file'].install(invalidResourceFiles[0], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files);
+ }).toThrow('Invalid arch attribute (must be "x86", "x64" or "ARM"): x85');
+
+ expect(function () {
+ windows['resource-file'].install(invalidResourceFiles[1], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files);
+ }).toThrow('Invalid versions attribute (must be a valid a valid node semantic version range): 8.0a');
+
+ expect(function () {
+ windows['resource-file'].install(invalidResourceFiles[2], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files);
+ }).toThrow('Invalid device-target attribute (must be "all", "phone", "windows" or "win"): daphne');
+ });
+ });
+
describe('of <lib-file> elements', function () {
var libfiles = copyArray(valid_libfiles);
var invalidLibFiles = copyArray(invalid_libfiles);
@@ -234,15 +281,15 @@ beforeEach(function () {
it('should throw if conditions are invalid', function () {
expect(function () {
windows['lib-file'].install(invalidLibFiles[0], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files);
- }).toThrow('Invalid lib-file arch attribute (must be "x86", "x64" or "ARM"): x85');
+ }).toThrow('Invalid arch attribute (must be "x86", "x64" or "ARM"): x85');
expect(function () {
windows['lib-file'].install(invalidLibFiles[1], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files);
- }).toThrow('Invalid lib-file versions attribute (must be a valid a valid node semantic version range): 8.0a');
+ }).toThrow('Invalid versions attribute (must be a valid a valid node semantic version range): 8.0a');
expect(function () {
windows['lib-file'].install(invalidLibFiles[2], faultyplugin, cordovaProjectWindowsPlatformDir, faulty_id, null, proj_files);
- }).toThrow('Invalid lib-file target attribute (must be "all", "phone", "windows" or "win"): daphne');
+ }).toThrow('Invalid device-target attribute (must be "all", "phone", "windows" or "win"): daphne');
});
});
@@ -321,7 +368,7 @@ beforeEach(function () {
});
projects.forEach(function (project) {
- var spy = spyOn(project, 'removeReferenceElementItemGroup');
+ var spy = spyOn(project, 'removeItemGroupElement');
if (projectsAddedTo.indexOf(path.basename(project.location)) > -1) {
projectsAddedToSpies.push(spy);
} else {
@@ -354,6 +401,36 @@ beforeEach(function () {
});
});
+ describe('of <resource-file> elements', function () {
+ // This could be separated into individual specs, but that results in a lot of copying and deleting the
+ // project files, which is not needed.
+ it('should remove from correct project files when conditions specified', function (done) {
+ var resourcefiles = copyArray(valid_resourceFiles);
+
+ install('windows', cordovaProjectWindowsPlatformDir, dummyplugin, cordovaProjectPluginsDir, {})
+ .then(function () {
+ var path = 'ItemGroup/Content';
+ var incText = resourcefiles[0].target;
+ var targetConditions = {versions: undefined, deviceTarget: undefined, arch: 'x86'};
+ validateUninstalledProjects('resource-file', resourcefiles[0], path, incText, targetConditions, ['all']);
+
+ incText = resourcefiles[1].target;
+ targetConditions = {versions: '>=8.1', deviceTarget: undefined, arch: undefined};
+ validateUninstalledProjects('resource-file', resourcefiles[1], path, incText, targetConditions, ['windows', 'phone', 'windows10']);
+
+ incText = resourcefiles[2].target;
+ targetConditions = {versions: undefined, deviceTarget: 'phone', arch: undefined};
+ validateUninstalledProjects('resource-file', resourcefiles[2], path, incText, targetConditions, ['phone']);
+
+ incText = resourcefiles[3].target;
+ targetConditions = {versions: '8.0', deviceTarget: 'windows', arch: 'x64'};
+ validateUninstalledProjects('resource-file', resourcefiles[3], path, incText, targetConditions, ['windows8']);
+
+ done();
+ });
+ });
+ });
+
describe('of <lib-file> elements', function () {
// This could be separated into individual specs, but that results in a lot of copying and deleting the
// project files, which is not needed.
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
index b8c4ec5..b2d7f75 100644
--- a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
+++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
@@ -183,6 +183,11 @@
<source-file src="src/windows/dummer.js"/>
+ <resource-file src="src/windows/text_sample1.txt" target="text_samples/text_sample1.txt" arch="x86" />
+ <resource-file src="src/windows/text_sample2.txt" target="text_samples/text_sample2.txt" versions=">=8.1" />
+ <resource-file src="src/windows/text_sample3.txt" target="text_samples/text_sample3.txt" device-target="phone"/>
+ <resource-file src="src/windows/text_sample4.txt" target="text_samples/text_sample4.txt" device-target="windows" versions="8.0" arch="x64"/>
+
<lib-file src="TestSDK1, Version=1.0" arch="x86"/>
<lib-file src="TestSDK2, Version=1.0" versions=">=8.1"/>
<lib-file src="TestSDK3, Version=1.0" device-target="phone"/>
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample1.txt
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample1.txt b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample1.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample2.txt
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample2.txt b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample2.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample3.txt
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample3.txt b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample3.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample4.txt
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample4.txt b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/text_sample4.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml b/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml
index abe2f2e..78f037f 100644
--- a/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml
+++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml
@@ -141,6 +141,10 @@
<source-file src="src/windows/faultyPlugin.js" />
+ <resource-file src="src/windows/text_sample1.txt" target="text_samples/text_sample1.txt" arch="x85" />
+ <resource-file src="src/windows/text_sample2.txt" target="text_samples/text_sample2.txt" versions="8.0a" />
+ <resource-file src="src/windows/text_sample3.txt" target="text_samples/text_sample3.txt" device-target="daphne"/>
+
<lib-file src="TestSDK1, Version=1.0" arch="x85"/>
<lib-file src="TestSDK2, Version=1.0" versions="8.0a"/>
<lib-file src="TestSDK3, Version=1.0" device-target="daphne"/>
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/src/windows/text_sample1.txt
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/src/windows/text_sample1.txt b/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/src/windows/text_sample1.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/src/windows/text_sample2.txt
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/src/windows/text_sample2.txt b/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/src/windows/text_sample2.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/src/windows/text_sample3.txt
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/src/windows/text_sample3.txt b/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/src/windows/text_sample3.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/src/PluginInfo.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/PluginInfo.js b/cordova-lib/src/PluginInfo.js
index 78f07f7..8e75d4a 100644
--- a/cordova-lib/src/PluginInfo.js
+++ b/cordova-lib/src/PluginInfo.js
@@ -203,14 +203,17 @@ function PluginInfo(dirname) {
// <resource-file>
// Example:
- // <resource-file src="FooPluginStrings.xml" target="res/values/FooPluginStrings.xml" />
+ // <resource-file src="FooPluginStrings.xml" target="res/values/FooPluginStrings.xml" device-target="win" arch="x86" versions=">=8.1" />
self.getResourceFiles = getResourceFiles;
function getResourceFiles(platform) {
var resourceFiles = _getTagsInPlatform(self._et, 'resource-file', platform, function(tag) {
return {
itemType: 'resource-file',
src: tag.attrib.src,
- target: tag.attrib.target
+ target: tag.attrib.target,
+ versions: tag.attrib.versions,
+ deviceTarget: tag.attrib['device-target'],
+ arch: tag.attrib.arch
};
});
return resourceFiles;
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/src/plugman/platforms/windows.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/windows.js b/cordova-lib/src/plugman/platforms/windows.js
index dd8aa07..7dd6ce8 100644
--- a/cordova-lib/src/plugman/platforms/windows.js
+++ b/cordova-lib/src/plugman/platforms/windows.js
@@ -87,9 +87,16 @@ module.exports = {
},
'resource-file':{
install:function(obj, plugin_dir, project_dir, plugin_id, options, project_file) {
- events.emit('verbose', 'resource-file is not supported for Windows');
+ var src = obj.src;
+ var dest = obj.target;
+ // as per specification resource-file target is specified relative to platform root
+ common.copyFile(plugin_dir, src, project_dir, dest);
+ project_file.addResourceFileToProject(dest, getTargetConditions(obj));
},
uninstall:function(obj, project_dir, plugin_id, options, project_file) {
+ var dest = obj.target;
+ common.removeFile(project_dir, dest);
+ project_file.removeResourceFileFromProject(dest, getTargetConditions(obj));
}
},
'lib-file': {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d146af3c/cordova-lib/src/util/windows/jsprojManager.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/util/windows/jsprojManager.js b/cordova-lib/src/util/windows/jsprojManager.js
index eda78a2..e7a68c9 100644
--- a/cordova-lib/src/util/windows/jsprojManager.js
+++ b/cordova-lib/src/util/windows/jsprojManager.js
@@ -74,7 +74,7 @@ jsprojManager.prototype = {
addSDKRef: function (incText, targetConditions) {
events.emit('verbose', 'jsprojManager.addSDKRef(incText: ' + incText + ', targetConditions: ' + JSON.stringify(targetConditions) + ')');
- var item = createReferenceElement('ItemGroup/SDKReference', incText, targetConditions);
+ var item = createItemGroupElement('ItemGroup/SDKReference', incText, targetConditions);
this._getMatchingProjects(targetConditions).forEach(function (project) {
project.appendToRoot(item);
});
@@ -84,7 +84,33 @@ jsprojManager.prototype = {
events.emit('verbose', 'jsprojManager.removeSDKRef(incText: ' + incText + ', targetConditions: ' + JSON.stringify(targetConditions) + ')');
this._getMatchingProjects(targetConditions).forEach(function (project) {
- project.removeReferenceElementItemGroup('ItemGroup/SDKReference', incText, targetConditions);
+ project.removeItemGroupElement('ItemGroup/SDKReference', incText, targetConditions);
+ });
+ },
+
+ addResourceFileToProject: function (relPath, targetConditions) {
+ events.emit('verbose', 'jsprojManager.addResourceFile(relPath: ' + relPath + ', targetConditions: ' + JSON.stringify(targetConditions) + ')');
+
+ // add hint path with full path
+ var link = new et.Element('Link');
+ link.text = relPath;
+ var children = [link];
+
+ var copyToOutputDirectory = new et.Element('CopyToOutputDirectory');
+ copyToOutputDirectory.text = 'Always';
+ children.push(copyToOutputDirectory);
+
+ var item = createItemGroupElement('ItemGroup/Content', relPath, targetConditions, children);
+ this._getMatchingProjects(targetConditions).forEach(function (project) {
+ project.appendToRoot(item);
+ });
+ },
+
+ removeResourceFileFromProject: function (relPath, targetConditions) {
+ events.emit('verbose', 'jsprojManager.removeResourceFile(relPath: ' + relPath + ', targetConditions: ' + JSON.stringify(targetConditions) + ')');
+
+ this._getMatchingProjects(targetConditions).forEach(function (project) {
+ project.removeItemGroupElement('ItemGroup/Content', relPath, targetConditions);
});
},
@@ -103,7 +129,7 @@ jsprojManager.prototype = {
children.push(mdFileTag);
}
- var item = createReferenceElement('ItemGroup/Reference', path.basename(relPath, extName), targetConditions, children);
+ var item = createItemGroupElement('ItemGroup/Reference', path.basename(relPath, extName), targetConditions, children);
this._getMatchingProjects(targetConditions).forEach(function (project) {
project.appendToRoot(item);
});
@@ -117,7 +143,7 @@ jsprojManager.prototype = {
var includeText = path.basename(relPath, extName);
this._getMatchingProjects(targetConditions).forEach(function (project) {
- project.removeReferenceElementItemGroup('ItemGroup/Reference', includeText, targetConditions);
+ project.removeItemGroupElement('ItemGroup/Reference', includeText, targetConditions);
});
},
@@ -205,7 +231,7 @@ jsprojManager.prototype = {
// Add the ItemGroup/ProjectReference to each matching cordova project :
// <ItemGroup><ProjectReference Include="blahblah.csproj"/></ItemGroup>
- var item = createReferenceElement('ItemGroup/ProjectReference', inserted_path, targetConditions);
+ var item = createItemGroupElement('ItemGroup/ProjectReference', inserted_path, targetConditions);
matchingProjects.forEach(function (project) {
project.appendToRoot(item);
});
@@ -252,14 +278,14 @@ jsprojManager.prototype = {
});
this._getMatchingProjects(targetConditions).forEach(function (project) {
- project.removeReferenceElementItemGroup('ItemGroup/ProjectReference', inserted_path, targetConditions);
+ project.removeItemGroupElement('ItemGroup/ProjectReference', inserted_path, targetConditions);
});
},
_getMatchingProjects: function (targetConditions) {
// If specified, target can be 'all' (default), 'phone' or 'windows'. Ultimately should probably allow a comma
// separated list, but not needed now.
- var target = getTarget(targetConditions);
+ var target = getDeviceTarget(targetConditions);
var versions = getVersions(targetConditions);
if (target || versions) {
@@ -336,7 +362,7 @@ function getProjectTypeGuid(projectPath) {
return null;
}
-function createReferenceElement(path, incText, targetConditions, children) {
+function createItemGroupElement(path, incText, targetConditions, children) {
path = path.split('/');
path.reverse();
@@ -365,7 +391,7 @@ function createReferenceElement(path, incText, targetConditions, children) {
return lastElement;
}
-function getTarget(targetConditions) {
+function getDeviceTarget(targetConditions) {
var target = targetConditions.deviceTarget;
if (target) {
target = target.toLowerCase().trim();
@@ -375,7 +401,7 @@ function getTarget(targetConditions) {
// Allow "win" as alternative to "windows"
target = "windows";
} else if (target !== 'phone' && target !== 'windows') {
- throw new Error('Invalid lib-file target attribute (must be "all", "phone", "windows" or "win"): ' + target);
+ throw new Error('Invalid device-target attribute (must be "all", "phone", "windows" or "win"): ' + target);
}
}
return target;
@@ -384,7 +410,7 @@ function getTarget(targetConditions) {
function getVersions(targetConditions) {
var versions = targetConditions.versions;
if (versions && !semver.validRange(versions, /* loose */ true)) {
- throw new Error('Invalid lib-file versions attribute (must be a valid a valid node semantic version range): ' + versions);
+ throw new Error('Invalid versions attribute (must be a valid semantic version range): ' + versions);
}
return versions;
}
@@ -411,7 +437,7 @@ proj.prototype = {
this.xml.getroot().append(element);
},
- removeReferenceElementItemGroup: function (path, incText, targetConditions) {
+ removeItemGroupElement: function (path, incText, targetConditions) {
var xpath = path + '[@Include="' + incText + '"]';
var condition = createConditionAttrib(targetConditions);
if (condition) {
@@ -554,7 +580,7 @@ function createConditionAttrib(targetConditions) {
// Specifcally allow "arm" as alternative to "ARM"
arch = "ARM";
} else if (arch !== "x86" && arch !== "x64" && arch !== "ARM") {
- throw new Error('Invalid lib-file arch attribute (must be "x86", "x64" or "ARM"): ' + arch);
+ throw new Error('Invalid arch attribute (must be "x86", "x64" or "ARM"): ' + arch);
}
return "'$(Platform)'=='" + arch + "'";
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/3] cordova-lib git commit: CB-8615 Improves plugman tests for
Windows
Posted by an...@apache.org.
CB-8615 Improves plugman tests for Windows
* Adds Windows10 project to tests
* Verifies <framework> copy dir
* Verifies <framework> reference string
* Adds tests for target-dir and versions attributes
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/eefd7af6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/eefd7af6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/eefd7af6
Branch: refs/heads/master
Commit: eefd7af6589525c1d9f35ca884dec52c1c10b3b2
Parents: ccdf9a6
Author: sgrebnov <v-...@microsoft.com>
Authored: Fri Sep 4 21:12:43 2015 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Wed Sep 16 14:57:04 2015 +0300
----------------------------------------------------------------------
.../spec-plugman/platforms/windows.spec.js | 68 ++++++++++++++++----
.../org.test.plugins.dummyplugin/plugin.xml | 2 +
.../src/windows/dummy5.dll | 0
.../src/windows/dummy6.dll | 0
.../windows/CordovaApp.Windows10.jsproj | 61 ++++++++++++++++++
5 files changed, 118 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/eefd7af6/cordova-lib/spec-plugman/platforms/windows.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/windows.spec.js b/cordova-lib/spec-plugman/platforms/windows.spec.js
index ddaa9ce..f9fe6cb 100644
--- a/cordova-lib/spec-plugman/platforms/windows.spec.js
+++ b/cordova-lib/spec-plugman/platforms/windows.spec.js
@@ -73,7 +73,8 @@ beforeEach(function () {
all: 'CordovaApp.projitems',
phone: 'CordovaApp.Phone.jsproj',
windows: 'CordovaApp.Windows.jsproj',
- windows8: 'CordovaApp.Windows80.jsproj'
+ windows8: 'CordovaApp.Windows80.jsproj',
+ windows10: 'CordovaApp.Windows10.jsproj'
}, windows8: {
all: 'TestApp.jsproj',
windows8: 'TestApp.jsproj'
@@ -125,8 +126,35 @@ beforeEach(function () {
projects.push(proj_files.master);
}
+ // Check that installed framework reference is properly added to project.
+ var checkInstalledFrameworkReference = function (tag, elementToInstall, xml) {
+ var frameworkCustomPathElement = xml.find(xpath);
+ expect(frameworkCustomPathElement).not.toBe(null);
+ var frameworkCustomPath = frameworkCustomPathElement.text;
+ expect(frameworkCustomPath).not.toBe(null);
+ var targetDir = elementToInstall.targetDir || '';
+ var frameworkCustomExpectedPath = path.join('plugins', dummy_id, targetDir,
+ path.basename(elementToInstall.src));
+ expect(frameworkCustomPath).toEqual(frameworkCustomExpectedPath);
+ };
+
+ // Check that framework file was copied to correct path
+ var checkInstalledFrameworkPath = function (framework) {
+ var targetDir = framework.targetDir || '';
+ var dest = path.join(cordovaProjectWindowsPlatformDir, 'plugins', dummy_id, targetDir, path.basename(framework.src));
+ var copiedSuccessfully = fs.existsSync(path.resolve(dest));
+ expect(copiedSuccessfully).toBe(true);
+ };
+
var appendToRootFake = function (itemGroup) {
expect(itemGroup).toContainXmlPath(xpath);
+ // In case we install framework with 'custom' attribute set to 'true'
+ // we verify that file is copied to correct dir and reference is added properly.
+ // This is not required in case of 'projectReference' attribute is used.
+ if (tag === 'framework' && elementToInstall.type !== 'projectReference') {
+ checkInstalledFrameworkReference(tag, elementToInstall, itemGroup);
+ checkInstalledFrameworkPath(elementToInstall);
+ }
};
var projectsAddedToSpies = [];
@@ -194,7 +222,7 @@ beforeEach(function () {
validateInstalledProjects('lib-file', libfiles[0], xpath, ['all']);
xpath = 'SDKReference[@Include="TestSDK2, Version=1.0"]';
- validateInstalledProjects('lib-file', libfiles[1], xpath, ['windows', 'phone']);
+ validateInstalledProjects('lib-file', libfiles[1], xpath, ['windows', 'phone', 'windows10']);
xpath = 'SDKReference[@Include="TestSDK3, Version=1.0"]';
validateInstalledProjects('lib-file', libfiles[2], xpath, ['phone']);
@@ -231,10 +259,16 @@ beforeEach(function () {
validateInstalledProjects('framework', frameworks[1], xpath, ['all']);
xpath = 'Reference[@Include="dummy3"]/HintPath';
- validateInstalledProjects('framework', frameworks[2], xpath, ['windows', 'windows8']);
+ validateInstalledProjects('framework', frameworks[2], xpath, ['windows', 'windows8', 'windows10']);
xpath = 'Reference[@Include="dummy4"][@Condition="\'$(Platform)\'==\'ARM\'"]/HintPath';
validateInstalledProjects('framework', frameworks[3], xpath, ['phone']);
+
+ xpath = 'Reference[@Include="dummy5"]/HintPath';
+ validateInstalledProjects('framework', frameworks[4], xpath, ['phone']);
+
+ xpath = 'Reference[@Include="dummy6"]/HintPath';
+ validateInstalledProjects('framework', frameworks[5], xpath, ['windows', 'windows10', 'phone']);
});
});
@@ -243,16 +277,16 @@ beforeEach(function () {
it('should write to correct project files when conditions are specified', function () {
var xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy1.vcxproj') + '"][@Condition="\'$(Platform)\'==\'x64\'"]';
- validateInstalledProjects('framework', frameworks[4], xpath, ['all']);
+ validateInstalledProjects('framework', frameworks[6], xpath, ['all']);
xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy2.vcxproj') + '"]';
- validateInstalledProjects('framework', frameworks[5], xpath, ['windows8']);
+ validateInstalledProjects('framework', frameworks[7], xpath, ['windows8']);
xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy3.vcxproj') + '"]';
- validateInstalledProjects('framework', frameworks[6], xpath, ['windows', 'windows8']);
+ validateInstalledProjects('framework', frameworks[8], xpath, ['windows', 'windows8', 'windows10']);
xpath = 'ProjectReference[@Include="' + windowsJoin(dummyplugin, 'src', 'windows', 'dummy4.vcxproj') + '"][@Condition="\'$(Platform)\'==\'x86\'"]';
- validateInstalledProjects('framework', frameworks[7], xpath, ['windows', 'phone']);
+ validateInstalledProjects('framework', frameworks[9], xpath, ['windows', 'phone']);
});
});
});
@@ -335,7 +369,7 @@ beforeEach(function () {
incText = 'TestSDK2, Version=1.0';
targetConditions = {versions: '>=8.1', deviceTarget: undefined, arch: undefined};
- validateUninstalledProjects('lib-file', libfiles[1], path, incText, targetConditions, ['windows', 'phone']);
+ validateUninstalledProjects('lib-file', libfiles[1], path, incText, targetConditions, ['windows', 'phone', 'windows10']);
incText = 'TestSDK3, Version=1.0';
targetConditions = {versions: undefined, deviceTarget: 'phone', arch: undefined};
@@ -369,12 +403,20 @@ beforeEach(function () {
incText = 'dummy3';
targetConditions = {versions: undefined, deviceTarget: 'windows', arch: undefined};
- validateUninstalledProjects('framework', frameworks[2], path, incText, targetConditions, ['windows', 'windows8']);
+ validateUninstalledProjects('framework', frameworks[2], path, incText, targetConditions, ['windows', 'windows8', 'windows10']);
incText = 'dummy4';
targetConditions = {versions: '8.1', deviceTarget: 'phone', arch: 'ARM'};
validateUninstalledProjects('framework', frameworks[3], path, incText, targetConditions, ['phone']);
+ incText = 'dummy5';
+ targetConditions = {versions: undefined, deviceTarget: 'phone', arch: undefined};
+ validateUninstalledProjects('framework', frameworks[4], path, incText, targetConditions, ['phone']);
+
+ incText = 'dummy6';
+ targetConditions = {versions: '>=8.1', deviceTarget: undefined, arch: undefined};
+ validateUninstalledProjects('framework', frameworks[5], path, incText, targetConditions, ['windows', 'windows10', 'phone']);
+
done();
});
});
@@ -391,19 +433,19 @@ beforeEach(function () {
var xmlPath = 'ItemGroup/ProjectReference';
var incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy1.vcxproj');
var targetConditions = {versions: undefined, deviceTarget: undefined, arch: 'x64'};
- validateUninstalledProjects('framework', frameworks[4], xmlPath, incText, targetConditions, ['all']);
+ validateUninstalledProjects('framework', frameworks[6], xmlPath, incText, targetConditions, ['all']);
incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy2.vcxproj');
targetConditions = {versions: '<8.1', deviceTarget: undefined, arch: undefined};
- validateUninstalledProjects('framework', frameworks[5], xmlPath, incText, targetConditions, ['windows8']);
+ validateUninstalledProjects('framework', frameworks[7], xmlPath, incText, targetConditions, ['windows8']);
incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy3.vcxproj');
targetConditions = {versions: undefined, deviceTarget: 'win', arch: undefined};
- validateUninstalledProjects('framework', frameworks[6], xmlPath, incText, targetConditions, ['windows', 'windows8']);
+ validateUninstalledProjects('framework', frameworks[8], xmlPath, incText, targetConditions, ['windows', 'windows8', 'windows10']);
incText = windowsJoin(cordovaProjectPluginsDir , dummy_id, 'src', 'windows', 'dummy4.vcxproj');
targetConditions = {versions: '8.1', deviceTarget: 'all', arch: 'x86'};
- validateUninstalledProjects('framework', frameworks[7], xmlPath, incText, targetConditions, ['windows', 'phone']);
+ validateUninstalledProjects('framework', frameworks[9], xmlPath, incText, targetConditions, ['windows', 'phone']);
done();
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/eefd7af6/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
index 02bb445..b8c4ec5 100644
--- a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
+++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
@@ -192,6 +192,8 @@
<framework src="src/windows/dummy2.dll" versions=">=8.0"/>
<framework src="src/windows/dummy3.dll" device-target="windows"/>
<framework src="src/windows/dummy4.dll" device-target="phone" versions="8.1" arch="ARM"/>
+ <framework src="src/windows/dummy5.dll" custom="true" target-dir="phoneDir" device-target="phone" />
+ <framework src="src/windows/dummy6.dll" custom="true" target-dir="sharedDir" versions=">=8.1" />
<framework src="src/windows/dummy1.vcxproj" type="projectReference" arch="x64"/>
<framework src="src/windows/dummy2.vcxproj" type="projectReference" versions="<8.1"/>
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/eefd7af6/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/dummy5.dll
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/dummy5.dll b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/dummy5.dll
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/eefd7af6/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/dummy6.dll
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/dummy6.dll b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/src/windows/dummy6.dll
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/eefd7af6/cordova-lib/spec-plugman/projects/windows/CordovaApp.Windows10.jsproj
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/projects/windows/CordovaApp.Windows10.jsproj b/cordova-lib/spec-plugman/projects/windows/CordovaApp.Windows10.jsproj
new file mode 100644
index 0000000..e4b9b06
--- /dev/null
+++ b/cordova-lib/spec-plugman/projects/windows/CordovaApp.Windows10.jsproj
@@ -0,0 +1,61 @@
+<?xml version='1.0' encoding='utf-8'?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <OutputPath>build\windows\$(Configuration)\$(Platform)\</OutputPath>
+ <IntermediateOutputPath>build\windows\bld\</IntermediateOutputPath>
+ <AppxPackageSigningEnabled>true</AppxPackageSigningEnabled>
+ </PropertyGroup>
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|AnyCPU">
+ <Configuration>Debug</Configuration>
+ <Platform>AnyCPU</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x86">
+ <Configuration>Debug</Configuration>
+ <Platform>x86</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|AnyCPU">
+ <Configuration>Release</Configuration>
+ <Platform>AnyCPU</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x86">
+ <Configuration>Release</Configuration>
+ <Platform>x86</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>f9b0ae20-c91c-42b9-9c6e-d3bc28b4509e</ProjectGuid>
+ </PropertyGroup>
+ <Import Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
+ <PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0'">
+ <VisualStudioVersion>14.0</VisualStudioVersion>
+ </PropertyGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
+ <PropertyGroup>
+ <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
+ <TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
+ <TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
+ <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(VisualStudioVersion)' < '14.0'">
+ <TargetPlatformVersion>10.0</TargetPlatformVersion>
+ <TargetPlatformMinVersion>10.0</TargetPlatformMinVersion>
+ </PropertyGroup>
+</Project>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org