diff options
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/generators/makefile.cpp | 9 | ||||
-rw-r--r-- | qmake/generators/projectgenerator.cpp | 12 | ||||
-rw-r--r-- | qmake/generators/win32/winmakefile.cpp | 6 | ||||
-rw-r--r-- | qmake/main.cpp | 5 | ||||
-rw-r--r-- | qmake/option.cpp | 39 | ||||
-rw-r--r-- | qmake/option.h | 2 | ||||
-rw-r--r-- | qmake/project.cpp | 124 | ||||
-rw-r--r-- | qmake/project.h | 1 | ||||
-rw-r--r-- | qmake/qmake.pri | 2 |
9 files changed, 104 insertions, 96 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index dd098596e9..59a615e63a 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2508,10 +2508,10 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT if(!in_directory.isEmpty()) { t << mkdir_p_asstring(out_directory) << out_directory_cdin - << "$(QMAKE) " << escapeFilePath(in) << buildArgs(in_directory) << " -o " << out + << "$(QMAKE) " << in << buildArgs(in_directory) << " -o " << out << in_directory_cdout << endl; } else { - t << "$(QMAKE) " << escapeFilePath(in) << buildArgs(in_directory) << " -o " << out << endl; + t << "$(QMAKE) " << in << buildArgs(in_directory) << " -o " << out << endl; } t << subtarget->target << "-qmake_all: "; if(project->isEmpty("QMAKE_NOFORCE")) @@ -2520,10 +2520,10 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT if(!in_directory.isEmpty()) { t << mkdir_p_asstring(out_directory) << out_directory_cdin - << "$(QMAKE) " << escapeFilePath(in) << buildArgs(in_directory) << " -o " << out + << "$(QMAKE) " << in << buildArgs(in_directory) << " -o " << out << in_directory_cdout << endl; } else { - t << "$(QMAKE) " << escapeFilePath(in) << buildArgs(in_directory) << " -o " << out << endl; + t << "$(QMAKE) " << in << buildArgs(in_directory) << " -o " << out << endl; } } @@ -3287,6 +3287,7 @@ MakefileGenerator::writePkgConfigFile() } else { pkgConfiglibDir = "-L${libdir}"; pkgConfiglibName = "-l" + lname.left(lname.length()-Option::libtool_ext.length()); + pkgConfiglibName += project->first("TARGET_VERSION_EXT"); } t << pkgConfiglibDir << " " << pkgConfiglibName << " " << endl; diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp index 4d1a310daf..a2eb45ef40 100644 --- a/qmake/generators/projectgenerator.cpp +++ b/qmake/generators/projectgenerator.cpp @@ -85,12 +85,6 @@ ProjectGenerator::init() templ.prepend(Option::user_template_prefix); v["TEMPLATE_ASSIGN"] += templ; - //figure out target - if(Option::output.fileName() == "-") - v["TARGET_ASSIGN"] = QStringList("unknown"); - else - v["TARGET_ASSIGN"] = QStringList(QFileInfo(Option::output).baseName()); - //the scary stuff if(project->first("TEMPLATE_ASSIGN") != "subdirs") { QString builtin_regex = project_builtin_regx(); @@ -360,6 +354,12 @@ ProjectGenerator::writeMakefile(QTextStream &t) t << endl << "# Directories" << "\n" << getWritableVar("SUBDIRS"); } else { + //figure out target + QString ofn = QFileInfo(static_cast<QFile *>(t.device())->fileName()).completeBaseName(); + if (ofn.isEmpty() || ofn == "-") + ofn = "unknown"; + project->variables()["TARGET_ASSIGN"] = QStringList(ofn); + t << getWritableVar("TARGET_ASSIGN") << getWritableVar("CONFIG", false) << getWritableVar("CONFIG_REMOVE", false) diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 5f0828383f..a26be16f78 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -844,6 +844,12 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t) QString dst_pc = pkgConfigFileName(false); if (!dst_pc.isEmpty()) { dst_pc = filePrefixRoot(root, targetdir + dst_pc); + const QString dst_pc_dir = fileInfo(dst_pc).path(); + if (!dst_pc_dir.isEmpty()) { + if (!ret.isEmpty()) + ret += "\n\t"; + ret += mkdir_p_asstring(dst_pc_dir, true); + } if(!ret.isEmpty()) ret += "\n\t"; ret += "-$(INSTALL_FILE) \"" + pkgConfigFileName(true) + "\" \"" + dst_pc + "\""; diff --git a/qmake/main.cpp b/qmake/main.cpp index 38e09f60fd..54cf9f9bdf 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -163,6 +163,11 @@ int runQMake(int argc, char **argv) fn = fn.right(fn.length() - di - 1); } + if (!Option::prepareProject()) { + exit_val = 3; + break; + } + // read project.. if(!project.read(fn)) { fprintf(stderr, "Error processing project file: %s\n", diff --git a/qmake/option.cpp b/qmake/option.cpp index 431299b46b..0c649fdd77 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; @@ -146,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) { @@ -314,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()); @@ -567,6 +576,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"]; diff --git a/qmake/option.h b/qmake/option.h index ee8a1c2403..b8a3b561fa 100644 --- a/qmake/option.h +++ b/qmake/option.h @@ -108,6 +108,7 @@ struct Option //both of these must be called.. static int init(int argc=0, char **argv=0); //parse cmdline static void applyHostMode(); + static bool prepareProject(); static bool postProcessProject(QMakeProject *); enum StringFixFlags { @@ -201,6 +202,7 @@ struct Option static bool do_dep_heuristics; static bool do_preprocess; static bool do_stub_makefile; + static QString project_build_root; static QString cachefile; static int cachefile_depth; static QStringList project_files; diff --git a/qmake/project.cpp b/qmake/project.cpp index f8b24bb097..1179812b1b 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -592,10 +592,6 @@ QStringList qmake_feature_paths(QMakeProperty *prop=0) } for(QStringList::Iterator concat_it = concat.begin(); concat_it != concat.end(); ++concat_it) - feature_roots << (QLibraryInfo::location(QLibraryInfo::PrefixPath) + - mkspecs_concat + (*concat_it)); - for(QStringList::Iterator concat_it = concat.begin(); - concat_it != concat.end(); ++concat_it) feature_roots << (QLibraryInfo::location(QLibraryInfo::DataPath) + mkspecs_concat + (*concat_it)); return feature_roots; @@ -1285,35 +1281,9 @@ QMakeProject::read(uchar cmd) base_vars["TEMPLATE_PREFIX"] = QStringList(Option::user_template_prefix); if ((cmd & ReadSetup) && Option::mkfile::do_cache) { // parse the cache - int cache_depth = -1; - QString qmake_cache = Option::mkfile::cachefile; - if(qmake_cache.isEmpty()) { //find it as it has not been specified - 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 (Option::output_dir.startsWith(Option::mkfile::project_build_root)) + Option::mkfile::cachefile_depth = + Option::output_dir.mid(Option::mkfile::project_build_root.length()).count('/'); } if (cmd & ReadSetup) { // parse mkspec QString qmakespec = fixEnvVariables(Option::mkfile::qmakespec); @@ -1444,16 +1414,6 @@ QMakeProject::read(uchar cmd) parse("CONFIG += " + Option::after_user_configs.join(" "), vars); } - if(pfile != "-" && vars["TARGET"].isEmpty()) - vars["TARGET"].append(QFileInfo(pfile).baseName()); - - if ((cmd & ReadSetup) && !Option::user_configs.isEmpty()) { - parser.file = "(configs)"; - parser.from_file = false; - parser.line_no = 1; //really arg count now.. duh - parse("CONFIG += " + Option::user_configs.join(" "), base_vars); - } - if(cmd & ReadFeatures) { debug_msg(1, "Processing default_post: %s", vars["CONFIG"].join("::").toLatin1().constData()); doProjectInclude("default_post", IncludeFlagFeature, vars); @@ -1519,6 +1479,36 @@ void QMakeProject::validateModes() } } +void +QMakeProject::resolveSpec(QString *spec, const QString &qmakespec) +{ + if (spec->isEmpty()) { + *spec = QFileInfo(qmakespec).fileName(); + if (*spec == "default") { +#ifdef Q_OS_UNIX + char buffer[1024]; + int l = readlink(qmakespec.toLatin1(), buffer, 1023); + if (l != -1) { + buffer[l] = '\0'; + *spec = QString::fromLatin1(buffer); +#else + // We can't resolve symlinks as they do on Unix, so configure.exe puts the source of the + // qmake.conf at the end of the default/qmake.conf in the QMAKESPEC_ORG variable. + const QStringList &spec_org = base_vars["QMAKESPEC_ORIGINAL"]; + if (spec_org.isEmpty()) { + // try again the next time around + *spec = QString(); + } else { + *spec = spec_org.at(0); +#endif + int lastSlash = spec->lastIndexOf(QLatin1Char('/')); + if (lastSlash != -1) + spec->remove(0, lastSlash + 1); + } + } + } +} + bool QMakeProject::isActiveConfig(const QString &x, bool regex, QHash<QString, QStringList> *place) { @@ -1545,44 +1535,10 @@ QMakeProject::isActiveConfig(const QString &x, bool regex, QHash<QString, QStrin //mkspecs static QString spec; - if(spec.isEmpty()) - spec = QFileInfo(Option::mkfile::qmakespec).fileName(); + resolveSpec(&spec, Option::mkfile::qmakespec); QRegExp re(x, Qt::CaseSensitive, QRegExp::Wildcard); if((regex && re.exactMatch(spec)) || (!regex && spec == x)) return true; -#ifdef Q_OS_UNIX - else if(spec == "default") { - static char *buffer = NULL; - if(!buffer) { - buffer = (char *)malloc(1024); - qmakeAddCacheClear(qmakeFreeCacheClear, (void**)&buffer); - } - int l = readlink(Option::mkfile::qmakespec.toLatin1(), buffer, 1024); - if(l != -1) { - buffer[l] = '\0'; - QString r = buffer; - if(r.lastIndexOf('/') != -1) - r = r.mid(r.lastIndexOf('/') + 1); - if((regex && re.exactMatch(r)) || (!regex && r == x)) - return true; - } - } -#elif defined(Q_OS_WIN) - else if(spec == "default") { - // We can't resolve symlinks as they do on Unix, so configure.exe puts the source of the - // qmake.conf at the end of the default/qmake.conf in the QMAKESPEC_ORG variable. - const QStringList &spec_org = (place ? (*place)["QMAKESPEC_ORIGINAL"] - : vars["QMAKESPEC_ORIGINAL"]); - if (!spec_org.isEmpty()) { - spec = spec_org.at(0); - int lastSlash = spec.lastIndexOf('/'); - if(lastSlash != -1) - spec = spec.mid(lastSlash + 1); - if((regex && re.exactMatch(spec)) || (!regex && spec == x)) - return true; - } - } -#endif //simple matching const QStringList &configs = (place ? (*place)["CONFIG"] : vars["CONFIG"]); @@ -1726,9 +1682,6 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QHash<QString, QString warn_msg(WarnParser, "%s:%d: QtScript support disabled for %s.", pi.file.toLatin1().constData(), pi.line_no, orig_file.toLatin1().constData()); } else { - QStack<ScopeBlock> sc = scope_blocks; - IteratorBlock *it = iterator; - FunctionBlock *fu = function; if(flags & (IncludeFlagNewProject|IncludeFlagNewParser)) { // The "project's variables" are used in other places (eg. export()) so it's not // possible to use "place" everywhere. Instead just set variables and grab them later @@ -1744,11 +1697,14 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QHash<QString, QString } place = proj.variables(); } else { + QStack<ScopeBlock> sc = scope_blocks; + IteratorBlock *it = iterator; + FunctionBlock *fu = function; parsed = read(file, place); + iterator = it; + function = fu; + scope_blocks = sc; } - iterator = it; - function = fu; - scope_blocks = sc; } if(parsed) { if(place["QMAKE_INTERNAL_INCLUDED_FILES"].indexOf(orig_file) == -1) diff --git a/qmake/project.h b/qmake/project.h index 7a9cc1eae4..ce90be035f 100644 --- a/qmake/project.h +++ b/qmake/project.h @@ -108,6 +108,7 @@ class QMakeProject void init(QMakeProperty *, const QHash<QString, QStringList> *); QStringList &values(const QString &v, QHash<QString, QStringList> &place); void validateModes(); + void resolveSpec(QString *spec, const QString &qmakespec); public: QMakeProject() { init(0, 0); } diff --git a/qmake/qmake.pri b/qmake/qmake.pri index ba6ab383c7..abb073c48e 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -92,7 +92,7 @@ bootstrap { #Qt code qdir_p.h \ qdiriterator.h \ qfile.h \ - qabstractfileengine.h \ + qabstractfileengine_p.h \ qfileinfo.h \ qglobal.h \ qnumeric.h \ |