From f59dfe3e633c5b9fdc78c0897617be47a553a064 Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Thu, 26 Dec 2013 16:17:48 +0200 Subject: 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 --- qmake/generators/win32/msbuild_objectmodel.cpp | 40 +++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'qmake') 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 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") -- cgit v1.2.3