author | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
commit | 155d68c1e7d7dc0fed2534ac43d6d77ce2781f55 (patch) (unidiff) | |
tree | e6edaa5a7040fe6c224c3943d1094dcf02e4f74c /qmake/option.cpp | |
parent | 86703e8a5527ef114facd02c005b6b3a7e62e263 (diff) | |
download | opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.zip opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.gz opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.bz2 |
update qmake to 1.05a
-rw-r--r-- | qmake/option.cpp | 153 |
1 files changed, 104 insertions, 49 deletions
diff --git a/qmake/option.cpp b/qmake/option.cpp index 34b3ee2..8b7e5e8 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp | |||
@@ -84,3 +84,3 @@ Option::TARG_MODE Option::target_mode = Option::TARG_UNIX_MODE; | |||
84 | bool Option::projfile::do_pwd = TRUE; | 84 | bool Option::projfile::do_pwd = TRUE; |
85 | bool Option::projfile::do_recursive = FALSE; | 85 | bool Option::projfile::do_recursive = TRUE; |
86 | QStringList Option::projfile::project_dirs; | 86 | QStringList Option::projfile::project_dirs; |
@@ -99,2 +99,13 @@ QString Option::mkfile::qmakespec_commandline; | |||
99 | 99 | ||
100 | static Option::QMAKE_MODE default_mode(QString progname) | ||
101 | { | ||
102 | int s = progname.findRev(Option::dir_sep); | ||
103 | if(s != -1) | ||
104 | progname = progname.right(progname.length() - (s + 1)); | ||
105 | if(progname == "qmakegen") | ||
106 | return Option::QMAKE_GENERATE_PROJECT; | ||
107 | return Option::QMAKE_GENERATE_MAKEFILE; | ||
108 | } | ||
109 | |||
110 | QString project_builtin_regx(); | ||
100 | bool usage(const char *a0) | 111 | bool usage(const char *a0) |
@@ -109,7 +120,7 @@ bool usage(const char *a0) | |||
109 | "Mode:\n" | 120 | "Mode:\n" |
110 | "\t-project Put qmake into project file generation mode\n" | 121 | "\t-project Put qmake into project file generation mode%s\n" |
111 | "\t In this mode qmake interprets files as files to\n" | 122 | "\t In this mode qmake interprets files as files to\n" |
112 | "\t be built,\n" | 123 | "\t be built,\n" |
113 | "\t defaults to *.cpp; *.l; *.y; *.ui\n" | 124 | "\t defaults to %s\n" |
114 | "\t-makefile Put qmake into makefile generation mode (default)\n" | 125 | "\t-makefile Put qmake into makefile generation mode%s\n" |
115 | "\t In this mode qmake interprets files as project files to\n" | 126 | "\t In this mode qmake interprets files as project files to\n" |
@@ -138,3 +149,3 @@ bool usage(const char *a0) | |||
138 | "\t-after All variable assignments after this will be\n" | 149 | "\t-after All variable assignments after this will be\n" |
139 | "\t parsed after [files] [makefile mode only]\n" | 150 | "\t parsed after [files]\n" |
140 | "\t-cache file Use file as cache [makefile mode only]\n" | 151 | "\t-cache file Use file as cache [makefile mode only]\n" |
@@ -145,22 +156,14 @@ bool usage(const char *a0) | |||
145 | "\t-nopwd Don't look for files in pwd [ project mode only]\n" | 156 | "\t-nopwd Don't look for files in pwd [ project mode only]\n" |
146 | "\t-r Recursive search [ project mode only]\n" | 157 | "\t-norecursive Don't do a recursive search [ project mode only]\n" |
147 | ,a0); | 158 | ,a0, |
159 | default_mode(a0) == Option::QMAKE_GENERATE_PROJECT ? " (default)" : "", project_builtin_regx().latin1(), | ||
160 | default_mode(a0) == Option::QMAKE_GENERATE_MAKEFILE ? " (default)" : ""); | ||
148 | return FALSE; | 161 | return FALSE; |
149 | } | 162 | } |
150 | static Option::QMAKE_MODE default_mode(QString progname) | ||
151 | { | ||
152 | int s = progname.findRev(Option::dir_sep); | ||
153 | if(s != -1) | ||
154 | progname = progname.right(progname.length() - (s + 1)); | ||
155 | if(progname == "qmakegen") | ||
156 | return Option::QMAKE_GENERATE_PROJECT; | ||
157 | return Option::QMAKE_GENERATE_MAKEFILE; | ||
158 | } | ||
159 | |||
160 | 163 | ||
161 | bool | 164 | bool |
162 | Option::parseCommandLine(int argc, char **argv) | 165 | Option::internalParseCommandLine(int argc, char **argv, int skip) |
163 | { | 166 | { |
164 | bool before = TRUE; | 167 | bool before = TRUE; |
165 | for(int x = 1; x < argc; x++) { | 168 | for(int x = skip; x < argc; x++) { |
166 | if(*argv[x] == '-' && strlen(argv[x]) > 1) { /* options */ | 169 | if(*argv[x] == '-' && strlen(argv[x]) > 1) { /* options */ |
@@ -181,3 +184,2 @@ Option::parseCommandLine(int argc, char **argv) | |||
181 | specified = FALSE; | 184 | specified = FALSE; |
182 | Option::qmake_mode = default_mode(argv[0]); | ||
183 | } | 185 | } |
@@ -206,3 +208,3 @@ Option::parseCommandLine(int argc, char **argv) | |||
206 | } else if(opt == "version" || opt == "v" || opt == "-version") { | 208 | } else if(opt == "version" || opt == "v" || opt == "-version") { |
207 | fprintf(stderr, "Qmake version: %s\n", qmake_version()); | 209 | fprintf(stderr, "Qmake version: %s (Qt %s)\n", qmake_version(), QT_VERSION_STR); |
208 | fprintf(stderr, "Qmake is free software from Trolltech AS.\n"); | 210 | fprintf(stderr, "Qmake is free software from Trolltech AS.\n"); |
@@ -210,3 +212,3 @@ Option::parseCommandLine(int argc, char **argv) | |||
210 | } else if(opt == "h" || opt == "help") { | 212 | } else if(opt == "h" || opt == "help") { |
211 | return usage(argv[0]); | 213 | return FALSE; |
212 | } else if(opt == "Wall") { | 214 | } else if(opt == "Wall") { |
@@ -246,5 +248,7 @@ Option::parseCommandLine(int argc, char **argv) | |||
246 | Option::projfile::do_recursive = TRUE; | 248 | Option::projfile::do_recursive = TRUE; |
249 | } else if(opt == "norecursive") { | ||
250 | Option::projfile::do_recursive = FALSE; | ||
247 | } else { | 251 | } else { |
248 | fprintf(stderr, "***Unknown option -%s\n", opt.latin1()); | 252 | fprintf(stderr, "***Unknown option -%s\n", opt.latin1()); |
249 | return usage(argv[0]); | 253 | return FALSE; |
250 | } | 254 | } |
@@ -253,5 +257,2 @@ Option::parseCommandLine(int argc, char **argv) | |||
253 | } else { | 257 | } else { |
254 | if(x == 1) | ||
255 | Option::qmake_mode = default_mode(argv[0]); | ||
256 | |||
257 | QString arg = argv[x]; | 258 | QString arg = argv[x]; |
@@ -274,4 +275,65 @@ Option::parseCommandLine(int argc, char **argv) | |||
274 | } | 275 | } |
276 | return TRUE; | ||
277 | } | ||
278 | |||
279 | |||
280 | bool | ||
281 | Option::parseCommandLine(int argc, char **argv) | ||
282 | { | ||
283 | Option::moc_mod = "moc_"; | ||
284 | Option::lex_mod = "_lex"; | ||
285 | Option::yacc_mod = "_yacc"; | ||
286 | Option::prl_ext = ".prl"; | ||
287 | Option::prf_ext = ".prf"; | ||
288 | Option::ui_ext = ".ui"; | ||
289 | Option::h_ext << ".h" << ".hpp" << ".hh" << ".H" << ".hxx"; | ||
290 | Option::moc_ext = ".moc"; | ||
291 | Option::cpp_ext << ".cpp" << ".cc" << ".cxx" << ".C"; | ||
292 | Option::lex_ext = ".l"; | ||
293 | Option::yacc_ext = ".y"; | ||
294 | |||
275 | if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) | 295 | if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) |
276 | Option::qmake_mode = default_mode(argv[0]); | 296 | Option::qmake_mode = default_mode(argv[0]); |
297 | if(const char *envflags = getenv("QMAKEFLAGS")) { | ||
298 | int env_argc = 0, env_size = 0, currlen=0; | ||
299 | char quote = 0, **env_argv = NULL; | ||
300 | for(int i = 0; envflags[i]; i++) { | ||
301 | if(!quote && (envflags[i] == '\'' || envflags[i] == '"')) { | ||
302 | quote = envflags[i]; | ||
303 | } else if(envflags[i] == quote) { | ||
304 | quote = 0; | ||
305 | } else if(!quote && envflags[i] == ' ') { | ||
306 | if(currlen && env_argv && env_argv[env_argc]) { | ||
307 | env_argv[env_argc][currlen] = '\0'; | ||
308 | currlen = 0; | ||
309 | env_argc++; | ||
310 | } | ||
311 | } else { | ||
312 | if(!env_argv || env_argc > env_size) { | ||
313 | env_argv = (char **)realloc(env_argv, sizeof(char *)*(env_size+=10)); | ||
314 | for(int i2 = env_argc; i2 < env_size; i2++) | ||
315 | env_argv[i2] = NULL; | ||
316 | } | ||
317 | if(!env_argv[env_argc]) { | ||
318 | currlen = 0; | ||
319 | env_argv[env_argc] = (char*)malloc(255); | ||
320 | } | ||
321 | if(currlen < 255) | ||
322 | env_argv[env_argc][currlen++] = envflags[i]; | ||
323 | } | ||
324 | } | ||
325 | if(env_argv[env_argc]) { | ||
326 | env_argv[env_argc][currlen] = '\0'; | ||
327 | currlen = 0; | ||
328 | env_argc++; | ||
329 | } | ||
330 | internalParseCommandLine(env_argc, env_argv); | ||
331 | for(int i2 = 0; i2 < env_size; i2++) { | ||
332 | if(env_argv[i2]) | ||
333 | free(env_argv[i2]); | ||
334 | } | ||
335 | free(env_argv); | ||
336 | } | ||
337 | if(!internalParseCommandLine(argc, argv, 1)) | ||
338 | return usage(argv[0]); | ||
277 | 339 | ||
@@ -285,8 +347,12 @@ Option::parseCommandLine(int argc, char **argv) | |||
285 | if(Option::mkfile::project_files.isEmpty()) { | 347 | if(Option::mkfile::project_files.isEmpty()) { |
286 | QString proj = QDir::currentDirPath(); | 348 | QString pwd = QDir::currentDirPath(), |
287 | proj = proj.right(proj.length() - (proj.findRev('/') + 1)) + ".pro"; | 349 | proj = pwd + "/" + pwd.right(pwd.length() - (pwd.findRev('/') + 1)) + ".pro"; |
288 | if(QFile::exists(proj)) | 350 | if(QFile::exists(proj)) { |
289 | Option::mkfile::project_files.append(proj); | 351 | Option::mkfile::project_files.append(proj); |
290 | else | 352 | } else { //last try.. |
291 | return usage(argv[0]); | 353 | QDir d(pwd, "*.pro"); |
354 | if(d.count() != 1) | ||
355 | return usage(argv[0]); | ||
356 | Option::mkfile::project_files.append(pwd + "/" + d[0]); | ||
357 | } | ||
292 | } | 358 | } |
@@ -295,13 +361,2 @@ Option::parseCommandLine(int argc, char **argv) | |||
295 | //defaults for globals | 361 | //defaults for globals |
296 | Option::moc_mod = "moc_"; | ||
297 | Option::lex_mod = "_lex"; | ||
298 | Option::yacc_mod = "_yacc"; | ||
299 | Option::prl_ext = ".prl"; | ||
300 | Option::prf_ext = ".prf"; | ||
301 | Option::ui_ext = ".ui"; | ||
302 | Option::h_ext << ".h" << ".hpp" << ".hh" << ".H" << ".hxx"; | ||
303 | Option::moc_ext = ".moc"; | ||
304 | Option::cpp_ext << ".cpp" << ".cc" << ".cxx" << ".C"; | ||
305 | Option::lex_ext = ".l"; | ||
306 | Option::yacc_ext = ".y"; | ||
307 | if(Option::target_mode == Option::TARG_WIN_MODE) { | 362 | if(Option::target_mode == Option::TARG_WIN_MODE) { |
@@ -388,9 +443,9 @@ Option::fixPathToTargetOS(const QString& in, bool fix_env, bool canonical) | |||
388 | QString rep; | 443 | QString rep; |
389 | if(Option::target_mode == TARG_MAC9_MODE) | 444 | if(Option::target_mode == TARG_MAC9_MODE) |
390 | rep = "[/\\\\]"; | 445 | tmp = tmp.replace('/', Option::dir_sep).replace('\\', Option::dir_sep); |
391 | else if(Option::target_mode == TARG_WIN_MODE) | 446 | else if(Option::target_mode == TARG_WIN_MODE) |
392 | rep = "[/]"; | 447 | tmp = tmp.replace('/', Option::dir_sep); |
393 | else | 448 | else |
394 | rep = "[\\\\]"; | 449 | tmp = tmp.replace('\\', Option::dir_sep); |
395 | return tmp.replace(QRegExp(rep), Option::dir_sep); | 450 | return tmp; |
396 | } | 451 | } |