summaryrefslogtreecommitdiffstats
path: root/qmake/generators
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2013-12-26 16:17:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-07 10:55:40 +0100
commitf59dfe3e633c5b9fdc78c0897617be47a553a064 (patch)
tree5f9f95fa3b9b24e9fe68fe587b296855884eccd4 /qmake/generators
parent2984ef35c5d1277896b9f440ff8c226fdb98f9ac (diff)
qmake vcproj generator: Add app manifest for WinRT projects
When creating a MSVC project file for WinRT/WinPhone, the package manifest and all referenced icons should be automatically added as content items. Task-number: QTBUG-35328 Change-Id: Id7f34388c5ba6746392ddadbb795ef47bef34af6 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'qmake/generators')
-rw-r--r--qmake/generators/win32/msbuild_objectmodel.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp
index f5a6e15a7b..1b18c8e91f 100644
--- a/qmake/generators/win32/msbuild_objectmodel.cpp
+++ b/qmake/generators/win32/msbuild_objectmodel.cpp
@@ -613,12 +613,16 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)
<< tag("ItemGroup")
<< attrTag("Label", "ProjectConfigurations");
+ bool isWinRT = false;
+ bool isPhone = false;
for (int i = 0; i < tool.SingleProjects.count(); ++i) {
xml << tag("ProjectConfiguration")
<< attrTag("Include" , tool.SingleProjects.at(i).Configuration.Name)
<< tagValue("Configuration", tool.SingleProjects.at(i).Configuration.ConfigurationName)
<< tagValue("Platform", tool.SingleProjects.at(i).PlatformName)
<< closetag();
+ isWinRT = isWinRT || tool.SingleProjects.at(i).Configuration.WinRT;
+ isPhone = isPhone || tool.SingleProjects.at(i).Configuration.WinPhone;
}
xml << closetag()
@@ -823,9 +827,43 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)
<< closetag();
}
+ // App manifest
+ if (isWinRT) {
+ QString manifest = isPhone ? QStringLiteral("WMAppManifest.xml") : QStringLiteral("Package.appxmanifest");
+
+ // Find all icons referenced in the manifest
+ QSet<QString> icons;
+ QFile manifestFile(manifest);
+ if (manifestFile.open(QFile::ReadOnly)) {
+ const QString contents = manifestFile.readAll();
+ QRegExp regexp("[\\\\/a-zA-Z0-9_\\-\\!]*\\.(png|jpg|jpeg)");
+ int pos = 0;
+ while (pos > -1) {
+ pos = regexp.indexIn(contents, pos);
+ if (pos >= 0) {
+ const QString match = regexp.cap(0);
+ icons.insert(match);
+ pos += match.length();
+ }
+ }
+ }
+
+ // Write out manifest + icons as content items
+ xml << tag(_ItemGroup)
+ << tag(isPhone ? "Xml" : "AppxManifest")
+ << attrTag("Include", manifest)
+ << closetag();
+ foreach (const QString &icon, icons) {
+ xml << tag("Image")
+ << attrTag("Include", icon)
+ << closetag();
+ }
+ xml << closetag();
+ }
+
xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");
- if (tool.SingleProjects.at(0).Configuration.WinPhone)
+ if (isPhone)
xml << import("Project", "$(MSBuildExtensionsPath)\\Microsoft\\WindowsPhone\\v8.0\\Microsoft.Cpp.WindowsPhone.8.0.targets");
xml << tag("ImportGroup")