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 <joerg.bornemann@digia.com>
This commit is contained in:
Kamil Trzcinski 2013-02-12 00:25:23 +01:00 committed by The Qt Project
parent 083b5b503c
commit 4bbbe06bef
5 changed files with 121 additions and 58 deletions

View File

@ -568,6 +568,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool)
addFilters(tempProj, xmlFilter, "Resource Files"); addFilters(tempProj, xmlFilter, "Resource Files");
addFilters(tempProj, xmlFilter, "Source Files"); addFilters(tempProj, xmlFilter, "Source Files");
addFilters(tempProj, xmlFilter, "Translation Files"); addFilters(tempProj, xmlFilter, "Translation Files");
addFilters(tempProj, xmlFilter, "Deployment Files");
for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x)
addFilters(tempProj, xmlFilter, tempProj.ExtraCompilers.at(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, "Translation Files");
outputFilter(tempProj, xml, xmlFilter, "Form Files"); outputFilter(tempProj, xml, xmlFilter, "Form Files");
outputFilter(tempProj, xml, xmlFilter, "Resource Files"); outputFilter(tempProj, xml, xmlFilter, "Resource Files");
outputFilter(tempProj, xml, xmlFilter, "Deployment Files");
for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) {
outputFilter(tempProj, xml, xmlFilter, tempProj.ExtraCompilers.at(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, "Resource Files");
addFilters(tool, xmlFilter, "Source Files"); addFilters(tool, xmlFilter, "Source Files");
addFilters(tool, xmlFilter, "Translation Files"); addFilters(tool, xmlFilter, "Translation Files");
addFilters(tool, xmlFilter, "Deployment Files");
for (int x = 0; x < tool.ExtraCompilers.count(); ++x) for (int x = 0; x < tool.ExtraCompilers.count(); ++x)
addFilters(tool, xmlFilter, tool.ExtraCompilers.at(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, "Translation Files");
outputFilter(tool, xml, xmlFilter, "Form Files"); outputFilter(tool, xml, xmlFilter, "Form Files");
outputFilter(tool, xml, xmlFilter, "Resource Files"); outputFilter(tool, xml, xmlFilter, "Resource Files");
outputFilter(tool, xml, xmlFilter, "Deployment Files");
for (int x = 0; x < tool.ExtraCompilers.count(); ++x) { for (int x = 0; x < tool.ExtraCompilers.count(); ++x) {
outputFilter(tool, xml, xmlFilter, tool.ExtraCompilers.at(x)); outputFilter(tool, xml, xmlFilter, tool.ExtraCompilers.at(x));
} }
@ -1728,6 +1732,8 @@ void VCXProjectWriter::addFilters(VCProject &project, XmlOutput &xmlFilter, cons
filter = singleCfg.FormFiles; filter = singleCfg.FormFiles;
} else if (filtername == "Resource Files") { } else if (filtername == "Resource Files") {
filter = singleCfg.ResourceFiles; filter = singleCfg.ResourceFiles;
} else if (filtername == "Deployment Files") {
filter = singleCfg.DeploymentFiles;
} else { } else {
// ExtraCompilers // ExtraCompilers
filter = project.SingleProjects[i].filterForExtraCompiler(filtername); filter = project.SingleProjects[i].filterForExtraCompiler(filtername);
@ -1775,6 +1781,8 @@ void VCXProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, XmlOutpu
filter = singleCfg.FormFiles; filter = singleCfg.FormFiles;
} else if (filtername == "Resource Files") { } else if (filtername == "Resource Files") {
filter = singleCfg.ResourceFiles; filter = singleCfg.ResourceFiles;
} else if (filtername == "Deployment Files") {
filter = singleCfg.DeploymentFiles;
} else { } else {
// ExtraCompilers // ExtraCompilers
filter = project.SingleProjects[i].filterForExtraCompiler(filtername); filter = project.SingleProjects[i].filterForExtraCompiler(filtername);
@ -1826,6 +1834,8 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml
filter = singleCfg.FormFiles; filter = singleCfg.FormFiles;
} else if (filtername.startsWith("Resource Files")) { } else if (filtername.startsWith("Resource Files")) {
filter = singleCfg.ResourceFiles; filter = singleCfg.ResourceFiles;
} else if (filtername.startsWith("Deployment Files")) {
filter = singleCfg.DeploymentFiles;
} else { } else {
// ExtraCompilers // ExtraCompilers
filter = project.SingleProjects[i].filterForExtraCompiler(filtername); filter = project.SingleProjects[i].filterForExtraCompiler(filtername);
@ -1956,7 +1966,8 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut
} }
// Actual XML output ---------------------------------- // Actual XML output ----------------------------------
if (filter.useCustomBuildTool || filter.useCompilerTool || !inBuild) { if (filter.useCustomBuildTool || filter.useCompilerTool
|| !inBuild || filtername.startsWith("Deployment Files")) {
if (filter.useCustomBuildTool) if (filter.useCustomBuildTool)
{ {
@ -1971,7 +1982,8 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut
xml << tag("CustomBuild") xml << tag("CustomBuild")
<< attrTag("Include",Option::fixPathToLocalOS(filename)); << 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"); xml << attrTagS("FileType", "Document");
} }
@ -2044,6 +2056,13 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut
xml << tag("ResourceCompile") xml << tag("ResourceCompile")
<< attrTag("Include",Option::fixPathToLocalOS(filename)); << 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"); << valueTag("true");
} }
if (filtername.startsWith("Deployment Files") && inBuild) {
xml << tag("DeploymentContent")
<< attrTag("Condition", condition)
<< valueTag("true");
}
if (filter.useCompilerTool) { if (filter.useCompilerTool) {
if ( !filter.CompilerTool.ForcedIncludeFiles.isEmpty() ) { if ( !filter.CompilerTool.ForcedIncludeFiles.isEmpty() ) {

View File

@ -2475,6 +2475,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool)
outputFilter(tempProj, xml, "TranslationFiles"); outputFilter(tempProj, xml, "TranslationFiles");
outputFilter(tempProj, xml, "FormFiles"); outputFilter(tempProj, xml, "FormFiles");
outputFilter(tempProj, xml, "ResourceFiles"); outputFilter(tempProj, xml, "ResourceFiles");
outputFilter(tempProj, xml, "DeploymentFiles");
QSet<QString> extraCompilersInProject; QSet<QString> extraCompilersInProject;
for (int i = 0; i < tool.ExtraCompilersFiles.count(); ++i) { 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, "TranslationFiles");
outputFilter(tool, xml, "FormFiles"); outputFilter(tool, xml, "FormFiles");
outputFilter(tool, xml, "ResourceFiles"); outputFilter(tool, xml, "ResourceFiles");
outputFilter(tool, xml, "DeploymentFiles");
for (int x = 0; x < tool.ExtraCompilers.count(); ++x) { for (int x = 0; x < tool.ExtraCompilers.count(); ++x) {
outputFilter(tool, xml, tool.ExtraCompilers.at(x)); outputFilter(tool, xml, tool.ExtraCompilers.at(x));
} }
@ -2878,6 +2880,8 @@ void VCProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, const QSt
filter = projectSingleConfig.FormFiles; filter = projectSingleConfig.FormFiles;
} else if (filtername == "ResourceFiles") { } else if (filtername == "ResourceFiles") {
filter = projectSingleConfig.ResourceFiles; filter = projectSingleConfig.ResourceFiles;
} else if (filtername == "DeploymentFiles") {
filter = projectSingleConfig.DeploymentFiles;
} else { } else {
// ExtraCompilers // ExtraCompilers
filter = project.SingleProjects[i].filterForExtraCompiler(filtername); filter = project.SingleProjects[i].filterForExtraCompiler(filtername);
@ -2938,6 +2942,8 @@ void VCProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, cons
filter = projectSingleConfig.FormFiles; filter = projectSingleConfig.FormFiles;
} else if (filtername == "ResourceFiles") { } else if (filtername == "ResourceFiles") {
filter = projectSingleConfig.ResourceFiles; filter = projectSingleConfig.ResourceFiles;
} else if (filtername == "DeploymentFiles") {
filter = projectSingleConfig.DeploymentFiles;
} else { } else {
// ExtraCompilers // ExtraCompilers
filter = project.SingleProjects[i].filterForExtraCompiler(filtername); filter = project.SingleProjects[i].filterForExtraCompiler(filtername);

View File

@ -1000,6 +1000,7 @@ public:
VCFilter TranslationFiles; VCFilter TranslationFiles;
VCFilter FormFiles; VCFilter FormFiles;
VCFilter ResourceFiles; VCFilter ResourceFiles;
VCFilter DeploymentFiles;
VCFilterList ExtraCompilersFiles; VCFilterList ExtraCompilersFiles;
bool flat_files; bool flat_files;

View File

@ -63,6 +63,7 @@ const char _GUIDLexYaccFiles[] = "{E12AE0D2-192F-4d59-BD23-7D3FA58D3183}
const char _GUIDTranslationFiles[] = "{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}"; const char _GUIDTranslationFiles[] = "{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}";
const char _GUIDFormFiles[] = "{99349809-55BA-4b9d-BF79-8FDBB0286EB3}"; const char _GUIDFormFiles[] = "{99349809-55BA-4b9d-BF79-8FDBB0286EB3}";
const char _GUIDExtraCompilerFiles[] = "{E0D8C965-CC5F-43d7-AD63-FAEF0BBC0F85}"; const char _GUIDExtraCompilerFiles[] = "{E0D8C965-CC5F-43d7-AD63-FAEF0BBC0F85}";
const char _GUIDDeploymentFiles[] = "{D9D6E243-F8AF-46E4-B9FD-80ECBC20BA3E}";
QT_END_NAMESPACE QT_END_NAMESPACE
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
@ -1012,8 +1013,9 @@ void VcprojGenerator::initConfiguration()
initCustomBuildTool(); initCustomBuildTool();
initPreBuildEventTools(); initPreBuildEventTools();
initPostBuildEventTools(); initPostBuildEventTools();
// Only deploy for CE projects // Only deploy for CE and WinRT projects
if (!project->isHostBuild() && !project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH")) if (!project->isHostBuild() && !project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH")
|| conf.WinRT)
initDeploymentTool(); initDeploymentTool();
initPreLinkEventTools(); initPreLinkEventTools();
@ -1173,11 +1175,19 @@ void VcprojGenerator::initPostBuildEventTools()
void VcprojGenerator::initDeploymentTool() void VcprojGenerator::initDeploymentTool()
{ {
VCConfiguration &conf = vcProject.Configuration; VCConfiguration &conf = vcProject.Configuration;
QString targetPath = project->values("deploy.path").join(' '); QString targetPath;
if (targetPath.isEmpty()) if (conf.WinRT) {
targetPath = QString("%CSIDL_PROGRAM_FILES%\\") + project->first("TARGET"); vcProject.DeploymentFiles.Name = "Deployment Files";
if (targetPath.endsWith("/") || targetPath.endsWith("\\")) vcProject.DeploymentFiles.ParseFiles = _False;
targetPath.chop(1); 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 // Only deploy Qt libs for shared build
if (!project->values("QMAKE_QT_DLL").isEmpty()) { if (!project->values("QMAKE_QT_DLL").isEmpty()) {
@ -1195,48 +1205,55 @@ void VcprojGenerator::initDeploymentTool()
continue; continue;
dllName.replace(QLatin1String(".lib") , QLatin1String(".dll")); dllName.replace(QLatin1String(".lib") , QLatin1String(".dll"));
QFileInfo info(dllName); QFileInfo info(dllName);
conf.deployment.AdditionalFiles += info.fileName() if (conf.WinRT) {
+ "|" + QDir::toNativeSeparators(info.absolutePath()) QString absoluteFilePath(QDir::toNativeSeparators(info.absoluteFilePath()));
+ "|" + targetPath vcProject.DeploymentFiles.addFile(absoluteFilePath);
+ "|0;"; } else {
conf.deployment.AdditionalFiles += info.fileName()
+ "|" + QDir::toNativeSeparators(info.absolutePath())
+ "|" + targetPath
+ "|0;";
}
} }
} }
} }
// C-runtime deployment if (!conf.WinRT) {
QString runtime = project->values("QT_CE_C_RUNTIME").join(QLatin1Char(' ')); // C-runtime deployment
if (!runtime.isEmpty() && (runtime != QLatin1String("no"))) { QString runtime = project->values("QT_CE_C_RUNTIME").join(QLatin1Char(' '));
QString runtimeVersion = QLatin1String("msvcr"); if (!runtime.isEmpty() && (runtime != QLatin1String("no"))) {
ProString mkspec = project->first("QMAKESPEC"); QString runtimeVersion = QLatin1String("msvcr");
ProString mkspec = project->first("QMAKESPEC");
if (!mkspec.isEmpty()) { if (!mkspec.isEmpty()) {
if (mkspec.endsWith("2008")) if (mkspec.endsWith("2008"))
runtimeVersion.append("90"); runtimeVersion.append("90");
else else
runtimeVersion.append("80"); runtimeVersion.append("80");
if (project->isActiveConfig("debug")) if (project->isActiveConfig("debug"))
runtimeVersion.append("d"); runtimeVersion.append("d");
runtimeVersion.append(".dll"); runtimeVersion.append(".dll");
if (runtime == "yes") { if (runtime == "yes") {
// Auto-find C-runtime // Auto-find C-runtime
QString vcInstallDir = qgetenv("VCINSTALLDIR"); QString vcInstallDir = qgetenv("VCINSTALLDIR");
if (!vcInstallDir.isEmpty()) { if (!vcInstallDir.isEmpty()) {
vcInstallDir += "\\ce\\dll\\"; vcInstallDir += "\\ce\\dll\\";
vcInstallDir += project->values("CE_ARCH").join(QLatin1Char(' ')); vcInstallDir += project->values("CE_ARCH").join(QLatin1Char(' '));
if (!QFileInfo(vcInstallDir + QDir::separator() + runtimeVersion).exists()) if (!QFileInfo(vcInstallDir + QDir::separator() + runtimeVersion).exists())
runtime.clear(); runtime.clear();
else else
runtime = vcInstallDir; runtime = vcInstallDir;
}
} }
} }
}
if (!runtime.isEmpty() && runtime != QLatin1String("yes")) { if (!runtime.isEmpty() && runtime != QLatin1String("yes")) {
conf.deployment.AdditionalFiles += runtimeVersion conf.deployment.AdditionalFiles += runtimeVersion
+ "|" + QDir::toNativeSeparators(runtime) + "|" + QDir::toNativeSeparators(runtime)
+ "|" + targetPath + "|" + targetPath
+ "|0;"; + "|0;";
}
} }
} }
@ -1244,14 +1261,16 @@ void VcprojGenerator::initDeploymentTool()
foreach (const ProString &item, project->values("DEPLOYMENT")) { foreach (const ProString &item, project->values("DEPLOYMENT")) {
// get item.path // get item.path
QString devicePath = project->first(ProKey(item + ".path")).toQString(); QString devicePath = project->first(ProKey(item + ".path")).toQString();
if (devicePath.isEmpty()) if (!conf.WinRT) {
devicePath = targetPath; if (devicePath.isEmpty())
// check if item.path is relative (! either /,\ or %) devicePath = targetPath;
if (!(devicePath.at(0) == QLatin1Char('/') // check if item.path is relative (! either /,\ or %)
|| devicePath.at(0) == QLatin1Char('\\') if (!(devicePath.at(0) == QLatin1Char('/')
|| devicePath.at(0) == QLatin1Char('%'))) { || devicePath.at(0) == QLatin1Char('\\')
// create output path || devicePath.at(0) == QLatin1Char('%'))) {
devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('\\') + devicePath)); // create output path
devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('\\') + devicePath));
}
} }
// foreach d in item.files // foreach d in item.files
foreach (const ProString &src, project->values(ProKey(item + ".files"))) { foreach (const ProString &src, project->values(ProKey(item + ".files"))) {
@ -1276,16 +1295,27 @@ void VcprojGenerator::initDeploymentTool()
// foreach dirIterator-entry in d // foreach dirIterator-entry in d
while(iterator.hasNext()) { while(iterator.hasNext()) {
iterator.next(); iterator.next();
QString absoluteItemPath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absolutePath()); if (conf.WinRT) {
// Identify if it is just another subdir QString absoluteItemFilePath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absoluteFilePath());
int diffSize = absoluteItemPath.size() - pathSize; vcProject.DeploymentFiles.addFile(absoluteItemFilePath);
// write out rules } else {
conf.deployment.AdditionalFiles += iterator.fileName() QString absoluteItemPath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absolutePath());
+ "|" + absoluteItemPath // Identify if it is just another subdir
+ "|" + itemDevicePath + (diffSize ? (absoluteItemPath.right(diffSize)) : QLatin1String("")) int diffSize = absoluteItemPath.size() - pathSize;
+ "|0;"; // 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;
}
} }
} }

View File

@ -117,6 +117,7 @@ protected:
void initTranslationFiles(); void initTranslationFiles();
void initFormFiles(); void initFormFiles();
void initResourceFiles(); void initResourceFiles();
void initDeploymentFiles();
void initLexYaccFiles(); void initLexYaccFiles();
void initExtraCompilerOutputs(); void initExtraCompilerOutputs();