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.cpp62
-rw-r--r--qmake/generators/win32/mingw_make.h3
-rw-r--r--qmake/generators/win32/msbuild_objectmodel.cpp6
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp64
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp34
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp63
-rw-r--r--qmake/generators/win32/msvc_vcproj.h7
-rw-r--r--qmake/generators/win32/winmakefile.cpp145
-rw-r--r--qmake/generators/win32/winmakefile.h2
9 files changed, 196 insertions, 190 deletions
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index 8aff6f93f3..af5e62330e 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;
@@ -89,9 +91,9 @@ bool MingwMakefileGenerator::findLibraries()
if (ver > 0)
extension += QString::number(ver);
extension += suffix;
- if(QMakeMetaInfo::libExists((*dir_it).local() + Option::dir_sep + steam) ||
- exists((*dir_it).local() + Option::dir_sep + steam + extension + ".a") ||
- exists((*dir_it).local() + Option::dir_sep + steam + extension + ".dll.a")) {
+ if (QMakeMetaInfo::libExists((*dir_it).local() + '/' + steam)
+ || exists((*dir_it).local() + '/' + steam + extension + ".a")
+ || exists((*dir_it).local() + '/' + steam + extension + ".dll.a")) {
out = *it + extension;
break;
}
@@ -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/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp
index a6ca07efee..3bb70c5c19 100644
--- a/qmake/generators/win32/msbuild_objectmodel.cpp
+++ b/qmake/generators/win32/msbuild_objectmodel.cpp
@@ -1900,11 +1900,11 @@ bool VCXProjectWriter::outputFileConfig(OutputFilterData *d, XmlOutput &xml, Xml
fileAdded = true;
xmlFilter << tag("CustomBuild")
- << attrTag("Include",Option::fixPathToLocalOS(filename))
+ << attrTag("Include", Option::fixPathToTargetOS(filename))
<< attrTagS("Filter", filter.Name);
xml << tag("CustomBuild")
- << attrTag("Include",Option::fixPathToLocalOS(filename));
+ << attrTag("Include", Option::fixPathToTargetOS(filename));
if (filter.Name.startsWith("Form Files")
|| filter.Name.startsWith("Generated Files")
@@ -1963,7 +1963,7 @@ bool VCXProjectWriter::outputFileConfig(OutputFilterData *d, XmlOutput &xml, Xml
void VCXProjectWriter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter,
const QString &filePath, const QString &filterName)
{
- const QString nativeFilePath = Option::fixPathToLocalOS(filePath);
+ const QString nativeFilePath = Option::fixPathToTargetOS(filePath);
if (filterName.startsWith("Source Files")) {
xmlFilter << tag("ClCompile")
<< attrTag("Include", nativeFilePath)
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
index bd17b6c528..ae888cb96d 100644
--- a/qmake/generators/win32/msvc_nmake.cpp
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -252,23 +252,21 @@ QString NmakeMakefileGenerator::defaultInstall(const QString &t)
const QString root = "$(INSTALL_ROOT)";
ProStringList &uninst = project->values(ProKey(t + ".uninstall"));
- QString targetdir = Option::fixPathToTargetOS(project->first(ProKey(t + ".path")).toQString(), false);
- targetdir = fileFixify(targetdir, FileFixifyAbsolute);
+ QString targetdir = fileFixify(project->first(ProKey(t + ".path")).toQString(), FileFixifyAbsolute);
if(targetdir.right(1) != Option::dir_sep)
targetdir += Option::dir_sep;
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 +292,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 +308,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 +357,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 +500,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 +524,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 +550,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 +563,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 +597,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 +610,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 28a67d9902..4a65d24687 100644
--- a/qmake/generators/win32/msvc_objectmodel.cpp
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -2295,9 +2295,8 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
QString cmd, cmd_name, out;
QStringList deps, inputs;
// Variabel replacement of output name
- out = Option::fixPathToTargetOS(
- Project->replaceExtraCompilerVariables(tmp_out, inFile, QString()),
- false);
+ out = Option::fixPathToTargetOS(Project->replaceExtraCompilerVariables(
+ tmp_out, inFile, QString(), MakefileGenerator::NoShell), false);
// If file has built-in compiler, we've swapped the input and output of
// the command, as we in Visual Studio cannot have a Custom Buildstep on
@@ -2318,9 +2317,8 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
if (!tmp_dep_cmd.isEmpty()) {
// Execute dependency command, and add every line as a dep
char buff[256];
- QString dep_cmd = Project->replaceExtraCompilerVariables(tmp_dep_cmd,
- Option::fixPathToLocalOS(inFile, true, false),
- out);
+ QString dep_cmd = Project->replaceExtraCompilerVariables(
+ tmp_dep_cmd, inFile, out, MakefileGenerator::LocalShell);
if(Project->canExecute(dep_cmd)) {
dep_cmd.prepend(QLatin1String("cd ")
+ Project->escapeFilePath(Option::fixPathToLocalOS(Option::output_dir, false))
@@ -2347,8 +2345,9 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
}
for (int i = 0; i < deps.count(); ++i)
deps[i] = Option::fixPathToTargetOS(
- Project->replaceExtraCompilerVariables(deps.at(i), inFile, out),
- false).trimmed();
+ Project->replaceExtraCompilerVariables(
+ deps.at(i), inFile, out, MakefileGenerator::NoShell),
+ false);
// Command for file
if (combined) {
// Add dependencies for each file
@@ -2364,28 +2363,27 @@ 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..
cmd = Project->replaceExtraCompilerVariables(tmp_cmd,
inFile,
- out);
+ out,
+ MakefileGenerator::TargetShell);
}
// Name for command
if (!tmp_cmd_name.isEmpty()) {
- cmd_name = Project->replaceExtraCompilerVariables(tmp_cmd_name, inFile, out);
+ cmd_name = Project->replaceExtraCompilerVariables(
+ tmp_cmd_name, inFile, out, MakefileGenerator::NoShell);
} else {
int space = cmd.indexOf(' ');
if (space != -1)
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
@@ -2903,7 +2901,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCFilter &tool)
for (int i = 0; i < tool.Files.count(); ++i) {
const VCFilterFile &info = tool.Files.at(i);
xml << tag(q_File)
- << attrS(_RelativePath, Option::fixPathToLocalOS(info.file))
+ << attrS(_RelativePath, Option::fixPathToTargetOS(info.file))
<< data(); // In case no custom builds, to avoid "/>" endings
outputFileConfig(tool, xml, tool.Files.at(i).file);
xml << closetag(q_File);
@@ -2962,7 +2960,7 @@ void VCProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, const QSt
void VCProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, const VCFilterFile &info, const QString &filtername)
{
xml << tag(q_File)
- << attrS(_RelativePath, Option::fixPathToLocalOS(info.file));
+ << attrS(_RelativePath, Option::fixPathToTargetOS(info.file));
for (int i = 0; i < project.SingleProjects.count(); ++i) {
VCFilter filter = project.SingleProjects.at(i).filterByName(filtername);
if (filter.Config) // only if the filter is not empty
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 64252ff076..57557732c5 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -324,7 +324,8 @@ QUuid VcprojGenerator::getProjectUUID(const QString &filename)
// If none, create one based on the MD5 of absolute project path
if(uuid.isNull() || !filename.isEmpty()) {
- QString abspath = Option::fixPathToLocalOS(filename.isEmpty()?project->first("QMAKE_MAKEFILE").toQString():filename);
+ QString abspath = Option::fixPathToTargetOS(
+ filename.isEmpty() ? project->first("QMAKE_MAKEFILE").toQString() : filename);
QByteArray digest = QCryptographicHash::hash(abspath.toUtf8(), QCryptographicHash::Sha1);
memcpy((unsigned char*)(&uuid), digest.constData(), sizeof(QUuid));
validUUID = !uuid.isNull();
@@ -457,14 +458,14 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
while (collectedIt.hasNext()) {
QPair<QString, ProStringList> subdir = collectedIt.next();
QString profile = subdir.first;
- QFileInfo fi(fileInfo(Option::fixPathToLocalOS(profile, true)));
+ QFileInfo fi(fileInfo(Option::normalizePath(profile)));
if (fi.exists()) {
if (fi.isDir()) {
if (!profile.endsWith(Option::dir_sep))
profile += Option::dir_sep;
profile += fi.baseName() + Option::pro_ext;
QString profileKey = fi.absoluteFilePath();
- fi = QFileInfo(fileInfo(Option::fixPathToLocalOS(profile, true)));
+ fi = QFileInfo(fileInfo(Option::normalizePath(profile)));
if (!fi.exists())
continue;
projLookup.insert(profileKey, fi.absoluteFilePath());
@@ -505,7 +506,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 +536,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 +672,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 +801,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 +815,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 +842,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 +855,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
@@ -893,7 +892,7 @@ void VcprojGenerator::init()
extraCompilerSources[file] += quc.toQString();
} else {
QString out = Option::fixPathToTargetOS(replaceExtraCompilerVariables(
- compiler_out, file, QString()), false);
+ compiler_out, file, QString(), NoShell), false);
extraCompilerSources[out] += quc.toQString();
extraCompilerOutputs[out] = QStringList(file); // Can only have one
}
@@ -947,7 +946,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 +1178,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 +1238,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;
}
@@ -1346,13 +1345,13 @@ void VcprojGenerator::initDeploymentTool()
|| devicePath.at(0) == QLatin1Char('\\')
|| devicePath.at(0) == QLatin1Char('%'))) {
// create output path
- devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('\\') + devicePath));
+ devicePath = Option::fixPathToTargetOS(targetPath + QLatin1Char('\\') + devicePath);
}
}
// foreach d in item.files
foreach (const ProString &src, project->values(ProKey(item + ".files"))) {
QString itemDevicePath = devicePath;
- QString source = Option::fixPathToLocalOS(src.toQString());
+ QString source = Option::normalizePath(src.toQString());
QString nameFilter;
QFileInfo info(source);
QString searchPath;
@@ -1361,7 +1360,7 @@ void VcprojGenerator::initDeploymentTool()
itemDevicePath += "\\" + info.fileName();
searchPath = info.absoluteFilePath();
} else {
- nameFilter = source.split('\\').last();
+ nameFilter = info.fileName();
searchPath = info.absolutePath();
}
@@ -1373,10 +1372,10 @@ void VcprojGenerator::initDeploymentTool()
while(iterator.hasNext()) {
iterator.next();
if (conf.WinRT) {
- QString absoluteItemFilePath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absoluteFilePath());
+ QString absoluteItemFilePath = Option::fixPathToTargetOS(QFileInfo(iterator.filePath()).absoluteFilePath());
vcProject.DeploymentFiles.addFile(absoluteItemFilePath);
} else {
- QString absoluteItemPath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absolutePath());
+ QString absoluteItemPath = Option::fixPathToTargetOS(QFileInfo(iterator.filePath()).absolutePath());
// Identify if it is just another subdir
int diffSize = absoluteItemPath.size() - pathSize;
// write out rules
@@ -1532,7 +1531,8 @@ void VcprojGenerator::initResourceFiles()
if(!qrc_files.isEmpty()) {
for (int i = 0; i < qrc_files.count(); ++i) {
char buff[256];
- QString dep_cmd = replaceExtraCompilerVariables(rcc_dep_cmd, qrc_files.at(i).toQString(), "");
+ QString dep_cmd = replaceExtraCompilerVariables(
+ rcc_dep_cmd, qrc_files.at(i).toQString(), QString(), LocalShell);
dep_cmd = Option::fixPathToLocalOS(dep_cmd, true, false);
if(canExecute(dep_cmd)) {
@@ -1605,16 +1605,16 @@ void VcprojGenerator::initExtraCompilerOutputs()
QString tmp_out = project->first(ProKey(*it + ".output")).toQString();
if (project->values(ProKey(*it + ".CONFIG")).indexOf("combine") != -1) {
// Combined output, only one file result
- extraCompile.addFile(
- Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_out, QString(), QString()), false));
+ extraCompile.addFile(Option::fixPathToTargetOS(
+ replaceExtraCompilerVariables(tmp_out, QString(), QString(), NoShell), false));
} else {
// One output file per input
const ProStringList &tmp_in = project->values(project->first(ProKey(*it + ".input")).toKey());
for (int i = 0; i < tmp_in.count(); ++i) {
const QString &filename = tmp_in.at(i).toQString();
if (extraCompilerSources.contains(filename))
- extraCompile.addFile(
- Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, tmp_out, QString()), false));
+ extraCompile.addFile(Option::fixPathToTargetOS(
+ replaceExtraCompilerVariables(filename, tmp_out, QString(), NoShell), false));
}
}
} else {
@@ -1629,8 +1629,8 @@ void VcprojGenerator::initExtraCompilerOutputs()
for (int i = 0; i < tmp_in.count(); ++i) {
const QString &filename = tmp_in.at(i).toQString();
if (extraCompilerSources.contains(filename))
- extraCompile.addFile(
- Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, QString(), QString()), false));
+ extraCompile.addFile(Option::fixPathToTargetOS(
+ replaceExtraCompilerVariables(filename, QString(), QString(), NoShell), false));
}
}
}
@@ -1650,9 +1650,10 @@ VCProjectWriter *VcprojGenerator::createProjectWriter()
return new VCProjectWriter;
}
-QString VcprojGenerator::replaceExtraCompilerVariables(const QString &var, const QStringList &in, const QStringList &out)
+QString VcprojGenerator::replaceExtraCompilerVariables(
+ const QString &var, const QStringList &in, const QStringList &out, ReplaceFor forShell)
{
- QString ret = MakefileGenerator::replaceExtraCompilerVariables(var, in, out);
+ QString ret = MakefileGenerator::replaceExtraCompilerVariables(var, in, out, forShell);
ProStringList &defines = project->values("VCPROJ_MAKEFILE_DEFINES");
if(defines.isEmpty())
@@ -1680,7 +1681,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/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
index 7d912616fd..87cc39f323 100644
--- a/qmake/generators/win32/msvc_vcproj.h
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -76,9 +76,10 @@ protected:
virtual VCProjectWriter *createProjectWriter();
virtual bool doDepends() const { return false; } //never necesary
virtual void processSources() { filterIncludedFiles("SOURCES"); filterIncludedFiles("GENERATED_SOURCES"); }
- virtual QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &);
- inline QString replaceExtraCompilerVariables(const QString &val, const QString &in, const QString &out)
- { return MakefileGenerator::replaceExtraCompilerVariables(val, in, out); }
+ using MakefileGenerator::ReplaceFor;
+ virtual QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &, ReplaceFor);
+ inline QString replaceExtraCompilerVariables(const QString &val, const QString &in, const QString &out, ReplaceFor forShell)
+ { return MakefileGenerator::replaceExtraCompilerVariables(val, in, out, forShell); }
virtual bool supportsMetaBuild() { return true; }
virtual bool supportsMergedBuilds() { return true; }
virtual bool mergeBuildProject(MakefileGenerator *other);
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index 41a8567545..ad6a19e5df 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -52,12 +52,12 @@ Win32MakefileGenerator::Win32MakefileGenerator() : MakefileGenerator()
int
Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem, const QString &ext)
{
- QString bd = Option::fixPathToLocalOS(d, true);
+ QString bd = Option::normalizePath(d);
if(!exists(bd))
return -1;
QMakeMetaInfo libinfo(project);
- bool libInfoRead = libinfo.readLib(bd + Option::dir_sep + stem);
+ bool libInfoRead = libinfo.readLib(bd + '/' + stem);
// If the library, for which we're trying to find the highest version
// number, is a static library
@@ -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;
}
@@ -139,22 +146,17 @@ Win32MakefileGenerator::findLibraries()
extension += QString::number(ver);
extension += suffix;
extension += ".lib";
- if(QMakeMetaInfo::libExists((*it).local() + Option::dir_sep + lib) ||
- exists((*it).local() + Option::dir_sep + lib + extension)) {
+ if (QMakeMetaInfo::libExists((*it).local() + '/' + lib)
+ || exists((*it).local() + '/' + 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))) {
+ } else if (!exists(Option::normalizePath(opt))) {
QList<QMakeLocalFileName> lib_dirs;
QString file = Option::fixPathToTargetOS(opt);
int slsh = file.lastIndexOf(Option::dir_sep);
@@ -167,7 +169,7 @@ Win32MakefileGenerator::findLibraries()
if(file.endsWith(".lib")) {
file = file.left(file.length() - 4);
if(!file.at(file.length()-1).isNumber()) {
- ProString suffix = project->first(ProKey("QMAKE_" + file.section(Option::dir_sep, -1).toUpper() + "_SUFFIX"));
+ ProString suffix = project->first(ProKey("QMAKE_" + file.toUpper() + "_SUFFIX"));
for(QList<QMakeLocalFileName>::Iterator dep_it = lib_dirs.begin(); dep_it != lib_dirs.end(); ++dep_it) {
QString lib_tmpl(file + "%1" + suffix + ".lib");
int ver = findHighestVersion((*dep_it).local(), file);
@@ -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))
@@ -226,21 +223,15 @@ Win32MakefileGenerator::processPrlFiles()
else
tmp = opt;
for(QList<QMakeLocalFileName>::Iterator it = libdirs.begin(); it != libdirs.end(); ++it) {
- QString prl = (*it).local() + Option::dir_sep + tmp;
+ QString prl = (*it).local() + '/' + tmp;
if (processPrlFile(prl))
break;
}
}
}
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) {
@@ -591,9 +581,9 @@ void Win32MakefileGenerator::writeCleanParts(QTextStream &t)
}
t << "\n\t-$(DEL_FILE) $(DESTDIR_TARGET)\n";
{
- QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.fileName()));
+ QString ofile = 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;
}
}
@@ -813,8 +803,7 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t)
const QString root = "$(INSTALL_ROOT)";
ProStringList &uninst = project->values(ProKey(t + ".uninstall"));
QString ret;
- QString targetdir = Option::fixPathToTargetOS(project->first(ProKey(t + ".path")).toQString(), false);
- targetdir = fileFixify(targetdir, FileFixifyAbsolute);
+ QString targetdir = fileFixify(project->first(ProKey(t + ".path")).toQString(), FileFixifyAbsolute);
if(targetdir.right(1) != Option::dir_sep)
targetdir += Option::dir_sep;
@@ -829,7 +818,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 +835,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 +872,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();