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 | 58 |
7 files changed, 76 insertions, 55 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 379854ed6a..52f2206410 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,9 +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 & ReadFeatures) { debug_msg(1, "Processing default_post: %s", vars["CONFIG"].join("::").toLatin1().constData()); doProjectInclude("default_post", IncludeFlagFeature, vars); @@ -1528,12 +1495,15 @@ QMakeProject::resolveSpec(QString *spec, const QString &qmakespec) // 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()) { + 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(lastSlash + 1); + spec->remove(0, lastSlash + 1); } } } @@ -1712,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 @@ -1730,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) |