QString QMakeProperty::keyBase(bool version) const { if (version) return QString(qmake_version()) + "/"; return QString(); }
bool ProjectGenerator::writeMakefile(QTextStream &t) { t << "######################################################################" << endl; t << "# Automatically generated by qmake (" << qmake_version() << ") " << QDateTime::currentDateTime().toString() << endl; t << "######################################################################" << endl << endl; QStringList::Iterator it; for(it = Option::before_user_vars.begin(); it != Option::before_user_vars.end(); ++it) t << (*it) << endl; t << getWritableVar("TEMPLATE_ASSIGN", FALSE); if(project->first("TEMPLATE_ASSIGN") == "subdirs") { t << endl << "# Directories" << "\n" << getWritableVar("SUBDIRS"); } else { t << getWritableVar("TARGET") << getWritableVar("CONFIG", FALSE) << getWritableVar("CONFIG_REMOVE", FALSE) << getWritableVar("DEPENDPATH") << getWritableVar("INCLUDEPATH") << endl; t << "# Input" << "\n"; t << getWritableVar("HEADERS") << getWritableVar("INTERFACES") << getWritableVar("LEXSOURCES") << getWritableVar("YACCSOURCES") << getWritableVar("SOURCES") << getWritableVar("TRANSLATIONS"); } for(it = Option::after_user_vars.begin(); it != Option::after_user_vars.end(); ++it) t << (*it) << endl; return TRUE; }
bool ProjectGenerator::writeMakefile(QTextStream &t) { t << "######################################################################" << endl; t << "# Automatically generated by qmake (" << qmake_version() << ") " << QDateTime::currentDateTime().toString() << endl; t << "######################################################################" << endl << endl; if(!Option::user_configs.isEmpty()) t << "CONFIG += " << Option::user_configs.join(" ") << endl; int i; for(i = 0; i < Option::before_user_vars.size(); ++i) t << Option::before_user_vars[i] << endl; t << getWritableVar("TEMPLATE_ASSIGN", false); if(project->first("TEMPLATE_ASSIGN") == "subdirs") { t << endl << "# Directories" << "\n" << getWritableVar("SUBDIRS"); } else { t << getWritableVar("TARGET_ASSIGN") << getWritableVar("CONFIG", false) << getWritableVar("CONFIG_REMOVE", false) << getWritableVar("DEPENDPATH") << getWritableVar("INCLUDEPATH") << endl; t << "# Input" << "\n"; t << getWritableVar("HEADERS") << getWritableVar("FORMS") << getWritableVar("LEXSOURCES") << getWritableVar("YACCSOURCES") << getWritableVar("SOURCES") << getWritableVar("RESOURCES") << getWritableVar("TRANSLATIONS"); } for(i = 0; i < Option::after_user_vars.size(); ++i) t << Option::after_user_vars[i] << endl; return true; }
void QMakeSourceFileInfo::saveCache(const QString &cf) { #ifdef QMAKE_USE_CACHE if(cf.isEmpty()) return; QFile file(QMakeLocalFileName(cf).local()); if(file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); stream << qmake_version() << endl << endl; //version { //cache verification QMap<QString, QStringList> verify = getCacheVerification(); stream << verify.count() << endl; for(QMap<QString, QStringList>::iterator it = verify.begin(); it != verify.end(); ++it) { stream << it.key() << endl << it.value().join(";") << endl; } stream << endl; } if(files->nodes) { for(int file = 0; file < files->num_nodes; ++file) { for(SourceFiles::SourceFileNode *node = files->nodes[file]; node; node = node->next) { stream << node->file->file.local() << endl; //source stream << node->file->type << endl; //type //depends stream << ";"; if(node->file->deps) { for(int depend = 0; depend < node->file->deps->used_nodes; ++depend) { if(depend) stream << ";"; stream << node->file->deps->children[depend]->file.local(); } } stream << endl; stream << node->file->mocable << endl; //mocable stream << endl; //just for human readability } } } stream.flush(); file.close(); } #else Q_UNUSED(cf); #endif }
QString QMakeProperty::value(QString v, bool just_check) { if(v == "QT_INSTALL_PREFIX") return QLibraryInfo::location(QLibraryInfo::PrefixPath); else if(v == "QT_INSTALL_DATA") return QLibraryInfo::location(QLibraryInfo::DataPath); else if(v == "QT_INSTALL_DOCS") return QLibraryInfo::location(QLibraryInfo::DocumentationPath); else if(v == "QT_INSTALL_HEADERS") return QLibraryInfo::location(QLibraryInfo::HeadersPath); else if(v == "QT_INSTALL_LIBS") return QLibraryInfo::location(QLibraryInfo::LibrariesPath); else if(v == "QT_INSTALL_BINS") return QLibraryInfo::location(QLibraryInfo::BinariesPath); else if(v == "QT_INSTALL_PLUGINS") return QLibraryInfo::location(QLibraryInfo::PluginsPath); else if(v == "QT_INSTALL_IMPORTS") return QLibraryInfo::location(QLibraryInfo::ImportsPath); else if(v == "QT_INSTALL_TRANSLATIONS") return QLibraryInfo::location(QLibraryInfo::TranslationsPath); else if(v == "QT_INSTALL_CONFIGURATION") return QLibraryInfo::location(QLibraryInfo::SettingsPath); else if(v == "QT_INSTALL_EXAMPLES") return QLibraryInfo::location(QLibraryInfo::ExamplesPath); else if(v == "QT_INSTALL_DEMOS") return QLibraryInfo::location(QLibraryInfo::ExamplesPath); else if(v == "QMAKE_MKSPECS") return qmake_mkspec_paths().join(Option::dirlist_sep); else if(v == "QMAKE_VERSION") return qmake_version(); #ifdef QT_VERSION_STR else if(v == "QT_VERSION") return QT_VERSION_STR; #endif initSettings(); int slash = v.lastIndexOf('/'); QVariant var = settings->value(keyBase(slash == -1) + v); bool ok = var.isValid(); QString ret = var.toString(); if(!ok) { QString version = qmake_version(); if(slash != -1) { version = v.left(slash-1); v = v.mid(slash+1); } settings->beginGroup(keyBase(false)); QStringList subs = settings->childGroups(); settings->endGroup(); subs.sort(); for (int x = subs.count() - 1; x >= 0; x--) { QString s = subs[x]; if(s.isEmpty() || s > version) continue; var = settings->value(keyBase(false) + s + "/" + v); ok = var.isValid(); ret = var.toString(); if (ok) { if(!just_check) debug_msg(1, "Fell back from %s -> %s for '%s'.", version.toLatin1().constData(), s.toLatin1().constData(), v.toLatin1().constData()); return ret; } } } return ok ? ret : QString(); }
bool QMakeProperty::exec() { bool ret = true; if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY) { if(Option::prop::properties.isEmpty()) { initSettings(); settings->beginGroup(keyBase(false)); QStringList subs = settings->childGroups(); settings->endGroup(); subs.sort(); for(int x = subs.count() - 1; x >= 0; x--) { QString s = subs[x]; if(s.isEmpty()) continue; settings->beginGroup(keyBase(false) + s); QStringList keys = settings->childKeys(); settings->endGroup(); for(QStringList::ConstIterator it2 = keys.begin(); it2 != keys.end(); it2++) { QString ret = settings->value(keyBase(false) + s + "/" + (*it2)).toString(); if(s != qmake_version()) fprintf(stdout, "%s/", s.toLatin1().constData()); fprintf(stdout, "%s:%s\n", (*it2).toLatin1().constData(), ret.toLatin1().constData()); } } QStringList specialProps; specialProps.append("QT_INSTALL_PREFIX"); specialProps.append("QT_INSTALL_DATA"); specialProps.append("QT_INSTALL_DOCS"); specialProps.append("QT_INSTALL_HEADERS"); specialProps.append("QT_INSTALL_LIBS"); specialProps.append("QT_INSTALL_BINS"); specialProps.append("QT_INSTALL_PLUGINS"); specialProps.append("QT_INSTALL_IMPORTS"); specialProps.append("QT_INSTALL_TRANSLATIONS"); specialProps.append("QT_INSTALL_CONFIGURATION"); specialProps.append("QT_INSTALL_EXAMPLES"); specialProps.append("QT_INSTALL_DEMOS"); specialProps.append("QMAKE_MKSPECS"); specialProps.append("QMAKE_VERSION"); #ifdef QT_VERSION_STR specialProps.append("QT_VERSION"); #endif foreach (QString prop, specialProps) fprintf(stdout, "%s:%s\n", prop.toLatin1().constData(), value(prop).toLatin1().constData()); return true; } for(QStringList::ConstIterator it = Option::prop::properties.begin(); it != Option::prop::properties.end(); it++) { if(Option::prop::properties.count() > 1) fprintf(stdout, "%s:", (*it).toLatin1().constData()); if(!hasValue((*it))) { ret = false; fprintf(stdout, "**Unknown**\n"); } else { fprintf(stdout, "%s\n", value((*it)).toLatin1().constData()); } } } else if(Option::qmake_mode == Option::QMAKE_SET_PROPERTY) { for(QStringList::ConstIterator it = Option::prop::properties.begin(); it != Option::prop::properties.end(); it++) { QString var = (*it); it++; if(it == Option::prop::properties.end()) { ret = false; break; } if(!var.startsWith(".")) setValue(var, (*it)); } } else if(Option::qmake_mode == Option::QMAKE_UNSET_PROPERTY) { for(QStringList::ConstIterator it = Option::prop::properties.begin(); it != Option::prop::properties.end(); it++) { QString var = (*it); if(!var.startsWith(".")) remove(var); } } return ret; }
void SymbianAbldMakefileGenerator::writeMkFile(const QString& wrapperFileName, bool deploymentOnly) { QString mkFullPath = Option::output_dir + QLatin1Char('/') + gnuMakefileName; QFile ft(mkFullPath); if (ft.open(QIODevice::WriteOnly)) { generatedFiles << ft.fileName(); QTextStream t(&ft); t << "# ==============================================================================" << endl; t << "# Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; t << QDateTime::currentDateTime().toString() << endl; t << "# This file is generated by qmake and should not be modified by the" << endl; t << "# user." << endl; t << "# Name : " << gnuMakefileName << endl; t << "# Part of : " << project->values("TARGET").join(" ") << endl; t << "# Description : This file is used to call necessary targets on wrapper makefile" << endl; t << "# during normal Symbian build process." << endl; t << "# Version : " << endl; t << "#" << endl; t << "# ==============================================================================" << "\n" << endl; t << endl << endl; t << "MAKE = make" << endl; t << endl; t << "VISUAL_CFG = RELEASE" << endl; t << "ifeq \"$(CFG)\" \"UDEB\"" << endl; t << "VISUAL_CFG = DEBUG" << endl; t << "endif" << endl; t << endl; t << DO_NOTHING_TARGET " :" << endl; t << "\t" << "@rem " DO_NOTHING_TARGET << endl << endl; QString buildDeps; QString cleanDeps; QString finalDeps; QString cleanDepsWinscw; QString finalDepsWinscw; QStringList wrapperTargets; if (deploymentOnly) { buildDeps.append(STORE_BUILD_TARGET); cleanDeps.append(DEPLOYMENT_CLEAN_TARGET); cleanDepsWinscw.append(WINSCW_DEPLOYMENT_CLEAN_TARGET " " DEPLOYMENT_CLEAN_TARGET); finalDeps.append(DEPLOYMENT_TARGET); finalDepsWinscw.append(WINSCW_DEPLOYMENT_TARGET " " DEPLOYMENT_TARGET); wrapperTargets << WINSCW_DEPLOYMENT_TARGET << WINSCW_DEPLOYMENT_CLEAN_TARGET << DEPLOYMENT_TARGET << DEPLOYMENT_CLEAN_TARGET << STORE_BUILD_TARGET; } else { buildDeps.append(CREATE_TEMPS_TARGET " " PRE_TARGETDEPS_TARGET " " STORE_BUILD_TARGET); cleanDeps.append(EXTENSION_CLEAN " " DEPLOYMENT_CLEAN_TARGET); cleanDepsWinscw.append(EXTENSION_CLEAN " " WINSCW_DEPLOYMENT_CLEAN_TARGET " " DEPLOYMENT_CLEAN_TARGET); finalDeps.append(FINALIZE_TARGET " " DEPLOYMENT_TARGET); finalDepsWinscw.append(FINALIZE_TARGET " " WINSCW_DEPLOYMENT_TARGET " " DEPLOYMENT_TARGET); wrapperTargets << PRE_TARGETDEPS_TARGET << CREATE_TEMPS_TARGET << EXTENSION_CLEAN << FINALIZE_TARGET << WINSCW_DEPLOYMENT_CLEAN_TARGET << WINSCW_DEPLOYMENT_TARGET << DEPLOYMENT_CLEAN_TARGET << DEPLOYMENT_TARGET << STORE_BUILD_TARGET; } t << "MAKMAKE: " << buildDeps << endl << endl; t << "LIB: " << buildDeps << endl << endl; t << "BLD: " << buildDeps << endl << endl; t << "ifeq \"$(PLATFORM)\" \"WINSCW\"" << endl; t << "CLEAN: " << cleanDepsWinscw << endl; t << "else" << endl; t << "CLEAN: " << cleanDeps << endl; t << "endif" << endl << endl; t << "CLEANLIB: " DO_NOTHING_TARGET << endl << endl; t << "RESOURCE: " DO_NOTHING_TARGET << endl << endl; t << "FREEZE: " DO_NOTHING_TARGET << endl << endl; t << "SAVESPACE: " DO_NOTHING_TARGET << endl << endl; t << "RELEASABLES: " DO_NOTHING_TARGET << endl << endl; t << "ifeq \"$(PLATFORM)\" \"WINSCW\"" << endl; t << "FINAL: " << finalDepsWinscw << endl; t << "else" << endl; t << "FINAL: " << finalDeps << endl; t << "endif" << endl << endl; QString makefile(Option::fixPathToTargetOS(fileInfo(wrapperFileName).canonicalFilePath())); foreach(QString target, wrapperTargets) { t << target << " : " << makefile << endl; t << "\t-$(MAKE) -f \"" << makefile << "\" " << target << " QT_SIS_TARGET=$(VISUAL_CFG)-$(PLATFORM)" << endl << endl; }
int Option::parseCommandLine(int argc, char **argv, int skip) { bool before = true; for(int x = skip; x < argc; x++) { if(*argv[x] == '-' && strlen(argv[x]) > 1) { /* options */ QString opt = argv[x] + 1; //first param is a mode, or we default if(x == 1) { bool specified = true; if(opt == "project") { Option::recursive = true; Option::qmake_mode = Option::QMAKE_GENERATE_PROJECT; } else if(opt == "prl") { Option::mkfile::do_deps = false; Option::mkfile::do_mocs = false; Option::qmake_mode = Option::QMAKE_GENERATE_PRL; } else if(opt == "set") { Option::qmake_mode = Option::QMAKE_SET_PROPERTY; } else if(opt == "query") { Option::qmake_mode = Option::QMAKE_QUERY_PROPERTY; } else if(opt == "makefile") { Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE; } else { specified = false; } if(specified) continue; } //all modes if(opt == "o" || opt == "output") { Option::output.setFileName(argv[++x]); } else if(opt == "after") { before = false; } else if(opt == "t" || opt == "template") { Option::user_template = argv[++x]; } else if(opt == "tp" || opt == "template_prefix") { Option::user_template_prefix = argv[++x]; } else if(opt == "mac9") { Option::target_mode = TARG_MAC9_MODE; } else if(opt == "macx") { Option::target_mode = TARG_MACX_MODE; } else if(opt == "unix") { Option::target_mode = TARG_UNIX_MODE; } else if(opt == "win32") { Option::target_mode = TARG_WIN_MODE; } else if(opt == "d") { Option::debug_level++; } else if(opt == "version" || opt == "v" || opt == "-version") { fprintf(stdout, "QMake version %s\n" "Using Qt version %s in %s\n", qmake_version(), QT_VERSION_STR, QLibraryInfo::location(QLibraryInfo::LibrariesPath).toLatin1().constData()); #ifdef QMAKE_OPENSOURCE_VERSION fprintf(stdout, "QMake is Open Source software from Nokia Corporation and/or its subsidiary(-ies).\n"); #endif return Option::QMAKE_CMDLINE_BAIL; } else if(opt == "h" || opt == "help") { return Option::QMAKE_CMDLINE_SHOW_USAGE; } else if(opt == "Wall") { Option::warn_level |= WarnAll; } else if(opt == "Wparser") { Option::warn_level |= WarnParser; } else if(opt == "Wlogic") { Option::warn_level |= WarnLogic; } else if(opt == "Wnone") { Option::warn_level = WarnNone; } else if(opt == "r" || opt == "recursive") { Option::recursive = true; } else if(opt == "norecursive") { Option::recursive = false; } else if(opt == "config") { Option::user_configs += argv[++x]; } else { if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { if(opt == "nodepend" || opt == "nodepends") { Option::mkfile::do_deps = false; } else if(opt == "nomoc") { Option::mkfile::do_mocs = false; } else if(opt == "nocache") { Option::mkfile::do_cache = false; } else if(opt == "createstub") { Option::mkfile::do_stub_makefile = true; } else if(opt == "nodependheuristics") { Option::mkfile::do_dep_heuristics = false; } else if(opt == "E") { Option::mkfile::do_preprocess = true; } else if(opt == "cache") { Option::mkfile::cachefile = argv[++x]; } else if(opt == "platform" || opt == "spec") { Option::mkfile::qmakespec = argv[++x]; Option::mkfile::qmakespec_commandline = argv[x]; } else { fprintf(stderr, "***Unknown option -%s\n", opt.toLatin1().constData()); return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR; } } else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { if(opt == "nopwd") { Option::projfile::do_pwd = false; } else { fprintf(stderr, "***Unknown option -%s\n", opt.toLatin1().constData()); return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR; } } } } else { QString arg = argv[x]; if(arg.indexOf('=') != -1) { if(before) Option::before_user_vars.append(arg); else Option::after_user_vars.append(arg); } else { bool handled = true; if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY || Option::qmake_mode == Option::QMAKE_SET_PROPERTY) { Option::prop::properties.append(arg); } else { QFileInfo fi(arg); if(!fi.makeAbsolute()) //strange arg = fi.filePath(); if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || Option::qmake_mode == Option::QMAKE_GENERATE_PRL) Option::mkfile::project_files.append(arg); else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) Option::projfile::project_dirs.append(arg); else handled = false; } if(!handled) { return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR; } } } } return Option::QMAKE_CMDLINE_SUCCESS; }
void QMakeSourceFileInfo::loadCache(const QString &cf) { if(cf.isEmpty()) return; #ifdef QMAKE_USE_CACHE QMakeLocalFileName cache_file(cf); int fd = open(QMakeLocalFileName(cf).local().toLatin1(), O_RDONLY); if(fd == -1) return; QFileInfo cache_fi = findFileInfo(cache_file); if(!cache_fi.exists() || cache_fi.isDir()) return; QFile file; if(!file.open(QIODevice::ReadOnly, fd)) return; QTextStream stream(&file); if(stream.readLine() == qmake_version()) { //version check stream.skipWhiteSpace(); bool verified = true; { //cache verification QMap<QString, QStringList> verify; int len = stream.readLine().toInt(); for(int i = 0; i < len; ++i) { QString var = stream.readLine(); QString val = stream.readLine(); verify.insert(var, val.split(';', QString::SkipEmptyParts)); } verified = verifyCache(verify); } if(verified) { stream.skipWhiteSpace(); if(!files) files = new SourceFiles; while(!stream.atEnd()) { QString source = stream.readLine(); QString type = stream.readLine(); QString depends = stream.readLine(); QString mocable = stream.readLine(); stream.skipWhiteSpace(); QMakeLocalFileName fn(source); QFileInfo fi = findFileInfo(fn); SourceFile *file = files->lookupFile(fn); if(!file) { file = new SourceFile; file->file = fn; files->addFile(file); file->type = (SourceFileType)type.toInt(); file->exists = fi.exists(); } if(fi.exists() && fi.lastModified() < cache_fi.lastModified()) { if(!file->dep_checked) { //get depends if(!file->deps) file->deps = new SourceDependChildren; file->dep_checked = true; QStringList depend_list = depends.split(";", QString::SkipEmptyParts); for(int depend = 0; depend < depend_list.size(); ++depend) { QMakeLocalFileName dep_fn(depend_list.at(depend)); QFileInfo dep_fi(findFileInfo(dep_fn)); SourceFile *dep = files->lookupFile(dep_fn); if(!dep) { dep = new SourceFile; dep->file = dep_fn; dep->exists = dep_fi.exists(); dep->type = QMakeSourceFileInfo::TYPE_UNKNOWN; files->addFile(dep); } dep->included_count++; file->deps->addChild(dep); } } if(!file->moc_checked) { //get mocs file->moc_checked = true; file->mocable = mocable.toInt(); } } } } } #endif }
int Option::internalParseCommandLine(int argc, char **argv, int skip) { bool before = TRUE; for(int x = skip; x < argc; x++) { if(*argv[x] == '-' && strlen(argv[x]) > 1) { /* options */ QString opt = argv[x] + 1; //first param is a mode, or we default if(x == 1) { bool specified = TRUE; if(opt == "project") { Option::qmake_mode = Option::QMAKE_GENERATE_PROJECT; } else if(opt == "prl") { Option::mkfile::do_deps = FALSE; Option::mkfile::do_mocs = FALSE; Option::qmake_mode = Option::QMAKE_GENERATE_PRL; } else if(opt == "set") { Option::qmake_mode = Option::QMAKE_SET_PROPERTY; } else if(opt == "query") { Option::qmake_mode = Option::QMAKE_QUERY_PROPERTY; } else if(opt == "makefile") { Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE; } else { specified = FALSE; } if(specified) continue; } //all modes if(opt == "o" || opt == "output") { Option::output.setName(argv[++x]); } else if(opt == "after") { before = FALSE; } else if(opt == "t" || opt == "template") { Option::user_template = argv[++x]; } else if(opt == "tp" || opt == "template_prefix") { Option::user_template_prefix = argv[++x]; } else if(opt == "mac9") { Option::target_mode = TARG_MAC9_MODE; } else if(opt == "macx") { Option::target_mode = TARG_MACX_MODE; } else if(opt == "unix") { Option::target_mode = TARG_UNIX_MODE; } else if(opt == "win32") { Option::target_mode = TARG_WIN_MODE; } else if(opt == "os2") { Option::target_mode = TARG_OS2_MODE; } else if(opt == "d") { Option::debug_level++; } else if(opt == "version" || opt == "v" || opt == "-version") { fprintf(stderr, "Qmake version: %s (Qt %s)\n", qmake_version(), QT_VERSION_STR); fprintf(stderr, "Qmake is free software from Trolltech AS.\n"); return QMAKE_CMDLINE_BAIL; } else if(opt == "h" || opt == "help") { return QMAKE_CMDLINE_SHOW_USAGE; } else if(opt == "Wall") { Option::warn_level |= WarnAll; } else if(opt == "Wparser") { Option::warn_level |= WarnParser; } else if(opt == "Wlogic") { Option::warn_level |= WarnLogic; } else if(opt == "Wnone") { Option::warn_level = WarnNone; } else { if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { if(opt == "nodepend") { Option::mkfile::do_deps = FALSE; } else if(opt == "nomoc") { Option::mkfile::do_mocs = FALSE; } else if(opt == "nocache") { Option::mkfile::do_cache = FALSE; } else if(opt == "nodependheuristics") { Option::mkfile::do_dep_heuristics = FALSE; } else if(opt == "E") { Option::mkfile::do_preprocess = TRUE; } else if(opt == "cache") { Option::mkfile::cachefile = argv[++x]; } else if(opt == "platform" || opt == "spec") { Option::mkfile::qmakespec = argv[++x]; Option::mkfile::qmakespec_commandline = argv[x]; } else { fprintf(stderr, "***Unknown option -%s\n", opt.latin1()); return QMAKE_CMDLINE_SHOW_USAGE; } } else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { if(opt == "nopwd") { Option::projfile::do_pwd = FALSE; } else if(opt == "r") { Option::projfile::do_recursive = TRUE; } else if(opt == "norecursive") { Option::projfile::do_recursive = FALSE; } else { fprintf(stderr, "***Unknown option -%s\n", opt.latin1()); return QMAKE_CMDLINE_SHOW_USAGE; } } } } else { QString arg = argv[x]; if(arg.find('=') != -1) { if(before) Option::before_user_vars.append(arg); else Option::after_user_vars.append(arg); } else { bool handled = TRUE; if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY || Option::qmake_mode == Option::QMAKE_SET_PROPERTY) { Option::prop::properties.append(arg); } else { QFileInfo fi(arg); if(!fi.convertToAbs()) //strange arg = fi.filePath(); if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || Option::qmake_mode == Option::QMAKE_GENERATE_PRL) Option::mkfile::project_files.append(arg); else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) Option::projfile::project_dirs.append(arg); else handled = FALSE; } if(!handled) return QMAKE_CMDLINE_SHOW_USAGE; } } } return QMAKE_CMDLINE_SUCCESS; }
int Option::parseCommandLine(QStringList &args) { QStringList user_configs; bool before = true; args << QString(); // Avoid bounds checking for options which take an argument for (int x = 0; x < args.size() - 1; ) { QString arg = args.at(x); if (arg.size() > 1 && arg.startsWith('-')) { /* options */ QString opt = arg.mid(1); if(opt == "o" || opt == "output") { Option::output.setFileName(args.at(x + 1)); args.erase(args.begin() + x, args.begin() + x + 2); continue; } else if(opt == "after") { before = false; } else if(opt == "t" || opt == "template") { Option::user_template = args.at(++x); } else if(opt == "tp" || opt == "template_prefix") { Option::user_template_prefix = args.at(++x); } else if(opt == "unix") { Option::dir_sep = "/"; } else if(opt == "win32") { Option::dir_sep = "\\"; } else if(opt == "d") { Option::debug_level++; } else if(opt == "version" || opt == "v" || opt == "-version") { fprintf(stdout, "QMake version %s\n" "Using Qt version %s in %s\n", qmake_version(), QT_VERSION_STR, QLibraryInfo::location(QLibraryInfo::LibrariesPath).toLatin1().constData()); #ifdef QMAKE_OPENSOURCE_VERSION fprintf(stdout, "QMake is Open Source software from Nokia Corporation and/or its subsidiary(-ies).\n"); #endif return Option::QMAKE_CMDLINE_BAIL; } else if(opt == "h" || opt == "help") { return Option::QMAKE_CMDLINE_SHOW_USAGE; } else if(opt == "Wall") { Option::warn_level |= WarnAll; } else if(opt == "Wparser") { Option::warn_level |= WarnParser; } else if(opt == "Wlogic") { Option::warn_level |= WarnLogic; } else if(opt == "Wdeprecated") { Option::warn_level |= WarnDeprecated; } else if(opt == "Wnone") { Option::warn_level = WarnNone; } else if(opt == "r" || opt == "recursive") { Option::recursive = true; args.removeAt(x); continue; } else if(opt == "nr" || opt == "norecursive") { Option::recursive = false; args.removeAt(x); continue; } else if(opt == "config") { user_configs += args.at(++x); } else { if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { if(opt == "nodepend" || opt == "nodepends") { Option::mkfile::do_deps = false; } else if(opt == "nomoc") { Option::mkfile::do_mocs = false; } else if(opt == "nocache") { Option::mkfile::do_cache = false; } else if(opt == "createstub") { Option::mkfile::do_stub_makefile = true; } else if(opt == "nodependheuristics") { Option::mkfile::do_dep_heuristics = false; } else if(opt == "E") { Option::mkfile::do_preprocess = true; } else if(opt == "cache") { Option::mkfile::cachefile = args.at(++x); } else if(opt == "platform" || opt == "spec") { Option::mkfile::qmakespec = args[x] = cleanSpec(args.at(++x)); } else if (opt == "xplatform" || opt == "xspec") { Option::mkfile::xqmakespec = args[x] = cleanSpec(args.at(x)); } else { fprintf(stderr, "***Unknown option -%s\n", opt.toLatin1().constData()); return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR; } } else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { if(opt == "nopwd") { Option::projfile::do_pwd = false; } else { fprintf(stderr, "***Unknown option -%s\n", opt.toLatin1().constData()); return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR; } } } } else { if(arg.indexOf('=') != -1) { if(before) Option::before_user_vars.append(arg); else Option::after_user_vars.append(arg); } else { bool handled = true; if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY || Option::qmake_mode == Option::QMAKE_SET_PROPERTY || Option::qmake_mode == Option::QMAKE_UNSET_PROPERTY) { Option::prop::properties.append(arg); } else { QFileInfo fi(arg); if(!fi.makeAbsolute()) //strange arg = fi.filePath(); if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { if(fi.isDir()) { QString proj = detectProjectFile(arg); if (!proj.isNull()) arg = proj; } Option::mkfile::project_files.append(arg); } else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { Option::projfile::project_dirs.append(arg); } else { handled = false; } } if(!handled) { return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR; } args.removeAt(x); continue; } } x++; } if (!user_configs.isEmpty()) Option::before_user_vars += "CONFIG += " + user_configs.join(" "); if (Option::mkfile::xqmakespec.isEmpty()) Option::mkfile::xqmakespec = Option::mkfile::qmakespec; args.takeLast(); return Option::QMAKE_CMDLINE_SUCCESS; }