From 4bbbe06bef637e97f67db8b0b31bffb9cdd849d3 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 12 Feb 2013 00:25:23 +0100 Subject: qmake: added file deployment support for winrt and winphone targets The user needs to specify the DEPLOYMENT variable. The syntax is the same as previously used for DEPLOYMENT. For more info please refer to the qmake documentation. The change adds a new itemgroup, "Deployment Files". All files in this itemgroup are marked as DeploymentContent and are then packaged with the application either as XAP or the WinRT specific file format. Change-Id: Icf85887287c1c97eb782704340eaa3f8dde6719e Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msbuild_objectmodel.cpp | 29 ++++- qmake/generators/win32/msvc_objectmodel.cpp | 6 + qmake/generators/win32/msvc_objectmodel.h | 1 + qmake/generators/win32/msvc_vcproj.cpp | 146 +++++++++++++++---------- qmake/generators/win32/msvc_vcproj.h | 1 + 5 files changed, 123 insertions(+), 60 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 0c29008610..ff7779f79f 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -568,6 +568,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) addFilters(tempProj, xmlFilter, "Resource Files"); addFilters(tempProj, xmlFilter, "Source Files"); addFilters(tempProj, xmlFilter, "Translation Files"); + addFilters(tempProj, xmlFilter, "Deployment Files"); for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) addFilters(tempProj, xmlFilter, tempProj.ExtraCompilers.at(x)); @@ -581,6 +582,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) outputFilter(tempProj, xml, xmlFilter, "Translation Files"); outputFilter(tempProj, xml, xmlFilter, "Form Files"); outputFilter(tempProj, xml, xmlFilter, "Resource Files"); + outputFilter(tempProj, xml, xmlFilter, "Deployment Files"); for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { outputFilter(tempProj, xml, xmlFilter, tempProj.ExtraCompilers.at(x)); @@ -790,6 +792,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) addFilters(tool, xmlFilter, "Resource Files"); addFilters(tool, xmlFilter, "Source Files"); addFilters(tool, xmlFilter, "Translation Files"); + addFilters(tool, xmlFilter, "Deployment Files"); for (int x = 0; x < tool.ExtraCompilers.count(); ++x) addFilters(tool, xmlFilter, tool.ExtraCompilers.at(x)); @@ -803,6 +806,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) outputFilter(tool, xml, xmlFilter, "Translation Files"); outputFilter(tool, xml, xmlFilter, "Form Files"); outputFilter(tool, xml, xmlFilter, "Resource Files"); + outputFilter(tool, xml, xmlFilter, "Deployment Files"); for (int x = 0; x < tool.ExtraCompilers.count(); ++x) { outputFilter(tool, xml, xmlFilter, tool.ExtraCompilers.at(x)); } @@ -1728,6 +1732,8 @@ void VCXProjectWriter::addFilters(VCProject &project, XmlOutput &xmlFilter, cons filter = singleCfg.FormFiles; } else if (filtername == "Resource Files") { filter = singleCfg.ResourceFiles; + } else if (filtername == "Deployment Files") { + filter = singleCfg.DeploymentFiles; } else { // ExtraCompilers filter = project.SingleProjects[i].filterForExtraCompiler(filtername); @@ -1775,6 +1781,8 @@ void VCXProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, XmlOutpu filter = singleCfg.FormFiles; } else if (filtername == "Resource Files") { filter = singleCfg.ResourceFiles; + } else if (filtername == "Deployment Files") { + filter = singleCfg.DeploymentFiles; } else { // ExtraCompilers filter = project.SingleProjects[i].filterForExtraCompiler(filtername); @@ -1826,6 +1834,8 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml filter = singleCfg.FormFiles; } else if (filtername.startsWith("Resource Files")) { filter = singleCfg.ResourceFiles; + } else if (filtername.startsWith("Deployment Files")) { + filter = singleCfg.DeploymentFiles; } else { // ExtraCompilers filter = project.SingleProjects[i].filterForExtraCompiler(filtername); @@ -1956,7 +1966,8 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut } // Actual XML output ---------------------------------- - if (filter.useCustomBuildTool || filter.useCompilerTool || !inBuild) { + if (filter.useCustomBuildTool || filter.useCompilerTool + || !inBuild || filtername.startsWith("Deployment Files")) { if (filter.useCustomBuildTool) { @@ -1971,7 +1982,8 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut xml << tag("CustomBuild") << attrTag("Include",Option::fixPathToLocalOS(filename)); - if ( filtername.startsWith("Form Files") || filtername.startsWith("Generated Files") || filtername.startsWith("Resource Files") ) + if (filtername.startsWith("Form Files") || filtername.startsWith("Generated Files") + || filtername.startsWith("Resource Files") || filtername.startsWith("Deployment Files")) xml << attrTagS("FileType", "Document"); } @@ -2044,6 +2056,13 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut xml << tag("ResourceCompile") << attrTag("Include",Option::fixPathToLocalOS(filename)); } + } else if (filtername.startsWith("Deployment Files")) { + xmlFilter << tag("None") + << attrTag("Include",Option::fixPathToLocalOS(filename)) + << attrTagS("Filter", filtername); + + xml << tag("None") + << attrTag("Include",Option::fixPathToLocalOS(filename)); } } @@ -2054,6 +2073,12 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut << valueTag("true"); } + if (filtername.startsWith("Deployment Files") && inBuild) { + xml << tag("DeploymentContent") + << attrTag("Condition", condition) + << valueTag("true"); + } + if (filter.useCompilerTool) { if ( !filter.CompilerTool.ForcedIncludeFiles.isEmpty() ) { diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 2b343fd9f7..09213bec8e 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2475,6 +2475,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) outputFilter(tempProj, xml, "TranslationFiles"); outputFilter(tempProj, xml, "FormFiles"); outputFilter(tempProj, xml, "ResourceFiles"); + outputFilter(tempProj, xml, "DeploymentFiles"); QSet extraCompilersInProject; for (int i = 0; i < tool.ExtraCompilersFiles.count(); ++i) { @@ -2527,6 +2528,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCProject &tool) outputFilter(tool, xml, "TranslationFiles"); outputFilter(tool, xml, "FormFiles"); outputFilter(tool, xml, "ResourceFiles"); + outputFilter(tool, xml, "DeploymentFiles"); for (int x = 0; x < tool.ExtraCompilers.count(); ++x) { outputFilter(tool, xml, tool.ExtraCompilers.at(x)); } @@ -2878,6 +2880,8 @@ void VCProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, const QSt filter = projectSingleConfig.FormFiles; } else if (filtername == "ResourceFiles") { filter = projectSingleConfig.ResourceFiles; + } else if (filtername == "DeploymentFiles") { + filter = projectSingleConfig.DeploymentFiles; } else { // ExtraCompilers filter = project.SingleProjects[i].filterForExtraCompiler(filtername); @@ -2938,6 +2942,8 @@ void VCProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, cons filter = projectSingleConfig.FormFiles; } else if (filtername == "ResourceFiles") { filter = projectSingleConfig.ResourceFiles; + } else if (filtername == "DeploymentFiles") { + filter = projectSingleConfig.DeploymentFiles; } else { // ExtraCompilers filter = project.SingleProjects[i].filterForExtraCompiler(filtername); diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index 48324b9d27..4e19a43a8c 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -1000,6 +1000,7 @@ public: VCFilter TranslationFiles; VCFilter FormFiles; VCFilter ResourceFiles; + VCFilter DeploymentFiles; VCFilterList ExtraCompilersFiles; bool flat_files; diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 9387eb39d4..7f4240f196 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -63,6 +63,7 @@ const char _GUIDLexYaccFiles[] = "{E12AE0D2-192F-4d59-BD23-7D3FA58D3183} const char _GUIDTranslationFiles[] = "{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}"; const char _GUIDFormFiles[] = "{99349809-55BA-4b9d-BF79-8FDBB0286EB3}"; const char _GUIDExtraCompilerFiles[] = "{E0D8C965-CC5F-43d7-AD63-FAEF0BBC0F85}"; +const char _GUIDDeploymentFiles[] = "{D9D6E243-F8AF-46E4-B9FD-80ECBC20BA3E}"; QT_END_NAMESPACE #ifdef Q_OS_WIN32 @@ -1012,8 +1013,9 @@ void VcprojGenerator::initConfiguration() initCustomBuildTool(); initPreBuildEventTools(); initPostBuildEventTools(); - // Only deploy for CE projects - if (!project->isHostBuild() && !project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH")) + // Only deploy for CE and WinRT projects + if (!project->isHostBuild() && !project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH") + || conf.WinRT) initDeploymentTool(); initPreLinkEventTools(); @@ -1173,11 +1175,19 @@ void VcprojGenerator::initPostBuildEventTools() void VcprojGenerator::initDeploymentTool() { VCConfiguration &conf = vcProject.Configuration; - QString targetPath = project->values("deploy.path").join(' '); - if (targetPath.isEmpty()) - targetPath = QString("%CSIDL_PROGRAM_FILES%\\") + project->first("TARGET"); - if (targetPath.endsWith("/") || targetPath.endsWith("\\")) - targetPath.chop(1); + QString targetPath; + if (conf.WinRT) { + vcProject.DeploymentFiles.Name = "Deployment Files"; + vcProject.DeploymentFiles.ParseFiles = _False; + vcProject.DeploymentFiles.Filter = "deploy"; + vcProject.DeploymentFiles.Guid = _GUIDDeploymentFiles; + } else { + targetPath = project->values("deploy.path").join(' '); + if (targetPath.isEmpty()) + targetPath = QString("%CSIDL_PROGRAM_FILES%\\") + project->first("TARGET"); + if (targetPath.endsWith("/") || targetPath.endsWith("\\")) + targetPath.chop(1); + } // Only deploy Qt libs for shared build if (!project->values("QMAKE_QT_DLL").isEmpty()) { @@ -1195,48 +1205,55 @@ void VcprojGenerator::initDeploymentTool() continue; dllName.replace(QLatin1String(".lib") , QLatin1String(".dll")); QFileInfo info(dllName); - conf.deployment.AdditionalFiles += info.fileName() - + "|" + QDir::toNativeSeparators(info.absolutePath()) - + "|" + targetPath - + "|0;"; + if (conf.WinRT) { + QString absoluteFilePath(QDir::toNativeSeparators(info.absoluteFilePath())); + vcProject.DeploymentFiles.addFile(absoluteFilePath); + } else { + conf.deployment.AdditionalFiles += info.fileName() + + "|" + QDir::toNativeSeparators(info.absolutePath()) + + "|" + targetPath + + "|0;"; + } } } } - // C-runtime deployment - QString runtime = project->values("QT_CE_C_RUNTIME").join(QLatin1Char(' ')); - if (!runtime.isEmpty() && (runtime != QLatin1String("no"))) { - QString runtimeVersion = QLatin1String("msvcr"); - ProString mkspec = project->first("QMAKESPEC"); - - if (!mkspec.isEmpty()) { - if (mkspec.endsWith("2008")) - runtimeVersion.append("90"); - else - runtimeVersion.append("80"); - if (project->isActiveConfig("debug")) - runtimeVersion.append("d"); - runtimeVersion.append(".dll"); - - if (runtime == "yes") { - // Auto-find C-runtime - QString vcInstallDir = qgetenv("VCINSTALLDIR"); - if (!vcInstallDir.isEmpty()) { - vcInstallDir += "\\ce\\dll\\"; - vcInstallDir += project->values("CE_ARCH").join(QLatin1Char(' ')); - if (!QFileInfo(vcInstallDir + QDir::separator() + runtimeVersion).exists()) - runtime.clear(); - else - runtime = vcInstallDir; + if (!conf.WinRT) { + // C-runtime deployment + QString runtime = project->values("QT_CE_C_RUNTIME").join(QLatin1Char(' ')); + if (!runtime.isEmpty() && (runtime != QLatin1String("no"))) { + QString runtimeVersion = QLatin1String("msvcr"); + ProString mkspec = project->first("QMAKESPEC"); + + if (!mkspec.isEmpty()) { + if (mkspec.endsWith("2008")) + runtimeVersion.append("90"); + else + runtimeVersion.append("80"); + if (project->isActiveConfig("debug")) + runtimeVersion.append("d"); + runtimeVersion.append(".dll"); + + if (runtime == "yes") { + // Auto-find C-runtime + QString vcInstallDir = qgetenv("VCINSTALLDIR"); + if (!vcInstallDir.isEmpty()) { + vcInstallDir += "\\ce\\dll\\"; + vcInstallDir += project->values("CE_ARCH").join(QLatin1Char(' ')); + if (!QFileInfo(vcInstallDir + QDir::separator() + runtimeVersion).exists()) + runtime.clear(); + else + runtime = vcInstallDir; + } } } - } - if (!runtime.isEmpty() && runtime != QLatin1String("yes")) { - conf.deployment.AdditionalFiles += runtimeVersion - + "|" + QDir::toNativeSeparators(runtime) - + "|" + targetPath - + "|0;"; + if (!runtime.isEmpty() && runtime != QLatin1String("yes")) { + conf.deployment.AdditionalFiles += runtimeVersion + + "|" + QDir::toNativeSeparators(runtime) + + "|" + targetPath + + "|0;"; + } } } @@ -1244,14 +1261,16 @@ void VcprojGenerator::initDeploymentTool() foreach (const ProString &item, project->values("DEPLOYMENT")) { // get item.path QString devicePath = project->first(ProKey(item + ".path")).toQString(); - if (devicePath.isEmpty()) - devicePath = targetPath; - // check if item.path is relative (! either /,\ or %) - if (!(devicePath.at(0) == QLatin1Char('/') - || devicePath.at(0) == QLatin1Char('\\') - || devicePath.at(0) == QLatin1Char('%'))) { - // create output path - devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('\\') + devicePath)); + if (!conf.WinRT) { + if (devicePath.isEmpty()) + devicePath = targetPath; + // check if item.path is relative (! either /,\ or %) + if (!(devicePath.at(0) == QLatin1Char('/') + || devicePath.at(0) == QLatin1Char('\\') + || devicePath.at(0) == QLatin1Char('%'))) { + // create output path + devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('\\') + devicePath)); + } } // foreach d in item.files foreach (const ProString &src, project->values(ProKey(item + ".files"))) { @@ -1276,16 +1295,27 @@ void VcprojGenerator::initDeploymentTool() // foreach dirIterator-entry in d while(iterator.hasNext()) { iterator.next(); - QString absoluteItemPath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absolutePath()); - // Identify if it is just another subdir - int diffSize = absoluteItemPath.size() - pathSize; - // write out rules - conf.deployment.AdditionalFiles += iterator.fileName() - + "|" + absoluteItemPath - + "|" + itemDevicePath + (diffSize ? (absoluteItemPath.right(diffSize)) : QLatin1String("")) - + "|0;"; + if (conf.WinRT) { + QString absoluteItemFilePath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absoluteFilePath()); + vcProject.DeploymentFiles.addFile(absoluteItemFilePath); + } else { + QString absoluteItemPath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absolutePath()); + // Identify if it is just another subdir + int diffSize = absoluteItemPath.size() - pathSize; + // write out rules + conf.deployment.AdditionalFiles += iterator.fileName() + + "|" + absoluteItemPath + + "|" + itemDevicePath + (diffSize ? (absoluteItemPath.right(diffSize)) : QLatin1String("")) + + "|0;"; + } } } + + if (conf.WinRT) { + vcProject.DeploymentFiles.Project = this; + vcProject.DeploymentFiles.Config = &(vcProject.Configuration); + vcProject.DeploymentFiles.CustomBuild = none; + } } } diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index 62a2da9629..561e56d232 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -117,6 +117,7 @@ protected: void initTranslationFiles(); void initFormFiles(); void initResourceFiles(); + void initDeploymentFiles(); void initLexYaccFiles(); void initExtraCompilerOutputs(); -- cgit v1.2.3