summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32/winmakefile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/generators/win32/winmakefile.cpp')
-rw-r--r--qmake/generators/win32/winmakefile.cpp126
1 files changed, 59 insertions, 67 deletions
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index 41a8567545..bcacdb0615 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -96,6 +96,16 @@ Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem
return biggest;
}
+ProString Win32MakefileGenerator::fixLibFlag(const ProString &lib)
+{
+ if (lib.startsWith('/')) {
+ if (lib.startsWith("/LIBPATH:"))
+ return QStringLiteral("/LIBPATH:") + escapeFilePath(lib.mid(9));
+ return lib;
+ }
+ return escapeFilePath(lib);
+}
+
bool
Win32MakefileGenerator::findLibraries()
{
@@ -104,26 +114,23 @@ Win32MakefileGenerator::findLibraries()
for (int i = 0; lflags[i]; i++) {
ProStringList &l = project->values(lflags[i]);
for (ProStringList::Iterator it = l.begin(); it != l.end();) {
- QChar quote;
- bool modified_opt = false, remove = false;
+ bool remove = false;
QString opt = (*it).trimmed().toQString();
- if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0]) {
- quote = opt[0];
- opt = opt.mid(1, opt.length()-2);
- }
if(opt.startsWith("/LIBPATH:")) {
- dirs.append(QMakeLocalFileName(opt.mid(9)));
+ QString libpath = opt.mid(9);
+ QMakeLocalFileName l(libpath);
+ if (!dirs.contains(l)) {
+ dirs.append(l);
+ (*it) = "/LIBPATH:" + l.real();
+ } else {
+ remove = true;
+ }
} else if(opt.startsWith("-L") || opt.startsWith("/L")) {
QString libpath = Option::fixPathToTargetOS(opt.mid(2), false, false);
QMakeLocalFileName l(libpath);
if(!dirs.contains(l)) {
dirs.append(l);
- modified_opt = true;
- if (!quote.isNull()) {
- libpath = quote + libpath + quote;
- quote = QChar();
- }
- (*it) = "/LIBPATH:" + libpath;
+ (*it) = "/LIBPATH:" + l.real();
} else {
remove = true;
}
@@ -142,17 +149,12 @@ Win32MakefileGenerator::findLibraries()
if(QMakeMetaInfo::libExists((*it).local() + Option::dir_sep + lib) ||
exists((*it).local() + Option::dir_sep + lib + extension)) {
out = (*it).real() + Option::dir_sep + lib + extension;
- if (out.contains(QLatin1Char(' '))) {
- out.prepend(QLatin1Char('\"'));
- out.append(QLatin1Char('\"'));
- }
break;
}
}
}
if(out.isEmpty())
out = lib + ".lib";
- modified_opt = true;
(*it) = out;
} else if(!exists(Option::fixPathToLocalOS(opt))) {
QList<QMakeLocalFileName> lib_dirs;
@@ -182,7 +184,6 @@ Win32MakefileGenerator::findLibraries()
dir += Option::dir_sep;
lib_tmpl.prepend(dir);
}
- modified_opt = true;
(*it) = lib_tmpl;
break;
}
@@ -193,8 +194,6 @@ Win32MakefileGenerator::findLibraries()
if(remove) {
it = l.erase(it);
} else {
- if(!quote.isNull() && modified_opt)
- (*it) = quote + (*it) + quote;
++it;
}
}
@@ -212,8 +211,6 @@ Win32MakefileGenerator::processPrlFiles()
ProStringList &l = project->values(lflags[i]);
for (int lit = 0; lit < l.size(); ++lit) {
QString opt = l.at(lit).trimmed().toQString();
- if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0])
- opt = opt.mid(1, opt.length()-2);
if (opt.startsWith(libArg)) {
QMakeLocalFileName l(opt.mid(libArg.length()));
if (!libdirs.contains(l))
@@ -233,14 +230,8 @@ Win32MakefileGenerator::processPrlFiles()
}
}
ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
- for (int prl = 0; prl < prl_libs.size(); ++prl) {
- ProString arg = prl_libs.at(prl);
- if (arg.startsWith(libArg))
- arg = arg.left(libArg.length()) + escapeFilePath(arg.mid(libArg.length()).toQString());
- else if (!arg.startsWith('/'))
- arg = escapeFilePath(arg.toQString());
- l.insert(lit + prl + 1, arg);
- }
+ for (int prl = 0; prl < prl_libs.size(); ++prl)
+ l.insert(lit + prl + 1, prl_libs.at(prl));
prl_libs.clear();
}
@@ -311,14 +302,13 @@ void Win32MakefileGenerator::processVars()
for (ProStringList::Iterator libDir_it = libDir.begin(); libDir_it != libDir.end(); ++libDir_it) {
QString lib = (*libDir_it).toQString();
if (!lib.isEmpty()) {
- lib.remove('"');
if (lib.endsWith('\\'))
lib.chop(1);
- libs << libArg + escapeFilePath(Option::fixPathToTargetOS(lib, false, false));
+ libs << libArg + Option::fixPathToTargetOS(lib, false, false);
}
}
- project->values("QMAKE_LIBS") += libs + escapeFilePaths(project->values("LIBS"));
- project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE"));
+ project->values("QMAKE_LIBS") += libs + project->values("LIBS");
+ project->values("QMAKE_LIBS_PRIVATE") += project->values("LIBS_PRIVATE");
if (project->values("TEMPLATE").contains("app")) {
project->values("QMAKE_CFLAGS") += project->values("QMAKE_CFLAGS_APP");
@@ -533,7 +523,7 @@ void Win32MakefileGenerator::processRcFileVar()
void Win32MakefileGenerator::writeCleanParts(QTextStream &t)
{
- t << "clean: compiler_clean " << var("CLEAN_DEPS");
+ t << "clean: compiler_clean " << depVar("CLEAN_DEPS");
{
const char *clean_targets[] = { "OBJECTS", "QMAKE_CLEAN", "CLEAN_FILES", 0 };
for(int i = 0; clean_targets[i]; ++i) {
@@ -562,7 +552,7 @@ void Win32MakefileGenerator::writeCleanParts(QTextStream &t)
}
t << endl << endl;
- t << "distclean: clean " << var("DISTCLEAN_DEPS");
+ t << "distclean: clean " << depVar("DISTCLEAN_DEPS");
{
const char *clean_targets[] = { "QMAKE_DISTCLEAN", 0 };
for(int i = 0; clean_targets[i]; ++i) {
@@ -593,7 +583,7 @@ void Win32MakefileGenerator::writeCleanParts(QTextStream &t)
{
QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.fileName()));
if(!ofile.isEmpty())
- t << "\t-$(DEL_FILE) " << ofile << endl;
+ t << "\t-$(DEL_FILE) " << escapeFilePath(ofile) << endl;
}
t << endl;
}
@@ -606,9 +596,8 @@ void Win32MakefileGenerator::writeIncPart(QTextStream &t)
for(int i = 0; i < incs.size(); ++i) {
QString inc = incs.at(i).toQString();
inc.replace(QRegExp("\\\\$"), "");
- inc.replace(QRegExp("\""), "");
if(!inc.isEmpty())
- t << "-I\"" << inc << "\" ";
+ t << "-I" << escapeFilePath(inc) << ' ';
}
t << endl;
}
@@ -633,8 +622,8 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
t << "IDL = " << (project->isEmpty("QMAKE_IDL") ? QString("midl") : var("QMAKE_IDL"))
<< endl;
t << "ZIP = " << var("QMAKE_ZIP") << endl;
- t << "DEF_FILE = " << varList("DEF_FILE") << endl;
- t << "RES_FILE = " << varList("RES_FILE") << endl; // Not on mingw, can't see why not though...
+ t << "DEF_FILE = " << fileVar("DEF_FILE") << endl;
+ t << "RES_FILE = " << fileVar("RES_FILE") << endl; // Not on mingw, can't see why not though...
t << "COPY = " << var("QMAKE_COPY") << endl;
t << "SED = " << var("QMAKE_STREAM_EDITOR") << endl;
t << "COPY_FILE = " << var("QMAKE_COPY_FILE") << endl;
@@ -651,7 +640,7 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
t << "####### Output directory\n\n";
if(!project->values("OBJECTS_DIR").isEmpty())
- t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl;
+ t << "OBJECTS_DIR = " << escapeFilePath(var("OBJECTS_DIR").remove(QRegExp("\\\\$"))) << endl;
else
t << "OBJECTS_DIR = . \n";
t << endl;
@@ -666,7 +655,6 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
if (!destDir.isEmpty() && (orgDestDir.endsWith('/') || orgDestDir.endsWith(Option::dir_sep)))
destDir += Option::dir_sep;
QString target = QString(project->first("TARGET")+project->first("TARGET_EXT"));
- target.remove("\"");
project->values("DEST_TARGET").prepend(destDir + target);
writeObjectsPart(t);
@@ -674,15 +662,14 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
writeExtraCompilerVariables(t);
writeExtraVariables(t);
- t << "DIST = " << varList("DISTFILES") << " "
- << varList("HEADERS") << " "
- << varList("SOURCES") << endl;
- t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
+ t << "DIST = " << fileVarList("DISTFILES") << ' '
+ << fileVarList("HEADERS") << ' ' << fileVarList("SOURCES") << endl;
+ t << "QMAKE_TARGET = " << fileVar("QMAKE_ORIG_TARGET") << endl;
// The comment is important to maintain variable compatibility with Unix
// Makefiles, while not interpreting a trailing-slash as a linebreak
t << "DESTDIR = " << escapeFilePath(destDir) << " #avoid trailing-slash linebreak\n";
t << "TARGET = " << escapeFilePath(target) << endl;
- t << "DESTDIR_TARGET = " << escapeFilePath(var("DEST_TARGET")) << endl;
+ t << "DESTDIR_TARGET = " << fileVar("DEST_TARGET") << endl;
t << endl;
t << "####### Implicit rules\n\n";
@@ -694,8 +681,8 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
if(project->isActiveConfig("shared") && !project->values("DLLDESTDIR").isEmpty()) {
const ProStringList &dlldirs = project->values("DLLDESTDIR");
for (ProStringList::ConstIterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir) {
- t << "\t-$(COPY_FILE) \"$(DESTDIR_TARGET)\" "
- << Option::fixPathToTargetOS((*dlldir).toQString(), false) << endl;
+ t << "\t-$(COPY_FILE) $(DESTDIR_TARGET) "
+ << escapeFilePath(Option::fixPathToTargetOS((*dlldir).toQString(), false)) << endl;
}
}
t << endl;
@@ -719,13 +706,13 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
}
t << "dist:\n\t"
<< "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip $(SOURCES) $(DIST) "
- << dist_files.join(' ') << " " << var("TRANSLATIONS") << " ";
+ << escapeFilePaths(dist_files).join(' ') << ' ' << fileVar("TRANSLATIONS") << ' ';
if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) {
const ProStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");
for (ProStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) {
const ProStringList &inputs = project->values(ProKey(*it + ".input"));
for (ProStringList::ConstIterator input = inputs.begin(); input != inputs.end(); ++input)
- t << (*input) << " ";
+ t << escapeFilePath(*input) << ' ';
}
}
t << endl << endl;
@@ -744,12 +731,14 @@ void Win32MakefileGenerator::writeLibsPart(QTextStream &t)
} else {
t << "LINKER = " << var("QMAKE_LINK") << endl;
t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
- t << "LIBS = " << var("QMAKE_LIBS") << " " << var("QMAKE_LIBS_PRIVATE") << endl;
+ t << "LIBS = " << fixLibFlags("QMAKE_LIBS").join(' ') << ' '
+ << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << endl;
}
}
void Win32MakefileGenerator::writeObjectsPart(QTextStream &t)
{
+ // Used in both deps and commands.
t << "OBJECTS = " << valList(escapeDependencyPaths(project->values("OBJECTS"))) << endl;
}
@@ -791,9 +780,10 @@ void Win32MakefileGenerator::writeRcFilePart(QTextStream &t)
incPathStr += escapeFilePath(path);
}
- t << res_file << ": " << rc_file << "\n\t"
+ t << escapeDependencyPath(res_file) << ": " << escapeDependencyPath(rc_file) << "\n\t"
<< var("QMAKE_RC") << (project->isActiveConfig("debug") ? " -D_DEBUG" : "")
- << " $(DEFINES)" << incPathStr << " -fo " << res_file << " " << rc_file;
+ << " $(DEFINES)" << incPathStr << " -fo " << escapeFilePath(res_file)
+ << ' ' << escapeFilePath(rc_file);
t << endl << endl;
}
}
@@ -829,7 +819,7 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t)
ret += installMetaFile(ProKey("QMAKE_PRL_INSTALL_REPLACE"), project->first("QMAKE_INTERNAL_PRL_FILE").toQString(), dst_prl);
if(!uninst.isEmpty())
uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_prl + "\"");
+ uninst.append("-$(DEL_FILE) " + escapeFilePath(dst_prl));
}
if(project->isActiveConfig("create_pc")) {
QString dst_pc = pkgConfigFileName(false);
@@ -846,32 +836,35 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t)
ret += installMetaFile(ProKey("QMAKE_PKGCONFIG_INSTALL_REPLACE"), pkgConfigFileName(true), dst_pc);
if(!uninst.isEmpty())
uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_pc + "\"");
+ uninst.append("-$(DEL_FILE) " + escapeFilePath(dst_pc));
}
}
if(project->isActiveConfig("shared") && !project->isActiveConfig("plugin")) {
QString lib_target = getLibTarget();
- lib_target.remove('"');
- QString src_targ = (project->isEmpty("DESTDIR") ? QString("$(DESTDIR)") : project->first("DESTDIR")) + lib_target;
- QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + lib_target, FileFixifyAbsolute));
+ QString src_targ = escapeFilePath(
+ (project->isEmpty("DESTDIR") ? QString("$(DESTDIR)") : project->first("DESTDIR"))
+ + lib_target);
+ QString dst_targ = escapeFilePath(
+ filePrefixRoot(root, fileFixify(targetdir + lib_target, FileFixifyAbsolute)));
if(!ret.isEmpty())
ret += "\n\t";
- ret += QString("-$(INSTALL_FILE)") + " \"" + src_targ + "\" \"" + dst_targ + "\"";
+ ret += QString("-$(INSTALL_FILE) ") + src_targ + ' ' + dst_targ;
if(!uninst.isEmpty())
uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
+ uninst.append("-$(DEL_FILE) " + dst_targ);
}
}
if (t == "dlltarget" || project->values(ProKey(t + ".CONFIG")).indexOf("no_dll") == -1) {
QString src_targ = "$(DESTDIR_TARGET)";
- QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + "$(TARGET)", FileFixifyAbsolute));
+ QString dst_targ = escapeFilePath(
+ filePrefixRoot(root, fileFixify(targetdir + "$(TARGET)", FileFixifyAbsolute)));
if(!ret.isEmpty())
ret += "\n\t";
- ret += QString("-$(INSTALL_FILE)") + " \"" + src_targ + "\" \"" + dst_targ + "\"";
+ ret += QString("-$(INSTALL_FILE) ") + src_targ + ' ' + dst_targ;
if(!uninst.isEmpty())
uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
+ uninst.append("-$(DEL_FILE) " + dst_targ);
}
return ret;
}
@@ -880,7 +873,6 @@ QString Win32MakefileGenerator::escapeFilePath(const QString &path) const
{
QString ret = path;
if(!ret.isEmpty()) {
- ret = unescapeFilePath(ret);
if (ret.contains(' ') || ret.contains('\t'))
ret = "\"" + ret + "\"";
debug_msg(2, "EscapeFilePath: %s -> %s", path.toLatin1().constData(), ret.toLatin1().constData());