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 <marius.storm-olsen@nokia.com>
fn = fn.right(fn.length() - di - 1);
}
+ Option::prepareProject(fn);
+
// read project..
if(!project.read(fn)) {
fprintf(stderr, "Error processing project file: %s\n",
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;
}
}
+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"];
//both of these must be called..
static int init(int argc=0, char **argv=0); //parse cmdline
static void applyHostMode();
+ static void prepareProject(const QString &pfile);
static bool postProcessProject(QMakeProject *);
enum StringFixFlags {
static bool do_dep_heuristics;
static bool do_preprocess;
static bool do_stub_makefile;
+ static QString source_root;
+ static QString build_root;
static QString cachefile;
static int cachefile_depth;
static QStringList project_files;
E_SPRINTF, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION,
E_FIND, E_SYSTEM, E_UNIQUE, E_QUOTE, E_ESCAPE_EXPAND,
E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE, E_REPLACE,
- E_SIZE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS };
+ E_SIZE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS,
+ E_SHADOWED };
QHash<QString, ExpandFunc> qmake_expandFunctions()
{
static QHash<QString, ExpandFunc> *qmake_expand_functions = 0;
qmake_expand_functions->insert("sort_depends", E_SORT_DEPENDS);
qmake_expand_functions->insert("resolve_depends", E_RESOLVE_DEPENDS);
qmake_expand_functions->insert("enumerate_vars", E_ENUMERATE_VARS);
+ qmake_expand_functions->insert("shadowed", E_SHADOWED);
}
return *qmake_expand_functions;
}
case E_ENUMERATE_VARS:
ret += place.keys();
break;
+ case E_SHADOWED: {
+ QString val = QDir::cleanPath(QFileInfo(args.at(0)).absoluteFilePath());
+ if (Option::mkfile::source_root.isEmpty())
+ ret += val;
+ else if (val.startsWith(Option::mkfile::source_root))
+ ret += Option::mkfile::build_root + val.mid(Option::mkfile::source_root.length());
+ break; }
default: {
fprintf(stderr, "%s:%d: Unknown replace function: %s\n",
parser.file.toLatin1().constData(), parser.line_no,
out = "easy \"less easy\" sca\$\${LITERAL_HASH}ry crazy\$\$escape_expand(\\\\t\\\\r\\\\n) \$\$escape_expand(\\\\t)shit \\\'no\\\"way\\\\here"
testReplace($$val_escape(in), $$out, "val_escape")
+testReplace($$shadowed($$PWD/something), $$OUT_PWD/something, "shadowed")
void tst_qmake::functions()
{
QString workDir = base_path + "/testdata/functions";
- QVERIFY( test_compiler.qmake( workDir, "functions" ));
+ QString buildDir = base_path + "/testdata/functions_build";
+ QVERIFY( test_compiler.qmake( workDir, "functions", buildDir ));
}
void tst_qmake::operators()