From 059200a44ba7177d0c9ec6bb5e6ee0b7e0c3f017 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 17:05:28 +0100 Subject: 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 --- qmake/option.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'qmake/option.cpp') diff --git a/qmake/option.cpp b/qmake/option.cpp index 431299b46b..306e6b5286 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -116,6 +116,7 @@ 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::project_build_root; QString Option::mkfile::cachefile; QStringList Option::mkfile::project_files; 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) { Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"]; -- cgit v1.2.3 From 08fe1f6871169bf36ee58025da40824547c21b5f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 24 Feb 2012 12:11:51 +0100 Subject: resolve relative spec paths already on the command line this is way more predictable than resolving it later. Change-Id: I0ce27977b795bde9235e1d51d6f2d0d917f2398c Reviewed-by: Joerg Bornemann --- qmake/option.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'qmake/option.cpp') diff --git a/qmake/option.cpp b/qmake/option.cpp index 306e6b5286..0c649fdd77 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -147,6 +147,14 @@ static QString detectProjectFile(const QString &path) return ret; } +static QString cleanSpec(const QString &spec) +{ + QString ret = QDir::cleanPath(spec); + if (ret.contains('/')) + ret = QDir::cleanPath(QFileInfo(ret).absoluteFilePath()); + return ret; +} + QString project_builtin_regx(); bool usage(const char *a0) { @@ -315,7 +323,7 @@ Option::parseCommandLine(int argc, char **argv, int skip) } else if(opt == "cache") { Option::mkfile::cachefile = argv[++x]; } else if(opt == "platform" || opt == "spec") { - Option::mkfile::qmakespec = argv[++x]; + Option::mkfile::qmakespec = cleanSpec(argv[++x]); Option::mkfile::qmakespec_commandline = argv[x]; } else { fprintf(stderr, "***Unknown option -%s\n", opt.toLatin1().constData()); -- cgit v1.2.3