author | zecke <zecke> | 2004-07-15 17:36:57 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-15 17:36:57 (UTC) |
commit | 323e9a7472a110b4befba7320540263147505bae (patch) (side-by-side diff) | |
tree | 14c810bdb9c0603a30356b17b4bdf9ccb72741c6 /qmake/option.cpp | |
parent | aa292b322f1ecb43dd8f4e3cd295855730dd9f59 (diff) | |
download | opie-323e9a7472a110b4befba7320540263147505bae.zip opie-323e9a7472a110b4befba7320540263147505bae.tar.gz opie-323e9a7472a110b4befba7320540263147505bae.tar.bz2 |
Manually updatet to qmake1.06a which includes support for precompiled
headers.
Opies 'PRO' keyword was already reintroduced
-rw-r--r-- | qmake/option.cpp | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/qmake/option.cpp b/qmake/option.cpp index 8b7e5e8..e6928fa 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -1,18 +1,16 @@ /**************************************************************************** -** $Id$ ** -** Definition of ________ class. ** -** Created : 970521 +** Implementation of Option class. ** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. ** -** This file is part of the network module of the Qt GUI Toolkit. +** This file is part of qmake. ** ** This file may be distributed under the terms of the Q Public License ** as defined by Trolltech AS of Norway and appearing in the file ** LICENSE.QPL included in the packaging of this file. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the @@ -39,25 +37,29 @@ #include <qdir.h> #include <qregexp.h> #include <stdlib.h> #include <stdarg.h> //convenience QString Option::prf_ext; QString Option::prl_ext; +QString Option::libtool_ext; +QString Option::pkgcfg_ext; QString Option::ui_ext; QStringList Option::h_ext; -QString Option::moc_ext; +QString Option::cpp_moc_ext; +QString Option::h_moc_ext; QStringList Option::cpp_ext; QString Option::obj_ext; QString Option::lex_ext; QString Option::yacc_ext; QString Option::dir_sep; -QString Option::moc_mod; +QString Option::h_moc_mod; +QString Option::cpp_moc_mod; QString Option::yacc_mod; QString Option::lex_mod; //mode Option::QMAKE_MODE Option::qmake_mode = Option::QMAKE_GENERATE_NOTHING; //all modes int Option::warn_level = WarnLogic; @@ -75,16 +77,19 @@ Option::TARG_MODE Option::target_mode = Option::TARG_MAC9_MODE; #elif defined(Q_OS_MACX) Option::TARG_MODE Option::target_mode = Option::TARG_MACX_MODE; #elif defined(Q_OS_QNX6) Option::TARG_MODE Option::target_mode = Option::TARG_QNX6_MODE; #else Option::TARG_MODE Option::target_mode = Option::TARG_UNIX_MODE; #endif +//QMAKE_*_PROPERTY stuff +QStringList Option::prop::properties; + //QMAKE_GENERATE_PROJECT stuff bool Option::projfile::do_pwd = TRUE; bool Option::projfile::do_recursive = TRUE; QStringList Option::projfile::project_dirs; //QMAKE_GENERATE_MAKEFILE stuff QString Option::mkfile::qmakespec; int Option::mkfile::cachefile_depth = -1; @@ -99,16 +104,18 @@ QString Option::mkfile::qmakespec_commandline; static Option::QMAKE_MODE default_mode(QString progname) { int s = progname.findRev(Option::dir_sep); if(s != -1) progname = progname.right(progname.length() - (s + 1)); if(progname == "qmakegen") return Option::QMAKE_GENERATE_PROJECT; + else if(progname == "qt-config") + return Option::QMAKE_QUERY_PROPERTY; return Option::QMAKE_GENERATE_MAKEFILE; } QString project_builtin_regx(); bool usage(const char *a0) { fprintf(stdout, "Usage: %s [mode] [options] [files]\n" "\n" @@ -156,33 +163,42 @@ bool usage(const char *a0) "\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; } -bool +enum { + QMAKE_CMDLINE_SUCCESS, + QMAKE_CMDLINE_SHOW_USAGE, + QMAKE_CMDLINE_BAIL +}; +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; } @@ -203,19 +219,19 @@ Option::internalParseCommandLine(int argc, char **argv, int skip) 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(stderr, "Qmake version: %s (Qt %s)\n", qmake_version(), QT_VERSION_STR); fprintf(stderr, "Qmake is free software from Trolltech AS.\n"); - return FALSE; + return QMAKE_CMDLINE_BAIL; } else if(opt == "h" || opt == "help") { - return FALSE; + 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; @@ -234,65 +250,79 @@ Option::internalParseCommandLine(int argc, char **argv, int skip) 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 usage(argv[0]); + 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 FALSE; + 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 + 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 TRUE; + } + return QMAKE_CMDLINE_SUCCESS; } bool Option::parseCommandLine(int argc, char **argv) { - Option::moc_mod = "moc_"; + 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::moc_ext = ".moc"; + 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; @@ -329,18 +359,21 @@ Option::parseCommandLine(int argc, char **argv) } internalParseCommandLine(env_argc, env_argv); for(int i2 = 0; i2 < env_size; i2++) { if(env_argv[i2]) free(env_argv[i2]); } free(env_argv); } - if(!internalParseCommandLine(argc, argv, 1)) - return usage(argv[0]); + { + 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.. @@ -376,32 +409,40 @@ bool Option::postProcessProject(QMakeProject *project) { Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"]; if(cpp_ext.isEmpty()) cpp_ext << ".cpp"; //something must be there Option::h_ext = project->variables()["QMAKE_EXT_H"]; if(h_ext.isEmpty()) h_ext << ".h"; + if(!project->isEmpty("QMAKE_EXT_PKGCONFIG")) + Option::pkgcfg_ext = project->first("QMAKE_EXT_PKGCONFIG"); + if(!project->isEmpty("QMAKE_EXT_LIBTOOL")) + Option::libtool_ext = project->first("QMAKE_EXT_LIBTOOL"); if(!project->isEmpty("QMAKE_EXT_PRL")) Option::prl_ext = project->first("QMAKE_EXT_PRL"); if(!project->isEmpty("QMAKE_EXT_PRF")) Option::prf_ext = project->first("QMAKE_EXT_PRF"); if(!project->isEmpty("QMAKE_EXT_UI")) Option::ui_ext = project->first("QMAKE_EXT_UI"); - if(!project->isEmpty("QMAKE_EXT_MOC")) - Option::moc_ext = project->first("QMAKE_EXT_MOC"); + if(!project->isEmpty("QMAKE_EXT_CPP_MOC")) + Option::cpp_moc_ext = project->first("QMAKE_EXT_CPP_MOC"); + if(!project->isEmpty("QMAKE_EXT_H_MOC")) + Option::h_moc_ext = project->first("QMAKE_EXT_H_MOC"); if(!project->isEmpty("QMAKE_EXT_LEX")) Option::lex_ext = project->first("QMAKE_EXT_LEX"); if(!project->isEmpty("QMAKE_EXT_YACC")) Option::yacc_ext = project->first("QMAKE_EXT_YACC"); if(!project->isEmpty("QMAKE_EXT_OBJ")) Option::obj_ext = project->first("QMAKE_EXT_OBJ"); - if(!project->isEmpty("QMAKE_MOD_MOC")) - Option::moc_mod = project->first("QMAKE_MOD_MOC"); + if(!project->isEmpty("QMAKE_H_MOD_MOC")) + Option::h_moc_mod = project->first("QMAKE_H_MOD_MOC"); + if(!project->isEmpty("QMAKE_CPP_MOD_MOC")) + Option::cpp_moc_mod = project->first("QMAKE_CPP_MOD_MOC"); if(!project->isEmpty("QMAKE_MOD_LEX")) Option::lex_mod = project->first("QMAKE_MOD_LEX"); if(!project->isEmpty("QMAKE_MOD_YACC")) Option::yacc_mod = project->first("QMAKE_MOD_YACC"); if(!project->isEmpty("QMAKE_DIR_SEP")) Option::dir_sep = project->first("QMAKE_DIR_SEP"); return TRUE; } |