move .qmake.cache search to Option
this is a one-time operation which depends only on the invocation, so this new home is much more appropriate. Change-Id: I11ef30a8227afed06e58e64e65809dba25e81567 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
This commit is contained in:
parent
bf29a8a27d
commit
059200a44b
@ -163,6 +163,11 @@ int runQMake(int argc, char **argv)
|
|||||||
fn = fn.right(fn.length() - di - 1);
|
fn = fn.right(fn.length() - di - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Option::prepareProject()) {
|
||||||
|
exit_val = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// read project..
|
// read project..
|
||||||
if(!project.read(fn)) {
|
if(!project.read(fn)) {
|
||||||
fprintf(stderr, "Error processing project file: %s\n",
|
fprintf(stderr, "Error processing project file: %s\n",
|
||||||
|
@ -116,6 +116,7 @@ bool Option::mkfile::do_dep_heuristics = true;
|
|||||||
bool Option::mkfile::do_preprocess = false;
|
bool Option::mkfile::do_preprocess = false;
|
||||||
bool Option::mkfile::do_stub_makefile = false;
|
bool Option::mkfile::do_stub_makefile = false;
|
||||||
bool Option::mkfile::do_cache = true;
|
bool Option::mkfile::do_cache = true;
|
||||||
|
QString Option::mkfile::project_build_root;
|
||||||
QString Option::mkfile::cachefile;
|
QString Option::mkfile::cachefile;
|
||||||
QStringList Option::mkfile::project_files;
|
QStringList Option::mkfile::project_files;
|
||||||
QString Option::mkfile::qmakespec_commandline;
|
QString Option::mkfile::qmakespec_commandline;
|
||||||
@ -567,6 +568,34 @@ void Option::applyHostMode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Option::prepareProject()
|
||||||
|
{
|
||||||
|
mkfile::project_build_root.clear();
|
||||||
|
if (mkfile::do_cache) {
|
||||||
|
if (mkfile::cachefile.isEmpty()) { //find it as it has not been specified
|
||||||
|
QDir dir(output_dir);
|
||||||
|
while (!dir.exists(QLatin1String(".qmake.cache")))
|
||||||
|
if (dir.isRoot() || !dir.cdUp())
|
||||||
|
goto no_cache;
|
||||||
|
mkfile::cachefile = dir.filePath(QLatin1String(".qmake.cache"));
|
||||||
|
mkfile::project_build_root = dir.path();
|
||||||
|
} else {
|
||||||
|
QFileInfo fi(mkfile::cachefile);
|
||||||
|
mkfile::cachefile = QDir::cleanPath(fi.absoluteFilePath());
|
||||||
|
mkfile::project_build_root = QDir::cleanPath(fi.absolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mkfile::qmakespec.isEmpty()) {
|
||||||
|
QMakeProject cproj;
|
||||||
|
if (!cproj.read(mkfile::cachefile, QMakeProject::ReadProFile))
|
||||||
|
return false;
|
||||||
|
mkfile::qmakespec = cproj.first(QLatin1String("QMAKESPEC"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
no_cache:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Option::postProcessProject(QMakeProject *project)
|
bool Option::postProcessProject(QMakeProject *project)
|
||||||
{
|
{
|
||||||
Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"];
|
Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"];
|
||||||
|
@ -108,6 +108,7 @@ struct Option
|
|||||||
//both of these must be called..
|
//both of these must be called..
|
||||||
static int init(int argc=0, char **argv=0); //parse cmdline
|
static int init(int argc=0, char **argv=0); //parse cmdline
|
||||||
static void applyHostMode();
|
static void applyHostMode();
|
||||||
|
static bool prepareProject();
|
||||||
static bool postProcessProject(QMakeProject *);
|
static bool postProcessProject(QMakeProject *);
|
||||||
|
|
||||||
enum StringFixFlags {
|
enum StringFixFlags {
|
||||||
@ -201,6 +202,7 @@ struct Option
|
|||||||
static bool do_dep_heuristics;
|
static bool do_dep_heuristics;
|
||||||
static bool do_preprocess;
|
static bool do_preprocess;
|
||||||
static bool do_stub_makefile;
|
static bool do_stub_makefile;
|
||||||
|
static QString project_build_root;
|
||||||
static QString cachefile;
|
static QString cachefile;
|
||||||
static int cachefile_depth;
|
static int cachefile_depth;
|
||||||
static QStringList project_files;
|
static QStringList project_files;
|
||||||
|
@ -1281,35 +1281,9 @@ QMakeProject::read(uchar cmd)
|
|||||||
base_vars["TEMPLATE_PREFIX"] = QStringList(Option::user_template_prefix);
|
base_vars["TEMPLATE_PREFIX"] = QStringList(Option::user_template_prefix);
|
||||||
|
|
||||||
if ((cmd & ReadSetup) && Option::mkfile::do_cache) { // parse the cache
|
if ((cmd & ReadSetup) && Option::mkfile::do_cache) { // parse the cache
|
||||||
int cache_depth = -1;
|
if (Option::output_dir.startsWith(Option::mkfile::project_build_root))
|
||||||
QString qmake_cache = Option::mkfile::cachefile;
|
Option::mkfile::cachefile_depth =
|
||||||
if(qmake_cache.isEmpty()) { //find it as it has not been specified
|
Option::output_dir.mid(Option::mkfile::project_build_root.length()).count('/');
|
||||||
QString dir = Option::output_dir;
|
|
||||||
while(!QFile::exists((qmake_cache = dir + QLatin1String("/.qmake.cache")))) {
|
|
||||||
dir = dir.left(dir.lastIndexOf(QLatin1Char('/')));
|
|
||||||
if(dir.isEmpty() || dir.indexOf(QLatin1Char('/')) == -1) {
|
|
||||||
qmake_cache = "";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(cache_depth == -1)
|
|
||||||
cache_depth = 1;
|
|
||||||
else
|
|
||||||
cache_depth++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
QString abs_cache = QFileInfo(Option::mkfile::cachefile).absoluteDir().path();
|
|
||||||
if(Option::output_dir.startsWith(abs_cache))
|
|
||||||
cache_depth = Option::output_dir.mid(abs_cache.length()).count('/');
|
|
||||||
}
|
|
||||||
if(!qmake_cache.isEmpty()) {
|
|
||||||
QHash<QString, QStringList> cache;
|
|
||||||
if(read(qmake_cache, cache)) {
|
|
||||||
Option::mkfile::cachefile_depth = cache_depth;
|
|
||||||
Option::mkfile::cachefile = qmake_cache;
|
|
||||||
if(Option::mkfile::qmakespec.isEmpty() && !cache["QMAKESPEC"].isEmpty())
|
|
||||||
Option::mkfile::qmakespec = cache["QMAKESPEC"].first();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (cmd & ReadSetup) { // parse mkspec
|
if (cmd & ReadSetup) { // parse mkspec
|
||||||
QString qmakespec = fixEnvVariables(Option::mkfile::qmakespec);
|
QString qmakespec = fixEnvVariables(Option::mkfile::qmakespec);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user