[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 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 | **
|
---|
[561] | 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.
|
---|
[2] | 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 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include "winmakefile.h"
|
---|
| 43 | #include "option.h"
|
---|
| 44 | #include "project.h"
|
---|
| 45 | #include "meta.h"
|
---|
| 46 | #include <qtextstream.h>
|
---|
| 47 | #include <qstring.h>
|
---|
| 48 | #include <qhash.h>
|
---|
| 49 | #include <qregexp.h>
|
---|
| 50 | #include <qstringlist.h>
|
---|
| 51 | #include <qdir.h>
|
---|
| 52 | #include <stdlib.h>
|
---|
| 53 |
|
---|
| 54 | QT_BEGIN_NAMESPACE
|
---|
| 55 |
|
---|
| 56 | Win32MakefileGenerator::Win32MakefileGenerator() : MakefileGenerator()
|
---|
| 57 | {
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | int
|
---|
| 61 | Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem, const QString &ext)
|
---|
| 62 | {
|
---|
| 63 | QString bd = Option::fixPathToLocalOS(d, true);
|
---|
| 64 | if(!exists(bd))
|
---|
| 65 | return -1;
|
---|
| 66 |
|
---|
| 67 | QString dllStem = stem + QTDLL_POSTFIX;
|
---|
| 68 | QMakeMetaInfo libinfo;
|
---|
| 69 | bool libInfoRead = libinfo.readLib(bd + Option::dir_sep + dllStem);
|
---|
| 70 |
|
---|
| 71 | // If the library, for which we're trying to find the highest version
|
---|
| 72 | // number, is a static library
|
---|
| 73 | if (libInfoRead && libinfo.values("QMAKE_PRL_CONFIG").contains("staticlib"))
|
---|
| 74 | return -1;
|
---|
| 75 |
|
---|
| 76 | if(!project->values("QMAKE_" + stem.toUpper() + "_VERSION_OVERRIDE").isEmpty())
|
---|
| 77 | return project->values("QMAKE_" + stem.toUpper() + "_VERSION_OVERRIDE").first().toInt();
|
---|
| 78 |
|
---|
| 79 | int biggest=-1;
|
---|
| 80 | if(!project->isActiveConfig("no_versionlink")) {
|
---|
| 81 | QDir dir(bd);
|
---|
| 82 | QStringList entries = dir.entryList();
|
---|
| 83 | QRegExp regx(QString("((lib)?%1([0-9]*)).(%2|prl)$").arg(dllStem).arg(ext), Qt::CaseInsensitive);
|
---|
| 84 | for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
|
---|
| 85 | if(regx.exactMatch((*it))) {
|
---|
| 86 | if (!regx.cap(3).isEmpty()) {
|
---|
| 87 | bool ok = true;
|
---|
| 88 | int num = regx.cap(3).toInt(&ok);
|
---|
| 89 | biggest = qMax(biggest, (!ok ? -1 : num));
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | if(libInfoRead
|
---|
| 95 | && !libinfo.values("QMAKE_PRL_CONFIG").contains("staticlib")
|
---|
| 96 | && !libinfo.isEmpty("QMAKE_PRL_VERSION"))
|
---|
| 97 | biggest = qMax(biggest, libinfo.first("QMAKE_PRL_VERSION").replace(".", "").toInt());
|
---|
| 98 | return biggest;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | bool
|
---|
| 102 | Win32MakefileGenerator::findLibraries(const QString &where)
|
---|
| 103 | {
|
---|
| 104 | QStringList &l = project->values(where);
|
---|
| 105 | QList<QMakeLocalFileName> dirs;
|
---|
| 106 | {
|
---|
| 107 | QStringList &libpaths = project->values("QMAKE_LIBDIR");
|
---|
| 108 | for(QStringList::Iterator libpathit = libpaths.begin();
|
---|
| 109 | libpathit != libpaths.end(); ++libpathit)
|
---|
| 110 | dirs.append(QMakeLocalFileName((*libpathit)));
|
---|
| 111 | }
|
---|
| 112 | for(QStringList::Iterator it = l.begin(); it != l.end();) {
|
---|
| 113 | QChar quote;
|
---|
| 114 | bool modified_opt = false, remove = false;
|
---|
| 115 | QString opt = (*it).trimmed();
|
---|
| 116 | if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0]) {
|
---|
| 117 | quote = opt[0];
|
---|
| 118 | opt = opt.mid(1, opt.length()-2);
|
---|
| 119 | }
|
---|
| 120 | if(opt.startsWith("/LIBPATH:")) {
|
---|
| 121 | dirs.append(QMakeLocalFileName(opt.mid(9)));
|
---|
| 122 | } else if(opt.startsWith("-L") || opt.startsWith("/L")) {
|
---|
| 123 | QString libpath = opt.mid(2);
|
---|
| 124 | QMakeLocalFileName l(libpath);
|
---|
| 125 | if(!dirs.contains(l)) {
|
---|
| 126 | dirs.append(l);
|
---|
| 127 | modified_opt = true;
|
---|
| 128 | if (!quote.isNull()) {
|
---|
| 129 | libpath = quote + libpath + quote;
|
---|
| 130 | quote = QChar();
|
---|
| 131 | }
|
---|
| 132 | (*it) = "/LIBPATH:" + libpath;
|
---|
| 133 | } else {
|
---|
| 134 | remove = true;
|
---|
| 135 | }
|
---|
| 136 | } else if(opt.startsWith("-l") || opt.startsWith("/l")) {
|
---|
| 137 | QString lib = opt.right(opt.length() - 2), out;
|
---|
| 138 | if(!lib.isEmpty()) {
|
---|
| 139 | QString suffix;
|
---|
| 140 | if(!project->isEmpty("QMAKE_" + lib.toUpper() + "_SUFFIX"))
|
---|
| 141 | suffix = project->first("QMAKE_" + lib.toUpper() + "_SUFFIX");
|
---|
| 142 | for(QList<QMakeLocalFileName>::Iterator it = dirs.begin();
|
---|
| 143 | it != dirs.end(); ++it) {
|
---|
| 144 | QString extension;
|
---|
| 145 | int ver = findHighestVersion((*it).local(), lib);
|
---|
| 146 | if(ver > 0)
|
---|
| 147 | extension += QString::number(ver);
|
---|
| 148 | extension += suffix;
|
---|
| 149 | extension += ".lib";
|
---|
| 150 | if(QMakeMetaInfo::libExists((*it).local() + Option::dir_sep + lib) ||
|
---|
| 151 | exists((*it).local() + Option::dir_sep + lib + extension)) {
|
---|
| 152 | out = (*it).real() + Option::dir_sep + lib + extension;
|
---|
[769] | 153 | if (out.contains(QLatin1Char(' '))) {
|
---|
| 154 | out.prepend(QLatin1Char('\"'));
|
---|
| 155 | out.append(QLatin1Char('\"'));
|
---|
| 156 | }
|
---|
[2] | 157 | break;
|
---|
| 158 | }
|
---|
| 159 | }
|
---|
| 160 | }
|
---|
| 161 | if(out.isEmpty())
|
---|
| 162 | out = lib + ".lib";
|
---|
| 163 | modified_opt = true;
|
---|
| 164 | (*it) = out;
|
---|
| 165 | } else if(!exists(Option::fixPathToLocalOS(opt))) {
|
---|
| 166 | QList<QMakeLocalFileName> lib_dirs;
|
---|
| 167 | QString file = opt;
|
---|
| 168 | int slsh = file.lastIndexOf(Option::dir_sep);
|
---|
| 169 | if(slsh != -1) {
|
---|
| 170 | lib_dirs.append(QMakeLocalFileName(file.left(slsh+1)));
|
---|
| 171 | file = file.right(file.length() - slsh - 1);
|
---|
| 172 | } else {
|
---|
| 173 | lib_dirs = dirs;
|
---|
| 174 | }
|
---|
| 175 | if(file.endsWith(".lib")) {
|
---|
| 176 | file = file.left(file.length() - 4);
|
---|
| 177 | if(!file.at(file.length()-1).isNumber()) {
|
---|
| 178 | QString suffix;
|
---|
| 179 | if(!project->isEmpty("QMAKE_" + file.section(Option::dir_sep, -1).toUpper() + "_SUFFIX"))
|
---|
| 180 | suffix = project->first("QMAKE_" + file.section(Option::dir_sep, -1).toUpper() + "_SUFFIX");
|
---|
| 181 | for(QList<QMakeLocalFileName>::Iterator dep_it = lib_dirs.begin(); dep_it != lib_dirs.end(); ++dep_it) {
|
---|
| 182 | QString lib_tmpl(file + "%1" + suffix + ".lib");
|
---|
| 183 | int ver = findHighestVersion((*dep_it).local(), file);
|
---|
| 184 | if(ver != -1) {
|
---|
| 185 | if(ver)
|
---|
| 186 | lib_tmpl = lib_tmpl.arg(ver);
|
---|
| 187 | else
|
---|
| 188 | lib_tmpl = lib_tmpl.arg("");
|
---|
| 189 | if(slsh != -1) {
|
---|
| 190 | QString dir = (*dep_it).real();
|
---|
| 191 | if(!dir.endsWith(Option::dir_sep))
|
---|
| 192 | dir += Option::dir_sep;
|
---|
| 193 | lib_tmpl.prepend(dir);
|
---|
| 194 | }
|
---|
| 195 | modified_opt = true;
|
---|
| 196 | (*it) = lib_tmpl;
|
---|
| 197 | break;
|
---|
| 198 | }
|
---|
| 199 | }
|
---|
| 200 | }
|
---|
| 201 | }
|
---|
| 202 | }
|
---|
| 203 | if(remove) {
|
---|
| 204 | it = l.erase(it);
|
---|
| 205 | } else {
|
---|
| 206 | if(!quote.isNull() && modified_opt)
|
---|
| 207 | (*it) = quote + (*it) + quote;
|
---|
| 208 | ++it;
|
---|
| 209 | }
|
---|
| 210 | }
|
---|
| 211 | return true;
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | void
|
---|
| 215 | Win32MakefileGenerator::processPrlFiles()
|
---|
| 216 | {
|
---|
| 217 | QHash<QString, bool> processed;
|
---|
| 218 | QList<QMakeLocalFileName> libdirs;
|
---|
| 219 | {
|
---|
| 220 | QStringList &libpaths = project->values("QMAKE_LIBDIR");
|
---|
| 221 | for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit)
|
---|
| 222 | libdirs.append(QMakeLocalFileName((*libpathit)));
|
---|
| 223 | }
|
---|
| 224 | for(bool ret = false; true; ret = false) {
|
---|
| 225 | //read in any prl files included..
|
---|
| 226 | QStringList l_out;
|
---|
| 227 | QString where = "QMAKE_LIBS";
|
---|
| 228 | if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
|
---|
| 229 | where = project->first("QMAKE_INTERNAL_PRL_LIBS");
|
---|
| 230 | QStringList l = project->values(where);
|
---|
| 231 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
| 232 | QString opt = (*it).trimmed();
|
---|
| 233 | if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0])
|
---|
| 234 | opt = opt.mid(1, opt.length()-2);
|
---|
| 235 | if(opt.startsWith("/")) {
|
---|
| 236 | if(opt.startsWith("/LIBPATH:")) {
|
---|
| 237 | QMakeLocalFileName l(opt.mid(9));
|
---|
| 238 | if(!libdirs.contains(l))
|
---|
| 239 | libdirs.append(l);
|
---|
| 240 | }
|
---|
| 241 | } else if(!processed.contains(opt)) {
|
---|
| 242 | if(processPrlFile(opt)) {
|
---|
| 243 | processed.insert(opt, true);
|
---|
| 244 | ret = true;
|
---|
| 245 | } else if(QDir::isRelativePath(opt) || opt.startsWith("-l")) {
|
---|
| 246 | QString tmp;
|
---|
| 247 | if (opt.startsWith("-l"))
|
---|
| 248 | tmp = opt.mid(2);
|
---|
| 249 | else
|
---|
| 250 | tmp = opt;
|
---|
| 251 | for(QList<QMakeLocalFileName>::Iterator it = libdirs.begin(); it != libdirs.end(); ++it) {
|
---|
[363] | 252 | QString prl = (*it).local() + Option::dir_sep + tmp;
|
---|
[2] | 253 | // the original is used as the key
|
---|
| 254 | QString orgprl = prl;
|
---|
| 255 | if(processed.contains(prl)) {
|
---|
| 256 | break;
|
---|
| 257 | } else if(processPrlFile(prl)) {
|
---|
| 258 | processed.insert(orgprl, true);
|
---|
| 259 | ret = true;
|
---|
| 260 | break;
|
---|
| 261 | }
|
---|
| 262 | }
|
---|
| 263 | }
|
---|
| 264 | }
|
---|
| 265 | if(!opt.isEmpty())
|
---|
| 266 | l_out.append(opt);
|
---|
| 267 | }
|
---|
| 268 | if(ret)
|
---|
| 269 | l = l_out;
|
---|
| 270 | else
|
---|
| 271 | break;
|
---|
| 272 | }
|
---|
| 273 | }
|
---|
| 274 |
|
---|
| 275 |
|
---|
| 276 | void Win32MakefileGenerator::processVars()
|
---|
| 277 | {
|
---|
| 278 | //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET
|
---|
| 279 | if(!project->isEmpty("TARGET")) {
|
---|
| 280 | QString targ = project->first("TARGET");
|
---|
| 281 | int slsh = qMax(targ.lastIndexOf('/'), targ.lastIndexOf(Option::dir_sep));
|
---|
| 282 | if(slsh != -1) {
|
---|
| 283 | if(project->isEmpty("DESTDIR"))
|
---|
| 284 | project->values("DESTDIR").append("");
|
---|
| 285 | else if(project->first("DESTDIR").right(1) != Option::dir_sep)
|
---|
| 286 | project->values("DESTDIR") = QStringList(project->first("DESTDIR") + Option::dir_sep);
|
---|
| 287 | project->values("DESTDIR") = QStringList(project->first("DESTDIR") + targ.left(slsh+1));
|
---|
| 288 | project->values("TARGET") = QStringList(targ.mid(slsh+1));
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | project->values("QMAKE_ORIG_TARGET") = project->values("TARGET");
|
---|
| 293 | if (!project->values("QMAKE_INCDIR").isEmpty())
|
---|
| 294 | project->values("INCLUDEPATH") += project->values("QMAKE_INCDIR");
|
---|
| 295 |
|
---|
| 296 | if (!project->values("VERSION").isEmpty()) {
|
---|
| 297 | QStringList l = project->first("VERSION").split('.');
|
---|
| 298 | if (l.size() > 0)
|
---|
| 299 | project->values("VER_MAJ").append(l[0]);
|
---|
| 300 | if (l.size() > 1)
|
---|
| 301 | project->values("VER_MIN").append(l[1]);
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | // TARGET_VERSION_EXT will be used to add a version number onto the target name
|
---|
| 305 | if (project->values("TARGET_VERSION_EXT").isEmpty()
|
---|
| 306 | && !project->values("VER_MAJ").isEmpty())
|
---|
| 307 | project->values("TARGET_VERSION_EXT").append(project->values("VER_MAJ").first());
|
---|
| 308 |
|
---|
| 309 | if(project->isEmpty("QMAKE_COPY_FILE"))
|
---|
| 310 | project->values("QMAKE_COPY_FILE").append("$(COPY)");
|
---|
| 311 | if(project->isEmpty("QMAKE_COPY_DIR"))
|
---|
| 312 | project->values("QMAKE_COPY_DIR").append("xcopy /s /q /y /i");
|
---|
| 313 | if(project->isEmpty("QMAKE_INSTALL_FILE"))
|
---|
| 314 | project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)");
|
---|
| 315 | if(project->isEmpty("QMAKE_INSTALL_PROGRAM"))
|
---|
| 316 | project->values("QMAKE_INSTALL_PROGRAM").append("$(COPY_FILE)");
|
---|
| 317 | if(project->isEmpty("QMAKE_INSTALL_DIR"))
|
---|
| 318 | project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)");
|
---|
| 319 |
|
---|
| 320 | fixTargetExt();
|
---|
| 321 | processRcFileVar();
|
---|
| 322 | processFileTagsVar();
|
---|
| 323 |
|
---|
| 324 | QStringList &incDir = project->values("INCLUDEPATH");
|
---|
| 325 | for(QStringList::Iterator incDir_it = incDir.begin(); incDir_it != incDir.end(); ++incDir_it) {
|
---|
[982] | 326 | if(!(*incDir_it).isEmpty())
|
---|
| 327 | (*incDir_it) = Option::fixPathToTargetOS((*incDir_it), false, false);
|
---|
[2] | 328 | }
|
---|
[982] | 329 | incDir.removeDuplicates();
|
---|
| 330 |
|
---|
[2] | 331 | QStringList &libDir = project->values("QMAKE_LIBDIR");
|
---|
| 332 | for(QStringList::Iterator libDir_it = libDir.begin(); libDir_it != libDir.end(); ++libDir_it) {
|
---|
[982] | 333 | if(!(*libDir_it).isEmpty())
|
---|
| 334 | (*libDir_it) = Option::fixPathToTargetOS((*libDir_it), false, false);
|
---|
[2] | 335 | }
|
---|
[982] | 336 | libDir.removeDuplicates();
|
---|
[2] | 337 | }
|
---|
| 338 |
|
---|
| 339 | void Win32MakefileGenerator::fixTargetExt()
|
---|
| 340 | {
|
---|
| 341 | if (!project->values("QMAKE_APP_FLAG").isEmpty())
|
---|
| 342 | project->values("TARGET_EXT").append(".exe");
|
---|
| 343 | else if (project->isActiveConfig("shared"))
|
---|
| 344 | project->values("TARGET_EXT").append(project->first("TARGET_VERSION_EXT") + ".dll");
|
---|
| 345 | else
|
---|
| 346 | project->values("TARGET_EXT").append(".lib");
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | void Win32MakefileGenerator::processRcFileVar()
|
---|
| 350 | {
|
---|
| 351 | if (Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING)
|
---|
| 352 | return;
|
---|
| 353 |
|
---|
| 354 | if (((!project->values("VERSION").isEmpty())
|
---|
| 355 | && project->values("RC_FILE").isEmpty()
|
---|
| 356 | && project->values("RES_FILE").isEmpty()
|
---|
| 357 | && !project->isActiveConfig("no_generated_target_info")
|
---|
| 358 | && (project->isActiveConfig("shared") || !project->values("QMAKE_APP_FLAG").isEmpty()))
|
---|
| 359 | || !project->values("QMAKE_WRITE_DEFAULT_RC").isEmpty()){
|
---|
| 360 |
|
---|
| 361 | QByteArray rcString;
|
---|
| 362 | QTextStream ts(&rcString, QFile::WriteOnly);
|
---|
| 363 |
|
---|
| 364 | QStringList vers = project->values("VERSION").first().split(".");
|
---|
| 365 | for (int i = vers.size(); i < 4; i++)
|
---|
| 366 | vers += "0";
|
---|
| 367 | QString versionString = vers.join(".");
|
---|
| 368 |
|
---|
| 369 | QString companyName;
|
---|
| 370 | if (!project->values("QMAKE_TARGET_COMPANY").isEmpty())
|
---|
| 371 | companyName = project->values("QMAKE_TARGET_COMPANY").join(" ");
|
---|
| 372 |
|
---|
| 373 | QString description;
|
---|
| 374 | if (!project->values("QMAKE_TARGET_DESCRIPTION").isEmpty())
|
---|
| 375 | description = project->values("QMAKE_TARGET_DESCRIPTION").join(" ");
|
---|
| 376 |
|
---|
| 377 | QString copyright;
|
---|
| 378 | if (!project->values("QMAKE_TARGET_COPYRIGHT").isEmpty())
|
---|
| 379 | copyright = project->values("QMAKE_TARGET_COPYRIGHT").join(" ");
|
---|
| 380 |
|
---|
| 381 | QString productName;
|
---|
| 382 | if (!project->values("QMAKE_TARGET_PRODUCT").isEmpty())
|
---|
| 383 | productName = project->values("QMAKE_TARGET_PRODUCT").join(" ");
|
---|
| 384 | else
|
---|
| 385 | productName = project->values("TARGET").first();
|
---|
| 386 |
|
---|
| 387 | QString originalName = project->values("TARGET").first() + project->values("TARGET_EXT").first();
|
---|
| 388 |
|
---|
| 389 | ts << "# if defined(UNDER_CE)" << endl;
|
---|
| 390 | ts << "# include <winbase.h>" << endl;
|
---|
| 391 | ts << "# else" << endl;
|
---|
| 392 | ts << "# include <winver.h>" << endl;
|
---|
| 393 | ts << "# endif" << endl;
|
---|
| 394 | ts << endl;
|
---|
| 395 | ts << "VS_VERSION_INFO VERSIONINFO" << endl;
|
---|
| 396 | ts << "\tFILEVERSION " << QString(versionString).replace(".", ",") << endl;
|
---|
| 397 | ts << "\tPRODUCTVERSION " << QString(versionString).replace(".", ",") << endl;
|
---|
| 398 | ts << "\tFILEFLAGSMASK 0x3fL" << endl;
|
---|
| 399 | ts << "#ifdef _DEBUG" << endl;
|
---|
| 400 | ts << "\tFILEFLAGS VS_FF_DEBUG" << endl;
|
---|
| 401 | ts << "#else" << endl;
|
---|
| 402 | ts << "\tFILEFLAGS 0x0L" << endl;
|
---|
| 403 | ts << "#endif" << endl;
|
---|
| 404 | ts << "\tFILEOS VOS__WINDOWS32" << endl;
|
---|
| 405 | if (project->isActiveConfig("shared"))
|
---|
| 406 | ts << "\tFILETYPE VFT_DLL" << endl;
|
---|
| 407 | else
|
---|
| 408 | ts << "\tFILETYPE VFT_APP" << endl;
|
---|
| 409 | ts << "\tFILESUBTYPE 0x0L" << endl;
|
---|
| 410 | ts << "\tBEGIN" << endl;
|
---|
| 411 | ts << "\t\tBLOCK \"StringFileInfo\"" << endl;
|
---|
| 412 | ts << "\t\tBEGIN" << endl;
|
---|
| 413 | ts << "\t\t\tBLOCK \"040904B0\"" << endl;
|
---|
| 414 | ts << "\t\t\tBEGIN" << endl;
|
---|
| 415 | ts << "\t\t\t\tVALUE \"CompanyName\", \"" << companyName << "\\0\"" << endl;
|
---|
| 416 | ts << "\t\t\t\tVALUE \"FileDescription\", \"" << description << "\\0\"" << endl;
|
---|
| 417 | ts << "\t\t\t\tVALUE \"FileVersion\", \"" << versionString << "\\0\"" << endl;
|
---|
| 418 | ts << "\t\t\t\tVALUE \"LegalCopyright\", \"" << copyright << "\\0\"" << endl;
|
---|
| 419 | ts << "\t\t\t\tVALUE \"OriginalFilename\", \"" << originalName << "\\0\"" << endl;
|
---|
| 420 | ts << "\t\t\t\tVALUE \"ProductName\", \"" << productName << "\\0\"" << endl;
|
---|
| 421 | ts << "\t\t\tEND" << endl;
|
---|
| 422 | ts << "\t\tEND" << endl;
|
---|
| 423 | ts << "\tEND" << endl;
|
---|
| 424 | ts << "/* End of Version info */" << endl;
|
---|
| 425 | ts << endl;
|
---|
| 426 |
|
---|
| 427 | ts.flush();
|
---|
| 428 |
|
---|
| 429 |
|
---|
| 430 | QString rcFilename = project->values("OUT_PWD").first()
|
---|
| 431 | + "/"
|
---|
| 432 | + project->values("TARGET").first()
|
---|
| 433 | + "_resource"
|
---|
| 434 | + ".rc";
|
---|
| 435 | QFile rcFile(QDir::cleanPath(rcFilename));
|
---|
| 436 |
|
---|
| 437 | bool writeRcFile = true;
|
---|
| 438 | if (rcFile.exists() && rcFile.open(QFile::ReadOnly)) {
|
---|
| 439 | writeRcFile = rcFile.readAll() != rcString;
|
---|
| 440 | rcFile.close();
|
---|
| 441 | }
|
---|
[561] | 442 | if (writeRcFile) {
|
---|
| 443 | bool ok;
|
---|
| 444 | ok = rcFile.open(QFile::WriteOnly);
|
---|
| 445 | if (!ok) {
|
---|
| 446 | // The file can't be opened... try creating the containing
|
---|
| 447 | // directory first (needed for clean shadow builds)
|
---|
| 448 | QDir().mkpath(QFileInfo(rcFile).path());
|
---|
| 449 | ok = rcFile.open(QFile::WriteOnly);
|
---|
| 450 | }
|
---|
| 451 | if (!ok) {
|
---|
| 452 | ::fprintf(stderr, "Cannot open for writing: %s", rcFile.fileName().toLatin1().constData());
|
---|
| 453 | ::exit(1);
|
---|
| 454 | }
|
---|
| 455 | rcFile.write(rcString);
|
---|
| 456 | rcFile.close();
|
---|
[2] | 457 | }
|
---|
| 458 | if (project->values("QMAKE_WRITE_DEFAULT_RC").isEmpty())
|
---|
| 459 | project->values("RC_FILE").insert(0, rcFile.fileName());
|
---|
| 460 | }
|
---|
| 461 | if (!project->values("RC_FILE").isEmpty()) {
|
---|
| 462 | if (!project->values("RES_FILE").isEmpty()) {
|
---|
| 463 | fprintf(stderr, "Both rc and res file specified.\n");
|
---|
| 464 | fprintf(stderr, "Please specify one of them, not both.");
|
---|
| 465 | exit(1);
|
---|
| 466 | }
|
---|
| 467 | QString resFile = project->values("RC_FILE").first();
|
---|
| 468 |
|
---|
| 469 | // if this is a shadow build then use the absolute path of the rc file
|
---|
| 470 | if (Option::output_dir != qmake_getpwd()) {
|
---|
| 471 | QFileInfo fi(resFile);
|
---|
| 472 | project->values("RC_FILE").first() = fi.absoluteFilePath();
|
---|
| 473 | }
|
---|
| 474 |
|
---|
| 475 | resFile.replace(".rc", Option::res_ext);
|
---|
| 476 | project->values("RES_FILE").prepend(fileInfo(resFile).fileName());
|
---|
[529] | 477 | if (!project->values("OBJECTS_DIR").isEmpty()) {
|
---|
[846] | 478 | QString resDestDir;
|
---|
| 479 | if (project->isActiveConfig("staticlib"))
|
---|
| 480 | resDestDir = fileInfo(project->first("DESTDIR")).absoluteFilePath();
|
---|
[2] | 481 | else
|
---|
[846] | 482 | resDestDir = project->first("OBJECTS_DIR");
|
---|
| 483 | resDestDir.append(Option::dir_sep);
|
---|
| 484 | project->values("RES_FILE").first().prepend(resDestDir);
|
---|
[529] | 485 | }
|
---|
[2] | 486 | project->values("RES_FILE").first() = Option::fixPathToTargetOS(project->values("RES_FILE").first(), false, false);
|
---|
| 487 | project->values("POST_TARGETDEPS") += project->values("RES_FILE");
|
---|
| 488 | project->values("CLEAN_FILES") += project->values("RES_FILE");
|
---|
| 489 | }
|
---|
| 490 | }
|
---|
| 491 |
|
---|
| 492 | void Win32MakefileGenerator::processFileTagsVar()
|
---|
| 493 | {
|
---|
| 494 | QStringList tags;
|
---|
| 495 | tags << "SOURCES" << "GENERATED_SOURCES" << "DEF_FILE" << "RC_FILE"
|
---|
| 496 | << "TARGET" << "QMAKE_LIBS" << "DESTDIR" << "DLLDESTDIR" << "INCLUDEPATH";
|
---|
| 497 | if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) {
|
---|
| 498 | const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");
|
---|
| 499 | for(QStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it)
|
---|
| 500 | tags += project->values((*it)+".input");
|
---|
| 501 | }
|
---|
| 502 |
|
---|
| 503 | //clean path
|
---|
| 504 | QStringList &filetags = project->values("QMAKE_FILETAGS");
|
---|
| 505 | for(int i = 0; i < tags.size(); ++i)
|
---|
| 506 | filetags += Option::fixPathToTargetOS(tags.at(i), false);
|
---|
| 507 | }
|
---|
| 508 |
|
---|
| 509 | void Win32MakefileGenerator::writeCleanParts(QTextStream &t)
|
---|
| 510 | {
|
---|
[37] | 511 | const QString del_statement("-$(DEL_FILE)");
|
---|
| 512 | const QString del_suffix =
|
---|
| 513 | Option::target_mode == Option::TARG_OS2_MODE ?
|
---|
[189] | 514 | QString(" >nul 2>&1"): // reduce noise
|
---|
| 515 | QString::null;
|
---|
[37] | 516 |
|
---|
| 517 | const int commandlineLimit =
|
---|
| 518 | Option::target_mode == Option::TARG_OS2_MODE ?
|
---|
[189] | 519 | 1000: // OS/2 CMD.EXE limit (1024 - suffix - reserve)
|
---|
[37] | 520 | 2047; // NT limit, expanded
|
---|
| 521 |
|
---|
[2] | 522 | t << "clean: compiler_clean " << var("CLEAN_DEPS");
|
---|
| 523 | {
|
---|
| 524 | const char *clean_targets[] = { "OBJECTS", "QMAKE_CLEAN", "CLEAN_FILES", 0 };
|
---|
| 525 | for(int i = 0; clean_targets[i]; ++i) {
|
---|
| 526 | const QStringList &list = project->values(clean_targets[i]);
|
---|
| 527 | if(project->isActiveConfig("no_delete_multiple_files")) {
|
---|
| 528 | for(QStringList::ConstIterator it = list.begin(); it != list.end(); ++it)
|
---|
[37] | 529 | t << "\n\t" << del_statement << " " << escapeFilePath((*it)) << del_suffix;
|
---|
[2] | 530 | } else {
|
---|
| 531 | QString files, file;
|
---|
| 532 | for(QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
|
---|
| 533 | file = " " + escapeFilePath((*it));
|
---|
| 534 | if(del_statement.length() + files.length() +
|
---|
[37] | 535 | qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit &&
|
---|
| 536 | !files.isEmpty()) {
|
---|
| 537 | t << "\n\t" << del_statement << files << del_suffix;
|
---|
[2] | 538 | files.clear();
|
---|
| 539 | }
|
---|
| 540 | files += file;
|
---|
| 541 | }
|
---|
| 542 | if(!files.isEmpty())
|
---|
[37] | 543 | t << "\n\t" << del_statement << files << del_suffix;
|
---|
[2] | 544 | }
|
---|
| 545 | }
|
---|
| 546 | }
|
---|
| 547 | t << endl << endl;
|
---|
| 548 |
|
---|
| 549 | t << "distclean: clean";
|
---|
| 550 | {
|
---|
| 551 | const char *clean_targets[] = { "QMAKE_DISTCLEAN", 0 };
|
---|
| 552 | for(int i = 0; clean_targets[i]; ++i) {
|
---|
| 553 | const QStringList &list = project->values(clean_targets[i]);
|
---|
| 554 | if(project->isActiveConfig("no_delete_multiple_files")) {
|
---|
| 555 | for(QStringList::ConstIterator it = list.begin(); it != list.end(); ++it)
|
---|
[37] | 556 | t << "\n\t" << del_statement << " " << escapeFilePath((*it)) << del_suffix;
|
---|
[2] | 557 | } else {
|
---|
| 558 | QString files, file;
|
---|
| 559 | for(QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
|
---|
| 560 | file = " " + escapeFilePath((*it));
|
---|
| 561 | if(del_statement.length() + files.length() +
|
---|
[37] | 562 | qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit &&
|
---|
| 563 | !files.isEmpty()) {
|
---|
| 564 | t << "\n\t" << del_statement << files << del_suffix;
|
---|
[2] | 565 | files.clear();
|
---|
| 566 | }
|
---|
| 567 | files += file;
|
---|
| 568 | }
|
---|
| 569 | if(!files.isEmpty())
|
---|
[37] | 570 | t << "\n\t" << del_statement << files << del_suffix;
|
---|
[2] | 571 | }
|
---|
| 572 | }
|
---|
| 573 | }
|
---|
[37] | 574 | t << "\n\t" << del_statement << " $(DESTDIR_TARGET)" << del_suffix << endl;
|
---|
[2] | 575 | {
|
---|
| 576 | QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.fileName()));
|
---|
| 577 | if(!ofile.isEmpty())
|
---|
[37] | 578 | t << "\t" << del_statement << " " << ofile << del_suffix << endl;
|
---|
[2] | 579 | }
|
---|
| 580 | t << endl;
|
---|
| 581 | }
|
---|
| 582 |
|
---|
| 583 | void Win32MakefileGenerator::writeIncPart(QTextStream &t)
|
---|
| 584 | {
|
---|
| 585 | t << "INCPATH = ";
|
---|
| 586 |
|
---|
| 587 | const QStringList &incs = project->values("INCLUDEPATH");
|
---|
| 588 | for(int i = 0; i < incs.size(); ++i) {
|
---|
| 589 | QString inc = incs.at(i);
|
---|
| 590 | inc.replace(QRegExp("\\\\$"), "");
|
---|
| 591 | inc.replace(QRegExp("\""), "");
|
---|
| 592 | if(!inc.isEmpty())
|
---|
| 593 | t << "-I" << "\"" << inc << "\" ";
|
---|
| 594 | }
|
---|
| 595 | t << "-I\"" << specdir() << "\""
|
---|
| 596 | << endl;
|
---|
| 597 | }
|
---|
| 598 |
|
---|
| 599 | void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
|
---|
| 600 | {
|
---|
| 601 | t << "####### Compiler, tools and options" << endl << endl;
|
---|
| 602 | t << "CC = " << var("QMAKE_CC") << endl;
|
---|
| 603 | t << "CXX = " << var("QMAKE_CXX") << endl;
|
---|
| 604 | t << "DEFINES = "
|
---|
| 605 | << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
|
---|
| 606 | << varGlue("DEFINES","-D"," -D","") << endl;
|
---|
| 607 | t << "CFLAGS = " << var("QMAKE_CFLAGS") << " $(DEFINES)" << endl;
|
---|
| 608 | t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " $(DEFINES)" << endl;
|
---|
| 609 |
|
---|
| 610 | writeIncPart(t);
|
---|
| 611 | writeLibsPart(t);
|
---|
| 612 |
|
---|
[846] | 613 | t << "QMAKE = " << var("QMAKE_QMAKE") << endl;
|
---|
[2] | 614 | t << "IDC = " << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
|
---|
| 615 | Option::fixPathToTargetOS(var("QMAKE_IDC"), false)) << endl;
|
---|
| 616 | t << "IDL = " << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
|
---|
| 617 | Option::fixPathToTargetOS(var("QMAKE_IDL"), false)) << endl;
|
---|
[193] | 618 | t << "RC = " << (project->isEmpty("QMAKE_RC") ? QString("rc") :
|
---|
| 619 | Option::fixPathToTargetOS(var("QMAKE_RC"), false)) << endl;
|
---|
[2] | 620 | t << "ZIP = " << var("QMAKE_ZIP") << endl;
|
---|
| 621 | t << "COPY = " << var("QMAKE_COPY") << endl;
|
---|
| 622 | t << "COPY_FILE = " << var("QMAKE_COPY_FILE") << endl;
|
---|
| 623 | t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl;
|
---|
| 624 | t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
|
---|
| 625 | t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
|
---|
| 626 | t << "MOVE = " << var("QMAKE_MOVE") << endl;
|
---|
| 627 | t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl;
|
---|
| 628 | t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
|
---|
| 629 | t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << endl;
|
---|
| 630 | t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << endl;
|
---|
| 631 | t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
|
---|
| 632 | t << endl;
|
---|
| 633 |
|
---|
| 634 | t << "####### Output directory" << endl << endl;
|
---|
| 635 | if(!project->values("OBJECTS_DIR").isEmpty())
|
---|
| 636 | t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl;
|
---|
| 637 | else
|
---|
[547] | 638 | t << "OBJECTS_DIR = ." << endl;
|
---|
[2] | 639 | t << endl;
|
---|
| 640 |
|
---|
| 641 | t << "####### Files" << endl << endl;
|
---|
| 642 | t << "SOURCES = " << valList(escapeFilePaths(project->values("SOURCES")))
|
---|
| 643 | << " " << valList(escapeFilePaths(project->values("GENERATED_SOURCES"))) << endl;
|
---|
| 644 |
|
---|
| 645 | // do this here so we can set DEST_TARGET to be the complete path to the final target if it is needed.
|
---|
| 646 | QString orgDestDir = var("DESTDIR");
|
---|
| 647 | QString destDir = Option::fixPathToTargetOS(orgDestDir, false);
|
---|
[561] | 648 | if (!destDir.isEmpty() && (orgDestDir.endsWith('/') || orgDestDir.endsWith(Option::dir_sep)))
|
---|
[2] | 649 | destDir += Option::dir_sep;
|
---|
[158] | 650 | QString target = project->first("TARGET_SHORT");
|
---|
| 651 | if (target.isEmpty())
|
---|
| 652 | target = project->first("TARGET");
|
---|
| 653 | target += project->first("TARGET_EXT");
|
---|
[2] | 654 | target.remove("\"");
|
---|
| 655 | project->values("DEST_TARGET").prepend(destDir + target);
|
---|
| 656 |
|
---|
| 657 | writeObjectsPart(t);
|
---|
[38] | 658 | writeRcAndDefVariables(t);
|
---|
[2] | 659 |
|
---|
| 660 | writeExtraCompilerVariables(t);
|
---|
| 661 | writeExtraVariables(t);
|
---|
| 662 |
|
---|
| 663 | t << "DIST = " << varList("DISTFILES") << endl;
|
---|
| 664 | t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
|
---|
[885] | 665 | t << "DESTDIR = " << escapeFilePath(destDir) << endl;
|
---|
[2] | 666 | t << "TARGET = " << escapeFilePath(target) << endl;
|
---|
| 667 | t << "DESTDIR_TARGET = " << escapeFilePath(var("DEST_TARGET")) << endl;
|
---|
| 668 | t << endl;
|
---|
| 669 |
|
---|
| 670 | t << "####### Implicit rules" << endl << endl;
|
---|
| 671 | writeImplicitRulesPart(t);
|
---|
| 672 |
|
---|
| 673 | t << "####### Build rules" << endl << endl;
|
---|
| 674 | writeBuildRulesPart(t);
|
---|
| 675 |
|
---|
| 676 | if(project->isActiveConfig("shared") && !project->values("DLLDESTDIR").isEmpty()) {
|
---|
| 677 | QStringList dlldirs = project->values("DLLDESTDIR");
|
---|
| 678 | for (QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir) {
|
---|
| 679 | t << "\n\t" << "-$(COPY_FILE) \"$(DESTDIR_TARGET)\" " << Option::fixPathToTargetOS(*dlldir, false);
|
---|
| 680 | }
|
---|
| 681 | }
|
---|
| 682 | t << endl << endl;
|
---|
| 683 |
|
---|
[38] | 684 | writeRcAndDefPart(t);
|
---|
[2] | 685 |
|
---|
| 686 | writeMakeQmake(t);
|
---|
| 687 |
|
---|
| 688 | QStringList dist_files = fileFixify(Option::mkfile::project_files);
|
---|
| 689 | if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES"))
|
---|
| 690 | dist_files += project->values("QMAKE_INTERNAL_INCLUDED_FILES");
|
---|
| 691 | if(!project->isEmpty("TRANSLATIONS"))
|
---|
| 692 | dist_files << var("TRANSLATIONS");
|
---|
| 693 | if(!project->isEmpty("FORMS")) {
|
---|
| 694 | QStringList &forms = project->values("FORMS");
|
---|
| 695 | for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
|
---|
| 696 | QString ui_h = fileFixify((*formit) + Option::h_ext.first());
|
---|
| 697 | if(exists(ui_h))
|
---|
| 698 | dist_files << ui_h;
|
---|
| 699 | }
|
---|
| 700 | }
|
---|
| 701 | t << "dist:" << "\n\t"
|
---|
| 702 | << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(DIST) "
|
---|
[682] | 703 | << dist_files.join(" ") << " ";
|
---|
[2] | 704 | if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) {
|
---|
| 705 | const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");
|
---|
| 706 | for(QStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) {
|
---|
| 707 | const QStringList &inputs = project->values((*it)+".input");
|
---|
| 708 | for(QStringList::ConstIterator input = inputs.begin(); input != inputs.end(); ++input) {
|
---|
| 709 | t << (*input) << " ";
|
---|
| 710 | }
|
---|
| 711 | }
|
---|
| 712 | }
|
---|
| 713 | t << endl << endl;
|
---|
| 714 |
|
---|
| 715 | writeCleanParts(t);
|
---|
| 716 | writeExtraTargets(t);
|
---|
| 717 | writeExtraCompilerTargets(t);
|
---|
| 718 | t << endl << endl;
|
---|
| 719 | }
|
---|
| 720 |
|
---|
| 721 | void Win32MakefileGenerator::writeLibsPart(QTextStream &t)
|
---|
| 722 | {
|
---|
| 723 | if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
|
---|
| 724 | t << "LIBAPP = " << var("QMAKE_LIB") << endl;
|
---|
| 725 | t << "LIBFLAGS = " << var("QMAKE_LIBFLAGS") << endl;
|
---|
| 726 | } else {
|
---|
| 727 | t << "LINK = " << var("QMAKE_LINK") << endl;
|
---|
| 728 | t << "LFLAGS = ";
|
---|
| 729 | if(!project->values("QMAKE_LIBDIR").isEmpty())
|
---|
| 730 | writeLibDirPart(t);
|
---|
| 731 | t << var("QMAKE_LFLAGS") << endl;
|
---|
[561] | 732 | t << "LIBS = " << var("QMAKE_LIBS") << " " << var("QMAKE_LIBS_PRIVATE") << endl;
|
---|
[2] | 733 | }
|
---|
| 734 | }
|
---|
| 735 |
|
---|
| 736 | void Win32MakefileGenerator::writeLibDirPart(QTextStream &t)
|
---|
| 737 | {
|
---|
| 738 | QStringList libDirs = project->values("QMAKE_LIBDIR");
|
---|
| 739 | for (int i = 0; i < libDirs.size(); ++i)
|
---|
| 740 | libDirs[i].remove("\"");
|
---|
| 741 | t << valGlue(libDirs,"-L\"","\" -L\"","\"") << " ";
|
---|
| 742 | }
|
---|
| 743 |
|
---|
| 744 | void Win32MakefileGenerator::writeObjectsPart(QTextStream &t)
|
---|
| 745 | {
|
---|
| 746 | t << "OBJECTS = " << valList(escapeDependencyPaths(project->values("OBJECTS"))) << endl;
|
---|
| 747 | }
|
---|
| 748 |
|
---|
| 749 | void Win32MakefileGenerator::writeImplicitRulesPart(QTextStream &t)
|
---|
| 750 | {
|
---|
| 751 | t << ".SUFFIXES:";
|
---|
| 752 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
|
---|
| 753 | t << " " << (*cppit);
|
---|
| 754 | for(QStringList::Iterator cit = Option::c_ext.begin(); cit != Option::c_ext.end(); ++cit)
|
---|
| 755 | t << " " << (*cit);
|
---|
| 756 | t << endl << endl;
|
---|
| 757 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
|
---|
| 758 | t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
|
---|
| 759 | for(QStringList::Iterator cit = Option::c_ext.begin(); cit != Option::c_ext.end(); ++cit)
|
---|
| 760 | t << (*cit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
|
---|
| 761 | }
|
---|
| 762 |
|
---|
| 763 | void Win32MakefileGenerator::writeBuildRulesPart(QTextStream &)
|
---|
| 764 | {
|
---|
| 765 | }
|
---|
| 766 |
|
---|
[38] | 767 | void Win32MakefileGenerator::writeRcAndDefVariables(QTextStream &t)
|
---|
[2] | 768 | {
|
---|
[38] | 769 | t << "DEF_FILE = " << varList("DEF_FILE") << endl;
|
---|
| 770 | t << "RES_FILE = " << varList("RES_FILE") << endl; // Not on mingw, can't see why not though...
|
---|
| 771 | }
|
---|
| 772 |
|
---|
| 773 | void Win32MakefileGenerator::writeRcAndDefPart(QTextStream &t)
|
---|
| 774 | {
|
---|
[2] | 775 | if(!project->values("RC_FILE").isEmpty()) {
|
---|
| 776 | const QString res_file = project->first("RES_FILE"),
|
---|
| 777 | rc_file = fileFixify(project->first("RC_FILE"));
|
---|
| 778 | // The resource tool needs to have the same defines passed in as the compiler, since you may
|
---|
| 779 | // use these defines in the .rc file itself. Also, we need to add the _DEBUG define manually
|
---|
| 780 | // since the compiler defines this symbol by itself, and we use it in the automatically
|
---|
| 781 | // created rc file when VERSION is define the .pro file.
|
---|
| 782 | t << res_file << ": " << rc_file << "\n\t"
|
---|
| 783 | << var("QMAKE_RC") << (project->isActiveConfig("debug") ? " -D_DEBUG" : "") << " $(DEFINES) -fo " << res_file << " " << rc_file;
|
---|
| 784 | t << endl << endl;
|
---|
| 785 | }
|
---|
| 786 | }
|
---|
| 787 |
|
---|
| 788 | QString Win32MakefileGenerator::getLibTarget()
|
---|
| 789 | {
|
---|
[886] | 790 | return QString(project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".lib");
|
---|
[2] | 791 | }
|
---|
| 792 |
|
---|
[846] | 793 | QString Win32MakefileGenerator::getPdbTarget()
|
---|
| 794 | {
|
---|
| 795 | return QString(project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".pdb");
|
---|
| 796 | }
|
---|
| 797 |
|
---|
[2] | 798 | QString Win32MakefileGenerator::defaultInstall(const QString &t)
|
---|
| 799 | {
|
---|
| 800 | if((t != "target" && t != "dlltarget") ||
|
---|
| 801 | (t == "dlltarget" && (project->first("TEMPLATE") != "lib" || !project->isActiveConfig("shared"))) ||
|
---|
| 802 | project->first("TEMPLATE") == "subdirs")
|
---|
| 803 | return QString();
|
---|
| 804 |
|
---|
| 805 | const QString root = "$(INSTALL_ROOT)";
|
---|
| 806 | QStringList &uninst = project->values(t + ".uninstall");
|
---|
| 807 | QString ret;
|
---|
| 808 | QString targetdir = Option::fixPathToTargetOS(project->first(t + ".path"), false);
|
---|
| 809 | targetdir = fileFixify(targetdir, FileFixifyAbsolute);
|
---|
| 810 | if(targetdir.right(1) != Option::dir_sep)
|
---|
| 811 | targetdir += Option::dir_sep;
|
---|
| 812 |
|
---|
[189] | 813 | const QString del_suffix =
|
---|
| 814 | Option::target_mode == Option::TARG_OS2_MODE ?
|
---|
| 815 | QString(" >nul 2>&1"): // reduce noise
|
---|
| 816 | QString::null;
|
---|
| 817 |
|
---|
[535] | 818 | const QString inst_prefix =
|
---|
| 819 | Option::target_mode == Option::TARG_OS2_MODE ?
|
---|
| 820 | QString::null: // report errors (copy command overwrites quietly)
|
---|
| 821 | QString("-");
|
---|
| 822 |
|
---|
[2] | 823 | if(t == "target" && project->first("TEMPLATE") == "lib") {
|
---|
| 824 | if(project->isActiveConfig("create_prl") && !project->isActiveConfig("no_install_prl") &&
|
---|
| 825 | !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) {
|
---|
| 826 | QString dst_prl = Option::fixPathToTargetOS(project->first("QMAKE_INTERNAL_PRL_FILE"));
|
---|
| 827 | int slsh = dst_prl.lastIndexOf(Option::dir_sep);
|
---|
| 828 | if(slsh != -1)
|
---|
| 829 | dst_prl = dst_prl.right(dst_prl.length() - slsh - 1);
|
---|
| 830 | dst_prl = filePrefixRoot(root, targetdir + dst_prl);
|
---|
[535] | 831 | ret += inst_prefix + "$(INSTALL_FILE) \"" + project->first("QMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\"";
|
---|
[2] | 832 | if(!uninst.isEmpty())
|
---|
| 833 | uninst.append("\n\t");
|
---|
[189] | 834 | uninst.append("-$(DEL_FILE) \"" + dst_prl + "\"" + del_suffix);
|
---|
[2] | 835 | }
|
---|
| 836 | if(project->isActiveConfig("shared") && !project->isActiveConfig("plugin")) {
|
---|
| 837 | QString lib_target = getLibTarget();
|
---|
| 838 | lib_target.remove('"');
|
---|
| 839 | QString src_targ = (project->isEmpty("DESTDIR") ? QString("$(DESTDIR)") : project->first("DESTDIR")) + lib_target;
|
---|
| 840 | QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + lib_target, FileFixifyAbsolute));
|
---|
| 841 | if(!ret.isEmpty())
|
---|
| 842 | ret += "\n\t";
|
---|
[535] | 843 | ret += QString(inst_prefix + "$(INSTALL_FILE)") + " \"" + src_targ + "\" \"" + dst_targ + "\"";
|
---|
[2] | 844 | if(!uninst.isEmpty())
|
---|
| 845 | uninst.append("\n\t");
|
---|
[189] | 846 | uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"" + del_suffix);
|
---|
[2] | 847 | }
|
---|
[846] | 848 | if(project->isActiveConfig("shared") && project->isActiveConfig("debug")) {
|
---|
| 849 | QString pdb_target = getPdbTarget();
|
---|
[896] | 850 | if (!pdb_target.isEmpty()) {
|
---|
| 851 | pdb_target.remove('"');
|
---|
| 852 | QString src_targ = (project->isEmpty("DESTDIR") ? QString("$(DESTDIR)") : project->first("DESTDIR")) + pdb_target;
|
---|
| 853 | QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + pdb_target, FileFixifyAbsolute));
|
---|
| 854 | if(!ret.isEmpty())
|
---|
| 855 | ret += "\n\t";
|
---|
| 856 | ret += QString("-$(INSTALL_FILE)") + " \"" + src_targ + "\" \"" + dst_targ + "\"";
|
---|
| 857 | if(!uninst.isEmpty())
|
---|
| 858 | uninst.append("\n\t");
|
---|
| 859 | uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
|
---|
| 860 | }
|
---|
[846] | 861 | }
|
---|
[2] | 862 | }
|
---|
| 863 |
|
---|
| 864 | if(t == "dlltarget" || project->values(t + ".CONFIG").indexOf("no_dll") == -1) {
|
---|
| 865 | QString src_targ = "$(DESTDIR_TARGET)";
|
---|
| 866 | QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + "$(TARGET)", FileFixifyAbsolute));
|
---|
| 867 | if(!ret.isEmpty())
|
---|
| 868 | ret += "\n\t";
|
---|
[535] | 869 | ret += QString(inst_prefix + "$(INSTALL_FILE)") + " \"" + src_targ + "\" \"" + dst_targ + "\"";
|
---|
[2] | 870 | if(!uninst.isEmpty())
|
---|
| 871 | uninst.append("\n\t");
|
---|
[189] | 872 | uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"" + del_suffix);
|
---|
[2] | 873 | }
|
---|
| 874 | return ret;
|
---|
| 875 | }
|
---|
| 876 |
|
---|
| 877 | QString Win32MakefileGenerator::escapeFilePath(const QString &path) const
|
---|
| 878 | {
|
---|
| 879 | QString ret = path;
|
---|
| 880 | if(!ret.isEmpty()) {
|
---|
| 881 | ret = unescapeFilePath(ret);
|
---|
[885] | 882 | // Note: also quote paths ending with the backslash to avoid
|
---|
| 883 | // interpreting it as a linebreak
|
---|
| 884 | if(ret.contains(' ') || ret.endsWith('\\'))
|
---|
[2] | 885 | ret = "\"" + ret + "\"";
|
---|
| 886 | debug_msg(2, "EscapeFilePath: %s -> %s", path.toLatin1().constData(), ret.toLatin1().constData());
|
---|
| 887 | }
|
---|
| 888 | return ret;
|
---|
| 889 | }
|
---|
| 890 |
|
---|
| 891 | QT_END_NAMESPACE
|
---|