bool usage(const char *a0) { fprintf(stdout, "Usage: %s [mode] [options] [files]\n" "\n" "QMake has two modes, one mode for generating project files based on\n" "some heuristics, and the other for generating makefiles. Normally you\n" "shouldn't need to specify a mode, as makefile generation is the default\n" "mode for qmake, but you may use this to test qmake on an existing project\n" "\n" "Mode:\n" " -project Put qmake into project file generation mode%s\n" " In this mode qmake interprets files as files to\n" " be built,\n" " defaults to %s\n" " Note: The created .pro file probably will \n" " need to be edited. For example add the QT variable to \n" " specify what modules are required.\n" " -makefile Put qmake into makefile generation mode%s\n" " In this mode qmake interprets files as project files to\n" " be processed, if skipped qmake will try to find a project\n" " file in your current working directory\n" "\n" "Warnings Options:\n" " -Wnone Turn off all warnings; specific ones may be re-enabled by\n" " later -W options\n" " -Wall Turn on all warnings\n" " -Wparser Turn on parser warnings\n" " -Wlogic Turn on logic warnings (on by default)\n" " -Wdeprecated Turn on deprecation warnings (on by default)\n" "\n" "Options:\n" " * You can place any variable assignment in options and it will be *\n" " * processed as if it was in [files]. These assignments will be parsed *\n" " * before [files]. *\n" " -o file Write output to file\n" " -d Increase debug level\n" " -t templ Overrides TEMPLATE as templ\n" " -tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n" " -help This help\n" " -v Version information\n" " -after All variable assignments after this will be\n" " parsed after [files]\n" " -norecursive Don't do a recursive search\n" " -recursive Do a recursive search\n" " -set <prop> <value> Set persistent property\n" " -unset <prop> Unset persistent property\n" " -query <prop> Query persistent property. Show all if <prop> is empty.\n" " -cache file Use file as cache [makefile mode only]\n" " -spec spec Use spec as QMAKESPEC [makefile mode only]\n" " -nocache Don't use a cache file [makefile mode only]\n" " -nodepend Don't generate dependencies [makefile mode only]\n" " -nomoc Don't generate moc targets [makefile mode only]\n" " -nopwd Don't look for files in pwd [project mode only]\n" ,a0, default_mode(a0) == Option::QMAKE_GENERATE_PROJECT ? " (default)" : "", project_builtin_regx().toLatin1().constData(), default_mode(a0) == Option::QMAKE_GENERATE_MAKEFILE ? " (default)" : "" ); return false; }
bool usage(const char *a0) { fprintf(stdout, "Usage: %s [mode] [options] [files]\n" "\n" " QMake has two modes, one mode for generating project files based on\n" "some heuristics, and the other for generating makefiles. Normally you\n" "shouldn't need to specify a mode, as makefile generation is the default\n" "mode for qmake, but you may use this to test qmake on an existing project\n" "\n" "Mode:\n" "\t-project Put qmake into project file generation mode%s\n" "\t In this mode qmake interprets files as files to\n" "\t be built,\n" "\t defaults to %s\n" "\t-makefile Put qmake into makefile generation mode%s\n" "\t In this mode qmake interprets files as project files to\n" "\t be processed, if skipped qmake will try to find a project\n" "\t file in your current working directory\n" "\n" "Warnings Options:\n" "\t-Wnone Turn off all warnings\n" "\t-Wall Turn on all warnings\n" "\t-Wparser Turn on parser warnings\n" "\t-Wlogic Turn on logic warnings\n" "\n" "Options:\n" "\t * You can place any variable assignment in options and it will be *\n" "\t * processed as if it was in [files]. These assignments will be parsed *\n" "\t * before [files]. *\n" "\t-o file Write output to file\n" "\t-unix Run in unix mode\n" "\t-win32 Run in win32 mode\n" "\t-os2 Run in OS/2 mode\n" "\t-macx Run in Mac OS X mode\n" "\t-d Increase debug level\n" "\t-t templ Overrides TEMPLATE as templ\n" "\t-tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n" "\t-help This help\n" "\t-v Version information\n" "\t-after All variable assignments after this will be\n" "\t parsed after [files]\n" "\t-cache file Use file as cache [makefile mode only]\n" "\t-spec spec Use spec as QMAKESPEC [makefile mode only]\n" "\t-nocache Don't use a cache file [makefile mode only]\n" "\t-nodepend Don't generate dependencies [makefile mode only]\n" "\t-nomoc Don't generate moc targets [makefile mode only]\n" "\t-nopwd Don't look for files in pwd [ project mode only]\n" "\t-norecursive Don't do a recursive search [ project mode only]\n" ,a0, default_mode(a0) == Option::QMAKE_GENERATE_PROJECT ? " (default)" : "", project_builtin_regx().latin1(), default_mode(a0) == Option::QMAKE_GENERATE_MAKEFILE ? " (default)" : ""); return FALSE; }
int event_timetick(int lasttimeofday, int timeofday, int dayofweek, int date, struct pstate *ps, struct lstate *ls) { int ret = 0; /* * If we've just ticked past the reset time while in AMODE_OFF * or a default mode, we call default_mode() to optionally go * into AMODE_CONFIRM. * * If we've just ticked past the alarm time, we should * _unconditionally_ reset to default mode: that's our strong * guarantee that everything done in the amodes has temporary * effect. However, _which_ alarm time is slightly more * subtle: it should be the one-off alarm time in AMODE_ON * (and in that case we also go beep!), or the default alarm * time in any other mode. */ if ((ls->amode == AMODE_OFF || ls->amode_default) && TICKEDPAST(lasttimeofday, timeofday, ps->resettime)) { default_mode(timeofday, dayofweek, date, ps, ls); } else if (ls->amode == AMODE_ON && TICKEDPAST(lasttimeofday, timeofday, ls->alarm_time)) { default_mode(timeofday, dayofweek, date, ps, ls); /* * Special case: if we're configuring the immediate snooze * time, the alarm doesn't sound. This is so we can cancel * a snooze by dialling the snooze timer down to zero. */ if (ls->dmode != DMODE_SETSNOOZE) ls->alarm_sounding = 1; } else if (ls->amode != AMODE_ON && TICKEDPAST(lasttimeofday, timeofday, defalarmtime(ps, dayofweek, date, NULL))) { default_mode(timeofday, dayofweek, date, ps, ls); } /* * If we're a decent half-hour before the reset time, suggest * that this might be a good moment to go to our exception * server and download the current list of exceptions. */ { int exctime = (ps->resettime + 86400 - 30*60) % 86400; if (TICKEDPAST(lasttimeofday, timeofday, exctime)) ret |= GET_EXCEPTIONS; } return ret; }
int main(int argc, char **argv) { t_list *list; char *term; char *bp; int tty; struct termios t; struct termios save; init_main(&bp, &list); tty = get_tty_fd(); if (argc < 2) { my_printf("[*] Usage : %s [arg:]\n", argv[0]); return (0); } if (my_params_to_list(&list, argc, argv)) return (1); if (catch_error(&term, bp, &t, &save)) return (1); raw_mode(&t); clean_screen(tty); my_select(&list, tty); default_mode(&save); return (0); }
Extsram::Extsram(){ DDRA = 0b11111111; DDRC |= 0b01111111; DDRB |= 0b11101110; DDRF = 0; PORTF = 0; default_mode(); }
void Extsram::write_single_byte(uint16_t addr, uint8_t data){ write_mode(); set_address(addr); *data_p = data; default_mode(); }
//#include "bluetooth.h" Extsram::Extsram(Bluetooth* b){ DDRA = 0b11111111; DDRC |= 0b01111111; DDRB |= 0b11100000; DDRF = 0; PORTF = 0; default_mode(); //bt = b; }
void event_updated_excdata(int timeofday, int dayofweek, int date, struct pstate *ps, struct lstate *ls) { /* * Exceptions are updated, so readjust our default mode if * we're in it. */ if (ls->amode_default) default_mode(timeofday, dayofweek, date, ps, ls); }
uint8_t Extsram::read_single_byte(uint16_t addr){ uint8_t data; read_mode(); set_address(addr); ce = low; oe = low; data = *data_v; default_mode(); return data; }
void Extsram::read_data_and_transmit(uint16_t start_address, uint16_t amount_of_bytes, Bluetooth* bt){ /* * reads provided amount of bytes to bt */ uint16_t a; uint8_t byte; read_sram_mode(); oe = low; for(a=0; a<amount_of_bytes; a++){ set_address(start_address+a); //_delay_us(20); ce = low; //_delay_us(20); byte = *data_v; //byte = 'u'; bt->put_c(byte); ce = hi; } default_mode(); }
void Extsram::write_data(uint16_t start_address, uint16_t amount_of_bytes, uint32_t flash_address){ uint16_t a; uint8_t byte; data_p_mode = out; addr_p_mode = out; for(a=0; a<amount_of_bytes; a++){ set_address(start_address+a); byte = pgm_read_byte(Emulator::eeprom1_image_address+a); *data_p = byte; //_delay_us(20); ce = low; we = low; //_delay_us(20); ce = hi; we = hi; //_delay_us(20); } default_mode(); //l.L2 = Leds::off; }
int event_button(int button, int timeofday, int dayofweek, int date, struct pstate *ps, struct lstate *ls) { int *p, wrap, adj; int ret = 0; switch (button) { case NORM_BUTTON_SNOOZE: ls->alarm_sounding = 0; set_mode(ps, ls, DMODE_SETSNOOZE); ls->snooze_time = ps->snoozeperiod; set_snooze(timeofday, ls); ls->saved_hours_digit = -1; break; case NORM_BUTTON_SETUP: set_mode(ps, ls, DMODE_CONFIGURE); break; case NORM_BUTTON_SHUT_UP: ls->alarm_sounding = 0; default_mode(timeofday, dayofweek, date, ps, ls); break; case NORM_BUTTON_ALARM_ON: set_mode(ps, ls, DMODE_SETALARM); ls->alarm_time = defalarmtime(ps, dayofweek, date, NULL); if (ls->alarm_time < timeofday) ls->alarm_time = defalarmtime(ps, (dayofweek+1) % 7, date+1, NULL); ls->amode = AMODE_ON; ls->amode_default = 0; ls->saved_hours_digit = -1; break; case NORM_BUTTON_CONFIRM: ls->amode = AMODE_CONFIRM; ls->amode_default = 0; break; case NORM_BUTTON_ALARM_OFF: ls->amode = AMODE_OFF; ls->amode_default = 0; ls->recent_touch = 0; /* immediately darken the display */ break; case NORM_BUTTON_ALARM_TIME: set_mode(ps, ls, DMODE_SETDEFALARM); ls->configuring_days = (1 << 7) - 1; ls->configuring_time = ps->defalarmtime[0]; /* no sensible default */ ls->saved_hours_digit = -1; break; case NORM_BUTTON_BACK: set_mode(ps, ls, DMODE_NORMAL); break; case NORM_BUTTON_RESET_TIME: set_mode(ps, ls, DMODE_SETRESET); ls->saved_hours_digit = -1; break; case NORM_BUTTON_SNOOZE_PERIOD: set_mode(ps, ls, DMODE_SETDEFSNOOZE); ls->saved_hours_digit = -1; break; case NORM_BUTTON_REDOWNLOAD: ret |= GET_EXCEPTIONS; break; case NORM_BUTTON_OFF_DAYS: set_mode(ps, ls, DMODE_SETOFFDAYS); break; case NORM_ADJUST_H10_UP: case NORM_ADJUST_H1_UP: case NORM_ADJUST_M10_UP: case NORM_ADJUST_M1_UP: case NORM_ADJUST_S10_UP: case NORM_ADJUST_S1_UP: case NORM_ADJUST_H10_DN: case NORM_ADJUST_H1_DN: case NORM_ADJUST_M10_DN: case NORM_ADJUST_M1_DN: case NORM_ADJUST_S10_DN: case NORM_ADJUST_S1_DN: switch (button) { case NORM_ADJUST_H10_UP: adj = +36000; break; case NORM_ADJUST_H1_UP: adj = +3600; break; case NORM_ADJUST_M10_UP: adj = +600; break; case NORM_ADJUST_M1_UP: adj = +60; break; case NORM_ADJUST_S10_UP: adj = +10; break; case NORM_ADJUST_S1_UP: adj = +1; break; case NORM_ADJUST_H10_DN: adj = -36000; break; case NORM_ADJUST_H1_DN: adj = -3600; break; case NORM_ADJUST_M10_DN: adj = -600; break; case NORM_ADJUST_M1_DN: adj = -60; break; case NORM_ADJUST_S10_DN: adj = -10; break; case NORM_ADJUST_S1_DN: adj = -1; break; } p = editable_value(ps, ls, &wrap, NULL); if (wrap) { /* * Special case when dealing with the upper digit of * the hours: if the digit becomes 2 and the old units * digit of the hours is greater than 3 and hence * undisplayable, we save it, and restore if the next * action is to change this digit again. */ if (abs(adj) == 36000) { int h1 = *p / 36000, h2 = *p / 3600 % 10; h1 += adj / 36000; h1 = (h1 + 3) % 3; if (h1 == 2 && h2 > 3) { ls->saved_hours_digit = h2; h2 = 3; } else { if (h1 != 2 && ls->saved_hours_digit > 0) h2 = ls->saved_hours_digit; ls->saved_hours_digit = -1; } *p = (h1 * 10 + h2) * 3600 + (*p % 3600); } else { /* * The normal case is simple. */ *p += adj; *p = (*p + 86400) % 86400; } } else { *p += adj; if (*p < 0) *p = 0; else if (*p >= 86400) *p = 86399; } if (ls->dmode == DMODE_SETSNOOZE) set_snooze(timeofday, ls); break; case OFFDAY_BUTTON_MONDAY: case OFFDAY_BUTTON_TUESDAY: case OFFDAY_BUTTON_WEDNESDAY: case OFFDAY_BUTTON_THURSDAY: case OFFDAY_BUTTON_FRIDAY: case OFFDAY_BUTTON_SATURDAY: case OFFDAY_BUTTON_SUNDAY: ps->offdays ^= 1 << (button - OFFDAY_BUTTON_MONDAY); break; case CONFIG_BUTTON_MONDAY: case CONFIG_BUTTON_TUESDAY: case CONFIG_BUTTON_WEDNESDAY: case CONFIG_BUTTON_THURSDAY: case CONFIG_BUTTON_FRIDAY: case CONFIG_BUTTON_SATURDAY: case CONFIG_BUTTON_SUNDAY: ls->configuring_days ^= 1 << (button - CONFIG_BUTTON_MONDAY); break; } return ret; }
void event_startup(int timeofday, int dayofweek, int date, struct pstate *ps, struct lstate *ls) { default_mode(timeofday, dayofweek, date, ps, ls); }
int Option::init(int argc, char **argv) { Option::application_argv0 = 0; Option::cpp_moc_mod = ""; Option::h_moc_mod = "moc_"; Option::lex_mod = "_lex"; Option::yacc_mod = "_yacc"; Option::prl_ext = ".prl"; Option::libtool_ext = ".la"; Option::pkgcfg_ext = ".pc"; Option::prf_ext = ".prf"; Option::js_ext = ".js"; Option::ui_ext = ".ui"; Option::h_ext << ".h" << ".hpp" << ".hh" << ".hxx"; Option::c_ext << ".c"; #ifndef Q_OS_WIN Option::h_ext << ".H"; #endif Option::cpp_moc_ext = ".moc"; Option::h_moc_ext = ".cpp"; Option::cpp_ext << ".cpp" << ".cc" << ".cxx"; #ifndef Q_OS_WIN Option::cpp_ext << ".C"; #endif Option::lex_ext = ".l"; Option::yacc_ext = ".y"; Option::pro_ext = ".pro"; #ifdef Q_OS_WIN Option::dirlist_sep = ";"; Option::shellPath = detectShellPath(); #else Option::dirlist_sep = ":"; #endif Option::sysenv_mod = "QMAKE_ENV_"; Option::field_sep = ' '; if(argc && argv) { Option::application_argv0 = argv[0]; QString argv0 = argv[0]; if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) Option::qmake_mode = default_mode(argv0); if(!argv0.isEmpty() && !QFileInfo(argv0).isRelative()) { Option::qmake_abslocation = argv0; } else if (argv0.contains(QLatin1Char('/')) #ifdef Q_OS_WIN || argv0.contains(QLatin1Char('\\')) #endif ) { //relative PWD Option::qmake_abslocation = QDir::current().absoluteFilePath(argv0); } else { //in the PATH QByteArray pEnv = qgetenv("PATH"); QDir currentDir = QDir::current(); #ifdef Q_OS_WIN QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(";")); #else QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(":")); #endif for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) { if ((*p).isEmpty()) continue; QString candidate = currentDir.absoluteFilePath(*p + QLatin1Char('/') + argv0); #ifdef Q_OS_WIN candidate += ".exe"; #endif if (QFile::exists(candidate)) { Option::qmake_abslocation = candidate; break; } } } if(!Option::qmake_abslocation.isNull()) Option::qmake_abslocation = QDir::cleanPath(Option::qmake_abslocation); } else { Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE; } const QByteArray envflags = qgetenv("QMAKEFLAGS"); if (!envflags.isNull()) { int env_argc = 0, env_size = 0, currlen=0; char quote = 0, **env_argv = NULL; for (int i = 0; i < envflags.size(); ++i) { if (!quote && (envflags.at(i) == '\'' || envflags.at(i) == '"')) { quote = envflags.at(i); } else if (envflags.at(i) == quote) { quote = 0; } else if (!quote && envflags.at(i) == ' ') { if (currlen && env_argv && env_argv[env_argc]) { env_argv[env_argc][currlen] = '\0'; currlen = 0; env_argc++; } } else { if(!env_argv || env_argc > env_size) { env_argv = (char **)realloc(env_argv, sizeof(char *)*(env_size+=10)); for(int i2 = env_argc; i2 < env_size; i2++) env_argv[i2] = NULL; } if(!env_argv[env_argc]) { currlen = 0; env_argv[env_argc] = (char*)malloc(255); } if(currlen < 255) env_argv[env_argc][currlen++] = envflags.at(i); } } if(env_argv) { if(env_argv[env_argc]) { env_argv[env_argc][currlen] = '\0'; currlen = 0; env_argc++; } parseCommandLine(env_argc, env_argv); for(int i2 = 0; i2 < env_size; i2++) { if(env_argv[i2]) free(env_argv[i2]); } free(env_argv); } } if(argc && argv) { int ret = parseCommandLine(argc, argv, 1); if(ret != Option::QMAKE_CMDLINE_SUCCESS) { if ((ret & Option::QMAKE_CMDLINE_SHOW_USAGE) != 0) usage(argv[0]); return ret; //return ret == QMAKE_CMDLINE_SHOW_USAGE ? usage(argv[0]) : false; } } //last chance for defaults if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { if(Option::mkfile::qmakespec.isNull() || Option::mkfile::qmakespec.isEmpty()) Option::mkfile::qmakespec = QString::fromLocal8Bit(qgetenv("QMAKESPEC").constData()); //try REALLY hard to do it for them, lazy.. if(Option::mkfile::project_files.isEmpty()) { QString pwd = qmake_getpwd(), proj = pwd + "/" + pwd.right(pwd.length() - (pwd.lastIndexOf('/') + 1)) + Option::pro_ext; if(QFile::exists(proj)) { Option::mkfile::project_files.append(proj); } else { //last try.. QStringList profiles = QDir(pwd).entryList(QStringList("*" + Option::pro_ext)); if(profiles.count() == 1) Option::mkfile::project_files.append(pwd + "/" + profiles[0]); } #ifndef QT_BUILD_QMAKE_LIBRARY if(Option::mkfile::project_files.isEmpty()) { usage(argv[0]); return Option::QMAKE_CMDLINE_ERROR; } #endif } } //defaults for globals if(Option::target_mode == Option::TARG_WIN_MODE) { Option::dir_sep = "\\"; Option::obj_ext = ".obj"; Option::res_ext = ".res"; } else { if(Option::target_mode == Option::TARG_MAC9_MODE) Option::dir_sep = ":"; else Option::dir_sep = "/"; Option::obj_ext = ".o"; } Option::qmake_abslocation = Option::fixPathToTargetOS(Option::qmake_abslocation); return QMAKE_CMDLINE_SUCCESS; }
int Option::init(int argc, char **argv) { Option::prf_ext = ".prf"; Option::pro_ext = ".pro"; Option::field_sep = ' '; if(argc && argv) { QString argv0 = argv[0]; if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) Option::qmake_mode = default_mode(argv0); if(!argv0.isEmpty() && !QFileInfo(argv0).isRelative()) { globals->qmake_abslocation = argv0; } else if (argv0.contains(QLatin1Char('/')) #ifdef Q_OS_WIN || argv0.contains(QLatin1Char('\\')) #endif ) { //relative PWD globals->qmake_abslocation = QDir::current().absoluteFilePath(argv0); } else { //in the PATH QByteArray pEnv = qgetenv("PATH"); QDir currentDir = QDir::current(); #ifdef Q_OS_WIN QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(";")); paths.prepend(QLatin1String(".")); #else QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(":")); #endif for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) { if ((*p).isEmpty()) continue; QString candidate = currentDir.absoluteFilePath(*p + QLatin1Char('/') + argv0); #ifdef Q_OS_WIN if (!candidate.endsWith(QLatin1String(".exe"))) candidate += QLatin1String(".exe"); #endif if (QFile::exists(candidate)) { globals->qmake_abslocation = candidate; break; } } } if (!globals->qmake_abslocation.isNull()) globals->qmake_abslocation = QDir::cleanPath(globals->qmake_abslocation); else // This is rather unlikely to ever happen on a modern system ... globals->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; } QMakeCmdLineParserState cmdstate(QDir::currentPath()); const QByteArray envflags = qgetenv("QMAKEFLAGS"); if (!envflags.isNull()) { QStringList args; QByteArray buf = ""; char quote = 0; bool hasWord = false; for (int i = 0; i < envflags.size(); ++i) { char c = envflags.at(i); if (!quote && (c == '\'' || c == '"')) { quote = c; } else if (c == quote) { quote = 0; } else if (!quote && c == ' ') { if (hasWord) { args << QString::fromLocal8Bit(buf); hasWord = false; buf = ""; } } else { buf += c; hasWord = true; } } if (hasWord) args << QString::fromLocal8Bit(buf); parseCommandLine(args, cmdstate); cmdstate.flush(); } if(argc && argv) { QStringList args; for (int i = 1; i < argc; i++) args << QString::fromLocal8Bit(argv[i]); while (!args.isEmpty()) { QString opt = args.at(0); 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 == "-unset") { Option::qmake_mode = Option::QMAKE_UNSET_PROPERTY; } else if (opt == "-query") { Option::qmake_mode = Option::QMAKE_QUERY_PROPERTY; } else if (opt == "-makefile") { Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE; } else { break; } args.takeFirst(); break; } int ret = parseCommandLine(args, cmdstate); if(ret != Option::QMAKE_CMDLINE_SUCCESS) { if ((ret & Option::QMAKE_CMDLINE_SHOW_USAGE) != 0) usage(argv[0]); return ret; //return ret == QMAKE_CMDLINE_SHOW_USAGE ? usage(argv[0]) : false; } globals->qmake_args = args; } globals->commitCommandLineArguments(cmdstate); globals->debugLevel = Option::debug_level; //last chance for defaults if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { globals->useEnvironment(); //try REALLY hard to do it for them, lazy.. if(Option::mkfile::project_files.isEmpty()) { QString proj = detectProjectFile(qmake_getpwd()); if(!proj.isNull()) Option::mkfile::project_files.append(proj); #ifndef QT_BUILD_QMAKE_LIBRARY if(Option::mkfile::project_files.isEmpty()) { usage(argv[0]); return Option::QMAKE_CMDLINE_ERROR; } #endif } } return QMAKE_CMDLINE_SUCCESS; }
bool Option::parseCommandLine(int argc, char **argv) { Option::cpp_moc_mod = ""; Option::h_moc_mod = "moc_"; Option::lex_mod = "_lex"; Option::yacc_mod = "_yacc"; Option::prl_ext = ".prl"; Option::libtool_ext = ".la"; Option::pkgcfg_ext = ".pc"; Option::prf_ext = ".prf"; Option::ui_ext = ".ui"; Option::h_ext << ".h" << ".hpp" << ".hh" << ".H" << ".hxx"; Option::cpp_moc_ext = ".moc"; Option::h_moc_ext = ".cpp"; Option::cpp_ext << ".cpp" << ".cc" << ".cxx" << ".C"; Option::lex_ext = ".l"; Option::yacc_ext = ".y"; if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) Option::qmake_mode = default_mode(argv[0]); if(const char *envflags = getenv("QMAKEFLAGS")) { int env_argc = 0, env_size = 0, currlen=0; char quote = 0, **env_argv = NULL; for(int i = 0; envflags[i]; i++) { if(!quote && (envflags[i] == '\'' || envflags[i] == '"')) { quote = envflags[i]; } else if(envflags[i] == quote) { quote = 0; } else if(!quote && envflags[i] == ' ') { if(currlen && env_argv && env_argv[env_argc]) { env_argv[env_argc][currlen] = '\0'; currlen = 0; env_argc++; } } else { if(!env_argv || env_argc > env_size) { env_argv = (char **)realloc(env_argv, sizeof(char *)*(env_size+=10)); for(int i2 = env_argc; i2 < env_size; i2++) env_argv[i2] = NULL; } if(!env_argv[env_argc]) { currlen = 0; env_argv[env_argc] = (char*)malloc(255); } if(currlen < 255) env_argv[env_argc][currlen++] = envflags[i]; } } if(env_argv[env_argc]) { env_argv[env_argc][currlen] = '\0'; currlen = 0; env_argc++; } internalParseCommandLine(env_argc, env_argv); for(int i2 = 0; i2 < env_size; i2++) { if(env_argv[i2]) free(env_argv[i2]); } free(env_argv); } { int ret = internalParseCommandLine(argc, argv, 1); if(ret != QMAKE_CMDLINE_SUCCESS) return ret == QMAKE_CMDLINE_SHOW_USAGE ? usage(argv[0]) : FALSE; } //last chance for defaults if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { if(Option::mkfile::qmakespec.isNull() || Option::mkfile::qmakespec.isEmpty()) Option::mkfile::qmakespec = getenv("QMAKESPEC"); //try REALLY hard to do it for them, lazy.. if(Option::mkfile::project_files.isEmpty()) { QString pwd = QDir::currentDirPath(), proj = pwd + "/" + pwd.right(pwd.length() - (pwd.findRev('/') + 1)) + ".pro"; if(QFile::exists(proj)) { Option::mkfile::project_files.append(proj); } else { //last try.. QDir d(pwd, "*.pro"); if(d.count() != 1) return usage(argv[0]); Option::mkfile::project_files.append(pwd + "/" + d[0]); } } } //defaults for globals if(Option::target_mode == Option::TARG_WIN_MODE || Option::target_mode == Option::TARG_OS2_MODE) { Option::dir_sep = "\\"; Option::obj_ext = ".obj"; } else { if(Option::target_mode == Option::TARG_MAC9_MODE) Option::dir_sep = ":"; else Option::dir_sep = "/"; Option::obj_ext = ".o"; } return TRUE; }