put core implementation of $$shadowed() into QMakeGlobals

to make it available to a wider audience

Change-Id: I7a706f8d31de97d8214ba5ea745e19d1dbfda1bc
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
Oswald Buddenhagen
2012-09-06 21:18:27 +02:00
parent 811f3627d9
commit f3d437870e
3 changed files with 15 additions and 10 deletions

View File

@@ -945,17 +945,9 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
if (args.count() != 1) { if (args.count() != 1) {
evalError(fL1S("shadowed(path) requires one argument.")); evalError(fL1S("shadowed(path) requires one argument."));
} else { } else {
QString val = resolvePath(args.at(0).toQString(m_tmp1)); QString rstr = m_option->shadowedPath(resolvePath(args.at(0).toQString(m_tmp1)));
QString rstr; if (rstr.isEmpty())
if (m_option->source_root.isEmpty()) {
rstr = val;
} else if (val.startsWith(m_option->source_root)
&& (val.length() == m_option->source_root.length()
|| val.at(m_option->source_root.length()) == QLatin1Char('/'))) {
rstr = m_option->build_root + val.mid(m_option->source_root.length());
} else {
break; break;
}
ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0))); ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0)));
} }
break; break;

View File

@@ -248,6 +248,18 @@ void QMakeGlobals::setDirectories(const QString &input_dir, const QString &outpu
} }
} }
QString QMakeGlobals::shadowedPath(const QString &fileName) const
{
if (source_root.isEmpty())
return fileName;
if (fileName.startsWith(source_root)
&& (fileName.length() == source_root.length()
|| fileName.at(source_root.length()) == QLatin1Char('/'))) {
return build_root + fileName.mid(source_root.length());
}
return QString();
}
QString QMakeGlobals::getEnv(const QString &var) const QString QMakeGlobals::getEnv(const QString &var) const
{ {
#ifdef PROEVALUATOR_SETENV #ifdef PROEVALUATOR_SETENV

View File

@@ -133,6 +133,7 @@ public:
#endif #endif
QString expandEnvVars(const QString &str) const; QString expandEnvVars(const QString &str) const;
QString shadowedPath(const QString &fileName) const;
private: private:
QString getEnv(const QString &) const; QString getEnv(const QString &) const;