diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-09-06 21:18:27 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-09-07 19:59:09 +0200 |
commit | f3d437870e13135fc79d2baadff81c4d9a2e2ad9 (patch) | |
tree | ae7f1619eb9a9dda12e936b1e6e049d4ad2fc73d /src/shared | |
parent | 811f3627d9015b1fd00219a23db9f84f5f95aeb0 (diff) | |
download | qt-creator-f3d437870e13135fc79d2baadff81c4d9a2e2ad9.tar.gz |
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>
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/proparser/qmakebuiltins.cpp | 12 | ||||
-rw-r--r-- | src/shared/proparser/qmakeglobals.cpp | 12 | ||||
-rw-r--r-- | src/shared/proparser/qmakeglobals.h | 1 |
3 files changed, 15 insertions, 10 deletions
diff --git a/src/shared/proparser/qmakebuiltins.cpp b/src/shared/proparser/qmakebuiltins.cpp index 568cbbc35a..2b7b1cd434 100644 --- a/src/shared/proparser/qmakebuiltins.cpp +++ b/src/shared/proparser/qmakebuiltins.cpp @@ -945,17 +945,9 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( if (args.count() != 1) { evalError(fL1S("shadowed(path) requires one argument.")); } else { - QString val = resolvePath(args.at(0).toQString(m_tmp1)); - QString rstr; - 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 { + QString rstr = m_option->shadowedPath(resolvePath(args.at(0).toQString(m_tmp1))); + if (rstr.isEmpty()) break; - } ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0))); } break; diff --git a/src/shared/proparser/qmakeglobals.cpp b/src/shared/proparser/qmakeglobals.cpp index 104f963d7a..3a94865529 100644 --- a/src/shared/proparser/qmakeglobals.cpp +++ b/src/shared/proparser/qmakeglobals.cpp @@ -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 { #ifdef PROEVALUATOR_SETENV diff --git a/src/shared/proparser/qmakeglobals.h b/src/shared/proparser/qmakeglobals.h index 3e6bad5bab..94c366be6d 100644 --- a/src/shared/proparser/qmakeglobals.h +++ b/src/shared/proparser/qmakeglobals.h @@ -133,6 +133,7 @@ public: #endif QString expandEnvVars(const QString &str) const; + QString shadowedPath(const QString &fileName) const; private: QString getEnv(const QString &) const; |