| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the qmake application of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include "msvc_vcproj.h"
|
|---|
| 43 | #include "option.h"
|
|---|
| 44 | #include "xmloutput.h"
|
|---|
| 45 | #include <qdir.h>
|
|---|
| 46 | #include <qdiriterator.h>
|
|---|
| 47 | #include <qcryptographichash.h>
|
|---|
| 48 | #include <qregexp.h>
|
|---|
| 49 | #include <qhash.h>
|
|---|
| 50 | #include <quuid.h>
|
|---|
| 51 | #include <stdlib.h>
|
|---|
| 52 |
|
|---|
| 53 | //#define DEBUG_SOLUTION_GEN
|
|---|
| 54 | //#define DEBUG_PROJECT_GEN
|
|---|
| 55 |
|
|---|
| 56 | QT_BEGIN_NAMESPACE
|
|---|
| 57 | // Filter GUIDs (Do NOT change these!) ------------------------------
|
|---|
| 58 | const char _GUIDSourceFiles[] = "{4FC737F1-C7A5-4376-A066-2A32D752A2FF}";
|
|---|
| 59 | const char _GUIDHeaderFiles[] = "{93995380-89BD-4b04-88EB-625FBE52EBFB}";
|
|---|
| 60 | const char _GUIDGeneratedFiles[] = "{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}";
|
|---|
| 61 | const char _GUIDResourceFiles[] = "{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}";
|
|---|
| 62 | const char _GUIDLexYaccFiles[] = "{E12AE0D2-192F-4d59-BD23-7D3FA58D3183}";
|
|---|
| 63 | const char _GUIDTranslationFiles[] = "{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}";
|
|---|
| 64 | const char _GUIDFormFiles[] = "{99349809-55BA-4b9d-BF79-8FDBB0286EB3}";
|
|---|
| 65 | const char _GUIDExtraCompilerFiles[] = "{E0D8C965-CC5F-43d7-AD63-FAEF0BBC0F85}";
|
|---|
| 66 | QT_END_NAMESPACE
|
|---|
| 67 |
|
|---|
| 68 | #ifdef Q_OS_WIN32
|
|---|
| 69 | #include <qt_windows.h>
|
|---|
| 70 | #include <windows/registry_p.h>
|
|---|
| 71 |
|
|---|
| 72 | QT_BEGIN_NAMESPACE
|
|---|
| 73 |
|
|---|
| 74 | struct {
|
|---|
| 75 | DotNET version;
|
|---|
| 76 | const char *versionStr;
|
|---|
| 77 | const char *regKey;
|
|---|
| 78 | } dotNetCombo[] = {
|
|---|
| 79 | #ifdef Q_OS_WIN64
|
|---|
| 80 | {NET2010, "MSVC.NET 2010 (10.0)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\10.0\\Setup\\VC\\ProductDir"},
|
|---|
| 81 | {NET2010, "MSVC.NET 2010 Express Edition (10.0)", "Software\\Wow6432Node\\Microsoft\\VCExpress\\10.0\\Setup\\VC\\ProductDir"},
|
|---|
| 82 | {NET2008, "MSVC.NET 2008 (9.0)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir"},
|
|---|
| 83 | {NET2008, "MSVC.NET 2008 Express Edition (9.0)", "Software\\Wow6432Node\\Microsoft\\VCExpress\\9.0\\Setup\\VC\\ProductDir"},
|
|---|
| 84 | {NET2005, "MSVC.NET 2005 (8.0)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"},
|
|---|
| 85 | {NET2005, "MSVC.NET 2005 Express Edition (8.0)", "Software\\Wow6432Node\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir"},
|
|---|
| 86 | {NET2003, "MSVC.NET 2003 (7.1)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"},
|
|---|
| 87 | {NET2002, "MSVC.NET 2002 (7.0)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"},
|
|---|
| 88 | #else
|
|---|
| 89 | {NET2010, "MSVC.NET 2010 (10.0)", "Software\\Microsoft\\VisualStudio\\10.0\\Setup\\VC\\ProductDir"},
|
|---|
| 90 | {NET2010, "MSVC.NET 2010 Express Edition (10.0)", "Software\\Microsoft\\VCExpress\\10.0\\Setup\\VC\\ProductDir"},
|
|---|
| 91 | {NET2008, "MSVC.NET 2008 (9.0)", "Software\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir"},
|
|---|
| 92 | {NET2008, "MSVC.NET 2008 Express Edition (9.0)", "Software\\Microsoft\\VCExpress\\9.0\\Setup\\VC\\ProductDir"},
|
|---|
| 93 | {NET2005, "MSVC.NET 2005 (8.0)", "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"},
|
|---|
| 94 | {NET2005, "MSVC.NET 2005 Express Edition (8.0)", "Software\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir"},
|
|---|
| 95 | {NET2003, "MSVC.NET 2003 (7.1)", "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"},
|
|---|
| 96 | {NET2002, "MSVC.NET 2002 (7.0)", "Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"},
|
|---|
| 97 | #endif
|
|---|
| 98 | {NETUnknown, "", ""},
|
|---|
| 99 | };
|
|---|
| 100 |
|
|---|
| 101 | QT_END_NAMESPACE
|
|---|
| 102 | #endif
|
|---|
| 103 |
|
|---|
| 104 | QT_BEGIN_NAMESPACE
|
|---|
| 105 | DotNET which_dotnet_version()
|
|---|
| 106 | {
|
|---|
| 107 | #ifndef Q_OS_WIN32
|
|---|
| 108 | return NET2002; // Always generate 7.0 versions on other platforms
|
|---|
| 109 | #else
|
|---|
| 110 | // Only search for the version once
|
|---|
| 111 | static DotNET current_version = NETUnknown;
|
|---|
| 112 | if(current_version != NETUnknown)
|
|---|
| 113 | return current_version;
|
|---|
| 114 |
|
|---|
| 115 | // Fallback to .NET 2002
|
|---|
| 116 | current_version = NET2002;
|
|---|
| 117 |
|
|---|
| 118 | QStringList warnPath;
|
|---|
| 119 | int installed = 0;
|
|---|
| 120 | int i = 0;
|
|---|
| 121 | for(; dotNetCombo[i].version; ++i) {
|
|---|
| 122 | QString path = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey);
|
|---|
| 123 | if(!path.isEmpty()) {
|
|---|
| 124 | ++installed;
|
|---|
| 125 | current_version = dotNetCombo[i].version;
|
|---|
| 126 | warnPath += QString("%1").arg(dotNetCombo[i].versionStr);
|
|---|
| 127 | }
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | if (installed < 2)
|
|---|
| 131 | return current_version;
|
|---|
| 132 |
|
|---|
| 133 | // More than one version installed, search directory path
|
|---|
| 134 | QString paths = qgetenv("PATH");
|
|---|
| 135 | QStringList pathlist = paths.toLower().split(";");
|
|---|
| 136 |
|
|---|
| 137 | i = installed = 0;
|
|---|
| 138 | for(; dotNetCombo[i].version; ++i) {
|
|---|
| 139 | QString productPath = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey).toLower();
|
|---|
| 140 | if (productPath.isEmpty())
|
|---|
| 141 | continue;
|
|---|
| 142 | QStringList::iterator it;
|
|---|
| 143 | for(it = pathlist.begin(); it != pathlist.end(); ++it) {
|
|---|
| 144 | if((*it).contains(productPath)) {
|
|---|
| 145 | ++installed;
|
|---|
| 146 | current_version = dotNetCombo[i].version;
|
|---|
| 147 | warnPath += QString("%1 in path").arg(dotNetCombo[i].versionStr);
|
|---|
| 148 | break;
|
|---|
| 149 | }
|
|---|
| 150 | }
|
|---|
| 151 | }
|
|---|
| 152 | switch(installed) {
|
|---|
| 153 | case 1:
|
|---|
| 154 | break;
|
|---|
| 155 | case 0:
|
|---|
| 156 | warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but"
|
|---|
| 157 | " none in your path! Fallback to lowest version (%s)", warnPath.join(", ").toLatin1().data());
|
|---|
| 158 | break;
|
|---|
| 159 | default:
|
|---|
| 160 | warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio in"
|
|---|
| 161 | " your path! Fallback to lowest version (%s)", warnPath.join(", ").toLatin1().data());
|
|---|
| 162 | break;
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | return current_version;
|
|---|
| 166 | #endif
|
|---|
| 167 | };
|
|---|
| 168 |
|
|---|
| 169 | // Flatfile Tags ----------------------------------------------------
|
|---|
| 170 | const char _slnHeader70[] = "Microsoft Visual Studio Solution File, Format Version 7.00";
|
|---|
| 171 | const char _slnHeader71[] = "Microsoft Visual Studio Solution File, Format Version 8.00";
|
|---|
| 172 | const char _slnHeader80[] = "Microsoft Visual Studio Solution File, Format Version 9.00"
|
|---|
| 173 | "\n# Visual Studio 2005";
|
|---|
| 174 | const char _slnHeader90[] = "Microsoft Visual Studio Solution File, Format Version 10.00"
|
|---|
| 175 | "\n# Visual Studio 2008";
|
|---|
| 176 | const char _slnHeader100[] = "Microsoft Visual Studio Solution File, Format Version 11.00"
|
|---|
| 177 | "\n# Visual Studio 2010";
|
|---|
| 178 | // The following UUID _may_ change for later servicepacks...
|
|---|
| 179 | // If so we need to search through the registry at
|
|---|
| 180 | // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects
|
|---|
| 181 | // to find the subkey that contains a "PossibleProjectExtension"
|
|---|
| 182 | // containing "vcproj"...
|
|---|
| 183 | // Use the hardcoded value for now so projects generated on other
|
|---|
| 184 | // platforms are actually usable.
|
|---|
| 185 | const char _slnMSVCvcprojGUID[] = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
|
|---|
| 186 | const char _slnProjectBeg[] = "\nProject(\"";
|
|---|
| 187 | const char _slnProjectMid[] = "\") = ";
|
|---|
| 188 | const char _slnProjectEnd[] = "\nEndProject";
|
|---|
| 189 | const char _slnGlobalBeg[] = "\nGlobal";
|
|---|
| 190 | const char _slnGlobalEnd[] = "\nEndGlobal";
|
|---|
| 191 | const char _slnSolutionConf[] = "\n\tGlobalSection(SolutionConfiguration) = preSolution"
|
|---|
| 192 | "\n\t\tConfigName.0 = Debug|Win32"
|
|---|
| 193 | "\n\t\tConfigName.1 = Release|Win32"
|
|---|
| 194 | "\n\tEndGlobalSection";
|
|---|
| 195 | const char _slnProjDepBeg[] = "\n\tGlobalSection(ProjectDependencies) = postSolution";
|
|---|
| 196 | const char _slnProjDepEnd[] = "\n\tEndGlobalSection";
|
|---|
| 197 | const char _slnProjConfBeg[] = "\n\tGlobalSection(ProjectConfiguration) = postSolution";
|
|---|
| 198 | const char _slnProjRelConfTag1[]= ".Release|%1.ActiveCfg = Release|";
|
|---|
| 199 | const char _slnProjRelConfTag2[]= ".Release|%1.Build.0 = Release|";
|
|---|
| 200 | const char _slnProjDbgConfTag1[]= ".Debug|%1.ActiveCfg = Debug|";
|
|---|
| 201 | const char _slnProjDbgConfTag2[]= ".Debug|%1.Build.0 = Debug|";
|
|---|
| 202 | const char _slnProjConfEnd[] = "\n\tEndGlobalSection";
|
|---|
| 203 | const char _slnExtSections[] = "\n\tGlobalSection(ExtensibilityGlobals) = postSolution"
|
|---|
| 204 | "\n\tEndGlobalSection"
|
|---|
| 205 | "\n\tGlobalSection(ExtensibilityAddIns) = postSolution"
|
|---|
| 206 | "\n\tEndGlobalSection";
|
|---|
| 207 | // ------------------------------------------------------------------
|
|---|
| 208 |
|
|---|
| 209 | VcprojGenerator::VcprojGenerator() : Win32MakefileGenerator(), init_flag(false)
|
|---|
| 210 | {
|
|---|
| 211 | }
|
|---|
| 212 | bool VcprojGenerator::writeMakefile(QTextStream &t)
|
|---|
| 213 | {
|
|---|
| 214 | initProject(); // Fills the whole project with proper data
|
|---|
| 215 |
|
|---|
| 216 | // Generate solution file
|
|---|
| 217 | if(project->first("TEMPLATE") == "vcsubdirs") {
|
|---|
| 218 | if (!project->isActiveConfig("build_pass")) {
|
|---|
| 219 | debug_msg(1, "Generator: MSVC.NET: Writing solution file");
|
|---|
| 220 | writeSubDirs(t);
|
|---|
| 221 | } else {
|
|---|
| 222 | debug_msg(1, "Generator: MSVC.NET: Not writing solution file for build_pass configs");
|
|---|
| 223 | }
|
|---|
| 224 | return true;
|
|---|
| 225 | } else
|
|---|
| 226 | // Generate single configuration project file
|
|---|
| 227 | if (project->first("TEMPLATE") == "vcapp" ||
|
|---|
| 228 | project->first("TEMPLATE") == "vclib") {
|
|---|
| 229 | if(!project->isActiveConfig("build_pass")) {
|
|---|
| 230 | debug_msg(1, "Generator: MSVC.NET: Writing single configuration project file");
|
|---|
| 231 | XmlOutput xmlOut(t);
|
|---|
| 232 | xmlOut << vcProject;
|
|---|
| 233 | }
|
|---|
| 234 | return true;
|
|---|
| 235 | }
|
|---|
| 236 | return project->isActiveConfig("build_pass");
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 | bool VcprojGenerator::writeProjectMakefile()
|
|---|
| 240 | {
|
|---|
| 241 | usePlatformDir();
|
|---|
| 242 | QTextStream t(&Option::output);
|
|---|
| 243 |
|
|---|
| 244 | // Check if all requirements are fulfilled
|
|---|
| 245 | if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) {
|
|---|
| 246 | fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",
|
|---|
| 247 | var("QMAKE_FAILED_REQUIREMENTS").toLatin1().constData());
|
|---|
| 248 | return true;
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | // Generate project file
|
|---|
| 252 | if(project->first("TEMPLATE") == "vcapp" ||
|
|---|
| 253 | project->first("TEMPLATE") == "vclib") {
|
|---|
| 254 | if (!mergedProjects.count()) {
|
|---|
| 255 | warn_msg(WarnLogic, "Generator: MSVC.NET: no single configuration created, cannot output project!");
|
|---|
| 256 | return false;
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | debug_msg(1, "Generator: MSVC.NET: Writing project file");
|
|---|
| 260 | VCProject mergedProject;
|
|---|
| 261 | for (int i = 0; i < mergedProjects.count(); ++i) {
|
|---|
| 262 | VCProjectSingleConfig *singleProject = &(mergedProjects.at(i)->vcProject);
|
|---|
| 263 | mergedProject.SingleProjects += *singleProject;
|
|---|
| 264 | for (int j = 0; j < singleProject->ExtraCompilersFiles.count(); ++j) {
|
|---|
| 265 | const QString &compilerName = singleProject->ExtraCompilersFiles.at(j).Name;
|
|---|
| 266 | if (!mergedProject.ExtraCompilers.contains(compilerName))
|
|---|
| 267 | mergedProject.ExtraCompilers += compilerName;
|
|---|
| 268 | }
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | if(mergedProjects.count() > 1 &&
|
|---|
| 272 | mergedProjects.at(0)->vcProject.Name ==
|
|---|
| 273 | mergedProjects.at(1)->vcProject.Name)
|
|---|
| 274 | mergedProjects.at(0)->writePrlFile();
|
|---|
| 275 | mergedProject.Name = unescapeFilePath(project->first("QMAKE_ORIG_TARGET"));
|
|---|
| 276 | mergedProject.Version = mergedProjects.at(0)->vcProject.Version;
|
|---|
| 277 | mergedProject.ProjectGUID = project->isEmpty("QMAKE_UUID") ? getProjectUUID().toString().toUpper() : project->first("QMAKE_UUID");
|
|---|
| 278 | mergedProject.Keyword = project->first("VCPROJ_KEYWORD");
|
|---|
| 279 | mergedProject.SccProjectName = mergedProjects.at(0)->vcProject.SccProjectName;
|
|---|
| 280 | mergedProject.SccLocalPath = mergedProjects.at(0)->vcProject.SccLocalPath;
|
|---|
| 281 | mergedProject.PlatformName = mergedProjects.at(0)->vcProject.PlatformName;
|
|---|
| 282 |
|
|---|
| 283 | XmlOutput xmlOut(t);
|
|---|
| 284 | xmlOut << mergedProject;
|
|---|
| 285 | return true;
|
|---|
| 286 | } else if(project->first("TEMPLATE") == "vcsubdirs") {
|
|---|
| 287 | return writeMakefile(t);
|
|---|
| 288 | }
|
|---|
| 289 | return false;
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | struct VcsolutionDepend {
|
|---|
| 293 | QString uuid;
|
|---|
| 294 | QString vcprojFile, orig_target, target;
|
|---|
| 295 | Target targetType;
|
|---|
| 296 | QStringList dependencies;
|
|---|
| 297 | };
|
|---|
| 298 |
|
|---|
| 299 | QUuid VcprojGenerator::getProjectUUID(const QString &filename)
|
|---|
| 300 | {
|
|---|
| 301 | bool validUUID = true;
|
|---|
| 302 |
|
|---|
| 303 | // Read GUID from variable-space
|
|---|
| 304 | QUuid uuid = project->first("GUID");
|
|---|
| 305 |
|
|---|
| 306 | // If none, create one based on the MD5 of absolute project path
|
|---|
| 307 | if(uuid.isNull() || !filename.isEmpty()) {
|
|---|
| 308 | QString abspath = Option::fixPathToLocalOS(filename.isEmpty()?project->first("QMAKE_MAKEFILE"):filename);
|
|---|
| 309 | QByteArray digest = QCryptographicHash::hash(abspath.toUtf8(), QCryptographicHash::Md5);
|
|---|
| 310 | memcpy((unsigned char*)(&uuid), digest.constData(), sizeof(QUuid));
|
|---|
| 311 | validUUID = !uuid.isNull();
|
|---|
| 312 | uuid.data4[0] = (uuid.data4[0] & 0x3F) | 0x80; // UV_DCE variant
|
|---|
| 313 | uuid.data3 = (uuid.data3 & 0x0FFF) | (QUuid::Name<<12);
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|
| 316 | // If still not valid, generate new one, and suggest adding to .pro
|
|---|
| 317 | if(uuid.isNull() || !validUUID) {
|
|---|
| 318 | uuid = QUuid::createUuid();
|
|---|
| 319 | fprintf(stderr,
|
|---|
| 320 | "qmake couldn't create a GUID based on filepath, and we couldn't\nfind a valid GUID in the .pro file (Consider adding\n'GUID = %s' to the .pro file)\n",
|
|---|
| 321 | uuid.toString().toUpper().toLatin1().constData());
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | // Store GUID in variable-space
|
|---|
| 325 | project->values("GUID") = QStringList(uuid.toString().toUpper());
|
|---|
| 326 | return uuid;
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | QUuid VcprojGenerator::increaseUUID(const QUuid &id)
|
|---|
| 330 | {
|
|---|
| 331 | QUuid result(id);
|
|---|
| 332 | qint64 dataFirst = (result.data4[0] << 24) +
|
|---|
| 333 | (result.data4[1] << 16) +
|
|---|
| 334 | (result.data4[2] << 8) +
|
|---|
| 335 | result.data4[3];
|
|---|
| 336 | qint64 dataLast = (result.data4[4] << 24) +
|
|---|
| 337 | (result.data4[5] << 16) +
|
|---|
| 338 | (result.data4[6] << 8) +
|
|---|
| 339 | result.data4[7];
|
|---|
| 340 |
|
|---|
| 341 | if(!(dataLast++))
|
|---|
| 342 | dataFirst++;
|
|---|
| 343 |
|
|---|
| 344 | result.data4[0] = uchar((dataFirst >> 24) & 0xff);
|
|---|
| 345 | result.data4[1] = uchar((dataFirst >> 16) & 0xff);
|
|---|
| 346 | result.data4[2] = uchar((dataFirst >> 8) & 0xff);
|
|---|
| 347 | result.data4[3] = uchar(dataFirst & 0xff);
|
|---|
| 348 | result.data4[4] = uchar((dataLast >> 24) & 0xff);
|
|---|
| 349 | result.data4[5] = uchar((dataLast >> 16) & 0xff);
|
|---|
| 350 | result.data4[6] = uchar((dataLast >> 8) & 0xff);
|
|---|
| 351 | result.data4[7] = uchar(dataLast & 0xff);
|
|---|
| 352 | return result;
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 | void VcprojGenerator::writeSubDirs(QTextStream &t)
|
|---|
| 356 | {
|
|---|
| 357 | // Check if all requirements are fulfilled
|
|---|
| 358 | if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) {
|
|---|
| 359 | fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",
|
|---|
| 360 | var("QMAKE_FAILED_REQUIREMENTS").toLatin1().constData());
|
|---|
| 361 | return;
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | switch(which_dotnet_version()) {
|
|---|
| 365 | case NET2010:
|
|---|
| 366 | t << _slnHeader100;
|
|---|
| 367 | break;
|
|---|
| 368 | case NET2008:
|
|---|
| 369 | t << _slnHeader90;
|
|---|
| 370 | break;
|
|---|
| 371 | case NET2005:
|
|---|
| 372 | t << _slnHeader80;
|
|---|
| 373 | break;
|
|---|
| 374 | case NET2003:
|
|---|
| 375 | t << _slnHeader71;
|
|---|
| 376 | break;
|
|---|
| 377 | case NET2002:
|
|---|
| 378 | t << _slnHeader70;
|
|---|
| 379 | break;
|
|---|
| 380 | default:
|
|---|
| 381 | t << _slnHeader70;
|
|---|
| 382 | warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .sln", which_dotnet_version());
|
|---|
| 383 | break;
|
|---|
| 384 | }
|
|---|
| 385 |
|
|---|
| 386 | QHash<QString, VcsolutionDepend*> solution_depends;
|
|---|
| 387 | QList<VcsolutionDepend*> solution_cleanup;
|
|---|
| 388 |
|
|---|
| 389 | QStringList subdirs = project->values("SUBDIRS");
|
|---|
| 390 | QString oldpwd = qmake_getpwd();
|
|---|
| 391 |
|
|---|
| 392 | // Make sure that all temp projects are configured
|
|---|
| 393 | // for release so that the depends are created
|
|---|
| 394 | // without the debug <lib>dxxx.lib name mangling
|
|---|
| 395 | QStringList old_after_vars = Option::after_user_vars;
|
|---|
| 396 | Option::after_user_vars.append("CONFIG+=release");
|
|---|
| 397 |
|
|---|
| 398 | for(int i = 0; i < subdirs.size(); ++i) {
|
|---|
| 399 | QString tmp = subdirs.at(i);
|
|---|
| 400 | if(!project->isEmpty(tmp + ".file")) {
|
|---|
| 401 | if(!project->isEmpty(tmp + ".subdir"))
|
|---|
| 402 | warn_msg(WarnLogic, "Cannot assign both file and subdir for subdir %s",
|
|---|
| 403 | tmp.toLatin1().constData());
|
|---|
| 404 | tmp = project->first(tmp + ".file");
|
|---|
| 405 | } else if(!project->isEmpty(tmp + ".subdir")) {
|
|---|
| 406 | tmp = project->first(tmp + ".subdir");
|
|---|
| 407 | }
|
|---|
| 408 | QFileInfo fi(fileInfo(Option::fixPathToLocalOS(tmp, true)));
|
|---|
| 409 | if(fi.exists()) {
|
|---|
| 410 | if(fi.isDir()) {
|
|---|
| 411 | QString profile = tmp;
|
|---|
| 412 | if(!profile.endsWith(Option::dir_sep))
|
|---|
| 413 | profile += Option::dir_sep;
|
|---|
| 414 | profile += fi.baseName() + Option::pro_ext;
|
|---|
| 415 | subdirs.append(profile);
|
|---|
| 416 | } else {
|
|---|
| 417 | QMakeProject tmp_proj;
|
|---|
| 418 | QString dir = fi.path(), fn = fi.fileName();
|
|---|
| 419 | if(!dir.isEmpty()) {
|
|---|
| 420 | if(!qmake_setpwd(dir))
|
|---|
| 421 | fprintf(stderr, "Cannot find directory: %s\n", dir.toLatin1().constData());
|
|---|
| 422 | }
|
|---|
| 423 | if(tmp_proj.read(fn)) {
|
|---|
| 424 | // Check if all requirements are fulfilled
|
|---|
| 425 | if(!tmp_proj.variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
|
|---|
| 426 | fprintf(stderr, "Project file(%s) not added to Solution because all requirements not met:\n\t%s\n",
|
|---|
| 427 | fn.toLatin1().constData(), tmp_proj.values("QMAKE_FAILED_REQUIREMENTS").join(" ").toLatin1().constData());
|
|---|
| 428 | continue;
|
|---|
| 429 | }
|
|---|
| 430 | if(tmp_proj.first("TEMPLATE") == "vcsubdirs") {
|
|---|
| 431 | QStringList tmp_proj_subdirs = tmp_proj.variables()["SUBDIRS"];
|
|---|
| 432 | for(int x = 0; x < tmp_proj_subdirs.size(); ++x) {
|
|---|
| 433 | QString tmpdir = tmp_proj_subdirs.at(x);
|
|---|
| 434 | if(!tmp_proj.isEmpty(tmpdir + ".file")) {
|
|---|
| 435 | if(!tmp_proj.isEmpty(tmpdir + ".subdir"))
|
|---|
| 436 | warn_msg(WarnLogic, "Cannot assign both file and subdir for subdir %s",
|
|---|
| 437 | tmpdir.toLatin1().constData());
|
|---|
| 438 | tmpdir = tmp_proj.first(tmpdir + ".file");
|
|---|
| 439 | } else if(!tmp_proj.isEmpty(tmpdir + ".subdir")) {
|
|---|
| 440 | tmpdir = tmp_proj.first(tmpdir + ".subdir");
|
|---|
| 441 | }
|
|---|
| 442 | subdirs += fileFixify(tmpdir);
|
|---|
| 443 | }
|
|---|
| 444 | } else if(tmp_proj.first("TEMPLATE") == "vcapp" || tmp_proj.first("TEMPLATE") == "vclib") {
|
|---|
| 445 | // Initialize a 'fake' project to get the correct variables
|
|---|
| 446 | // and to be able to extract all the dependencies
|
|---|
| 447 | Option::QMAKE_MODE old_mode = Option::qmake_mode;
|
|---|
| 448 | Option::qmake_mode = Option::QMAKE_GENERATE_NOTHING;
|
|---|
| 449 | VcprojGenerator tmp_vcproj;
|
|---|
| 450 | tmp_vcproj.setNoIO(true);
|
|---|
| 451 | tmp_vcproj.setProjectFile(&tmp_proj);
|
|---|
| 452 | Option::qmake_mode = old_mode;
|
|---|
| 453 | if(Option::debug_level) {
|
|---|
| 454 | QMap<QString, QStringList> &vars = tmp_proj.variables();
|
|---|
| 455 | for(QMap<QString, QStringList>::Iterator it = vars.begin();
|
|---|
| 456 | it != vars.end(); ++it) {
|
|---|
| 457 | if(it.key().left(1) != "." && !it.value().isEmpty())
|
|---|
| 458 | debug_msg(1, "%s: %s === %s", fn.toLatin1().constData(), it.key().toLatin1().constData(),
|
|---|
| 459 | it.value().join(" :: ").toLatin1().constData());
|
|---|
| 460 | }
|
|---|
| 461 | }
|
|---|
| 462 |
|
|---|
| 463 | // We assume project filename is [QMAKE_ORIG_TARGET].vcproj
|
|---|
| 464 | QString vcproj = unescapeFilePath(tmp_vcproj.project->first("QMAKE_ORIG_TARGET") + project->first("VCPROJ_EXTENSION"));
|
|---|
| 465 | QString vcprojDir = qmake_getpwd();
|
|---|
| 466 |
|
|---|
| 467 | // If file doesn't exsist, then maybe the users configuration
|
|---|
| 468 | // doesn't allow it to be created. Skip to next...
|
|---|
| 469 | if(!exists(vcprojDir + Option::dir_sep + vcproj)) {
|
|---|
| 470 |
|
|---|
| 471 | // Try to find the directory which fits relative
|
|---|
| 472 | // to the output path, which represents the shadow
|
|---|
| 473 | // path in case we are shadow building
|
|---|
| 474 | QStringList list = fi.path().split(QLatin1Char('/'));
|
|---|
| 475 | QString tmpDir = QFileInfo(Option::output).path() + Option::dir_sep;
|
|---|
| 476 | bool found = false;
|
|---|
| 477 | for (int i = list.size() - 1; i >= 0; --i) {
|
|---|
| 478 | QString curr;
|
|---|
| 479 | for (int j = i; j < list.size(); ++j)
|
|---|
| 480 | curr += list.at(j) + Option::dir_sep;
|
|---|
| 481 | if (exists(tmpDir + curr + vcproj)) {
|
|---|
| 482 | vcprojDir = QDir::cleanPath(tmpDir + curr);
|
|---|
| 483 | found = true;
|
|---|
| 484 | break;
|
|---|
| 485 | }
|
|---|
| 486 | }
|
|---|
| 487 | if (!found) {
|
|---|
| 488 | warn_msg(WarnLogic, "Ignored (not found) '%s'", QString(vcprojDir + Option::dir_sep + vcproj).toLatin1().constData());
|
|---|
| 489 | goto nextfile; // # Dirty!
|
|---|
| 490 | }
|
|---|
| 491 | }
|
|---|
| 492 |
|
|---|
| 493 | VcsolutionDepend *newDep = new VcsolutionDepend;
|
|---|
| 494 | newDep->vcprojFile = vcprojDir + Option::dir_sep + vcproj;
|
|---|
| 495 | newDep->orig_target = unescapeFilePath(tmp_proj.first("QMAKE_ORIG_TARGET"));
|
|---|
| 496 | newDep->target = tmp_proj.first("MSVCPROJ_TARGET").section(Option::dir_sep, -1);
|
|---|
| 497 | newDep->targetType = tmp_vcproj.projectTarget;
|
|---|
| 498 | newDep->uuid = tmp_proj.isEmpty("QMAKE_UUID") ? getProjectUUID(Option::fixPathToLocalOS(vcprojDir + QDir::separator() + vcproj)).toString().toUpper(): tmp_proj.first("QMAKE_UUID");
|
|---|
| 499 |
|
|---|
| 500 | // We want to store it as the .lib name.
|
|---|
| 501 | if(newDep->target.endsWith(".dll"))
|
|---|
| 502 | newDep->target = newDep->target.left(newDep->target.length()-3) + "lib";
|
|---|
| 503 |
|
|---|
| 504 | // All ActiveQt Server projects are dependent on idc.exe
|
|---|
| 505 | if(tmp_proj.variables()["CONFIG"].contains("qaxserver"))
|
|---|
| 506 | newDep->dependencies << "idc.exe";
|
|---|
| 507 |
|
|---|
| 508 | // All extra compilers which has valid input are considered dependencies
|
|---|
| 509 | const QStringList &quc = tmp_proj.variables()["QMAKE_EXTRA_COMPILERS"];
|
|---|
| 510 | for(QStringList::ConstIterator it = quc.constBegin(); it != quc.constEnd(); ++it) {
|
|---|
| 511 | const QStringList &invar = tmp_proj.variables().value((*it) + ".input");
|
|---|
| 512 | for(QStringList::ConstIterator iit = invar.constBegin(); iit != invar.constEnd(); ++iit) {
|
|---|
| 513 | const QStringList fileList = tmp_proj.variables().value(*iit);
|
|---|
| 514 | if (!fileList.isEmpty()) {
|
|---|
| 515 | const QStringList &cmdsParts = tmp_proj.variables().value((*it) + ".commands");
|
|---|
| 516 | bool startOfLine = true;
|
|---|
| 517 | foreach(QString cmd, cmdsParts) {
|
|---|
| 518 | if (!startOfLine) {
|
|---|
| 519 | if (cmd.contains("\r"))
|
|---|
| 520 | startOfLine = true;
|
|---|
| 521 | continue;
|
|---|
| 522 | }
|
|---|
| 523 | if (cmd.isEmpty())
|
|---|
| 524 | continue;
|
|---|
| 525 |
|
|---|
| 526 | startOfLine = false;
|
|---|
| 527 | // Extra compiler commands might be defined in variables, so
|
|---|
| 528 | // expand them (don't care about the in/out files)
|
|---|
| 529 | cmd = tmp_vcproj.replaceExtraCompilerVariables(cmd, QStringList(), QStringList());
|
|---|
| 530 | // Pull out command based on spaces and quoting, if the
|
|---|
| 531 | // command starts with that
|
|---|
| 532 | cmd = cmd.left(cmd.indexOf(cmd.at(0) == '"' ? '"' : ' ', 1));
|
|---|
| 533 | QString dep = cmd.section('/', -1).section('\\', -1);
|
|---|
| 534 | if (!newDep->dependencies.contains(dep))
|
|---|
| 535 | newDep->dependencies << dep;
|
|---|
| 536 | }
|
|---|
| 537 | }
|
|---|
| 538 | }
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | // Add all unknown libs to the deps
|
|---|
| 542 | QStringList where = QStringList() << "QMAKE_LIBS" << "QMAKE_LIBS_PRIVATE";
|
|---|
| 543 | if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
|
|---|
| 544 | where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"];
|
|---|
| 545 | for(QStringList::iterator wit = where.begin();
|
|---|
| 546 | wit != where.end(); ++wit) {
|
|---|
| 547 | QStringList &l = tmp_proj.variables()[(*wit)];
|
|---|
| 548 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
|---|
| 549 | QString opt = (*it);
|
|---|
| 550 | if(!opt.startsWith("/") && // Not a switch
|
|---|
| 551 | opt != newDep->target && // Not self
|
|---|
| 552 | opt != "opengl32.lib" && // We don't care about these libs
|
|---|
| 553 | opt != "glu32.lib" && // to make depgen alittle faster
|
|---|
| 554 | opt != "kernel32.lib" &&
|
|---|
| 555 | opt != "user32.lib" &&
|
|---|
| 556 | opt != "gdi32.lib" &&
|
|---|
| 557 | opt != "comdlg32.lib" &&
|
|---|
| 558 | opt != "advapi32.lib" &&
|
|---|
| 559 | opt != "shell32.lib" &&
|
|---|
| 560 | opt != "ole32.lib" &&
|
|---|
| 561 | opt != "oleaut32.lib" &&
|
|---|
| 562 | opt != "uuid.lib" &&
|
|---|
| 563 | opt != "imm32.lib" &&
|
|---|
| 564 | opt != "winmm.lib" &&
|
|---|
| 565 | opt != "wsock32.lib" &&
|
|---|
| 566 | opt != "ws2_32.lib" &&
|
|---|
| 567 | opt != "winspool.lib" &&
|
|---|
| 568 | opt != "delayimp.lib")
|
|---|
| 569 | {
|
|---|
| 570 | newDep->dependencies << opt.section(Option::dir_sep, -1);
|
|---|
| 571 | }
|
|---|
| 572 | }
|
|---|
| 573 | }
|
|---|
| 574 | #ifdef DEBUG_SOLUTION_GEN
|
|---|
| 575 | qDebug("Deps for %20s: [%s]", newDep->target.toLatin1().constData(), newDep->dependencies.join(" :: ").toLatin1().constData());
|
|---|
| 576 | #endif
|
|---|
| 577 | solution_cleanup.append(newDep);
|
|---|
| 578 | solution_depends.insert(newDep->target, newDep);
|
|---|
| 579 | t << _slnProjectBeg << _slnMSVCvcprojGUID << _slnProjectMid
|
|---|
| 580 | << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile
|
|---|
| 581 | << "\", \"" << newDep->uuid << "\"";
|
|---|
| 582 | t << _slnProjectEnd;
|
|---|
| 583 | }
|
|---|
| 584 | }
|
|---|
| 585 | nextfile:
|
|---|
| 586 | qmake_setpwd(oldpwd);
|
|---|
| 587 | }
|
|---|
| 588 | }
|
|---|
| 589 | }
|
|---|
| 590 | t << _slnGlobalBeg;
|
|---|
| 591 | if (!project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH")) {
|
|---|
| 592 | QString slnConfCE = _slnSolutionConf;
|
|---|
| 593 | QString platform = QString("|") + project->values("CE_SDK").join(" ") + " (" + project->first("CE_ARCH") + ")";
|
|---|
| 594 | slnConfCE.replace(QString("|Win32"), platform);
|
|---|
| 595 | t << slnConfCE;
|
|---|
| 596 | } else {
|
|---|
| 597 | t << _slnSolutionConf;
|
|---|
| 598 | }
|
|---|
| 599 | t << _slnProjDepBeg;
|
|---|
| 600 |
|
|---|
| 601 | // Restore previous after_user_var options
|
|---|
| 602 | Option::after_user_vars = old_after_vars;
|
|---|
| 603 |
|
|---|
| 604 | // Figure out dependencies
|
|---|
| 605 | for(QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) {
|
|---|
| 606 | int cnt = 0;
|
|---|
| 607 | for(QStringList::iterator dit = (*it)->dependencies.begin(); dit != (*it)->dependencies.end(); ++dit) {
|
|---|
| 608 | if(VcsolutionDepend *vc = solution_depends[*dit])
|
|---|
| 609 | t << "\n\t\t" << (*it)->uuid << "." << cnt++ << " = " << vc->uuid;
|
|---|
| 610 | }
|
|---|
| 611 | }
|
|---|
| 612 | t << _slnProjDepEnd;
|
|---|
| 613 | t << _slnProjConfBeg;
|
|---|
| 614 | for(QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) {
|
|---|
| 615 | QString platform = "Win32";
|
|---|
| 616 | if (!project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH"))
|
|---|
| 617 | platform = project->values("CE_SDK").join(" ") + " (" + project->first("CE_ARCH") + ")";
|
|---|
| 618 | t << "\n\t\t" << (*it)->uuid << QString(_slnProjDbgConfTag1).arg(platform) << platform;
|
|---|
| 619 | t << "\n\t\t" << (*it)->uuid << QString(_slnProjDbgConfTag2).arg(platform) << platform;
|
|---|
| 620 | t << "\n\t\t" << (*it)->uuid << QString(_slnProjRelConfTag1).arg(platform) << platform;
|
|---|
| 621 | t << "\n\t\t" << (*it)->uuid << QString(_slnProjRelConfTag2).arg(platform) << platform;
|
|---|
| 622 | }
|
|---|
| 623 | t << _slnProjConfEnd;
|
|---|
| 624 | t << _slnExtSections;
|
|---|
| 625 | t << _slnGlobalEnd;
|
|---|
| 626 |
|
|---|
| 627 |
|
|---|
| 628 | while (!solution_cleanup.isEmpty())
|
|---|
| 629 | delete solution_cleanup.takeFirst();
|
|---|
| 630 | }
|
|---|
| 631 |
|
|---|
| 632 | // ------------------------------------------------------------------------------------------------
|
|---|
| 633 | // ------------------------------------------------------------------------------------------------
|
|---|
| 634 |
|
|---|
| 635 | bool VcprojGenerator::hasBuiltinCompiler(const QString &file)
|
|---|
| 636 | {
|
|---|
| 637 | // Source files
|
|---|
| 638 | for (int i = 0; i < Option::cpp_ext.count(); ++i)
|
|---|
| 639 | if (file.endsWith(Option::cpp_ext.at(i)))
|
|---|
| 640 | return true;
|
|---|
| 641 | for (int i = 0; i < Option::c_ext.count(); ++i)
|
|---|
| 642 | if (file.endsWith(Option::c_ext.at(i)))
|
|---|
| 643 | return true;
|
|---|
| 644 | if (file.endsWith(".rc")
|
|---|
| 645 | || file.endsWith(".idl"))
|
|---|
| 646 | return true;
|
|---|
| 647 | return false;
|
|---|
| 648 | }
|
|---|
| 649 |
|
|---|
| 650 | void VcprojGenerator::init()
|
|---|
| 651 | {
|
|---|
| 652 | if(init_flag)
|
|---|
| 653 | return;
|
|---|
| 654 | if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs
|
|---|
| 655 | init_flag = true;
|
|---|
| 656 | return;
|
|---|
| 657 | }
|
|---|
| 658 |
|
|---|
| 659 | debug_msg(1, "Generator: MSVC.NET: Initializing variables");
|
|---|
| 660 |
|
|---|
| 661 | // this should probably not be here, but I'm using it to wrap the .t files
|
|---|
| 662 | if (project->first("TEMPLATE") == "vcapp")
|
|---|
| 663 | project->values("QMAKE_APP_FLAG").append("1");
|
|---|
| 664 | else if (project->first("TEMPLATE") == "vclib")
|
|---|
| 665 | project->values("QMAKE_LIB_FLAG").append("1");
|
|---|
| 666 | if (project->values("QMAKESPEC").isEmpty())
|
|---|
| 667 | project->values("QMAKESPEC").append(qgetenv("QMAKESPEC"));
|
|---|
| 668 |
|
|---|
| 669 | processVars();
|
|---|
| 670 | initOld(); // Currently calling old DSP code to set variables. CLEAN UP!
|
|---|
| 671 |
|
|---|
| 672 | // Figure out what we're trying to build
|
|---|
| 673 | if(project->first("TEMPLATE") == "vcapp") {
|
|---|
| 674 | projectTarget = Application;
|
|---|
| 675 | } else if(project->first("TEMPLATE") == "vclib") {
|
|---|
| 676 | if(project->isActiveConfig("staticlib")) {
|
|---|
| 677 | if (!project->values("RES_FILE").isEmpty())
|
|---|
| 678 | project->values("MSVCPROJ_LIBS") += escapeFilePaths(project->values("RES_FILE"));
|
|---|
| 679 | projectTarget = StaticLib;
|
|---|
| 680 | } else
|
|---|
| 681 | projectTarget = SharedLib;
|
|---|
| 682 | }
|
|---|
| 683 |
|
|---|
| 684 | // Setup PCH variables
|
|---|
| 685 | precompH = project->first("PRECOMPILED_HEADER");
|
|---|
| 686 | precompCPP = project->first("PRECOMPILED_SOURCE");
|
|---|
| 687 | usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header");
|
|---|
| 688 | if (usePCH) {
|
|---|
| 689 | precompHFilename = fileInfo(precompH).fileName();
|
|---|
| 690 | // Created files
|
|---|
| 691 | QString origTarget = unescapeFilePath(project->first("QMAKE_ORIG_TARGET"));
|
|---|
| 692 | precompObj = origTarget + Option::obj_ext;
|
|---|
| 693 | precompPch = origTarget + ".pch";
|
|---|
| 694 | // Add PRECOMPILED_HEADER to HEADERS
|
|---|
| 695 | if (!project->values("HEADERS").contains(precompH))
|
|---|
| 696 | project->values("HEADERS") += precompH;
|
|---|
| 697 | // Return to variable pool
|
|---|
| 698 | project->values("PRECOMPILED_OBJECT") = QStringList(precompObj);
|
|---|
| 699 | project->values("PRECOMPILED_PCH") = QStringList(precompPch);
|
|---|
| 700 |
|
|---|
| 701 | autogenPrecompCPP = precompCPP.isEmpty() && project->isActiveConfig("autogen_precompile_source");
|
|---|
| 702 | if (autogenPrecompCPP) {
|
|---|
| 703 | precompCPP = precompH
|
|---|
| 704 | + (Option::cpp_ext.count() ? Option::cpp_ext.at(0) : QLatin1String(".cpp"));
|
|---|
| 705 | project->values("GENERATED_SOURCES") += precompCPP;
|
|---|
| 706 | } else if (!precompCPP.isEmpty()) {
|
|---|
| 707 | project->values("SOURCES") += precompCPP;
|
|---|
| 708 | }
|
|---|
| 709 | }
|
|---|
| 710 |
|
|---|
| 711 | // Add all input files for a custom compiler into a map for uniqueness,
|
|---|
| 712 | // unless the compiler is configure as a combined stage, then use the first one
|
|---|
| 713 | const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");
|
|---|
| 714 | for(QStringList::ConstIterator it = quc.constBegin(); it != quc.constEnd(); ++it) {
|
|---|
| 715 | const QStringList &invar = project->variables().value((*it) + ".input");
|
|---|
| 716 | const QString compiler_out = project->first((*it) + ".output");
|
|---|
| 717 | for(QStringList::ConstIterator iit = invar.constBegin(); iit != invar.constEnd(); ++iit) {
|
|---|
| 718 | QStringList fileList = project->variables().value(*iit);
|
|---|
| 719 | if (!fileList.isEmpty()) {
|
|---|
| 720 | if (project->values((*it) + ".CONFIG").indexOf("combine") != -1)
|
|---|
| 721 | fileList = QStringList(fileList.first());
|
|---|
| 722 | for(QStringList::ConstIterator fit = fileList.constBegin(); fit != fileList.constEnd(); ++fit) {
|
|---|
| 723 | QString file = (*fit);
|
|---|
| 724 | if (verifyExtraCompiler((*it), file)) {
|
|---|
| 725 | if (!hasBuiltinCompiler(file)) {
|
|---|
| 726 | extraCompilerSources[file] += *it;
|
|---|
| 727 | } else {
|
|---|
| 728 | QString out = Option::fixPathToTargetOS(replaceExtraCompilerVariables(
|
|---|
| 729 | compiler_out, file, QString()), false);
|
|---|
| 730 | extraCompilerSources[out] += *it;
|
|---|
| 731 | extraCompilerOutputs[out] = QStringList(file); // Can only have one
|
|---|
| 732 | }
|
|---|
| 733 | }
|
|---|
| 734 | }
|
|---|
| 735 | }
|
|---|
| 736 | }
|
|---|
| 737 | }
|
|---|
| 738 |
|
|---|
| 739 | #if 0 // Debugging
|
|---|
| 740 | Q_FOREACH(QString aKey, extraCompilerSources.keys()) {
|
|---|
| 741 | qDebug("Extracompilers for %s are (%s)", aKey.toLatin1().constData(), extraCompilerSources.value(aKey).join(", ").toLatin1().constData());
|
|---|
| 742 | }
|
|---|
| 743 | Q_FOREACH(QString aKey, extraCompilerOutputs.keys()) {
|
|---|
| 744 | qDebug("Object mapping for %s is (%s)", aKey.toLatin1().constData(), extraCompilerOutputs.value(aKey).join(", ").toLatin1().constData());
|
|---|
| 745 | }
|
|---|
| 746 | qDebug("");
|
|---|
| 747 | #endif
|
|---|
| 748 | }
|
|---|
| 749 |
|
|---|
| 750 | bool VcprojGenerator::mergeBuildProject(MakefileGenerator *other)
|
|---|
| 751 | {
|
|---|
| 752 | VcprojGenerator *otherVC = static_cast<VcprojGenerator*>(other);
|
|---|
| 753 | if (!otherVC) {
|
|---|
| 754 | warn_msg(WarnLogic, "VcprojGenerator: Cannot merge other types of projects! (ignored)");
|
|---|
| 755 | return false;
|
|---|
| 756 | }
|
|---|
| 757 | mergedProjects += otherVC;
|
|---|
| 758 | return true;
|
|---|
| 759 | }
|
|---|
| 760 |
|
|---|
| 761 | void VcprojGenerator::initProject()
|
|---|
| 762 | {
|
|---|
| 763 | // Initialize XML sub elements
|
|---|
| 764 | // - Do this first since project elements may need
|
|---|
| 765 | // - to know of certain configuration options
|
|---|
| 766 | initConfiguration();
|
|---|
| 767 | initRootFiles();
|
|---|
| 768 | initSourceFiles();
|
|---|
| 769 | initHeaderFiles();
|
|---|
| 770 | initGeneratedFiles();
|
|---|
| 771 | initLexYaccFiles();
|
|---|
| 772 | initTranslationFiles();
|
|---|
| 773 | initFormFiles();
|
|---|
| 774 | initResourceFiles();
|
|---|
| 775 | initExtraCompilerOutputs();
|
|---|
| 776 |
|
|---|
| 777 | // Own elements -----------------------------
|
|---|
| 778 | vcProject.Name = unescapeFilePath(project->first("QMAKE_ORIG_TARGET"));
|
|---|
| 779 | switch(which_dotnet_version()) {
|
|---|
| 780 | case NET2008:
|
|---|
| 781 | vcProject.Version = "9,00";
|
|---|
| 782 | break;
|
|---|
| 783 | case NET2005:
|
|---|
| 784 | //### using ',' because of a bug in 2005 B2
|
|---|
| 785 | //### VS uses '.' or ',' depending on the regional settings! Using ',' always works.
|
|---|
| 786 | vcProject.Version = "8,00";
|
|---|
| 787 | break;
|
|---|
| 788 | case NET2003:
|
|---|
| 789 | vcProject.Version = "7.10";
|
|---|
| 790 | break;
|
|---|
| 791 | case NET2002:
|
|---|
| 792 | vcProject.Version = "7.00";
|
|---|
| 793 | break;
|
|---|
| 794 | default:
|
|---|
| 795 | vcProject.Version = "7.00";
|
|---|
| 796 | warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .vcproj", which_dotnet_version());
|
|---|
| 797 | break;
|
|---|
| 798 | }
|
|---|
| 799 |
|
|---|
| 800 | vcProject.Keyword = project->first("VCPROJ_KEYWORD");
|
|---|
| 801 | if (project->isEmpty("CE_SDK") || project->isEmpty("CE_ARCH")) {
|
|---|
| 802 | vcProject.PlatformName = (vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32");
|
|---|
| 803 | } else {
|
|---|
| 804 | vcProject.PlatformName = project->values("CE_SDK").join(" ") + " (" + project->first("CE_ARCH") + ")";
|
|---|
| 805 | }
|
|---|
| 806 | // These are not used by Qt, but may be used by customers
|
|---|
| 807 | vcProject.SccProjectName = project->first("SCCPROJECTNAME");
|
|---|
| 808 | vcProject.SccLocalPath = project->first("SCCLOCALPATH");
|
|---|
| 809 | vcProject.flat_files = project->isActiveConfig("flat");
|
|---|
| 810 | }
|
|---|
| 811 |
|
|---|
| 812 | void VcprojGenerator::initConfiguration()
|
|---|
| 813 | {
|
|---|
| 814 | // Initialize XML sub elements
|
|---|
| 815 | // - Do this first since main configuration elements may need
|
|---|
| 816 | // - to know of certain compiler/linker options
|
|---|
| 817 | VCConfiguration &conf = vcProject.Configuration;
|
|---|
| 818 | conf.CompilerVersion = which_dotnet_version();
|
|---|
| 819 |
|
|---|
| 820 | initCompilerTool();
|
|---|
| 821 |
|
|---|
| 822 | // Only on configuration per build
|
|---|
| 823 | bool isDebug = project->isActiveConfig("debug");
|
|---|
| 824 |
|
|---|
| 825 | if(projectTarget == StaticLib)
|
|---|
| 826 | initLibrarianTool();
|
|---|
| 827 | else {
|
|---|
| 828 | conf.linker.GenerateDebugInformation = isDebug ? _True : _False;
|
|---|
| 829 | initLinkerTool();
|
|---|
| 830 | }
|
|---|
| 831 | initResourceTool();
|
|---|
| 832 | initIDLTool();
|
|---|
| 833 |
|
|---|
| 834 | // Own elements -----------------------------
|
|---|
| 835 | QString temp = project->first("BuildBrowserInformation");
|
|---|
| 836 | switch (projectTarget) {
|
|---|
| 837 | case SharedLib:
|
|---|
| 838 | conf.ConfigurationType = typeDynamicLibrary;
|
|---|
| 839 | break;
|
|---|
| 840 | case StaticLib:
|
|---|
| 841 | conf.ConfigurationType = typeStaticLibrary;
|
|---|
| 842 | break;
|
|---|
| 843 | case Application:
|
|---|
| 844 | default:
|
|---|
| 845 | conf.ConfigurationType = typeApplication;
|
|---|
| 846 | break;
|
|---|
| 847 | }
|
|---|
| 848 |
|
|---|
| 849 | conf.Name = project->values("BUILD_NAME").join(" ");
|
|---|
| 850 | if (conf.Name.isEmpty())
|
|---|
| 851 | conf.Name = isDebug ? "Debug" : "Release";
|
|---|
| 852 | if (project->isEmpty("CE_SDK") || project->isEmpty("CE_ARCH")) {
|
|---|
| 853 | conf.Name += (conf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32");
|
|---|
| 854 | } else {
|
|---|
| 855 | conf.Name += "|" + project->values("CE_SDK").join(" ") + " (" + project->first("CE_ARCH") + ")";
|
|---|
| 856 | }
|
|---|
| 857 | conf.ATLMinimizesCRunTimeLibraryUsage = (project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True);
|
|---|
| 858 | conf.BuildBrowserInformation = triState(temp.isEmpty() ? (short)unset : temp.toShort());
|
|---|
| 859 | temp = project->first("CharacterSet");
|
|---|
| 860 | conf.CharacterSet = charSet(temp.isEmpty() ? (short)charSetNotSet : temp.toShort());
|
|---|
| 861 | conf.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean");
|
|---|
| 862 | conf.ImportLibrary = conf.linker.ImportLibrary;
|
|---|
| 863 | conf.IntermediateDirectory = project->first("OBJECTS_DIR");
|
|---|
| 864 | conf.OutputDirectory = ".";
|
|---|
| 865 | conf.PrimaryOutput = project->first("PrimaryOutput");
|
|---|
| 866 | conf.WholeProgramOptimization = conf.compiler.WholeProgramOptimization;
|
|---|
| 867 | temp = project->first("UseOfATL");
|
|---|
| 868 | if(!temp.isEmpty())
|
|---|
| 869 | conf.UseOfATL = useOfATL(temp.toShort());
|
|---|
| 870 | temp = project->first("UseOfMfc");
|
|---|
| 871 | if(!temp.isEmpty())
|
|---|
| 872 | conf.UseOfMfc = useOfMfc(temp.toShort());
|
|---|
| 873 |
|
|---|
| 874 | // Configuration does not need parameters from
|
|---|
| 875 | // these sub XML items;
|
|---|
| 876 | initCustomBuildTool();
|
|---|
| 877 | initPreBuildEventTools();
|
|---|
| 878 | initPostBuildEventTools();
|
|---|
| 879 | // Only deploy for CE projects
|
|---|
| 880 | if (!project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH"))
|
|---|
| 881 | initDeploymentTool();
|
|---|
| 882 | initPreLinkEventTools();
|
|---|
| 883 |
|
|---|
| 884 | // Set definite values in both configurations
|
|---|
| 885 | if (isDebug) {
|
|---|
| 886 | conf.compiler.PreprocessorDefinitions.removeAll("NDEBUG");
|
|---|
| 887 | } else {
|
|---|
| 888 | conf.compiler.PreprocessorDefinitions += "NDEBUG";
|
|---|
| 889 | }
|
|---|
| 890 |
|
|---|
| 891 | }
|
|---|
| 892 |
|
|---|
| 893 | void VcprojGenerator::initCompilerTool()
|
|---|
| 894 | {
|
|---|
| 895 | QString placement = project->first("OBJECTS_DIR");
|
|---|
| 896 | if(placement.isEmpty())
|
|---|
| 897 | placement = ".\\";
|
|---|
| 898 |
|
|---|
| 899 | VCConfiguration &conf = vcProject.Configuration;
|
|---|
| 900 | conf.compiler.AssemblerListingLocation = placement ;
|
|---|
| 901 | conf.compiler.ProgramDataBaseFileName = ".\\" ;
|
|---|
| 902 | conf.compiler.ObjectFile = placement ;
|
|---|
| 903 | conf.compiler.ExceptionHandling = ehNone;
|
|---|
| 904 | // PCH
|
|---|
| 905 | if (usePCH) {
|
|---|
| 906 | conf.compiler.UsePrecompiledHeader = pchUseUsingSpecific;
|
|---|
| 907 | conf.compiler.PrecompiledHeaderFile = "$(IntDir)\\" + precompPch;
|
|---|
| 908 | conf.compiler.PrecompiledHeaderThrough = project->first("PRECOMPILED_HEADER");
|
|---|
| 909 | conf.compiler.ForcedIncludeFiles = project->values("PRECOMPILED_HEADER");
|
|---|
| 910 | // Minimal build option triggers an Internal Compiler Error
|
|---|
| 911 | // when used in conjunction with /FI and /Yu, so remove it
|
|---|
| 912 | project->values("QMAKE_CFLAGS_DEBUG").removeAll("-Gm");
|
|---|
| 913 | project->values("QMAKE_CFLAGS_DEBUG").removeAll("/Gm");
|
|---|
| 914 | project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("-Gm");
|
|---|
| 915 | project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("/Gm");
|
|---|
| 916 | }
|
|---|
| 917 |
|
|---|
| 918 | conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS"));
|
|---|
| 919 | if(project->isActiveConfig("debug")){
|
|---|
| 920 | // Debug version
|
|---|
| 921 | if((projectTarget == Application) || (projectTarget == StaticLib))
|
|---|
| 922 | conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT_DBG"));
|
|---|
| 923 | else
|
|---|
| 924 | conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT_DLLDBG"));
|
|---|
| 925 | } else {
|
|---|
| 926 | // Release version
|
|---|
| 927 | conf.compiler.PreprocessorDefinitions += "QT_NO_DEBUG";
|
|---|
| 928 | conf.compiler.PreprocessorDefinitions += "NDEBUG";
|
|---|
| 929 | if((projectTarget == Application) || (projectTarget == StaticLib))
|
|---|
| 930 | conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT"));
|
|---|
| 931 | else
|
|---|
| 932 | conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT_DLL"));
|
|---|
| 933 | }
|
|---|
| 934 |
|
|---|
| 935 | // Common for both release and debug
|
|---|
| 936 | if(project->isActiveConfig("windows"))
|
|---|
| 937 | conf.compiler.PreprocessorDefinitions += project->values("MSVCPROJ_WINCONDEF");
|
|---|
| 938 |
|
|---|
| 939 | // Can this be set for ALL configs?
|
|---|
| 940 | // If so, use qmake.conf!
|
|---|
| 941 | if(projectTarget == SharedLib)
|
|---|
| 942 | conf.compiler.PreprocessorDefinitions += "_WINDOWS";
|
|---|
| 943 |
|
|---|
| 944 | conf.compiler.PreprocessorDefinitions += project->values("DEFINES");
|
|---|
| 945 | conf.compiler.PreprocessorDefinitions += project->values("PRL_EXPORT_DEFINES");
|
|---|
| 946 | conf.compiler.parseOptions(project->values("MSVCPROJ_INCPATH"));
|
|---|
| 947 | }
|
|---|
| 948 |
|
|---|
| 949 | void VcprojGenerator::initLibrarianTool()
|
|---|
| 950 | {
|
|---|
| 951 | VCConfiguration &conf = vcProject.Configuration;
|
|---|
| 952 | conf.librarian.OutputFile = project->first("DESTDIR");
|
|---|
| 953 | if(conf.librarian.OutputFile.isEmpty())
|
|---|
| 954 | conf.librarian.OutputFile = ".\\";
|
|---|
| 955 |
|
|---|
| 956 | if(!conf.librarian.OutputFile.endsWith("\\"))
|
|---|
| 957 | conf.librarian.OutputFile += '\\';
|
|---|
| 958 |
|
|---|
| 959 | conf.librarian.OutputFile += project->first("MSVCPROJ_TARGET");
|
|---|
| 960 | conf.librarian.AdditionalOptions += project->values("QMAKE_LIBFLAGS");
|
|---|
| 961 | }
|
|---|
| 962 |
|
|---|
| 963 | void VcprojGenerator::initLinkerTool()
|
|---|
| 964 | {
|
|---|
| 965 | findLibraries(); // Need to add the highest version of the libs
|
|---|
| 966 | VCConfiguration &conf = vcProject.Configuration;
|
|---|
| 967 | conf.linker.parseOptions(project->values("MSVCPROJ_LFLAGS"));
|
|---|
| 968 |
|
|---|
| 969 | foreach(QString libs, project->values("MSVCPROJ_LIBS")) {
|
|---|
| 970 | if (libs.left(9).toUpper() == "/LIBPATH:") {
|
|---|
| 971 | QStringList l = QStringList(libs);
|
|---|
| 972 | conf.linker.parseOptions(l);
|
|---|
| 973 | } else {
|
|---|
| 974 | conf.linker.AdditionalDependencies += libs;
|
|---|
| 975 | }
|
|---|
| 976 | }
|
|---|
| 977 |
|
|---|
| 978 | switch (projectTarget) {
|
|---|
| 979 | case Application:
|
|---|
| 980 | conf.linker.OutputFile = project->first("DESTDIR");
|
|---|
| 981 | break;
|
|---|
| 982 | case SharedLib:
|
|---|
| 983 | conf.linker.parseOptions(project->values("MSVCPROJ_LIBOPTIONS"));
|
|---|
| 984 | conf.linker.OutputFile = project->first("DESTDIR");
|
|---|
| 985 | break;
|
|---|
| 986 | case StaticLib: //unhandled - added to remove warnings..
|
|---|
| 987 | break;
|
|---|
| 988 | }
|
|---|
| 989 |
|
|---|
| 990 | if(conf.linker.OutputFile.isEmpty())
|
|---|
| 991 | conf.linker.OutputFile = ".\\";
|
|---|
| 992 |
|
|---|
| 993 | if(!conf.linker.OutputFile.endsWith("\\"))
|
|---|
| 994 | conf.linker.OutputFile += '\\';
|
|---|
| 995 |
|
|---|
| 996 | conf.linker.OutputFile += project->first("MSVCPROJ_TARGET");
|
|---|
| 997 |
|
|---|
| 998 | if(project->isActiveConfig("dll")){
|
|---|
| 999 | conf.linker.parseOptions(project->values("QMAKE_LFLAGS_QT_DLL"));
|
|---|
| 1000 | }
|
|---|
| 1001 | }
|
|---|
| 1002 |
|
|---|
| 1003 | void VcprojGenerator::initResourceTool()
|
|---|
| 1004 | {
|
|---|
| 1005 | VCConfiguration &conf = vcProject.Configuration;
|
|---|
| 1006 | conf.resource.PreprocessorDefinitions = conf.compiler.PreprocessorDefinitions;
|
|---|
| 1007 |
|
|---|
| 1008 | // We need to add _DEBUG for the debug version of the project, since the normal compiler defines
|
|---|
| 1009 | // do not contain it. (The compiler defines this symbol automatically, which is wy we don't need
|
|---|
| 1010 | // to add it for the compiler) However, the resource tool does not do this.
|
|---|
| 1011 | if(project->isActiveConfig("debug"))
|
|---|
| 1012 | conf.resource.PreprocessorDefinitions += "_DEBUG";
|
|---|
| 1013 | if(project->isActiveConfig("staticlib"))
|
|---|
| 1014 | conf.resource.ResourceOutputFileName = project->first("DESTDIR") + "/$(InputName).res";
|
|---|
| 1015 | }
|
|---|
| 1016 |
|
|---|
| 1017 |
|
|---|
| 1018 | void VcprojGenerator::initIDLTool()
|
|---|
| 1019 | {
|
|---|
| 1020 | }
|
|---|
| 1021 |
|
|---|
| 1022 | void VcprojGenerator::initCustomBuildTool()
|
|---|
| 1023 | {
|
|---|
| 1024 | }
|
|---|
| 1025 |
|
|---|
| 1026 | void VcprojGenerator::initPreBuildEventTools()
|
|---|
| 1027 | {
|
|---|
| 1028 | }
|
|---|
| 1029 |
|
|---|
| 1030 | void VcprojGenerator::initPostBuildEventTools()
|
|---|
| 1031 | {
|
|---|
| 1032 | VCConfiguration &conf = vcProject.Configuration;
|
|---|
| 1033 | if(!project->values("QMAKE_POST_LINK").isEmpty()) {
|
|---|
| 1034 | QStringList cmdline = VCToolBase::fixCommandLine(var("QMAKE_POST_LINK"));
|
|---|
| 1035 | conf.postBuild.CommandLine = cmdline;
|
|---|
| 1036 | conf.postBuild.Description = cmdline.join(QLatin1String("\r\n"));
|
|---|
| 1037 | }
|
|---|
| 1038 |
|
|---|
| 1039 | QString signature = !project->isEmpty("SIGNATURE_FILE") ? var("SIGNATURE_FILE") : var("DEFAULT_SIGNATURE");
|
|---|
| 1040 | bool useSignature = !signature.isEmpty() && !project->isActiveConfig("staticlib") &&
|
|---|
| 1041 | !project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH");
|
|---|
| 1042 | if(useSignature)
|
|---|
| 1043 | conf.postBuild.CommandLine.prepend(
|
|---|
| 1044 | QLatin1String("signtool sign /F ") + signature + QLatin1String(" \"$(TargetPath)\""));
|
|---|
| 1045 |
|
|---|
| 1046 | if(!project->values("MSVCPROJ_COPY_DLL").isEmpty()) {
|
|---|
| 1047 | conf.postBuild.Description += var("MSVCPROJ_COPY_DLL_DESC");
|
|---|
| 1048 | conf.postBuild.CommandLine += var("MSVCPROJ_COPY_DLL");
|
|---|
| 1049 | }
|
|---|
| 1050 | }
|
|---|
| 1051 |
|
|---|
| 1052 | void VcprojGenerator::initDeploymentTool()
|
|---|
| 1053 | {
|
|---|
| 1054 | VCConfiguration &conf = vcProject.Configuration;
|
|---|
| 1055 | QString targetPath = project->values("deploy.path").join(" ");
|
|---|
| 1056 | if (targetPath.isEmpty())
|
|---|
| 1057 | targetPath = QString("%CSIDL_PROGRAM_FILES%\\") + project->first("TARGET");
|
|---|
| 1058 | if (targetPath.endsWith("/") || targetPath.endsWith("\\"))
|
|---|
| 1059 | targetPath.chop(1);
|
|---|
| 1060 |
|
|---|
| 1061 | // Only deploy Qt libs for shared build
|
|---|
| 1062 | if (!project->values("QMAKE_QT_DLL").isEmpty()) {
|
|---|
| 1063 | QStringList& arg = project->values("MSVCPROJ_LIBS");
|
|---|
| 1064 | for (QStringList::ConstIterator it = arg.constBegin(); it != arg.constEnd(); ++it) {
|
|---|
| 1065 | if (it->contains(project->first("QMAKE_LIBDIR"))) {
|
|---|
| 1066 | QString dllName = *it;
|
|---|
| 1067 |
|
|---|
| 1068 | if (dllName.contains(QLatin1String("QAxContainer"))
|
|---|
| 1069 | || dllName.contains(QLatin1String("qtmain"))
|
|---|
| 1070 | || dllName.contains(QLatin1String("QtUiTools")))
|
|---|
| 1071 | continue;
|
|---|
| 1072 | dllName.replace(QLatin1String(".lib") , QLatin1String(".dll"));
|
|---|
| 1073 | QFileInfo info(dllName);
|
|---|
| 1074 | conf.deployment.AdditionalFiles += info.fileName()
|
|---|
| 1075 | + "|" + QDir::toNativeSeparators(info.absolutePath())
|
|---|
| 1076 | + "|" + targetPath
|
|---|
| 1077 | + "|0;";
|
|---|
| 1078 | }
|
|---|
| 1079 | }
|
|---|
| 1080 | }
|
|---|
| 1081 |
|
|---|
| 1082 | // C-runtime deployment
|
|---|
| 1083 | QString runtime = project->values("QT_CE_C_RUNTIME").join(QLatin1String(" "));
|
|---|
| 1084 | if (!runtime.isEmpty() && (runtime != QLatin1String("no"))) {
|
|---|
| 1085 | QString runtimeVersion = QLatin1String("msvcr");
|
|---|
| 1086 | QString mkspec = project->first("QMAKESPEC");
|
|---|
| 1087 | // If no .qmake.cache has been found, we fallback to the original mkspec
|
|---|
| 1088 | if (mkspec.isEmpty())
|
|---|
| 1089 | mkspec = project->first("QMAKESPEC_ORIGINAL");
|
|---|
| 1090 |
|
|---|
| 1091 | if (!mkspec.isEmpty()) {
|
|---|
| 1092 | if (mkspec.endsWith("2008"))
|
|---|
| 1093 | runtimeVersion.append("90");
|
|---|
| 1094 | else
|
|---|
| 1095 | runtimeVersion.append("80");
|
|---|
| 1096 | if (project->isActiveConfig("debug"))
|
|---|
| 1097 | runtimeVersion.append("d");
|
|---|
| 1098 | runtimeVersion.append(".dll");
|
|---|
| 1099 |
|
|---|
| 1100 | if (runtime == "yes") {
|
|---|
| 1101 | // Auto-find C-runtime
|
|---|
| 1102 | QString vcInstallDir = qgetenv("VCINSTALLDIR");
|
|---|
| 1103 | if (!vcInstallDir.isEmpty()) {
|
|---|
| 1104 | vcInstallDir += "\\ce\\dll\\";
|
|---|
| 1105 | vcInstallDir += project->values("CE_ARCH").join(QLatin1String(" "));
|
|---|
| 1106 | if (!QFileInfo(vcInstallDir + QDir::separator() + runtimeVersion).exists())
|
|---|
| 1107 | runtime.clear();
|
|---|
| 1108 | else
|
|---|
| 1109 | runtime = vcInstallDir;
|
|---|
| 1110 | }
|
|---|
| 1111 | }
|
|---|
| 1112 | }
|
|---|
| 1113 |
|
|---|
| 1114 | if (!runtime.isEmpty() && runtime != QLatin1String("yes")) {
|
|---|
| 1115 | conf.deployment.AdditionalFiles += runtimeVersion
|
|---|
| 1116 | + "|" + QDir::toNativeSeparators(runtime)
|
|---|
| 1117 | + "|" + targetPath
|
|---|
| 1118 | + "|0;";
|
|---|
| 1119 | }
|
|---|
| 1120 | }
|
|---|
| 1121 |
|
|---|
| 1122 | // foreach item in DEPLOYMENT
|
|---|
| 1123 | foreach(QString item, project->values("DEPLOYMENT")) {
|
|---|
| 1124 | // get item.path
|
|---|
| 1125 | QString devicePath = project->first(item + ".path");
|
|---|
| 1126 | if (devicePath.isEmpty())
|
|---|
| 1127 | devicePath = targetPath;
|
|---|
| 1128 | // check if item.path is relative (! either /,\ or %)
|
|---|
| 1129 | if (!(devicePath.at(0) == QLatin1Char('/')
|
|---|
| 1130 | || devicePath.at(0) == QLatin1Char('\\')
|
|---|
| 1131 | || devicePath.at(0) == QLatin1Char('%'))) {
|
|---|
| 1132 | // create output path
|
|---|
| 1133 | devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('\\') + devicePath));
|
|---|
| 1134 | }
|
|---|
| 1135 | // foreach d in item.sources
|
|---|
| 1136 | foreach(QString source, project->values(item + ".sources")) {
|
|---|
| 1137 | QString itemDevicePath = devicePath;
|
|---|
| 1138 | source = Option::fixPathToLocalOS(source);
|
|---|
| 1139 | QString nameFilter;
|
|---|
| 1140 | QFileInfo info(source);
|
|---|
| 1141 | QString searchPath;
|
|---|
| 1142 | if (info.isDir()) {
|
|---|
| 1143 | nameFilter = QLatin1String("*");
|
|---|
| 1144 | itemDevicePath += "\\" + info.fileName();
|
|---|
| 1145 | searchPath = info.absoluteFilePath();
|
|---|
| 1146 | } else {
|
|---|
| 1147 | nameFilter = source.split('\\').last();
|
|---|
| 1148 | searchPath = info.absolutePath();
|
|---|
| 1149 | }
|
|---|
| 1150 |
|
|---|
| 1151 | int pathSize = searchPath.size();
|
|---|
| 1152 | QDirIterator iterator(searchPath, QStringList() << nameFilter
|
|---|
| 1153 | , QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks
|
|---|
| 1154 | , QDirIterator::Subdirectories);
|
|---|
| 1155 | // foreach dirIterator-entry in d
|
|---|
| 1156 | while(iterator.hasNext()) {
|
|---|
| 1157 | iterator.next();
|
|---|
| 1158 | QString absoluteItemPath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absolutePath());
|
|---|
| 1159 | // Identify if it is just another subdir
|
|---|
| 1160 | int diffSize = absoluteItemPath.size() - pathSize;
|
|---|
| 1161 | // write out rules
|
|---|
| 1162 | conf.deployment.AdditionalFiles += iterator.fileName()
|
|---|
| 1163 | + "|" + absoluteItemPath
|
|---|
| 1164 | + "|" + itemDevicePath + (diffSize ? (absoluteItemPath.right(diffSize)) : QLatin1String(""))
|
|---|
| 1165 | + "|0;";
|
|---|
| 1166 | }
|
|---|
| 1167 | }
|
|---|
| 1168 | }
|
|---|
| 1169 | }
|
|---|
| 1170 |
|
|---|
| 1171 | void VcprojGenerator::initPreLinkEventTools()
|
|---|
| 1172 | {
|
|---|
| 1173 | VCConfiguration &conf = vcProject.Configuration;
|
|---|
| 1174 | if(!project->values("QMAKE_PRE_LINK").isEmpty()) {
|
|---|
| 1175 | QStringList cmdline = VCToolBase::fixCommandLine(var("QMAKE_PRE_LINK"));
|
|---|
| 1176 | conf.preLink.CommandLine = cmdline;
|
|---|
| 1177 | conf.preLink.Description = cmdline.join(QLatin1String("\r\n"));
|
|---|
| 1178 | }
|
|---|
| 1179 | }
|
|---|
| 1180 |
|
|---|
| 1181 | void VcprojGenerator::initRootFiles()
|
|---|
| 1182 | {
|
|---|
| 1183 | // Note: Root files do _not_ have any filter name, filter nor GUID!
|
|---|
| 1184 | vcProject.RootFiles.addFiles(project->values("RC_FILE"));
|
|---|
| 1185 |
|
|---|
| 1186 | vcProject.RootFiles.Project = this;
|
|---|
| 1187 | vcProject.RootFiles.Config = &(vcProject.Configuration);
|
|---|
| 1188 | vcProject.RootFiles.CustomBuild = none;
|
|---|
| 1189 | }
|
|---|
| 1190 |
|
|---|
| 1191 | void VcprojGenerator::initSourceFiles()
|
|---|
| 1192 | {
|
|---|
| 1193 | vcProject.SourceFiles.Name = "Source Files";
|
|---|
| 1194 | vcProject.SourceFiles.Filter = "cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx";
|
|---|
| 1195 | vcProject.SourceFiles.Guid = _GUIDSourceFiles;
|
|---|
| 1196 |
|
|---|
| 1197 | vcProject.SourceFiles.addFiles(project->values("SOURCES"));
|
|---|
| 1198 |
|
|---|
| 1199 | vcProject.SourceFiles.Project = this;
|
|---|
| 1200 | vcProject.SourceFiles.Config = &(vcProject.Configuration);
|
|---|
| 1201 | vcProject.SourceFiles.CustomBuild = none;
|
|---|
| 1202 | }
|
|---|
| 1203 |
|
|---|
| 1204 | void VcprojGenerator::initHeaderFiles()
|
|---|
| 1205 | {
|
|---|
| 1206 | vcProject.HeaderFiles.Name = "Header Files";
|
|---|
| 1207 | vcProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl;inc;xsd";
|
|---|
| 1208 | vcProject.HeaderFiles.Guid = _GUIDHeaderFiles;
|
|---|
| 1209 |
|
|---|
| 1210 | vcProject.HeaderFiles.addFiles(project->values("HEADERS"));
|
|---|
| 1211 | if (usePCH) // Generated PCH cpp file
|
|---|
| 1212 | vcProject.HeaderFiles.addFile(precompH);
|
|---|
| 1213 |
|
|---|
| 1214 | vcProject.HeaderFiles.Project = this;
|
|---|
| 1215 | vcProject.HeaderFiles.Config = &(vcProject.Configuration);
|
|---|
| 1216 | // vcProject.HeaderFiles.CustomBuild = mocHdr;
|
|---|
| 1217 | // addMocArguments(vcProject.HeaderFiles);
|
|---|
| 1218 | }
|
|---|
| 1219 |
|
|---|
| 1220 | void VcprojGenerator::initGeneratedFiles()
|
|---|
| 1221 | {
|
|---|
| 1222 | vcProject.GeneratedFiles.Name = "Generated Files";
|
|---|
| 1223 | vcProject.GeneratedFiles.Filter = "cpp;c;cxx;moc;h;def;odl;idl;res;";
|
|---|
| 1224 | vcProject.GeneratedFiles.Guid = _GUIDGeneratedFiles;
|
|---|
| 1225 |
|
|---|
| 1226 | // ### These cannot have CustomBuild (mocSrc)!!
|
|---|
| 1227 | vcProject.GeneratedFiles.addFiles(project->values("GENERATED_SOURCES"));
|
|---|
| 1228 | vcProject.GeneratedFiles.addFiles(project->values("GENERATED_FILES"));
|
|---|
| 1229 | vcProject.GeneratedFiles.addFiles(project->values("IDLSOURCES"));
|
|---|
| 1230 | vcProject.GeneratedFiles.addFiles(project->values("RES_FILE"));
|
|---|
| 1231 | vcProject.GeneratedFiles.addFiles(project->values("QMAKE_IMAGE_COLLECTION")); // compat
|
|---|
| 1232 | if(!extraCompilerOutputs.isEmpty())
|
|---|
| 1233 | vcProject.GeneratedFiles.addFiles(extraCompilerOutputs.keys());
|
|---|
| 1234 |
|
|---|
| 1235 | vcProject.GeneratedFiles.Project = this;
|
|---|
| 1236 | vcProject.GeneratedFiles.Config = &(vcProject.Configuration);
|
|---|
| 1237 | // vcProject.GeneratedFiles.CustomBuild = mocSrc;
|
|---|
| 1238 | }
|
|---|
| 1239 |
|
|---|
| 1240 | void VcprojGenerator::initLexYaccFiles()
|
|---|
| 1241 | {
|
|---|
| 1242 | vcProject.LexYaccFiles.Name = "Lex / Yacc Files";
|
|---|
| 1243 | vcProject.LexYaccFiles.ParseFiles = _False;
|
|---|
| 1244 | vcProject.LexYaccFiles.Filter = "l;y";
|
|---|
| 1245 | vcProject.LexYaccFiles.Guid = _GUIDLexYaccFiles;
|
|---|
| 1246 |
|
|---|
| 1247 | vcProject.LexYaccFiles.addFiles(project->values("LEXSOURCES"));
|
|---|
| 1248 | vcProject.LexYaccFiles.addFiles(project->values("YACCSOURCES"));
|
|---|
| 1249 |
|
|---|
| 1250 | vcProject.LexYaccFiles.Project = this;
|
|---|
| 1251 | vcProject.LexYaccFiles.Config = &(vcProject.Configuration);
|
|---|
| 1252 | vcProject.LexYaccFiles.CustomBuild = lexyacc;
|
|---|
| 1253 | }
|
|---|
| 1254 |
|
|---|
| 1255 | void VcprojGenerator::initTranslationFiles()
|
|---|
| 1256 | {
|
|---|
| 1257 | vcProject.TranslationFiles.Name = "Translation Files";
|
|---|
| 1258 | vcProject.TranslationFiles.ParseFiles = _False;
|
|---|
| 1259 | vcProject.TranslationFiles.Filter = "ts;xlf";
|
|---|
| 1260 | vcProject.TranslationFiles.Guid = _GUIDTranslationFiles;
|
|---|
| 1261 |
|
|---|
| 1262 | vcProject.TranslationFiles.addFiles(project->values("TRANSLATIONS"));
|
|---|
| 1263 |
|
|---|
| 1264 | vcProject.TranslationFiles.Project = this;
|
|---|
| 1265 | vcProject.TranslationFiles.Config = &(vcProject.Configuration);
|
|---|
| 1266 | vcProject.TranslationFiles.CustomBuild = none;
|
|---|
| 1267 | }
|
|---|
| 1268 |
|
|---|
| 1269 |
|
|---|
| 1270 | void VcprojGenerator::initFormFiles()
|
|---|
| 1271 | {
|
|---|
| 1272 | vcProject.FormFiles.Name = "Form Files";
|
|---|
| 1273 | vcProject.FormFiles.ParseFiles = _False;
|
|---|
| 1274 | vcProject.FormFiles.Filter = "ui";
|
|---|
| 1275 | vcProject.FormFiles.Guid = _GUIDFormFiles;
|
|---|
| 1276 |
|
|---|
| 1277 | vcProject.FormFiles.addFiles(project->values("FORMS"));
|
|---|
| 1278 | vcProject.FormFiles.addFiles(project->values("FORMS3"));
|
|---|
| 1279 |
|
|---|
| 1280 | vcProject.FormFiles.Project = this;
|
|---|
| 1281 | vcProject.FormFiles.Config = &(vcProject.Configuration);
|
|---|
| 1282 | vcProject.FormFiles.CustomBuild = none;
|
|---|
| 1283 | }
|
|---|
| 1284 |
|
|---|
| 1285 |
|
|---|
| 1286 | void VcprojGenerator::initResourceFiles()
|
|---|
| 1287 | {
|
|---|
| 1288 | vcProject.ResourceFiles.Name = "Resource Files";
|
|---|
| 1289 | vcProject.ResourceFiles.ParseFiles = _False;
|
|---|
| 1290 | vcProject.ResourceFiles.Filter = "qrc;*"; //"rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;ts;xlf;qrc";
|
|---|
| 1291 | vcProject.ResourceFiles.Guid = _GUIDResourceFiles;
|
|---|
| 1292 |
|
|---|
| 1293 | // Bad hack, please look away -------------------------------------
|
|---|
| 1294 | QString rcc_dep_cmd = project->values("rcc.depend_command").join(" ");
|
|---|
| 1295 | if(!rcc_dep_cmd.isEmpty()) {
|
|---|
| 1296 | QStringList qrc_files = project->values("RESOURCES");
|
|---|
| 1297 | QStringList deps;
|
|---|
| 1298 | if(!qrc_files.isEmpty()) {
|
|---|
| 1299 | for (int i = 0; i < qrc_files.count(); ++i) {
|
|---|
| 1300 | char buff[256];
|
|---|
| 1301 | QString dep_cmd = replaceExtraCompilerVariables(rcc_dep_cmd, qrc_files.at(i),"");
|
|---|
| 1302 |
|
|---|
| 1303 | dep_cmd = Option::fixPathToLocalOS(dep_cmd, true, false);
|
|---|
| 1304 | if(canExecute(dep_cmd)) {
|
|---|
| 1305 | if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
|
|---|
| 1306 | QString indeps;
|
|---|
| 1307 | while(!feof(proc)) {
|
|---|
| 1308 | int read_in = (int)fread(buff, 1, 255, proc);
|
|---|
| 1309 | if(!read_in)
|
|---|
| 1310 | break;
|
|---|
| 1311 | indeps += QByteArray(buff, read_in);
|
|---|
| 1312 | }
|
|---|
| 1313 | QT_PCLOSE(proc);
|
|---|
| 1314 | if(!indeps.isEmpty())
|
|---|
| 1315 | deps += fileFixify(indeps.replace('\n', ' ').simplified().split(' '));
|
|---|
| 1316 | }
|
|---|
| 1317 | }
|
|---|
| 1318 | }
|
|---|
| 1319 | vcProject.ResourceFiles.addFiles(deps);
|
|---|
| 1320 | }
|
|---|
| 1321 | }
|
|---|
| 1322 | // You may look again --------------------------------------------
|
|---|
| 1323 |
|
|---|
| 1324 | vcProject.ResourceFiles.addFiles(project->values("RESOURCES"));
|
|---|
| 1325 | vcProject.ResourceFiles.addFiles(project->values("IMAGES"));
|
|---|
| 1326 |
|
|---|
| 1327 | vcProject.ResourceFiles.Project = this;
|
|---|
| 1328 | vcProject.ResourceFiles.Config = &(vcProject.Configuration);
|
|---|
| 1329 | vcProject.ResourceFiles.CustomBuild = none;
|
|---|
| 1330 | }
|
|---|
| 1331 |
|
|---|
| 1332 | void VcprojGenerator::initExtraCompilerOutputs()
|
|---|
| 1333 | {
|
|---|
| 1334 | QStringList otherFilters;
|
|---|
| 1335 | otherFilters << "FORMS"
|
|---|
| 1336 | << "FORMS3"
|
|---|
| 1337 | << "GENERATED_FILES"
|
|---|
| 1338 | << "GENERATED_SOURCES"
|
|---|
| 1339 | << "HEADERS"
|
|---|
| 1340 | << "IDLSOURCES"
|
|---|
| 1341 | << "IMAGES"
|
|---|
| 1342 | << "LEXSOURCES"
|
|---|
| 1343 | << "QMAKE_IMAGE_COLLECTION"
|
|---|
| 1344 | << "RC_FILE"
|
|---|
| 1345 | << "RESOURCES"
|
|---|
| 1346 | << "RES_FILE"
|
|---|
| 1347 | << "SOURCES"
|
|---|
| 1348 | << "TRANSLATIONS"
|
|---|
| 1349 | << "YACCSOURCES";
|
|---|
| 1350 | const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");
|
|---|
| 1351 | for(QStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) {
|
|---|
| 1352 | QString extracompilerName = project->first((*it) + ".name");
|
|---|
| 1353 | if (extracompilerName.isEmpty())
|
|---|
| 1354 | extracompilerName = (*it);
|
|---|
| 1355 |
|
|---|
| 1356 | // Create an extra compiler filter and add the files
|
|---|
| 1357 | VCFilter extraCompile;
|
|---|
| 1358 | extraCompile.Name = extracompilerName;
|
|---|
| 1359 | extraCompile.ParseFiles = _False;
|
|---|
| 1360 | extraCompile.Filter = "";
|
|---|
| 1361 | extraCompile.Guid = QString(_GUIDExtraCompilerFiles) + "-" + (*it);
|
|---|
| 1362 |
|
|---|
| 1363 |
|
|---|
| 1364 | // If the extra compiler has a variable_out set the output file
|
|---|
| 1365 | // is added to an other file list, and does not need its own..
|
|---|
| 1366 | bool addOnInput = hasBuiltinCompiler(project->first((*it) + ".output"));
|
|---|
| 1367 | QString tmp_other_out = project->first((*it) + ".variable_out");
|
|---|
| 1368 | if (!tmp_other_out.isEmpty() && !addOnInput)
|
|---|
| 1369 | continue;
|
|---|
| 1370 |
|
|---|
| 1371 | if (!addOnInput) {
|
|---|
| 1372 | QString tmp_out = project->first((*it) + ".output");
|
|---|
| 1373 | if (project->values((*it) + ".CONFIG").indexOf("combine") != -1) {
|
|---|
| 1374 | // Combined output, only one file result
|
|---|
| 1375 | extraCompile.addFile(
|
|---|
| 1376 | Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_out, QString(), QString()), false));
|
|---|
| 1377 | } else {
|
|---|
| 1378 | // One output file per input
|
|---|
| 1379 | QStringList tmp_in = project->values(project->first((*it) + ".input"));
|
|---|
| 1380 | for (int i = 0; i < tmp_in.count(); ++i) {
|
|---|
| 1381 | const QString &filename = tmp_in.at(i);
|
|---|
| 1382 | if (extraCompilerSources.contains(filename))
|
|---|
| 1383 | extraCompile.addFile(
|
|---|
| 1384 | Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, tmp_out, QString()), false));
|
|---|
| 1385 | }
|
|---|
| 1386 | }
|
|---|
| 1387 | } else {
|
|---|
| 1388 | // In this case we the outputs have a built-in compiler, so we cannot add the custom
|
|---|
| 1389 | // build steps there. So, we turn it around and add it to the input files instead,
|
|---|
| 1390 | // provided that the input file variable is not handled already (those in otherFilters
|
|---|
| 1391 | // are handled, so we avoid them).
|
|---|
| 1392 | QStringList inputVars = project->values((*it) + ".input");
|
|---|
| 1393 | foreach(QString inputVar, inputVars) {
|
|---|
| 1394 | if (!otherFilters.contains(inputVar)) {
|
|---|
| 1395 | QStringList tmp_in = project->values(inputVar);
|
|---|
| 1396 | for (int i = 0; i < tmp_in.count(); ++i) {
|
|---|
| 1397 | const QString &filename = tmp_in.at(i);
|
|---|
| 1398 | if (extraCompilerSources.contains(filename))
|
|---|
| 1399 | extraCompile.addFile(
|
|---|
| 1400 | Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, QString(), QString()), false));
|
|---|
| 1401 | }
|
|---|
| 1402 | }
|
|---|
| 1403 | }
|
|---|
| 1404 | }
|
|---|
| 1405 | extraCompile.Project = this;
|
|---|
| 1406 | extraCompile.Config = &(vcProject.Configuration);
|
|---|
| 1407 | extraCompile.CustomBuild = none;
|
|---|
| 1408 |
|
|---|
| 1409 | vcProject.ExtraCompilersFiles.append(extraCompile);
|
|---|
| 1410 | }
|
|---|
| 1411 | }
|
|---|
| 1412 |
|
|---|
| 1413 | /* \internal
|
|---|
| 1414 | Sets up all needed variables from the environment and all the different caches and .conf files
|
|---|
| 1415 | */
|
|---|
| 1416 |
|
|---|
| 1417 | void VcprojGenerator::initOld()
|
|---|
| 1418 | {
|
|---|
| 1419 | if(init_flag)
|
|---|
| 1420 | return;
|
|---|
| 1421 |
|
|---|
| 1422 | init_flag = true;
|
|---|
| 1423 | QStringList::Iterator it;
|
|---|
| 1424 |
|
|---|
| 1425 | // Decode version, and add it to $$MSVCPROJ_VERSION --------------
|
|---|
| 1426 | if(!project->values("VERSION").isEmpty()) {
|
|---|
| 1427 | QString version = project->values("VERSION")[0];
|
|---|
| 1428 | int firstDot = version.indexOf(".");
|
|---|
| 1429 | QString major = version.left(firstDot);
|
|---|
| 1430 | QString minor = version.right(version.length() - firstDot - 1);
|
|---|
| 1431 | minor.replace(QRegExp("\\."), "");
|
|---|
| 1432 | project->values("MSVCPROJ_VERSION").append("/VERSION:" + major + "." + minor);
|
|---|
| 1433 | project->values("QMAKE_LFLAGS").append("/VERSION:" + major + "." + minor);
|
|---|
| 1434 | }
|
|---|
| 1435 |
|
|---|
| 1436 | project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS"));
|
|---|
| 1437 | project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE"));
|
|---|
| 1438 |
|
|---|
| 1439 | // Get filename w/o extension -----------------------------------
|
|---|
| 1440 | QString msvcproj_project = "";
|
|---|
| 1441 | QString targetfilename = "";
|
|---|
| 1442 | if(!project->isEmpty("TARGET")) {
|
|---|
| 1443 | project->values("TARGET") = unescapeFilePaths(project->values("TARGET"));
|
|---|
| 1444 | targetfilename = msvcproj_project = project->first("TARGET");
|
|---|
| 1445 | }
|
|---|
| 1446 |
|
|---|
| 1447 | // Init base class too -------------------------------------------
|
|---|
| 1448 | MakefileGenerator::init();
|
|---|
| 1449 |
|
|---|
| 1450 | if(msvcproj_project.isEmpty())
|
|---|
| 1451 | msvcproj_project = Option::output.fileName();
|
|---|
| 1452 |
|
|---|
| 1453 | msvcproj_project = msvcproj_project.right(msvcproj_project.length() - msvcproj_project.lastIndexOf("\\") - 1);
|
|---|
| 1454 | msvcproj_project = msvcproj_project.left(msvcproj_project.lastIndexOf("."));
|
|---|
| 1455 | msvcproj_project.replace(QRegExp("-"), "");
|
|---|
| 1456 |
|
|---|
| 1457 | project->values("MSVCPROJ_PROJECT").append(msvcproj_project);
|
|---|
| 1458 | QStringList &proj = project->values("MSVCPROJ_PROJECT");
|
|---|
| 1459 |
|
|---|
| 1460 | for(it = proj.begin(); it != proj.end(); ++it)
|
|---|
| 1461 | (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), "");
|
|---|
| 1462 |
|
|---|
| 1463 | // SUBSYSTEM -----------------------------------------------------
|
|---|
| 1464 | if(!project->values("QMAKE_APP_FLAG").isEmpty()) {
|
|---|
| 1465 | project->values("MSVCPROJ_TEMPLATE").append("win32app" + project->first("VCPROJ_EXTENSION"));
|
|---|
| 1466 | if(project->isActiveConfig("console")) {
|
|---|
| 1467 | project->values("MSVCPROJ_CONSOLE").append("CONSOLE");
|
|---|
| 1468 | project->values("MSVCPROJ_WINCONDEF").append("_CONSOLE");
|
|---|
| 1469 | project->values("MSVCPROJ_VCPROJTYPE").append("0x0103");
|
|---|
| 1470 | project->values("MSVCPROJ_SUBSYSTEM").append("CONSOLE");
|
|---|
| 1471 | } else {
|
|---|
| 1472 | project->values("MSVCPROJ_CONSOLE").clear();
|
|---|
| 1473 | project->values("MSVCPROJ_WINCONDEF").append("_WINDOWS");
|
|---|
| 1474 | project->values("MSVCPROJ_VCPROJTYPE").append("0x0101");
|
|---|
| 1475 | project->values("MSVCPROJ_SUBSYSTEM").append("WINDOWS");
|
|---|
| 1476 | }
|
|---|
| 1477 | }
|
|---|
| 1478 |
|
|---|
| 1479 | // $$QMAKE.. -> $$MSVCPROJ.. -------------------------------------
|
|---|
| 1480 | project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS");
|
|---|
| 1481 | project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS_PRIVATE");
|
|---|
| 1482 | project->values("MSVCPROJ_LFLAGS") += project->values("QMAKE_LFLAGS");
|
|---|
| 1483 | if(!project->values("QMAKE_LIBDIR").isEmpty()) {
|
|---|
| 1484 | QStringList strl = project->values("QMAKE_LIBDIR");
|
|---|
| 1485 | QStringList::iterator stri;
|
|---|
| 1486 | for(stri = strl.begin(); stri != strl.end(); ++stri) {
|
|---|
| 1487 | if(!(*stri).startsWith("/LIBPATH:"))
|
|---|
| 1488 | (*stri).prepend("/LIBPATH:");
|
|---|
| 1489 | }
|
|---|
| 1490 | project->values("MSVCPROJ_LFLAGS") += strl;
|
|---|
| 1491 | }
|
|---|
| 1492 | project->values("MSVCPROJ_CXXFLAGS") += project->values("QMAKE_CXXFLAGS");
|
|---|
| 1493 | QStringList &incs = project->values("INCLUDEPATH");
|
|---|
| 1494 | for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
|
|---|
| 1495 | QString inc = (*incit);
|
|---|
| 1496 | if (!inc.startsWith('"') && !inc.endsWith('"'))
|
|---|
| 1497 | inc = QString("\"%1\"").arg(inc); // Quote all paths if not quoted already
|
|---|
| 1498 | project->values("MSVCPROJ_INCPATH").append("-I" + inc);
|
|---|
| 1499 | }
|
|---|
| 1500 | project->values("MSVCPROJ_INCPATH").append("-I" + specdir());
|
|---|
| 1501 |
|
|---|
| 1502 | QString dest;
|
|---|
| 1503 | project->values("MSVCPROJ_TARGET") = QStringList(project->first("TARGET"));
|
|---|
| 1504 | Option::fixPathToTargetOS(project->first("TARGET"));
|
|---|
| 1505 | dest = project->first("TARGET") + project->first("TARGET_EXT");
|
|---|
| 1506 | project->values("MSVCPROJ_TARGET") = QStringList(dest);
|
|---|
| 1507 |
|
|---|
| 1508 | // DLL COPY ------------------------------------------------------
|
|---|
| 1509 | if(project->isActiveConfig("dll") && !project->values("DLLDESTDIR").isEmpty()) {
|
|---|
| 1510 | QStringList dlldirs = project->values("DLLDESTDIR");
|
|---|
| 1511 | QString copydll("");
|
|---|
| 1512 | QStringList::Iterator dlldir;
|
|---|
| 1513 | for(dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir) {
|
|---|
| 1514 | if(!copydll.isEmpty())
|
|---|
| 1515 | copydll += " && ";
|
|---|
| 1516 | copydll += "copy \"$(TargetPath)\" \"" + *dlldir + "\"";
|
|---|
| 1517 | }
|
|---|
| 1518 |
|
|---|
| 1519 | QString deststr("Copy " + dest + " to ");
|
|---|
| 1520 | for(dlldir = dlldirs.begin(); dlldir != dlldirs.end();) {
|
|---|
| 1521 | deststr += *dlldir;
|
|---|
| 1522 | ++dlldir;
|
|---|
| 1523 | if(dlldir != dlldirs.end())
|
|---|
| 1524 | deststr += ", ";
|
|---|
| 1525 | }
|
|---|
| 1526 |
|
|---|
| 1527 | project->values("MSVCPROJ_COPY_DLL").append(copydll);
|
|---|
| 1528 | project->values("MSVCPROJ_COPY_DLL_DESC").append(deststr);
|
|---|
| 1529 | }
|
|---|
| 1530 |
|
|---|
| 1531 | if (!project->values("DEF_FILE").isEmpty())
|
|---|
| 1532 | project->values("MSVCPROJ_LFLAGS").append("/DEF:"+project->first("DEF_FILE"));
|
|---|
| 1533 |
|
|---|
| 1534 | project->values("QMAKE_INTERNAL_PRL_LIBS") << "MSVCPROJ_LIBS";
|
|---|
| 1535 |
|
|---|
| 1536 | // Verbose output if "-d -d"...
|
|---|
| 1537 | outputVariables();
|
|---|
| 1538 | }
|
|---|
| 1539 |
|
|---|
| 1540 | // ------------------------------------------------------------------------------------------------
|
|---|
| 1541 | // ------------------------------------------------------------------------------------------------
|
|---|
| 1542 |
|
|---|
| 1543 | QString VcprojGenerator::replaceExtraCompilerVariables(const QString &var, const QStringList &in, const QStringList &out)
|
|---|
| 1544 | {
|
|---|
| 1545 | QString ret = MakefileGenerator::replaceExtraCompilerVariables(var, in, out);
|
|---|
| 1546 |
|
|---|
| 1547 | QStringList &defines = project->values("VCPROJ_MAKEFILE_DEFINES");
|
|---|
| 1548 | if(defines.isEmpty())
|
|---|
| 1549 | defines.append(varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") +
|
|---|
| 1550 | varGlue("DEFINES"," -D"," -D",""));
|
|---|
| 1551 | ret.replace("$(DEFINES)", defines.first());
|
|---|
| 1552 |
|
|---|
| 1553 | QStringList &incpath = project->values("VCPROJ_MAKEFILE_INCPATH");
|
|---|
| 1554 | if(incpath.isEmpty() && !this->var("MSVCPROJ_INCPATH").isEmpty())
|
|---|
| 1555 | incpath.append(this->var("MSVCPROJ_INCPATH"));
|
|---|
| 1556 | ret.replace("$(INCPATH)", incpath.join(" "));
|
|---|
| 1557 |
|
|---|
| 1558 | return ret;
|
|---|
| 1559 | }
|
|---|
| 1560 |
|
|---|
| 1561 |
|
|---|
| 1562 |
|
|---|
| 1563 | bool VcprojGenerator::openOutput(QFile &file, const QString &/*build*/) const
|
|---|
| 1564 | {
|
|---|
| 1565 | QString outdir;
|
|---|
| 1566 | if(!file.fileName().isEmpty()) {
|
|---|
| 1567 | QFileInfo fi(fileInfo(file.fileName()));
|
|---|
| 1568 | if(fi.isDir())
|
|---|
| 1569 | outdir = file.fileName() + QDir::separator();
|
|---|
| 1570 | }
|
|---|
| 1571 | if(!outdir.isEmpty() || file.fileName().isEmpty()) {
|
|---|
| 1572 | QString ext = project->first("VCPROJ_EXTENSION");
|
|---|
| 1573 | if(project->first("TEMPLATE") == "vcsubdirs")
|
|---|
| 1574 | ext = project->first("VCSOLUTION_EXTENSION");
|
|---|
| 1575 | QString outputName = unescapeFilePath(project->first("TARGET"));
|
|---|
| 1576 | if (!project->first("MAKEFILE").isEmpty())
|
|---|
| 1577 | outputName = project->first("MAKEFILE");
|
|---|
| 1578 | file.setFileName(outdir + outputName + ext);
|
|---|
| 1579 | }
|
|---|
| 1580 | return Win32MakefileGenerator::openOutput(file, QString());
|
|---|
| 1581 | }
|
|---|
| 1582 |
|
|---|
| 1583 | QString VcprojGenerator::fixFilename(QString ofile) const
|
|---|
| 1584 | {
|
|---|
| 1585 | ofile = Option::fixPathToLocalOS(ofile);
|
|---|
| 1586 | int slashfind = ofile.lastIndexOf(Option::dir_sep);
|
|---|
| 1587 | if(slashfind == -1) {
|
|---|
| 1588 | ofile = ofile.replace('-', '_');
|
|---|
| 1589 | } else {
|
|---|
| 1590 | int hyphenfind = ofile.indexOf('-', slashfind);
|
|---|
| 1591 | while (hyphenfind != -1 && slashfind < hyphenfind) {
|
|---|
| 1592 | ofile = ofile.replace(hyphenfind, 1, '_');
|
|---|
| 1593 | hyphenfind = ofile.indexOf('-', hyphenfind + 1);
|
|---|
| 1594 | }
|
|---|
| 1595 | }
|
|---|
| 1596 | return ofile;
|
|---|
| 1597 | }
|
|---|
| 1598 |
|
|---|
| 1599 | QString VcprojGenerator::findTemplate(QString file)
|
|---|
| 1600 | {
|
|---|
| 1601 | QString ret;
|
|---|
| 1602 | if(!exists((ret = file)) &&
|
|---|
| 1603 | !exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&
|
|---|
| 1604 | !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc.net/" + file))) &&
|
|---|
| 1605 | !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2002/" + file))) &&
|
|---|
| 1606 | !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2003/" + file))) &&
|
|---|
| 1607 | !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2005/" + file))) &&
|
|---|
| 1608 | !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2008/" + file))))
|
|---|
| 1609 | return "";
|
|---|
| 1610 | debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.toLatin1().constData());
|
|---|
| 1611 | return ret;
|
|---|
| 1612 | }
|
|---|
| 1613 |
|
|---|
| 1614 |
|
|---|
| 1615 | void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l)
|
|---|
| 1616 | {
|
|---|
| 1617 | if(var == "QMAKE_PRL_DEFINES") {
|
|---|
| 1618 | QStringList &out = project->values("MSVCPROJ_DEFINES");
|
|---|
| 1619 | for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
|
|---|
| 1620 | if(out.indexOf((*it)) == -1)
|
|---|
| 1621 | out.append((" /D " + *it));
|
|---|
| 1622 | }
|
|---|
| 1623 | } else {
|
|---|
| 1624 | MakefileGenerator::processPrlVariable(var, l);
|
|---|
| 1625 | }
|
|---|
| 1626 | }
|
|---|
| 1627 |
|
|---|
| 1628 | void VcprojGenerator::outputVariables()
|
|---|
| 1629 | {
|
|---|
| 1630 | #if 0
|
|---|
| 1631 | qDebug("Generator: MSVC.NET: List of current variables:");
|
|---|
| 1632 | for(QMap<QString, QStringList>::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it)
|
|---|
| 1633 | qDebug("Generator: MSVC.NET: %s => %s", it.key().toLatin1().constData(), it.data().join(" | ").toLatin1().constData());
|
|---|
| 1634 | #endif
|
|---|
| 1635 | }
|
|---|
| 1636 |
|
|---|
| 1637 | QT_END_NAMESPACE
|
|---|
| 1638 |
|
|---|