diff --git a/qmake/option.cpp b/qmake/option.cpp index ec4c3546bd..d2ab2514d6 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -432,6 +432,14 @@ Option::init(int argc, char **argv) } if(!Option::qmake_abslocation.isNull()) Option::qmake_abslocation = QDir::cleanPath(Option::qmake_abslocation); + else // This is rather unlikely to ever happen on a modern system ... + Option::qmake_abslocation = QLibraryInfo::rawLocation(QLibraryInfo::HostBinariesPath, + QLibraryInfo::EffectivePaths) + +#ifdef Q_OS_WIN + "/qmake.exe"; +#else + "/qmake"; +#endif } else { Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE; } diff --git a/qmake/project.cpp b/qmake/project.cpp index fbfe84a581..1a5b7e7e76 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1314,7 +1314,14 @@ bool QMakeProject::read(uchar cmd) { again: - if ((cmd & ReadSetup) && base_vars.isEmpty()) { + if (init_vars.isEmpty()) { + loadDefaults(); + init_vars = vars; + } else { + vars = init_vars; + } + if (cmd & ReadSetup) { + if (base_vars.isEmpty()) { QString superdir; QString project_root; QString project_build_root; @@ -1390,6 +1397,11 @@ QMakeProject::read(uchar cmd) if (Option::output_dir.startsWith(project_build_root)) Option::mkfile::cachefile_depth = Option::output_dir.mid(project_build_root.length()).count('/'); + + if (!superfile.isEmpty()) + vars["_QMAKE_SUPER_CACHE_"] << superfile; + if (!cachefile.isEmpty()) + vars["_QMAKE_CACHE_"] << cachefile; } no_cache: @@ -1489,8 +1501,9 @@ QMakeProject::read(uchar cmd) } base_vars = vars; - } else { + } else { vars = base_vars; // start with the base + } } for (QHash::ConstIterator it = extra_vars.constBegin(); @@ -1594,6 +1607,90 @@ QMakeProject::read(uchar cmd) return true; } +void +QMakeProject::loadDefaults() +{ + vars["LITERAL_WHITESPACE"] << QLatin1String("\t"); + vars["LITERAL_DOLLAR"] << QLatin1String("$"); + vars["LITERAL_HASH"] << QLatin1String("#"); + vars["DIR_SEPARATOR"] << Option::dir_sep; + vars["DIRLIST_SEPARATOR"] << Option::dirlist_sep; + vars["QMAKE_QMAKE"] << Option::qmake_abslocation; +#if defined(Q_OS_WIN32) + vars["QMAKE_HOST.os"] << QString::fromLatin1("Windows"); + + DWORD name_length = 1024; + wchar_t name[1024]; + if (GetComputerName(name, &name_length)) + vars["QMAKE_HOST.name"] << QString::fromWCharArray(name); + + QSysInfo::WinVersion ver = QSysInfo::WindowsVersion; + vars["QMAKE_HOST.version"] << QString::number(ver); + QString verStr; + switch (ver) { + case QSysInfo::WV_Me: verStr = QLatin1String("WinMe"); break; + case QSysInfo::WV_95: verStr = QLatin1String("Win95"); break; + case QSysInfo::WV_98: verStr = QLatin1String("Win98"); break; + case QSysInfo::WV_NT: verStr = QLatin1String("WinNT"); break; + case QSysInfo::WV_2000: verStr = QLatin1String("Win2000"); break; + case QSysInfo::WV_2003: verStr = QLatin1String("Win2003"); break; + case QSysInfo::WV_XP: verStr = QLatin1String("WinXP"); break; + case QSysInfo::WV_VISTA: verStr = QLatin1String("WinVista"); break; + default: verStr = QLatin1String("Unknown"); break; + } + vars["QMAKE_HOST.version_string"] << verStr; + + SYSTEM_INFO info; + GetSystemInfo(&info); + QString archStr; + switch (info.wProcessorArchitecture) { +# ifdef PROCESSOR_ARCHITECTURE_AMD64 + case PROCESSOR_ARCHITECTURE_AMD64: + archStr = QLatin1String("x86_64"); + break; +# endif + case PROCESSOR_ARCHITECTURE_INTEL: + archStr = QLatin1String("x86"); + break; + case PROCESSOR_ARCHITECTURE_IA64: +# ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 + case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: +# endif + archStr = QLatin1String("IA64"); + break; + default: + archStr = QLatin1String("Unknown"); + break; + } + vars["QMAKE_HOST.arch"] << archStr; + +# if defined(Q_CC_MSVC) + QString paths = QString::fromLocal8Bit(qgetenv("PATH")); + QString vcBin64 = QString::fromLocal8Bit(qgetenv("VCINSTALLDIR")); + if (!vcBin64.endsWith('\\')) + vcBin64.append('\\'); + vcBin64.append("bin\\amd64"); + QString vcBinX86_64 = QString::fromLocal8Bit(qgetenv("VCINSTALLDIR")); + if (!vcBinX86_64.endsWith('\\')) + vcBinX86_64.append('\\'); + vcBinX86_64.append("bin\\x86_amd64"); + if (paths.contains(vcBin64,Qt::CaseInsensitive) || paths.contains(vcBinX86_64,Qt::CaseInsensitive)) + vars["QMAKE_TARGET.arch"] << QString::fromLatin1("x86_64"); + else + vars["QMAKE_TARGET.arch"] << QString::fromLatin1("x86"); +# endif +#elif defined(Q_OS_UNIX) + struct utsname name; + if (!uname(&name)) { + vars["QMAKE_HOST.os"] << QString::fromLocal8Bit(name.sysname); + vars["QMAKE_HOST.name"] << QString::fromLocal8Bit(name.nodename); + vars["QMAKE_HOST.version"] << QString::fromLocal8Bit(name.release); + vars["QMAKE_HOST.version_string"] << QString::fromLocal8Bit(name.version); + vars["QMAKE_HOST.arch"] << QString::fromLocal8Bit(name.machine); + } +#endif +} + bool QMakeProject::isActiveConfig(const QString &x, bool regex, QHash *place) { @@ -3229,12 +3326,14 @@ QMakeProject::doProjectTest(QString func, QList args_list, QHash &place) { QString var = varMap(_var); - if(var == QLatin1String("LITERAL_WHITESPACE")) { //a real space in a token) - var = ".BUILTIN." + var; - place[var] = QStringList(QLatin1String("\t")); - } else if(var == QLatin1String("LITERAL_DOLLAR")) { //a real $ - var = ".BUILTIN." + var; - place[var] = QStringList(QLatin1String("$")); - } else if(var == QLatin1String("LITERAL_HASH")) { //a real # - var = ".BUILTIN." + var; - place[var] = QStringList("#"); - } else if(var == QLatin1String("OUT_PWD")) { //the out going dir + if (var == QLatin1String("OUT_PWD")) { //the out going dir var = ".BUILTIN." + var; place[var] = QStringList(Option::output_dir); } else if(var == QLatin1String("PWD") || //current working dir (of _FILE_) var == QLatin1String("IN_PWD")) { var = ".BUILTIN." + var; place[var] = QStringList(qmake_getpwd()); - } else if(var == QLatin1String("DIR_SEPARATOR")) { - var = ".BUILTIN." + var; - place[var] = QStringList(Option::dir_sep); - } else if(var == QLatin1String("DIRLIST_SEPARATOR")) { - var = ".BUILTIN." + var; - place[var] = QStringList(Option::dirlist_sep); } else if(var == QLatin1String("_LINE_")) { //parser line number var = ".BUILTIN." + var; place[var] = QStringList(QString::number(parser.line_no)); @@ -3667,14 +3751,6 @@ QStringList &QMakeProject::values(const QString &_var, QHash[%s]", qPrintable(var), qPrintable(place[var].join("::"))); return place[var]; } diff --git a/qmake/project.h b/qmake/project.h index 8314c39321..11d0eb4a27 100644 --- a/qmake/project.h +++ b/qmake/project.h @@ -91,7 +91,7 @@ class QMakeProject QMakeProperty *prop; void reset(); QStringList extra_configs; - QHash vars, base_vars, extra_vars; + QHash vars, init_vars, base_vars, extra_vars; bool parse(const QString &text, QHash &place, int line_count=1); enum IncludeStatus { @@ -114,6 +114,7 @@ class QMakeProject QStringList doVariableReplaceExpand(const QString &str, QHash &place, bool *ok=0); void init(QMakeProperty *); void cleanup(); + void loadDefaults(); QStringList &values(const QString &v, QHash &place); QStringList qmakeFeaturePaths();