summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/generators/win32')
-rw-r--r--qmake/generators/win32/mingw_make.cpp56
-rw-r--r--qmake/generators/win32/mingw_make.h3
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp61
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp8
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp24
-rw-r--r--qmake/generators/win32/winmakefile.cpp126
-rw-r--r--qmake/generators/win32/winmakefile.h2
7 files changed, 141 insertions, 139 deletions
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index 8aff6f93f3..b5bb7b5b7e 100644
--- a/qmake/generators/win32/mingw_make.cpp
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -46,17 +46,12 @@ QT_BEGIN_NAMESPACE
MingwMakefileGenerator::MingwMakefileGenerator() : Win32MakefileGenerator()
{
- if (isWindowsShell())
- quote = "\"";
- else
- quote = "'";
}
QString MingwMakefileGenerator::escapeDependencyPath(const QString &path) const
{
QString ret = path;
- ret.remove('\"');
- ret.replace('\\', "/");
+ ret.replace('\\', "/"); // ### this shouldn't be here
ret.replace(' ', "\\ ");
return ret;
}
@@ -71,6 +66,13 @@ QString MingwMakefileGenerator::getManifestFileForRcFile() const
return project->first("QMAKE_MANIFEST").toQString();
}
+ProString MingwMakefileGenerator::fixLibFlag(const ProString &lib)
+{
+ if (lib.startsWith("lib"))
+ return QStringLiteral("-l") + escapeFilePath(lib.mid(3));
+ return escapeFilePath(lib);
+}
+
bool MingwMakefileGenerator::findLibraries()
{
QList<QMakeLocalFileName> dirs;
@@ -99,7 +101,9 @@ bool MingwMakefileGenerator::findLibraries()
if (!out.isEmpty()) // We assume if it never finds it that its correct
(*it) = out;
} else if ((*it).startsWith("-L")) {
- dirs.append(QMakeLocalFileName((*it).mid(2).toQString()));
+ QMakeLocalFileName f((*it).mid(2).toQString());
+ dirs.append(f);
+ *it = "-L" + f.real();
}
++it;
@@ -124,7 +128,7 @@ bool MingwMakefileGenerator::writeMakefile(QTextStream &t)
t << "QMAKE = " << var("QMAKE_QMAKE") << endl;
const ProStringList &qut = project->values("QMAKE_EXTRA_TARGETS");
for (ProStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)
- t << *it << " ";
+ t << escapeDependencyPath(*it) << ' ';
t << "first all clean install distclean uninstall: qmake\n"
<< "qmake_all:\n";
writeMakeQmake(t);
@@ -150,6 +154,7 @@ void createLdObjectScriptFile(const QString &fileName, const ProStringList &objL
t << "INPUT(\n";
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
QString path = (*it).toQString();
+ // ### quoting?
if (QDir::isRelativePath(path))
t << "./" << path << endl;
else
@@ -167,6 +172,7 @@ void createArObjectScriptFile(const QString &fileName, const QString &target, co
QFile file(filePath);
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream t(&file);
+ // ### quoting?
t << "CREATE " << target << endl;
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
t << "ADDMOD " << *it << endl;
@@ -185,6 +191,7 @@ void createRvctObjectScriptFile(const QString &fileName, const ProStringList &ob
QTextStream t(&file);
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
QString path = (*it).toQString();
+ // ### quoting?
if (QDir::isRelativePath(path))
t << "./" << path << endl;
else
@@ -205,14 +212,14 @@ void MingwMakefileGenerator::writeMingwParts(QTextStream &t)
t << escapeDependencyPath(cHeader) << ": " << escapeDependencyPath(header) << " "
<< escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
<< "\n\t" << mkdir_p_asstring(preCompHeaderOut)
- << "\n\t$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << cHeader << " " << header
- << endl << endl;
+ << "\n\t$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << escapeFilePath(cHeader)
+ << ' ' << escapeFilePath(header) << endl << endl;
QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";
t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " "
<< escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")
<< "\n\t" << mkdir_p_asstring(preCompHeaderOut)
- << "\n\t$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << cppHeader << " " << header
- << endl << endl;
+ << "\n\t$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << escapeFilePath(cppHeader)
+ << ' ' << escapeFilePath(header) << endl << endl;
}
}
@@ -246,9 +253,7 @@ void MingwMakefileGenerator::init()
processVars();
- if (!project->values("RES_FILE").isEmpty()) {
- project->values("QMAKE_LIBS") += escapeFilePaths(project->values("RES_FILE"));
- }
+ project->values("QMAKE_LIBS") += project->values("RES_FILE");
if (project->isActiveConfig("dll")) {
QString destDir = "";
@@ -256,7 +261,7 @@ void MingwMakefileGenerator::init()
destDir = Option::fixPathToTargetOS(project->first("DESTDIR") + Option::dir_sep, false, false);
project->values("MINGW_IMPORT_LIB").prepend(destDir + "lib" + project->first("TARGET")
+ project->first("TARGET_VERSION_EXT") + ".a");
- project->values("QMAKE_LFLAGS").append(QString("-Wl,--out-implib,") + project->first("MINGW_IMPORT_LIB"));
+ project->values("QMAKE_LFLAGS").append(QString("-Wl,--out-implib,") + fileVar("MINGW_IMPORT_LIB"));
}
if (!project->values("DEF_FILE").isEmpty()) {
@@ -278,6 +283,7 @@ void MingwMakefileGenerator::init()
project->values("QMAKE_CLEAN").append(preCompHeaderOut + Option::dir_sep + "c");
project->values("QMAKE_CLEAN").append(preCompHeaderOut + Option::dir_sep + "c++");
+ preCompHeader = escapeFilePath(preCompHeader);
project->values("QMAKE_RUN_CC").clear();
project->values("QMAKE_RUN_CC").append("$(CC) -c -include " + preCompHeader +
" $(CFLAGS) $(INCPATH) " + var("QMAKE_CC_O_FLAG") + "$obj $src");
@@ -306,13 +312,12 @@ void MingwMakefileGenerator::writeIncPart(QTextStream &t)
for (ProStringList::ConstIterator incit = incs.begin(); incit != incs.end(); ++incit) {
QString inc = (*incit).toQString();
inc.replace(QRegExp("\\\\$"), "");
- inc.replace(QRegExp("\""), "");
if (!isystem.isEmpty() && isSystemInclude(inc))
t << isystem << ' ';
else
t << "-I";
- t << quote << inc << quote << " ";
+ t << escapeFilePath(inc) << ' ';
}
t << endl;
}
@@ -325,8 +330,8 @@ void MingwMakefileGenerator::writeLibsPart(QTextStream &t)
t << "LINKER = " << var("QMAKE_LINK") << endl;
t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
t << "LIBS = "
- << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << ' '
- << var("QMAKE_LIBS_PRIVATE").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
+ << fixLibFlags("QMAKE_LIBS").join(' ') << ' '
+ << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << endl;
}
}
@@ -345,7 +350,7 @@ void MingwMakefileGenerator::writeObjectsPart(QTextStream &t)
QString ar_cmd = project->values("QMAKE_LIB").join(' ');
if (ar_cmd.isEmpty())
ar_cmd = "armar --create";
- objectsLinkLine = ar_cmd + " " + var("DEST_TARGET") + " --via " + escapeFilePath(ar_script_file);
+ objectsLinkLine = ar_cmd + ' ' + fileVar("DEST_TARGET") + " --via " + escapeFilePath(ar_script_file);
} else {
// Strip off any options since the ar commands will be read from file.
QString ar_cmd = var("QMAKE_LIB").section(" ", 0, 0);;
@@ -373,8 +378,9 @@ void MingwMakefileGenerator::writeObjectsPart(QTextStream &t)
void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t)
{
t << "first: all\n";
- t << "all: " << escapeDependencyPath(fileFixify(Option::output.fileName())) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS"))," "," "," ") << " $(DESTDIR_TARGET)\n\n";
- t << "$(DESTDIR_TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " << var("POST_TARGETDEPS");
+ t << "all: " << escapeDependencyPath(fileFixify(Option::output.fileName()))
+ << ' ' << depVar("ALL_DEPS") << " $(DESTDIR_TARGET)\n\n";
+ t << "$(DESTDIR_TARGET): " << depVar("PRE_TARGETDEPS") << " $(OBJECTS) " << depVar("POST_TARGETDEPS");
if(!project->isEmpty("QMAKE_PRE_LINK"))
t << "\n\t" <<var("QMAKE_PRE_LINK");
if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
@@ -409,8 +415,8 @@ void MingwMakefileGenerator::writeRcFilePart(QTextStream &t)
}
if (!rc_file.isEmpty()) {
- t << escapeDependencyPath(var("RES_FILE")) << ": " << rc_file << "\n\t"
- << var("QMAKE_RC") << " -i " << rc_file << " -o " << var("RES_FILE")
+ t << escapeDependencyPath(var("RES_FILE")) << ": " << escapeDependencyPath(rc_file) << "\n\t"
+ << var("QMAKE_RC") << " -i " << escapeFilePath(rc_file) << " -o " << fileVar("RES_FILE")
<< incPathStr << " $(DEFINES)\n\n";
}
}
diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h
index a29442c916..e76391080c 100644
--- a/qmake/generators/win32/mingw_make.h
+++ b/qmake/generators/win32/mingw_make.h
@@ -45,6 +45,8 @@ public:
~MingwMakefileGenerator();
protected:
QString escapeDependencyPath(const QString &path) const;
+ ProString escapeDependencyPath(const ProString &path) const { return MakefileGenerator::escapeDependencyPath(path); }
+ virtual ProString fixLibFlag(const ProString &lib);
QString getLibTarget();
virtual QString getManifestFileForRcFile() const;
bool writeMakefile(QTextStream &);
@@ -64,7 +66,6 @@ private:
virtual bool findLibraries();
QString objectsLinkLine;
- QString quote;
};
inline MingwMakefileGenerator::~MingwMakefileGenerator()
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
index bd17b6c528..450f224654 100644
--- a/qmake/generators/win32/msvc_nmake.cpp
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -260,15 +260,14 @@ QString NmakeMakefileGenerator::defaultInstall(const QString &t)
if (project->isActiveConfig("debug_info")) {
if (t == "dlltarget" || project->values(ProKey(t + ".CONFIG")).indexOf("no_dll") == -1) {
QString pdb_target = getPdbTarget();
- pdb_target.remove('"');
QString src_targ = (project->isEmpty("DESTDIR") ? QString("$(DESTDIR)") : project->first("DESTDIR")) + pdb_target;
QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + pdb_target, FileFixifyAbsolute));
if(!ret.isEmpty())
ret += "\n\t";
- ret += QString("-$(INSTALL_FILE)") + " \"" + src_targ + "\" \"" + dst_targ + "\"";
+ ret += QString("-$(INSTALL_FILE) ") + escapeFilePath(src_targ) + ' ' + escapeFilePath(dst_targ);
if(!uninst.isEmpty())
uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
+ uninst.append("-$(DEL_FILE) " + escapeFilePath(dst_targ));
}
}
@@ -294,9 +293,12 @@ void NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
// precompiled header
if(usePCH) {
- QString precompRule = QString("-c -Yc -Fp%1 -Fo%2").arg(precompPch).arg(precompObj);
- t << precompObj << ": " << precompH << " " << escapeDependencyPaths(findDependencies(precompH)).join(" \\\n\t\t")
- << "\n\t$(CXX) " + precompRule +" $(CXXFLAGS) $(INCPATH) -TP " << precompH << endl << endl;
+ QString precompRule = QString("-c -Yc -Fp%1 -Fo%2")
+ .arg(escapeFilePath(precompPch), escapeFilePath(precompObj));
+ t << escapeDependencyPath(precompObj) << ": " << escapeDependencyPath(precompH) << ' '
+ << escapeDependencyPaths(findDependencies(precompH)).join(" \\\n\t\t")
+ << "\n\t$(CXX) " + precompRule +" $(CXXFLAGS) $(INCPATH) -TP "
+ << escapeFilePath(precompH) << endl << endl;
}
}
@@ -307,10 +309,9 @@ QString NmakeMakefileGenerator::var(const ProKey &value) const
|| value == "QMAKE_RUN_CXX_IMP"
|| value == "QMAKE_RUN_CXX")) {
QFileInfo precompHInfo(fileInfo(precompH));
+ QString precompH_f = escapeFilePath(precompHInfo.fileName());
QString precompRule = QString("-c -FI%1 -Yu%2 -Fp%3")
- .arg(precompHInfo.fileName())
- .arg(precompHInfo.fileName())
- .arg(precompPch);
+ .arg(precompH_f, precompH_f, escapeFilePath(precompPch));
QString p = MakefileGenerator::var(value);
p.replace("-c", precompRule);
// Cannot use -Gm with -FI & -Yu, as this gives an
@@ -357,9 +358,7 @@ void NmakeMakefileGenerator::init()
processVars();
- if (!project->values("RES_FILE").isEmpty()) {
- project->values("QMAKE_LIBS") += escapeFilePaths(project->values("RES_FILE"));
- }
+ project->values("QMAKE_LIBS") += project->values("RES_FILE");
if (!project->values("DEF_FILE").isEmpty()) {
QString defFileName = fileFixify(project->first("DEF_FILE").toQString());
@@ -502,11 +501,15 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t)
if (objDir == ".\\")
objDir = "";
for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
- t << "{" << sourceDir << "}" << (*cppit) << "{" << objDir << "}" << Option::obj_ext << "::\n\t"
- << var("QMAKE_RUN_CXX_IMP_BATCH").replace(QRegExp("\\$@"), var("OBJECTS_DIR")) << endl << "\t$<\n<<\n\n";
+ t << '{' << escapeDependencyPath(sourceDir) << '}' << (*cppit)
+ << '{' << escapeDependencyPath(objDir) << '}' << Option::obj_ext << "::\n\t"
+ << var("QMAKE_RUN_CXX_IMP_BATCH").replace(QRegExp("\\$@"), fileVar("OBJECTS_DIR"))
+ << "\n\t$<\n<<\n\n";
for(QStringList::Iterator cit = Option::c_ext.begin(); cit != Option::c_ext.end(); ++cit)
- t << "{" << sourceDir << "}" << (*cit) << "{" << objDir << "}" << Option::obj_ext << "::\n\t"
- << var("QMAKE_RUN_CC_IMP_BATCH").replace(QRegExp("\\$@"), var("OBJECTS_DIR")) << endl << "\t$<\n<<\n\n";
+ t << '{' << escapeDependencyPath(sourceDir) << '}' << (*cit)
+ << '{' << escapeDependencyPath(objDir) << '}' << Option::obj_ext << "::\n\t"
+ << var("QMAKE_RUN_CC_IMP_BATCH").replace(QRegExp("\\$@"), fileVar("OBJECTS_DIR"))
+ << "\n\t$<\n<<\n\n";
}
} else {
for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
@@ -522,8 +525,9 @@ void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t)
const ProString templateName = project->first("TEMPLATE");
t << "first: all\n";
- t << "all: " << fileFixify(Option::output.fileName()) << " " << varGlue("ALL_DEPS"," "," "," ") << "$(DESTDIR_TARGET)\n\n";
- t << "$(DESTDIR_TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " << var("POST_TARGETDEPS");
+ t << "all: " << escapeDependencyPath(fileFixify(Option::output.fileName()))
+ << ' ' << depVar("ALL_DEPS") << " $(DESTDIR_TARGET)\n\n";
+ t << "$(DESTDIR_TARGET): " << depVar("PRE_TARGETDEPS") << " $(OBJECTS) " << depVar("POST_TARGETDEPS");
if(!project->isEmpty("QMAKE_PRE_LINK"))
t << "\n\t" <<var("QMAKE_PRE_LINK");
@@ -547,12 +551,12 @@ void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t)
if (linkerSupportsEmbedding) {
extraLFlags = "/MANIFEST:embed";
} else {
- manifest = escapeFilePath(target + ".embed.manifest");
- extraLFlags += "/MANIFEST /MANIFESTFILE:" + manifest;
+ manifest = target + ".embed.manifest";
+ extraLFlags += "/MANIFEST /MANIFESTFILE:" + escapeFilePath(manifest);
project->values("QMAKE_CLEAN") << manifest;
}
} else {
- manifest = escapeFilePath(fileFixify(manifest));
+ manifest = fileFixify(manifest);
}
const QString resourceId = (templateName == "app") ? "1" : "2";
@@ -560,16 +564,19 @@ void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t)
if (incrementalLinking && !linkerSupportsEmbedding) {
// Link a resource that contains the manifest without modifying the exe/dll after linking.
- QString manifest_rc = escapeFilePath(target + "_manifest.rc");
- QString manifest_res = escapeFilePath(target + "_manifest.res");
- QString manifest_bak = escapeFilePath(target + "_manifest.bak");
+ QString manifest_rc = target + "_manifest.rc";
+ QString manifest_res = target + "_manifest.res";
project->values("QMAKE_CLEAN") << manifest_rc << manifest_res;
+ manifest_rc = escapeFilePath(manifest_rc);
+ manifest_res = escapeFilePath(manifest_res);
t << "\n\techo " << resourceId
<< " /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ "
- << cQuoted(unescapeFilePath(manifest)) << ">" << manifest_rc;
+ << cQuoted(manifest) << '>' << manifest_rc;
if (generateManifest) {
+ manifest = escapeFilePath(manifest);
+ QString manifest_bak = escapeFilePath(target + "_manifest.bak");
t << "\n\tif not exist $(DESTDIR_TARGET) if exist " << manifest
<< " del " << manifest;
t << "\n\tif exist " << manifest << " copy /Y " << manifest << ' ' << manifest_bak;
@@ -591,7 +598,7 @@ void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t)
t << "\n\t";
writeLinkCommand(t, extraLFlags);
if (!linkerSupportsEmbedding) {
- t << "\n\tmt.exe /nologo /manifest " << manifest
+ t << "\n\tmt.exe /nologo /manifest " << escapeFilePath(manifest)
<< " /outputresource:$(DESTDIR_TARGET);" << resourceId;
}
}
@@ -604,7 +611,7 @@ void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t)
bool useSignature = !signature.isEmpty() && !project->isActiveConfig("staticlib") &&
!project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH");
if(useSignature) {
- t << "\n\tsigntool sign /F " << signature << " $(DESTDIR_TARGET)";
+ t << "\n\tsigntool sign /F " << escapeFilePath(signature) << " $(DESTDIR_TARGET)";
}
if(!project->isEmpty("QMAKE_POST_LINK")) {
t << "\n\t" << var("QMAKE_POST_LINK");
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
index 62f5814ce3..d14bb7b892 100644
--- a/qmake/generators/win32/msvc_objectmodel.cpp
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -2363,10 +2363,9 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
deps = inputs + deps; // input files themselves too..
// Replace variables for command w/all input files
- // ### join gives path issues with directories containing spaces!
cmd = Project->replaceExtraCompilerVariables(tmp_cmd,
- inputs.join(' '),
- out,
+ inputs,
+ QStringList(out),
MakefileGenerator::TargetShell);
} else {
deps.prepend(inFile); // input file itself too..
@@ -2385,9 +2384,6 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
cmd_name = cmd.left(space);
else
cmd_name = cmd;
- if ((cmd_name[0] == '\'' || cmd_name[0] == '"') &&
- cmd_name[0] == cmd_name[cmd_name.length()-1])
- cmd_name = cmd_name.mid(1,cmd_name.length()-2);
}
// Fixify paths
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index dd0fdafb49..5da6f5807d 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -505,7 +505,7 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
Option::qmake_mode = old_mode;
// We assume project filename is [QMAKE_PROJECT_NAME].vcproj
- QString vcproj = unescapeFilePath(tmp_vcproj.project->first("QMAKE_PROJECT_NAME") + project->first("VCPROJ_EXTENSION"));
+ QString vcproj = tmp_vcproj.project->first("QMAKE_PROJECT_NAME") + project->first("VCPROJ_EXTENSION");
QString vcprojDir = qmake_getpwd();
// If file doesn't exsist, then maybe the users configuration
@@ -535,7 +535,7 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
VcsolutionDepend *newDep = new VcsolutionDepend;
newDep->vcprojFile = vcprojDir + Option::dir_sep + vcproj;
- newDep->orig_target = unescapeFilePath(tmp_proj.first("QMAKE_ORIG_TARGET")).toQString();
+ newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET").toQString();
newDep->target = tmp_proj.first("MSVCPROJ_TARGET").toQString().section(Option::dir_sep, -1);
newDep->targetType = tmp_vcproj.projectTarget;
newDep->uuid = tmp_proj.isEmpty("QMAKE_UUID") ? getProjectUUID(Option::fixPathToLocalOS(vcprojDir + QDir::separator() + vcproj)).toString().toUpper(): tmp_proj.first("QMAKE_UUID").toQString();
@@ -671,6 +671,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
// write out projects
for (QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) {
+ // ### quoting rules?
t << _slnProjectBeg << _slnMSVCvcprojGUID << _slnProjectMid
<< "\"" << (*it)->orig_target << "\", \"" << (*it)->vcprojFile
<< "\", \"" << (*it)->uuid << "\"";
@@ -799,9 +800,7 @@ void VcprojGenerator::init()
const ProStringList &incs = project->values("INCLUDEPATH");
for (ProStringList::ConstIterator incit = incs.begin(); incit != incs.end(); ++incit) {
QString inc = (*incit).toQString();
- if (!inc.startsWith('"') && !inc.endsWith('"'))
- inc = QString("\"%1\"").arg(inc); // Quote all paths if not quoted already
- project->values("MSVCPROJ_INCPATH").append("-I" + inc);
+ project->values("MSVCPROJ_INCPATH").append("-I" + escapeFilePath(inc));
}
QString dest = Option::fixPathToTargetOS(project->first("TARGET").toQString()) + project->first("TARGET_EXT");
@@ -815,7 +814,7 @@ void VcprojGenerator::init()
for (dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir) {
if (!copydll.isEmpty())
copydll += " && ";
- copydll += "copy \"$(TargetPath)\" \"" + *dlldir + "\"";
+ copydll += "copy \"$(TargetPath)\" " + escapeFilePath(*dlldir);
}
QString deststr("Copy " + dest + " to ");
@@ -842,8 +841,7 @@ void VcprojGenerator::init()
projectTarget = Application;
} else if(project->first("TEMPLATE") == "vclib") {
if(project->isActiveConfig("staticlib")) {
- if (!project->values("RES_FILE").isEmpty())
- project->values("QMAKE_LIBS") += escapeFilePaths(project->values("RES_FILE"));
+ project->values("QMAKE_LIBS") += project->values("RES_FILE");
projectTarget = StaticLib;
} else
projectTarget = SharedLib;
@@ -856,7 +854,7 @@ void VcprojGenerator::init()
if (usePCH) {
precompHFilename = fileInfo(precompH).fileName();
// Created files
- QString origTarget = unescapeFilePath(project->first("QMAKE_ORIG_TARGET").toQString());
+ QString origTarget = project->first("QMAKE_ORIG_TARGET").toQString();
precompObj = origTarget + Option::obj_ext;
precompPch = origTarget + ".pch";
// Add PRECOMPILED_HEADER to HEADERS
@@ -947,7 +945,7 @@ void VcprojGenerator::initProject()
initExtraCompilerOutputs();
// Own elements -----------------------------
- vcProject.Name = unescapeFilePath(project->first("QMAKE_ORIG_TARGET").toQString());
+ vcProject.Name = project->first("QMAKE_ORIG_TARGET").toQString();
switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) {
case NET2013:
vcProject.Version = "12.00";
@@ -1179,7 +1177,7 @@ void VcprojGenerator::initLinkerTool()
ProStringList l = ProStringList(libs);
conf.linker.parseOptions(l);
} else {
- conf.linker.AdditionalDependencies += libs.toQString();
+ conf.linker.AdditionalDependencies << escapeFilePath(libs.toQString());
}
}
@@ -1239,7 +1237,7 @@ void VcprojGenerator::initPostBuildEventTools()
!project->isHostBuild() && !project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH");
if (useSignature) {
conf.postBuild.CommandLine.prepend(
- QLatin1String("signtool sign /F ") + signature + QLatin1String(" \"$(TargetPath)\""));
+ QLatin1String("signtool sign /F ") + escapeFilePath(signature) + QLatin1String(" \"$(TargetPath)\""));
conf.postBuild.ExcludedFromBuild = _False;
}
@@ -1682,7 +1680,7 @@ bool VcprojGenerator::openOutput(QFile &file, const QString &/*build*/) const
ProString ext = project->first("VCPROJ_EXTENSION");
if(project->first("TEMPLATE") == "vcsubdirs")
ext = project->first("VCSOLUTION_EXTENSION");
- ProString outputName = unescapeFilePath(project->first("TARGET"));
+ ProString outputName = project->first("TARGET");
if (!project->first("MAKEFILE").isEmpty())
outputName = project->first("MAKEFILE");
file.setFileName(outdir + outputName + ext);
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());
diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h
index 795ca2b874..ea763c3175 100644
--- a/qmake/generators/win32/winmakefile.h
+++ b/qmake/generators/win32/winmakefile.h
@@ -60,6 +60,8 @@ protected:
int findHighestVersion(const QString &dir, const QString &stem, const QString &ext = QLatin1String("lib"));
virtual bool findLibraries();
+ virtual ProString fixLibFlag(const ProString &lib);
+
virtual void processPrlFiles();
void processVars();
void fixTargetExt();