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 <marius.storm-olsen@nokia.com>bb10
parent
6a66fef520
commit
bf984d5f24
|
|
@ -163,6 +163,8 @@ int runQMake(int argc, char **argv)
|
|||
fn = fn.right(fn.length() - di - 1);
|
||||
}
|
||||
|
||||
Option::prepareProject(fn);
|
||||
|
||||
// read project..
|
||||
if(!project.read(fn)) {
|
||||
fprintf(stderr, "Error processing project file: %s\n",
|
||||
|
|
|
|||
|
|
@ -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"];
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ struct Option
|
|||
//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 {
|
||||
|
|
@ -203,6 +204,8 @@ struct Option
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ enum ExpandFunc { E_MEMBER=1, E_FIRST, E_LAST, E_CAT, E_FROMFILE, E_EVAL, E_LIST
|
|||
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;
|
||||
|
|
@ -117,6 +118,7 @@ QHash<QString, ExpandFunc> qmake_expandFunctions()
|
|||
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;
|
||||
}
|
||||
|
|
@ -2493,6 +2495,13 @@ QMakeProject::doProjectExpand(QString func, QList<QStringList> args_list,
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -112,3 +112,4 @@ in = easy "less easy" sca$${LITERAL_HASH}ry crazy$$escape_expand(\\t\\r\\n) $$es
|
|||
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")
|
||||
|
|
|
|||
|
|
@ -250,7 +250,8 @@ void tst_qmake::subdir_via_pro_file_extra_target()
|
|||
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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue