From bf984d5f24741a52a70024f3f43432307281f0ae Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 9 May 2012 15:29:25 +0200 Subject: add $$shadowed() function return the build directory corresponding to a given source directory. this is the identity function if not shadow-building. if input lies outside the source directory, return empty value. Change-Id: I2d2a6b1112bd19989fe29cfe19a12d39a0d208c1 Reviewed-by: Marius Storm-Olsen --- qmake/option.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'qmake/option.cpp') diff --git a/qmake/option.cpp b/qmake/option.cpp index 836cc3f492..a22d184456 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -115,6 +115,8 @@ bool Option::mkfile::do_dep_heuristics = true; bool Option::mkfile::do_preprocess = false; bool Option::mkfile::do_stub_makefile = false; bool Option::mkfile::do_cache = true; +QString Option::mkfile::source_root; +QString Option::mkfile::build_root; QString Option::mkfile::cachefile; QStringList Option::mkfile::project_files; QString Option::mkfile::qmakespec_commandline; @@ -594,6 +596,29 @@ void Option::applyHostMode() } } +void Option::prepareProject(const QString &pfile) +{ + QString srcpath = (pfile != "-") + ? QDir::cleanPath(QFileInfo(pfile).absolutePath()) : qmake_getpwd(); + if (srcpath != output_dir) { + if (!srcpath.endsWith(QLatin1Char('/'))) + srcpath += QLatin1Char('/'); + QString dstpath = output_dir; + if (!dstpath.endsWith(QLatin1Char('/'))) + dstpath += QLatin1Char('/'); + int srcLen = srcpath.length(); + int dstLen = dstpath.length(); + int lastSl = 0; + while (++lastSl, srcpath.at(--srcLen) == dstpath.at(--dstLen)) + if (srcpath.at(srcLen) == QLatin1Char('/')) + lastSl = 1; + mkfile::source_root = srcpath.left(srcLen + lastSl); + mkfile::build_root = dstpath.left(dstLen + lastSl); + } else { + mkfile::source_root.clear(); + } +} + bool Option::postProcessProject(QMakeProject *project) { Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"]; -- cgit v1.2.3