fix filename handling in replaceExtraCompilerVariables()
fixing and escaping is now a tri-state option: - none (this removes the need to unescape the result right afterwards in some cases) - local shell (for system()) - target shell (for Makefile) Change-Id: I5b78d9b70630fe4484dc964eff5f62793da35764 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
6ccf0a326e
commit
c0d67bb5c9
@ -773,7 +773,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
|
|||||||
mkt << "\\\n\t";
|
mkt << "\\\n\t";
|
||||||
++added;
|
++added;
|
||||||
const QString file_name = fileFixify(fn, Option::output_dir, Option::output_dir);
|
const QString file_name = fileFixify(fn, Option::output_dir, Option::output_dir);
|
||||||
mkt << " " << replaceExtraCompilerVariables(Option::fixPathToTargetOS(tmp_out.first().toQString(), false), file_name, QString());
|
mkt << " " << replaceExtraCompilerVariables(
|
||||||
|
Option::fixPathToTargetOS(tmp_out.first().toQString(), false), file_name, QString(), NoShell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,8 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
using namespace QMakeInternal;
|
||||||
|
|
||||||
bool MakefileGenerator::canExecute(const QStringList &cmdline, int *a) const
|
bool MakefileGenerator::canExecute(const QStringList &cmdline, int *a) const
|
||||||
{
|
{
|
||||||
int argv0 = -1;
|
int argv0 = -1;
|
||||||
@ -210,7 +212,7 @@ MakefileGenerator::initOutPaths()
|
|||||||
for (ProStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
|
for (ProStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
|
||||||
QString finp = fileFixify((*input).toQString(), Option::output_dir, Option::output_dir);
|
QString finp = fileFixify((*input).toQString(), Option::output_dir, Option::output_dir);
|
||||||
*input = ProString(finp);
|
*input = ProString(finp);
|
||||||
QString path = unescapeFilePath(replaceExtraCompilerVariables(tmp_out, finp, QString()));
|
QString path = replaceExtraCompilerVariables(tmp_out, finp, QString(), NoShell);
|
||||||
path = Option::fixPathToTargetOS(path);
|
path = Option::fixPathToTargetOS(path);
|
||||||
int slash = path.lastIndexOf(Option::dir_sep);
|
int slash = path.lastIndexOf(Option::dir_sep);
|
||||||
if(slash != -1) {
|
if(slash != -1) {
|
||||||
@ -728,7 +730,7 @@ MakefileGenerator::init()
|
|||||||
QString in = Option::fixPathToTargetOS(inpf, false);
|
QString in = Option::fixPathToTargetOS(inpf, false);
|
||||||
if (!verifyExtraCompiler((*it).toQString(), in)) //verify
|
if (!verifyExtraCompiler((*it).toQString(), in)) //verify
|
||||||
continue;
|
continue;
|
||||||
QString out = replaceExtraCompilerVariables(tmp_out.toQString(), inpf, QString());
|
QString out = replaceExtraCompilerVariables(tmp_out.toQString(), inpf, QString(), NoShell);
|
||||||
out = fileFixify(out, Option::output_dir, Option::output_dir);
|
out = fileFixify(out, Option::output_dir, Option::output_dir);
|
||||||
bool pre_dep = (config.indexOf("target_predeps") != -1);
|
bool pre_dep = (config.indexOf("target_predeps") != -1);
|
||||||
if (v.contains(vokey)) {
|
if (v.contains(vokey)) {
|
||||||
@ -1513,7 +1515,8 @@ MakefileGenerator::createObjectList(const ProStringList &sources)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplaceExtraCompilerCacheKey::ReplaceExtraCompilerCacheKey(const QString &v, const QStringList &i, const QStringList &o)
|
ReplaceExtraCompilerCacheKey::ReplaceExtraCompilerCacheKey(
|
||||||
|
const QString &v, const QStringList &i, const QStringList &o, MakefileGenerator::ReplaceFor s)
|
||||||
{
|
{
|
||||||
static QString doubleColon = QLatin1String("::");
|
static QString doubleColon = QLatin1String("::");
|
||||||
|
|
||||||
@ -1530,11 +1533,13 @@ ReplaceExtraCompilerCacheKey::ReplaceExtraCompilerCacheKey(const QString &v, con
|
|||||||
ol.sort();
|
ol.sort();
|
||||||
out = ol.join(doubleColon);
|
out = ol.join(doubleColon);
|
||||||
}
|
}
|
||||||
|
forShell = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReplaceExtraCompilerCacheKey::operator==(const ReplaceExtraCompilerCacheKey &f) const
|
bool ReplaceExtraCompilerCacheKey::operator==(const ReplaceExtraCompilerCacheKey &f) const
|
||||||
{
|
{
|
||||||
return (hashCode() == f.hashCode() &&
|
return (hashCode() == f.hashCode() &&
|
||||||
|
f.forShell == forShell &&
|
||||||
f.in == in &&
|
f.in == in &&
|
||||||
f.out == out &&
|
f.out == out &&
|
||||||
f.var == var &&
|
f.var == var &&
|
||||||
@ -1543,10 +1548,11 @@ bool ReplaceExtraCompilerCacheKey::operator==(const ReplaceExtraCompilerCacheKey
|
|||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
MakefileGenerator::replaceExtraCompilerVariables(const QString &orig_var, const QStringList &in, const QStringList &out)
|
MakefileGenerator::replaceExtraCompilerVariables(
|
||||||
|
const QString &orig_var, const QStringList &in, const QStringList &out, ReplaceFor forShell)
|
||||||
{
|
{
|
||||||
//lazy cache
|
//lazy cache
|
||||||
ReplaceExtraCompilerCacheKey cacheKey(orig_var, in, out);
|
ReplaceExtraCompilerCacheKey cacheKey(orig_var, in, out, forShell);
|
||||||
QString cacheVal = extraCompilerVariablesCache.value(cacheKey);
|
QString cacheVal = extraCompilerVariablesCache.value(cacheKey);
|
||||||
if(!cacheVal.isNull())
|
if(!cacheVal.isNull())
|
||||||
return cacheVal;
|
return cacheVal;
|
||||||
@ -1633,12 +1639,14 @@ MakefileGenerator::replaceExtraCompilerVariables(const QString &orig_var, const
|
|||||||
|
|
||||||
if(!val.isEmpty()) {
|
if(!val.isEmpty()) {
|
||||||
QString fullVal;
|
QString fullVal;
|
||||||
if(filePath) {
|
if (filePath && forShell != NoShell) {
|
||||||
for(int i = 0; i < val.size(); ++i) {
|
for(int i = 0; i < val.size(); ++i) {
|
||||||
const QString file = Option::fixPathToTargetOS(unescapeFilePath(val.at(i)), false);
|
|
||||||
if(!fullVal.isEmpty())
|
if(!fullVal.isEmpty())
|
||||||
fullVal += " ";
|
fullVal += " ";
|
||||||
fullVal += escapeFilePath(file);
|
if (forShell == LocalShell)
|
||||||
|
fullVal += IoUtils::shellQuote(Option::fixPathToLocalOS(unescapeFilePath(val.at(i)), false));
|
||||||
|
else
|
||||||
|
fullVal += escapeFilePath(Option::fixPathToTargetOS(unescapeFilePath(val.at(i)), false));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fullVal = val.join(' ');
|
fullVal = val.join(' ');
|
||||||
@ -1705,7 +1713,7 @@ MakefileGenerator::verifyExtraCompiler(const ProString &comp, const QString &fil
|
|||||||
QString in = fileFixify(Option::fixPathToTargetOS(inpf, false));
|
QString in = fileFixify(Option::fixPathToTargetOS(inpf, false));
|
||||||
if(in == file) {
|
if(in == file) {
|
||||||
bool pass = project->test(verify.toKey(),
|
bool pass = project->test(verify.toKey(),
|
||||||
QList<ProStringList>() << ProStringList(replaceExtraCompilerVariables(tmp_out.toQString(), inpf, QString())) <<
|
QList<ProStringList>() << ProStringList(replaceExtraCompilerVariables(tmp_out.toQString(), inpf, QString(), NoShell)) <<
|
||||||
ProStringList(file));
|
ProStringList(file));
|
||||||
if(invert)
|
if(invert)
|
||||||
pass = !pass;
|
pass = !pass;
|
||||||
@ -1723,7 +1731,7 @@ MakefileGenerator::verifyExtraCompiler(const ProString &comp, const QString &fil
|
|||||||
return false;
|
return false;
|
||||||
const QString tmp_cmd = project->values(ProKey(comp + ".commands")).join(' ');
|
const QString tmp_cmd = project->values(ProKey(comp + ".commands")).join(' ');
|
||||||
if (config.indexOf("combine") != -1) {
|
if (config.indexOf("combine") != -1) {
|
||||||
QString cmd = replaceExtraCompilerVariables(tmp_cmd, QString(), tmp_out);
|
QString cmd = replaceExtraCompilerVariables(tmp_cmd, QString(), tmp_out, LocalShell);
|
||||||
if(system(cmd.toLatin1().constData()))
|
if(system(cmd.toLatin1().constData()))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -1736,8 +1744,8 @@ MakefileGenerator::verifyExtraCompiler(const ProString &comp, const QString &fil
|
|||||||
QString inpf = (*input).toQString();
|
QString inpf = (*input).toQString();
|
||||||
QString in = fileFixify(Option::fixPathToTargetOS(inpf, false));
|
QString in = fileFixify(Option::fixPathToTargetOS(inpf, false));
|
||||||
if(in == file) {
|
if(in == file) {
|
||||||
QString out = replaceExtraCompilerVariables(tmp_out, inpf, QString());
|
QString out = replaceExtraCompilerVariables(tmp_out, inpf, QString(), NoShell);
|
||||||
QString cmd = replaceExtraCompilerVariables(tmp_cmd, in, out);
|
QString cmd = replaceExtraCompilerVariables(tmp_cmd, in, out, LocalShell);
|
||||||
if(system(cmd.toLatin1().constData()))
|
if(system(cmd.toLatin1().constData()))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
@ -1814,10 +1822,12 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
if (config.indexOf("combine") != -1) {
|
if (config.indexOf("combine") != -1) {
|
||||||
// compilers with a combined input only have one output
|
// compilers with a combined input only have one output
|
||||||
QString input = project->first(ProKey(*it + ".output")).toQString();
|
QString input = project->first(ProKey(*it + ".output")).toQString();
|
||||||
t << " " << escapeDependencyPath(Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_out, input, QString())));
|
t << ' ' << escapeDependencyPath(Option::fixPathToTargetOS(
|
||||||
|
replaceExtraCompilerVariables(tmp_out, input, QString(), NoShell)));
|
||||||
} else {
|
} else {
|
||||||
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
|
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
|
||||||
t << " " << escapeDependencyPath(Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_out, (*input).toQString(), QString())));
|
t << ' ' << escapeDependencyPath(Option::fixPathToTargetOS(
|
||||||
|
replaceExtraCompilerVariables(tmp_out, (*input).toQString(), QString(), NoShell)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t << endl;
|
t << endl;
|
||||||
@ -1849,7 +1859,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
|
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
|
||||||
QString tinp = (*input).toQString();
|
QString tinp = (*input).toQString();
|
||||||
cleans.append(" " + Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_clean, tinp,
|
cleans.append(" " + Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_clean, tinp,
|
||||||
replaceExtraCompilerVariables(tmp_out, tinp, QString()))));
|
replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell), TargetShell)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QString files, file;
|
QString files, file;
|
||||||
@ -1857,7 +1867,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
for(int input = 0; input < tmp_inputs.size(); ++input) {
|
for(int input = 0; input < tmp_inputs.size(); ++input) {
|
||||||
QString tinp = tmp_inputs.at(input).toQString();
|
QString tinp = tmp_inputs.at(input).toQString();
|
||||||
file = " " + replaceExtraCompilerVariables(tmp_clean, tinp,
|
file = " " + replaceExtraCompilerVariables(tmp_clean, tinp,
|
||||||
replaceExtraCompilerVariables(tmp_out, tinp, QString()));
|
replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell), TargetShell);
|
||||||
if(del_statement.length() + files.length() +
|
if(del_statement.length() + files.length() +
|
||||||
qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) {
|
qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) {
|
||||||
cleans.append(files);
|
cleans.append(files);
|
||||||
@ -1875,7 +1885,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
|
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
|
||||||
QString tinp = (*input).toQString();
|
QString tinp = (*input).toQString();
|
||||||
t << "\n\t" << replaceExtraCompilerVariables(tmp_clean_cmds, tinp,
|
t << "\n\t" << replaceExtraCompilerVariables(tmp_clean_cmds, tinp,
|
||||||
replaceExtraCompilerVariables(tmp_out, tinp, QString()));
|
replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell), TargetShell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1897,7 +1907,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
inputs += Option::fixPathToTargetOS(inpf, false);
|
inputs += Option::fixPathToTargetOS(inpf, false);
|
||||||
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
|
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
|
||||||
char buff[256];
|
char buff[256];
|
||||||
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out);
|
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell);
|
||||||
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
|
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
|
||||||
if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
|
if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
|
||||||
QString indeps;
|
QString indeps;
|
||||||
@ -1959,8 +1969,8 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
if (inputs.isEmpty())
|
if (inputs.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QString out = replaceExtraCompilerVariables(tmp_out, QString(), QString());
|
QString out = replaceExtraCompilerVariables(tmp_out, QString(), QString(), NoShell);
|
||||||
QString cmd = replaceExtraCompilerVariables(tmp_cmd, escapeFilePaths(inputs), QStringList() << out);
|
QString cmd = replaceExtraCompilerVariables(tmp_cmd, inputs, QStringList() << out, TargetShell);
|
||||||
t << escapeDependencyPath(Option::fixPathToTargetOS(out)) << ":";
|
t << escapeDependencyPath(Option::fixPathToTargetOS(out)) << ":";
|
||||||
// compiler.CONFIG+=explicit_dependencies means that ONLY compiler.depends gets to cause Makefile dependencies
|
// compiler.CONFIG+=explicit_dependencies means that ONLY compiler.depends gets to cause Makefile dependencies
|
||||||
if (config.indexOf("explicit_dependencies") != -1) {
|
if (config.indexOf("explicit_dependencies") != -1) {
|
||||||
@ -1976,19 +1986,19 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
|||||||
QString in = Option::fixPathToTargetOS(inpf, false);
|
QString in = Option::fixPathToTargetOS(inpf, false);
|
||||||
QStringList deps = findDependencies(inpf);
|
QStringList deps = findDependencies(inpf);
|
||||||
deps += escapeDependencyPath(in);
|
deps += escapeDependencyPath(in);
|
||||||
QString out = unescapeFilePath(Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_out, inpf, QString())));
|
QString out = Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_out, inpf, QString(), NoShell));
|
||||||
if(!tmp_dep.isEmpty()) {
|
if(!tmp_dep.isEmpty()) {
|
||||||
QStringList pre_deps = fileFixify(tmp_dep, Option::output_dir, Option::output_dir);
|
QStringList pre_deps = fileFixify(tmp_dep, Option::output_dir, Option::output_dir);
|
||||||
for(int i = 0; i < pre_deps.size(); ++i)
|
for(int i = 0; i < pre_deps.size(); ++i)
|
||||||
deps += replaceExtraCompilerVariables(pre_deps.at(i), inpf, out);
|
deps << replaceExtraCompilerVariables(pre_deps.at(i), inpf, out, NoShell);
|
||||||
}
|
}
|
||||||
QString cmd = replaceExtraCompilerVariables(tmp_cmd, inpf, out);
|
QString cmd = replaceExtraCompilerVariables(tmp_cmd, inpf, out, LocalShell);
|
||||||
// NOTE: The var -> QMAKE_COMP_var replace feature is unsupported, do not use!
|
// NOTE: The var -> QMAKE_COMP_var replace feature is unsupported, do not use!
|
||||||
for (ProStringList::ConstIterator it3 = vars.constBegin(); it3 != vars.constEnd(); ++it3)
|
for (ProStringList::ConstIterator it3 = vars.constBegin(); it3 != vars.constEnd(); ++it3)
|
||||||
cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
|
cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
|
||||||
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
|
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
|
||||||
char buff[256];
|
char buff[256];
|
||||||
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, out);
|
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, out, LocalShell);
|
||||||
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
|
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
|
||||||
if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
|
if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
|
||||||
QString indeps;
|
QString indeps;
|
||||||
@ -2982,8 +2992,8 @@ MakefileGenerator::findFileForDep(const QMakeLocalFileName &dep, const QMakeLoca
|
|||||||
for (ProStringList::ConstIterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
|
for (ProStringList::ConstIterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
|
||||||
const ProStringList &inputs = project->values((*it2).toKey());
|
const ProStringList &inputs = project->values((*it2).toKey());
|
||||||
for (ProStringList::ConstIterator input = inputs.begin(); input != inputs.end(); ++input) {
|
for (ProStringList::ConstIterator input = inputs.begin(); input != inputs.end(); ++input) {
|
||||||
QString out = Option::fixPathToTargetOS(unescapeFilePath(
|
QString out = Option::fixPathToTargetOS(
|
||||||
replaceExtraCompilerVariables(tmp_out.toQString(), (*input).toQString(), QString())));
|
replaceExtraCompilerVariables(tmp_out.toQString(), (*input).toQString(), QString(), NoShell));
|
||||||
if (out == dep.real() || out.section(Option::dir_sep, -1) == dep_basename) {
|
if (out == dep.real() || out.section(Option::dir_sep, -1) == dep_basename) {
|
||||||
ret = QMakeLocalFileName(fileFixify(out, qmake_getpwd(), Option::output_dir));
|
ret = QMakeLocalFileName(fileFixify(out, qmake_getpwd(), Option::output_dir));
|
||||||
goto found_dep_from_heuristic;
|
goto found_dep_from_heuristic;
|
||||||
|
@ -52,20 +52,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
#define QT_PCLOSE pclose
|
#define QT_PCLOSE pclose
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ReplaceExtraCompilerCacheKey
|
|
||||||
{
|
|
||||||
mutable uint hash;
|
|
||||||
QString var, in, out, pwd;
|
|
||||||
ReplaceExtraCompilerCacheKey(const QString &v, const QStringList &i, const QStringList &o);
|
|
||||||
bool operator==(const ReplaceExtraCompilerCacheKey &f) const;
|
|
||||||
inline uint hashCode() const {
|
|
||||||
if(!hash)
|
|
||||||
hash = qHash(var) ^ qHash(in) ^ qHash(out) /*^ qHash(pwd)*/;
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
inline uint qHash(const ReplaceExtraCompilerCacheKey &f) { return f.hashCode(); }
|
|
||||||
|
|
||||||
struct ReplaceExtraCompilerCacheKey;
|
struct ReplaceExtraCompilerCacheKey;
|
||||||
|
|
||||||
class MakefileGenerator : protected QMakeSourceFileInfo
|
class MakefileGenerator : protected QMakeSourceFileInfo
|
||||||
@ -81,6 +67,10 @@ class MakefileGenerator : protected QMakeSourceFileInfo
|
|||||||
mutable QHash<QString, QStringList> dependsCache;
|
mutable QHash<QString, QStringList> dependsCache;
|
||||||
mutable QHash<ReplaceExtraCompilerCacheKey, QString> extraCompilerVariablesCache;
|
mutable QHash<ReplaceExtraCompilerCacheKey, QString> extraCompilerVariablesCache;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// We can't make it visible to VCFilter in VS2008 except by making it public or directly friending it.
|
||||||
|
enum ReplaceFor { NoShell, LocalShell, TargetShell };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum TARG_MODE { TARG_UNIX_MODE, TARG_MAC_MODE, TARG_WIN_MODE } target_mode;
|
enum TARG_MODE { TARG_UNIX_MODE, TARG_MAC_MODE, TARG_WIN_MODE } target_mode;
|
||||||
|
|
||||||
@ -132,9 +122,9 @@ protected:
|
|||||||
|
|
||||||
//extra compiler interface
|
//extra compiler interface
|
||||||
bool verifyExtraCompiler(const ProString &c, const QString &f);
|
bool verifyExtraCompiler(const ProString &c, const QString &f);
|
||||||
virtual QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &);
|
virtual QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &, ReplaceFor forShell);
|
||||||
inline QString replaceExtraCompilerVariables(const QString &val, const QString &in, const QString &out)
|
inline QString replaceExtraCompilerVariables(const QString &val, const QString &in, const QString &out, ReplaceFor forShell)
|
||||||
{ return replaceExtraCompilerVariables(val, QStringList(in), QStringList(out)); }
|
{ return replaceExtraCompilerVariables(val, QStringList(in), QStringList(out), forShell); }
|
||||||
|
|
||||||
//interface to the source file info
|
//interface to the source file info
|
||||||
QMakeLocalFileName fixPathForFile(const QMakeLocalFileName &, bool);
|
QMakeLocalFileName fixPathForFile(const QMakeLocalFileName &, bool);
|
||||||
@ -281,6 +271,21 @@ inline bool MakefileGenerator::findLibraries()
|
|||||||
inline MakefileGenerator::~MakefileGenerator()
|
inline MakefileGenerator::~MakefileGenerator()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
struct ReplaceExtraCompilerCacheKey
|
||||||
|
{
|
||||||
|
mutable uint hash;
|
||||||
|
QString var, in, out, pwd;
|
||||||
|
MakefileGenerator::ReplaceFor forShell;
|
||||||
|
ReplaceExtraCompilerCacheKey(const QString &v, const QStringList &i, const QStringList &o, MakefileGenerator::ReplaceFor s);
|
||||||
|
bool operator==(const ReplaceExtraCompilerCacheKey &f) const;
|
||||||
|
inline uint hashCode() const {
|
||||||
|
if (!hash)
|
||||||
|
hash = (uint)forShell ^ qHash(var) ^ qHash(in) ^ qHash(out) /*^ qHash(pwd)*/;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
inline uint qHash(const ReplaceExtraCompilerCacheKey &f) { return f.hashCode(); }
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // MAKEFILE_H
|
#endif // MAKEFILE_H
|
||||||
|
@ -308,7 +308,7 @@ ProjectGenerator::init()
|
|||||||
for (ProStringList::ConstIterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
|
for (ProStringList::ConstIterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
|
||||||
ProStringList &inputs = project->values((*it2).toKey());
|
ProStringList &inputs = project->values((*it2).toKey());
|
||||||
for (ProStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
|
for (ProStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
|
||||||
QString path = replaceExtraCompilerVariables(tmp_out, (*input).toQString(), QString());
|
QString path = replaceExtraCompilerVariables(tmp_out, (*input).toQString(), QString(), NoShell);
|
||||||
path = fixPathToQmake(path).section('/', -1);
|
path = fixPathToQmake(path).section('/', -1);
|
||||||
for(int i = 0; i < var_out.size(); ++i) {
|
for(int i = 0; i < var_out.size(); ++i) {
|
||||||
ProString v = var_out.at(i);
|
ProString v = var_out.at(i);
|
||||||
|
@ -2295,9 +2295,8 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
|
|||||||
QString cmd, cmd_name, out;
|
QString cmd, cmd_name, out;
|
||||||
QStringList deps, inputs;
|
QStringList deps, inputs;
|
||||||
// Variabel replacement of output name
|
// Variabel replacement of output name
|
||||||
out = Option::fixPathToTargetOS(
|
out = Option::fixPathToTargetOS(Project->replaceExtraCompilerVariables(
|
||||||
Project->replaceExtraCompilerVariables(tmp_out, inFile, QString()),
|
tmp_out, inFile, QString(), MakefileGenerator::NoShell), false);
|
||||||
false);
|
|
||||||
|
|
||||||
// If file has built-in compiler, we've swapped the input and output of
|
// 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
|
// 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()) {
|
if (!tmp_dep_cmd.isEmpty()) {
|
||||||
// Execute dependency command, and add every line as a dep
|
// Execute dependency command, and add every line as a dep
|
||||||
char buff[256];
|
char buff[256];
|
||||||
QString dep_cmd = Project->replaceExtraCompilerVariables(tmp_dep_cmd,
|
QString dep_cmd = Project->replaceExtraCompilerVariables(
|
||||||
Option::fixPathToLocalOS(inFile, true, false),
|
tmp_dep_cmd, inFile, out, MakefileGenerator::LocalShell);
|
||||||
out);
|
|
||||||
if(Project->canExecute(dep_cmd)) {
|
if(Project->canExecute(dep_cmd)) {
|
||||||
dep_cmd.prepend(QLatin1String("cd ")
|
dep_cmd.prepend(QLatin1String("cd ")
|
||||||
+ Project->escapeFilePath(Option::fixPathToLocalOS(Option::output_dir, false))
|
+ Project->escapeFilePath(Option::fixPathToLocalOS(Option::output_dir, false))
|
||||||
@ -2347,7 +2345,8 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < deps.count(); ++i)
|
for (int i = 0; i < deps.count(); ++i)
|
||||||
deps[i] = Option::fixPathToTargetOS(
|
deps[i] = Option::fixPathToTargetOS(
|
||||||
Project->replaceExtraCompilerVariables(deps.at(i), inFile, out),
|
Project->replaceExtraCompilerVariables(
|
||||||
|
deps.at(i), inFile, out, MakefileGenerator::NoShell),
|
||||||
false).trimmed();
|
false).trimmed();
|
||||||
// Command for file
|
// Command for file
|
||||||
if (combined) {
|
if (combined) {
|
||||||
@ -2367,16 +2366,19 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
|
|||||||
// ### join gives path issues with directories containing spaces!
|
// ### join gives path issues with directories containing spaces!
|
||||||
cmd = Project->replaceExtraCompilerVariables(tmp_cmd,
|
cmd = Project->replaceExtraCompilerVariables(tmp_cmd,
|
||||||
inputs.join(' '),
|
inputs.join(' '),
|
||||||
out);
|
out,
|
||||||
|
MakefileGenerator::TargetShell);
|
||||||
} else {
|
} else {
|
||||||
deps.prepend(inFile); // input file itself too..
|
deps.prepend(inFile); // input file itself too..
|
||||||
cmd = Project->replaceExtraCompilerVariables(tmp_cmd,
|
cmd = Project->replaceExtraCompilerVariables(tmp_cmd,
|
||||||
inFile,
|
inFile,
|
||||||
out);
|
out,
|
||||||
|
MakefileGenerator::TargetShell);
|
||||||
}
|
}
|
||||||
// Name for command
|
// Name for command
|
||||||
if (!tmp_cmd_name.isEmpty()) {
|
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 {
|
} else {
|
||||||
int space = cmd.indexOf(' ');
|
int space = cmd.indexOf(' ');
|
||||||
if (space != -1)
|
if (space != -1)
|
||||||
|
@ -893,7 +893,7 @@ void VcprojGenerator::init()
|
|||||||
extraCompilerSources[file] += quc.toQString();
|
extraCompilerSources[file] += quc.toQString();
|
||||||
} else {
|
} else {
|
||||||
QString out = Option::fixPathToTargetOS(replaceExtraCompilerVariables(
|
QString out = Option::fixPathToTargetOS(replaceExtraCompilerVariables(
|
||||||
compiler_out, file, QString()), false);
|
compiler_out, file, QString(), NoShell), false);
|
||||||
extraCompilerSources[out] += quc.toQString();
|
extraCompilerSources[out] += quc.toQString();
|
||||||
extraCompilerOutputs[out] = QStringList(file); // Can only have one
|
extraCompilerOutputs[out] = QStringList(file); // Can only have one
|
||||||
}
|
}
|
||||||
@ -1532,7 +1532,8 @@ void VcprojGenerator::initResourceFiles()
|
|||||||
if(!qrc_files.isEmpty()) {
|
if(!qrc_files.isEmpty()) {
|
||||||
for (int i = 0; i < qrc_files.count(); ++i) {
|
for (int i = 0; i < qrc_files.count(); ++i) {
|
||||||
char buff[256];
|
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);
|
dep_cmd = Option::fixPathToLocalOS(dep_cmd, true, false);
|
||||||
if(canExecute(dep_cmd)) {
|
if(canExecute(dep_cmd)) {
|
||||||
@ -1605,16 +1606,16 @@ void VcprojGenerator::initExtraCompilerOutputs()
|
|||||||
QString tmp_out = project->first(ProKey(*it + ".output")).toQString();
|
QString tmp_out = project->first(ProKey(*it + ".output")).toQString();
|
||||||
if (project->values(ProKey(*it + ".CONFIG")).indexOf("combine") != -1) {
|
if (project->values(ProKey(*it + ".CONFIG")).indexOf("combine") != -1) {
|
||||||
// Combined output, only one file result
|
// Combined output, only one file result
|
||||||
extraCompile.addFile(
|
extraCompile.addFile(Option::fixPathToTargetOS(
|
||||||
Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_out, QString(), QString()), false));
|
replaceExtraCompilerVariables(tmp_out, QString(), QString(), NoShell), false));
|
||||||
} else {
|
} else {
|
||||||
// One output file per input
|
// One output file per input
|
||||||
const ProStringList &tmp_in = project->values(project->first(ProKey(*it + ".input")).toKey());
|
const ProStringList &tmp_in = project->values(project->first(ProKey(*it + ".input")).toKey());
|
||||||
for (int i = 0; i < tmp_in.count(); ++i) {
|
for (int i = 0; i < tmp_in.count(); ++i) {
|
||||||
const QString &filename = tmp_in.at(i).toQString();
|
const QString &filename = tmp_in.at(i).toQString();
|
||||||
if (extraCompilerSources.contains(filename))
|
if (extraCompilerSources.contains(filename))
|
||||||
extraCompile.addFile(
|
extraCompile.addFile(Option::fixPathToTargetOS(
|
||||||
Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, tmp_out, QString()), false));
|
replaceExtraCompilerVariables(filename, tmp_out, QString(), NoShell), false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1629,8 +1630,8 @@ void VcprojGenerator::initExtraCompilerOutputs()
|
|||||||
for (int i = 0; i < tmp_in.count(); ++i) {
|
for (int i = 0; i < tmp_in.count(); ++i) {
|
||||||
const QString &filename = tmp_in.at(i).toQString();
|
const QString &filename = tmp_in.at(i).toQString();
|
||||||
if (extraCompilerSources.contains(filename))
|
if (extraCompilerSources.contains(filename))
|
||||||
extraCompile.addFile(
|
extraCompile.addFile(Option::fixPathToTargetOS(
|
||||||
Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, QString(), QString()), false));
|
replaceExtraCompilerVariables(filename, QString(), QString(), NoShell), false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1650,9 +1651,10 @@ VCProjectWriter *VcprojGenerator::createProjectWriter()
|
|||||||
return new VCProjectWriter;
|
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");
|
ProStringList &defines = project->values("VCPROJ_MAKEFILE_DEFINES");
|
||||||
if(defines.isEmpty())
|
if(defines.isEmpty())
|
||||||
|
@ -76,9 +76,10 @@ protected:
|
|||||||
virtual VCProjectWriter *createProjectWriter();
|
virtual VCProjectWriter *createProjectWriter();
|
||||||
virtual bool doDepends() const { return false; } //never necesary
|
virtual bool doDepends() const { return false; } //never necesary
|
||||||
virtual void processSources() { filterIncludedFiles("SOURCES"); filterIncludedFiles("GENERATED_SOURCES"); }
|
virtual void processSources() { filterIncludedFiles("SOURCES"); filterIncludedFiles("GENERATED_SOURCES"); }
|
||||||
virtual QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &);
|
using MakefileGenerator::ReplaceFor;
|
||||||
inline QString replaceExtraCompilerVariables(const QString &val, const QString &in, const QString &out)
|
virtual QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &, ReplaceFor);
|
||||||
{ return MakefileGenerator::replaceExtraCompilerVariables(val, in, out); }
|
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 supportsMetaBuild() { return true; }
|
||||||
virtual bool supportsMergedBuilds() { return true; }
|
virtual bool supportsMergedBuilds() { return true; }
|
||||||
virtual bool mergeBuildProject(MakefileGenerator *other);
|
virtual bool mergeBuildProject(MakefileGenerator *other);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user