-rw-r--r-- | qmake/generators/makefile.cpp | 548 |
1 files changed, 391 insertions, 157 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index c12375d..5ce387f 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp | |||
@@ -1,16 +1,14 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | ||
3 | ** | 2 | ** |
4 | ** Definition of ________ class. | ||
5 | ** | 3 | ** |
6 | ** Created : 970521 | 4 | ** Implementation of MakefileGenerator class. |
7 | ** | 5 | ** |
8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. | 6 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. |
9 | ** | 7 | ** |
10 | ** This file is part of the network module of the Qt GUI Toolkit. | 8 | ** This file is part of qmake. |
11 | ** | 9 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 10 | ** This file may be distributed under the terms of the Q Public License |
13 | ** as defined by Trolltech AS of Norway and appearing in the file | 11 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 12 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 13 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 14 | ** This file may be distributed and/or modified under the terms of the |
@@ -34,12 +32,13 @@ | |||
34 | ** not clear to you. | 32 | ** not clear to you. |
35 | ** | 33 | ** |
36 | **********************************************************************/ | 34 | **********************************************************************/ |
37 | 35 | ||
38 | #include "makefile.h" | 36 | #include "makefile.h" |
39 | #include "option.h" | 37 | #include "option.h" |
38 | #include "meta.h" | ||
40 | #include <qdir.h> | 39 | #include <qdir.h> |
41 | #include <qfile.h> | 40 | #include <qfile.h> |
42 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
43 | #include <qregexp.h> | 42 | #include <qregexp.h> |
44 | #include <qdict.h> | 43 | #include <qdict.h> |
45 | #if defined(Q_OS_UNIX) | 44 | #if defined(Q_OS_UNIX) |
@@ -55,14 +54,15 @@ | |||
55 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
56 | 55 | ||
57 | // Well, Windows doesn't have this, so here's the macro | 56 | // Well, Windows doesn't have this, so here's the macro |
58 | #ifndef S_ISDIR | 57 | #ifndef S_ISDIR |
59 | #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR) | 58 | #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR) |
60 | #endif | 59 | #endif |
60 | #define QMAKE_EOL(x) (x == '\r' || x == '\n') | ||
61 | 61 | ||
62 | static QString mkdir_p_asstring(const QString &dir) | 62 | QString mkdir_p_asstring(const QString &dir) |
63 | { | 63 | { |
64 | QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" "; | 64 | QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" "; |
65 | if(Option::target_mode == Option::TARG_WIN_MODE) | 65 | if(Option::target_mode == Option::TARG_WIN_MODE) |
66 | ret += "$(MKDIR)"; | 66 | ret += "$(MKDIR)"; |
67 | else | 67 | else |
68 | ret += "|| $(MKDIR)"; | 68 | ret += "|| $(MKDIR)"; |
@@ -71,13 +71,12 @@ static QString mkdir_p_asstring(const QString &dir) | |||
71 | } | 71 | } |
72 | 72 | ||
73 | static bool createDir(const QString& fullPath) | 73 | static bool createDir(const QString& fullPath) |
74 | { | 74 | { |
75 | if(QFile::exists(fullPath)) | 75 | if(QFile::exists(fullPath)) |
76 | return FALSE; | 76 | return FALSE; |
77 | |||
78 | QDir dirTmp; | 77 | QDir dirTmp; |
79 | bool ret = TRUE; | 78 | bool ret = TRUE; |
80 | QString pathComponent, tmpPath; | 79 | QString pathComponent, tmpPath; |
81 | QStringList hierarchy = QStringList::split(QString(Option::dir_sep), fullPath, TRUE); | 80 | QStringList hierarchy = QStringList::split(QString(Option::dir_sep), fullPath, TRUE); |
82 | for(QStringList::Iterator it = hierarchy.begin(); it != hierarchy.end(); ++it) { | 81 | for(QStringList::Iterator it = hierarchy.begin(); it != hierarchy.end(); ++it) { |
83 | pathComponent = *it + QDir::separator(); | 82 | pathComponent = *it + QDir::separator(); |
@@ -139,13 +138,13 @@ MakefileGenerator::generateMocList(const QString &fn_target) | |||
139 | int x; | 138 | int x; |
140 | for(x = 0; x < (total_size_read-COMP_LEN); x++) { | 139 | for(x = 0; x < (total_size_read-COMP_LEN); x++) { |
141 | if(*(big_buffer + x) == '/') { | 140 | if(*(big_buffer + x) == '/') { |
142 | x++; | 141 | x++; |
143 | if(total_size_read >= x) { | 142 | if(total_size_read >= x) { |
144 | if(*(big_buffer + x) == '/') { //c++ style comment | 143 | if(*(big_buffer + x) == '/') { //c++ style comment |
145 | for( ;x < total_size_read && *(big_buffer + x) != '\n'; x++); | 144 | for( ;x < total_size_read && !QMAKE_EOL(*(big_buffer + x)); x++); |
146 | line_count++; | 145 | line_count++; |
147 | } else if(*(big_buffer + x) == '*') { //c style comment | 146 | } else if(*(big_buffer + x) == '*') { //c style comment |
148 | for( ;x < total_size_read; x++) { | 147 | for( ;x < total_size_read; x++) { |
149 | if(*(big_buffer + x) == 't' || *(big_buffer + x) == 'q') { //ignore | 148 | if(*(big_buffer + x) == 't' || *(big_buffer + x) == 'q') { //ignore |
150 | if(total_size_read >= (x + 20)) { | 149 | if(total_size_read >= (x + 20)) { |
151 | if(!strncmp(big_buffer + x + 1, "make ignore Q_OBJECT", 20)) { | 150 | if(!strncmp(big_buffer + x + 1, "make ignore Q_OBJECT", 20)) { |
@@ -157,13 +156,13 @@ MakefileGenerator::generateMocList(const QString &fn_target) | |||
157 | } | 156 | } |
158 | } else if(*(big_buffer + x) == '*') { | 157 | } else if(*(big_buffer + x) == '*') { |
159 | if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') { | 158 | if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') { |
160 | x += 2; | 159 | x += 2; |
161 | break; | 160 | break; |
162 | } | 161 | } |
163 | } else if(*(big_buffer + x) == '\n') { | 162 | } else if(QMAKE_EOL(*(big_buffer + x))) { |
164 | line_count++; | 163 | line_count++; |
165 | } | 164 | } |
166 | } | 165 | } |
167 | } | 166 | } |
168 | } | 167 | } |
169 | } | 168 | } |
@@ -203,20 +202,20 @@ MakefileGenerator::generateMocList(const QString &fn_target) | |||
203 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); | 202 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); |
204 | cppit != Option::cpp_ext.end(); ++cppit) { | 203 | cppit != Option::cpp_ext.end(); ++cppit) { |
205 | if((cpp_ext = (fn_target.right(ext_len) == (*cppit)))) | 204 | if((cpp_ext = (fn_target.right(ext_len) == (*cppit)))) |
206 | break; | 205 | break; |
207 | } | 206 | } |
208 | if(cpp_ext) { | 207 | if(cpp_ext) { |
209 | mocFile += fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::moc_ext; | 208 | mocFile += Option::cpp_moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::cpp_moc_ext; |
210 | project->variables()["_SRCMOC"].append(mocFile); | 209 | project->variables()["_SRCMOC"].append(mocFile); |
211 | } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) { | 210 | } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) { |
212 | for(QStringList::Iterator hit = Option::h_ext.begin(); | 211 | for(QStringList::Iterator hit = Option::h_ext.begin(); |
213 | hit != Option::h_ext.end(); ++hit) { | 212 | hit != Option::h_ext.end(); ++hit) { |
214 | if((fn_target.right(ext_len) == (*hit))) { | 213 | if((fn_target.right(ext_len) == (*hit))) { |
215 | mocFile += Option::moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + | 214 | mocFile += Option::h_moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + |
216 | Option::cpp_ext.first(); | 215 | Option::h_moc_ext; |
217 | logicWarn(mocFile, "SOURCES"); | 216 | logicWarn(mocFile, "SOURCES"); |
218 | project->variables()["_HDRMOC"].append(mocFile); | 217 | project->variables()["_HDRMOC"].append(mocFile); |
219 | break; | 218 | break; |
220 | } | 219 | } |
221 | } | 220 | } |
222 | } | 221 | } |
@@ -229,26 +228,28 @@ MakefileGenerator::generateMocList(const QString &fn_target) | |||
229 | break; | 228 | break; |
230 | } | 229 | } |
231 | } | 230 | } |
232 | 231 | ||
233 | while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x))) | 232 | while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x))) |
234 | x++; | 233 | x++; |
235 | if(*(big_buffer+x) == '\n') | 234 | if(QMAKE_EOL(*(big_buffer+x))) |
236 | line_count++; | 235 | line_count++; |
237 | } | 236 | } |
238 | #undef OBJ_LEN | 237 | #undef OBJ_LEN |
239 | #undef DIS_LEN | 238 | #undef DIS_LEN |
240 | return TRUE; | 239 | return TRUE; |
241 | } | 240 | } |
242 | 241 | ||
243 | bool | 242 | bool |
244 | MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse) | 243 | MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse) |
245 | { | 244 | { |
246 | QStringList &fndeps = findDependencies(f); | 245 | if(processedDependencies(f)) |
247 | if(!fndeps.isEmpty()) | ||
248 | return TRUE; | 246 | return TRUE; |
247 | setProcessedDependencies(f, TRUE); | ||
248 | |||
249 | QStringList &fndeps = findDependencies(f); | ||
249 | QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir); | 250 | QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir); |
250 | fn = Option::fixPathToLocalOS(fn, FALSE); | 251 | fn = Option::fixPathToLocalOS(fn, FALSE); |
251 | QString fix_env_fn = Option::fixPathToLocalOS(fn); | 252 | QString fix_env_fn = Option::fixPathToLocalOS(fn); |
252 | int file = open(fix_env_fn.latin1(), O_RDONLY); | 253 | int file = open(fix_env_fn.latin1(), O_RDONLY); |
253 | if(file == -1) | 254 | if(file == -1) |
254 | return FALSE; | 255 | return FALSE; |
@@ -280,27 +281,30 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const | |||
280 | QString inc; | 281 | QString inc; |
281 | if(!ui_file) { | 282 | if(!ui_file) { |
282 | if(*(big_buffer + x) == '/') { | 283 | if(*(big_buffer + x) == '/') { |
283 | x++; | 284 | x++; |
284 | if(total_size_read >= x) { | 285 | if(total_size_read >= x) { |
285 | if(*(big_buffer + x) == '/') { //c++ style comment | 286 | if(*(big_buffer + x) == '/') { //c++ style comment |
286 | for( ; x < total_size_read && *(big_buffer + x) != '\n'; x++); | 287 | for( ; x < total_size_read && !QMAKE_EOL(*(big_buffer + x)); x++); |
287 | } else if(*(big_buffer + x) == '*') { //c style comment | 288 | } else if(*(big_buffer + x) == '*') { //c style comment |
288 | for( ; x < total_size_read; x++) { | 289 | for( ; x < total_size_read; x++) { |
289 | if(*(big_buffer + x) == '*') { | 290 | if(*(big_buffer + x) == '*') { |
290 | if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') { | 291 | if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') { |
291 | x += 2; | 292 | x += 2; |
292 | break; | 293 | break; |
293 | } | 294 | } |
294 | } else if(*(big_buffer + x) == '\n') { | 295 | } else if(QMAKE_EOL(*(big_buffer + x))) { |
295 | line_count++; | 296 | line_count++; |
296 | } | 297 | } |
297 | } | 298 | } |
298 | } | 299 | } |
299 | } | 300 | } |
300 | } | 301 | } |
302 | while(x < total_size_read && //Skip spaces | ||
303 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) | ||
304 | x++; | ||
301 | if(*(big_buffer + x) == '#') { | 305 | if(*(big_buffer + x) == '#') { |
302 | x++; | 306 | x++; |
303 | while(x < total_size_read && //Skip spaces after hash | 307 | while(x < total_size_read && //Skip spaces after hash |
304 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) | 308 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) |
305 | x++; | 309 | x++; |
306 | if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && | 310 | if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && |
@@ -315,50 +319,73 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const | |||
315 | term = '>'; | 319 | term = '>'; |
316 | else | 320 | else |
317 | continue; //wtf? | 321 | continue; //wtf? |
318 | x++; | 322 | x++; |
319 | 323 | ||
320 | int inc_len; | 324 | int inc_len; |
321 | for(inc_len = 0; *(big_buffer + x + inc_len) != term; inc_len++); | 325 | for(inc_len = 0; *(big_buffer + x + inc_len) != term && |
326 | !QMAKE_EOL(*(big_buffer + x + inc_len)); inc_len++); | ||
322 | *(big_buffer + x + inc_len) = '\0'; | 327 | *(big_buffer + x + inc_len) = '\0'; |
323 | inc = big_buffer + x; | 328 | inc = big_buffer + x; |
324 | } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) { | 329 | } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) { |
325 | for(x+=14; //skip spaces after keyword | 330 | for(x+=14; //skip spaces after keyword |
326 | x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); | 331 | x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); |
327 | x++); | 332 | x++); |
328 | char term = '\n'; | 333 | char term = 0; |
329 | if(*(big_buffer + x) == '"') | 334 | if(*(big_buffer + x) == '"') |
330 | term = '"'; | 335 | term = '"'; |
331 | if(*(big_buffer + x) == '\'') | 336 | if(*(big_buffer + x) == '\'') |
332 | term = '\''; | 337 | term = '\''; |
333 | if(term != '\n') | 338 | if(term) |
334 | x++; | 339 | x++; |
335 | 340 | ||
336 | int msg_len; | 341 | int msg_len; |
337 | for(msg_len = 0; *(big_buffer + x + msg_len) != term; msg_len++); | 342 | for(msg_len = 0; (term && *(big_buffer + x + msg_len) != term) && |
343 | !QMAKE_EOL(*(big_buffer + x + msg_len)); msg_len++); | ||
344 | const char saved_term = *(big_buffer + x + msg_len); | ||
338 | *(big_buffer + x + msg_len) = '\0'; | 345 | *(big_buffer + x + msg_len) = '\0'; |
339 | QString msg = big_buffer + x; | 346 | QString msg = big_buffer + x; |
340 | debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(), | 347 | debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(), |
341 | line_count, msg.latin1()); | 348 | line_count, msg.latin1()); |
342 | *(big_buffer + x + msg_len) = term; //put it back | 349 | *(big_buffer + x + msg_len) = saved_term; //put it back |
343 | } | 350 | } |
344 | } | 351 | } |
345 | } else if(ui_file) { | 352 | } else if(ui_file) { |
346 | // skip whitespaces | 353 | // skip whitespaces |
347 | while(x < total_size_read && | 354 | while(x < total_size_read && |
348 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) | 355 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) |
349 | x++; | 356 | x++; |
350 | if(*(big_buffer + x) == '<') { | 357 | if(*(big_buffer + x) == '<') { |
351 | x++; | 358 | x++; |
352 | if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) && | 359 | if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) && |
353 | (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) { | 360 | (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) { |
354 | for(x += 12; *(big_buffer + x) != '>'; x++); | 361 | for(x += 11; *(big_buffer + x) != '>'; x++); |
355 | int inc_len = 0; | 362 | int inc_len = 0; |
356 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); | 363 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); |
357 | *(big_buffer + x + inc_len) = '\0'; | 364 | *(big_buffer + x + inc_len) = '\0'; |
358 | inc = big_buffer + x; | 365 | inc = big_buffer + x; |
366 | } else if(total_size_read >= x + 13 && !strncmp(big_buffer + x, "customwidget", 12) && | ||
367 | (*(big_buffer + x + 12) == ' ' || *(big_buffer + x + 12) == '>')) { | ||
368 | for(x += 13; *(big_buffer + x) != '>'; x++); //skip up to > | ||
369 | while(x < total_size_read) { | ||
370 | for(x++; *(big_buffer + x) != '<'; x++); //skip up to < | ||
371 | x++; | ||
372 | if(total_size_read >= x + 7 && !strncmp(big_buffer+x, "header", 6) && | ||
373 | (*(big_buffer + x + 6) == ' ' || *(big_buffer + x + 6) == '>')) { | ||
374 | for(x += 7; *(big_buffer + x) != '>'; x++); //skip up to > | ||
375 | int inc_len = 0; | ||
376 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); | ||
377 | *(big_buffer + x + inc_len) = '\0'; | ||
378 | inc = big_buffer + x; | ||
379 | break; | ||
380 | } else if(total_size_read >= x + 14 && !strncmp(big_buffer+x, "/customwidget", 13) && | ||
381 | (*(big_buffer + x + 13) == ' ' || *(big_buffer + x + 13) == '>')) { | ||
382 | x += 14; | ||
383 | break; | ||
384 | } | ||
385 | } | ||
359 | } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && | 386 | } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && |
360 | (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) { | 387 | (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) { |
361 | for(x += 8; *(big_buffer + x) != '>'; x++) { | 388 | for(x += 8; *(big_buffer + x) != '>'; x++) { |
362 | if(total_size_read >= x + 9 && *(big_buffer + x) == 'i' && | 389 | if(total_size_read >= x + 9 && *(big_buffer + x) == 'i' && |
363 | !strncmp(big_buffer + x, "impldecl", 8)) { | 390 | !strncmp(big_buffer + x, "impldecl", 8)) { |
364 | for(x += 8; *(big_buffer + x) != '='; x++); | 391 | for(x += 8; *(big_buffer + x) != '='; x++); |
@@ -414,18 +441,21 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const | |||
414 | break; | 441 | break; |
415 | } | 442 | } |
416 | } | 443 | } |
417 | if(found) | 444 | if(found) |
418 | continue; | 445 | continue; |
419 | } | 446 | } |
420 | |||
421 | QString fqn; | 447 | QString fqn; |
422 | if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") && | 448 | if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") && |
423 | !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) { | 449 | !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) { |
424 | fqn = fndir + inc; | 450 | fqn = fndir + inc; |
425 | goto handle_fqn; | 451 | goto handle_fqn; |
452 | } else if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") && | ||
453 | !stat(inc, &fst) && !S_ISDIR(fst.st_mode)) { | ||
454 | fqn = inc; | ||
455 | goto handle_fqn; | ||
426 | } else { | 456 | } else { |
427 | if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) || | 457 | if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) || |
428 | (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') || | 458 | (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') || |
429 | ((Option::target_mode == Option::TARG_UNIX_MODE || | 459 | ((Option::target_mode == Option::TARG_UNIX_MODE || |
430 | Option::target_mode == Option::TARG_QNX6_MODE || | 460 | Option::target_mode == Option::TARG_QNX6_MODE || |
431 | Option::target_mode == Option::TARG_MACX_MODE) && | 461 | Option::target_mode == Option::TARG_MACX_MODE) && |
@@ -443,12 +473,13 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const | |||
443 | //these are some hacky heuristics it will try to do on an include | 473 | //these are some hacky heuristics it will try to do on an include |
444 | //however these can be turned off at runtime, I'm not sure how | 474 | //however these can be turned off at runtime, I'm not sure how |
445 | //reliable these will be, most likely when problems arise turn it off | 475 | //reliable these will be, most likely when problems arise turn it off |
446 | //and see if they go away.. | 476 | //and see if they go away.. |
447 | if(depHeuristics.contains(inc)) { | 477 | if(depHeuristics.contains(inc)) { |
448 | fqn = depHeuristics[inc]; | 478 | fqn = depHeuristics[inc]; |
479 | from_source_dir = FALSE; | ||
449 | } else if(Option::mkfile::do_dep_heuristics) { //some heuristics.. | 480 | } else if(Option::mkfile::do_dep_heuristics) { //some heuristics.. |
450 | //is it a file from a .ui? | 481 | //is it a file from a .ui? |
451 | QString inc_file = inc.section(Option::dir_sep, -1); | 482 | QString inc_file = inc.section(Option::dir_sep, -1); |
452 | int extn = inc_file.findRev('.'); | 483 | int extn = inc_file.findRev('.'); |
453 | if(extn != -1 && | 484 | if(extn != -1 && |
454 | (inc_file.right(inc_file.length()-extn) == Option::cpp_ext.first() || | 485 | (inc_file.right(inc_file.length()-extn) == Option::cpp_ext.first() || |
@@ -465,13 +496,13 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const | |||
465 | fqn = (*it).section(Option::dir_sep, 0, -2); | 496 | fqn = (*it).section(Option::dir_sep, 0, -2); |
466 | if(!fqn.isEmpty() && !fqn.endsWith(Option::dir_sep)) | 497 | if(!fqn.isEmpty() && !fqn.endsWith(Option::dir_sep)) |
467 | fqn += Option::dir_sep; | 498 | fqn += Option::dir_sep; |
468 | fqn += inc_file; | 499 | fqn += inc_file; |
469 | from_source_dir = FALSE; //uics go in the output_dir (so don't fix them) | 500 | from_source_dir = FALSE; //uics go in the output_dir (so don't fix them) |
470 | fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir); | 501 | fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir); |
471 | goto handle_fqn; | 502 | goto cache_fqn; |
472 | } | 503 | } |
473 | } | 504 | } |
474 | } | 505 | } |
475 | if(project->isActiveConfig("lex_included")) { //is this the lex file? | 506 | if(project->isActiveConfig("lex_included")) { //is this the lex file? |
476 | QString rhs = Option::lex_mod + Option::cpp_ext.first(); | 507 | QString rhs = Option::lex_mod + Option::cpp_ext.first(); |
477 | if(inc.endsWith(rhs)) { | 508 | if(inc.endsWith(rhs)) { |
@@ -485,13 +516,15 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const | |||
485 | s = s.right(s.length() - slsh - 1); | 516 | s = s.right(s.length() - slsh - 1); |
486 | } | 517 | } |
487 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) | 518 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) |
488 | d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); | 519 | d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); |
489 | if(s == lhs) { | 520 | if(s == lhs) { |
490 | fqn = d + inc; | 521 | fqn = d + inc; |
491 | goto handle_fqn; | 522 | from_source_dir = FALSE; //uics go in the output_dir (so don't fix them) |
523 | fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir); | ||
524 | goto cache_fqn; | ||
492 | } | 525 | } |
493 | } | 526 | } |
494 | } | 527 | } |
495 | } | 528 | } |
496 | { //is it from a .y? | 529 | { //is it from a .y? |
497 | QString rhs = Option::yacc_mod + Option::h_ext.first(); | 530 | QString rhs = Option::yacc_mod + Option::h_ext.first(); |
@@ -506,44 +539,53 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const | |||
506 | s = s.right(s.length() - slsh - 1); | 539 | s = s.right(s.length() - slsh - 1); |
507 | } | 540 | } |
508 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) | 541 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) |
509 | d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); | 542 | d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); |
510 | if(s == lhs) { | 543 | if(s == lhs) { |
511 | fqn = d + inc; | 544 | fqn = d + inc; |
512 | goto handle_fqn; | 545 | from_source_dir = FALSE; //uics go in the output_dir (so don't fix them) |
546 | fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir); | ||
547 | goto cache_fqn; | ||
513 | } | 548 | } |
514 | } | 549 | } |
515 | } | 550 | } |
516 | } | 551 | } |
517 | if(mocAware() && //is it a moc file? | 552 | if(mocAware() && //is it a moc file? |
518 | (inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::moc_ext))) { | 553 | ( inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::cpp_moc_ext) ) |
554 | || ( (Option::cpp_ext.first() != Option::h_moc_ext) && inc.endsWith(Option::h_moc_ext) )) { | ||
519 | QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null }; | 555 | QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null }; |
520 | for(int moc = 0; !mocs[moc].isNull(); moc++) { | 556 | for(int moc = 0; !mocs[moc].isNull(); moc++) { |
521 | QStringList &l = project->variables()[mocs[moc]]; | 557 | QStringList &l = project->variables()[mocs[moc]]; |
522 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | 558 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { |
523 | QString file = Option::fixPathToTargetOS((*it)); | 559 | QString file = Option::fixPathToTargetOS((*it)); |
524 | if(file.section(Option::dir_sep, -(inc.contains('/')+1)) == inc) { | 560 | if(file.section(Option::dir_sep, -(inc.contains('/')+1)) == inc) { |
525 | fqn = (*it); | 561 | fqn = (*it); |
526 | if(mocs[moc] == "_HDRMOC") { | 562 | if(mocs[moc] == "_HDRMOC") { |
527 | //Since it is include, no need to link it in as well | 563 | //Since it is include, no need to link it in as well |
528 | project->variables()["_SRCMOC"].append((*it)); | 564 | project->variables()["_SRCMOC"].append((*it)); |
529 | l.remove(it); | 565 | l.remove(it); |
530 | } else if(!findMocSource(fqn).endsWith(fn)) { | 566 | } else if(!findMocSource(fqn).endsWith(fileFixify(fn))) { |
531 | /* Not really a very good test, but this will at least avoid | 567 | /* Not really a very good test, but this will at least avoid |
532 | confusion if it really does happen (since tmake/qmake | 568 | confusion if it really does happen (since tmake/qmake |
533 | previously didn't even allow this the test is mostly accurate) */ | 569 | previously didn't even allow this the test is mostly accurate) */ |
534 | warn_msg(WarnLogic, | 570 | warn_msg(WarnLogic, |
535 | "Found potential multiple MOC include %s (%s) in '%s'", | 571 | "Found potential multiple MOC include %s (%s) in '%s'", |
536 | inc.latin1(), fqn.latin1(), fix_env_fn.latin1()); | 572 | inc.latin1(), fqn.latin1(), fix_env_fn.latin1()); |
537 | } | 573 | } |
538 | from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them) | 574 | from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them) |
539 | goto handle_fqn; | 575 | goto cache_fqn; |
540 | } | 576 | } |
541 | } | 577 | } |
542 | } | 578 | } |
543 | } | 579 | } |
580 | fqn = findDependency(inc); //all else fails.. | ||
581 | cache_fqn: | ||
582 | if(from_source_dir) { | ||
583 | fqn = fileFixify(fqn); | ||
584 | from_source_dir = FALSE; | ||
585 | } | ||
544 | depHeuristics.insert(inc, fqn); | 586 | depHeuristics.insert(inc, fqn); |
545 | } | 587 | } |
546 | } | 588 | } |
547 | handle_fqn: | 589 | handle_fqn: |
548 | if(fqn.isEmpty()) //I give up | 590 | if(fqn.isEmpty()) //I give up |
549 | continue; | 591 | continue; |
@@ -552,22 +594,22 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const | |||
552 | fqn = fileFixify(fqn); | 594 | fqn = fileFixify(fqn); |
553 | debug_msg(4, "Resolved dependency of %s to %s", inc.latin1(), fqn.latin1()); | 595 | debug_msg(4, "Resolved dependency of %s to %s", inc.latin1(), fqn.latin1()); |
554 | if(outdeps && outdeps->findIndex(fqn) == -1) | 596 | if(outdeps && outdeps->findIndex(fqn) == -1) |
555 | outdeps->append(fqn); | 597 | outdeps->append(fqn); |
556 | } | 598 | } |
557 | //read past new line now.. | 599 | //read past new line now.. |
558 | for( ; x < total_size_read && (*(big_buffer + x) != '\n'); x++); | 600 | for( ; x < total_size_read && !QMAKE_EOL(*(big_buffer + x)); x++); |
559 | line_count++; | 601 | line_count++; |
560 | } | 602 | } |
561 | 603 | ||
562 | if(recurse) { | 604 | if(recurse) { |
563 | for(QStringList::Iterator fnit = fndeps.begin(); fnit != fndeps.end(); ++fnit) { | 605 | for(QStringList::Iterator fnit = fndeps.begin(); fnit != fndeps.end(); ++fnit) { |
564 | generateDependencies(dirs, (*fnit), recurse); | 606 | generateDependencies(dirs, (*fnit), recurse); |
565 | QStringList &deplist = findDependencies((*fnit)); | 607 | QStringList &deplist = findDependencies((*fnit)); |
566 | for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it) | 608 | for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it) |
567 | if(fndeps.findIndex((*it)) == -1) | 609 | if(fndeps.findIndex((*it)) == -1 && (*it) != fn) |
568 | fndeps.append((*it)); | 610 | fndeps.append((*it)); |
569 | } | 611 | } |
570 | } | 612 | } |
571 | debug_msg(2, "Dependencies: %s -> %s", fn.latin1(), fndeps.join(" :: ").latin1()); | 613 | debug_msg(2, "Dependencies: %s -> %s", fn.latin1(), fndeps.join(" :: ").latin1()); |
572 | return TRUE; | 614 | return TRUE; |
573 | } | 615 | } |
@@ -603,16 +645,20 @@ MakefileGenerator::initOutPaths() | |||
603 | if(asp.isEmpty() || asp == Option::output_dir) //if they're the same, why bother? | 645 | if(asp.isEmpty() || asp == Option::output_dir) //if they're the same, why bother? |
604 | v["QMAKE_ABSOLUTE_SOURCE_PATH"].clear(); | 646 | v["QMAKE_ABSOLUTE_SOURCE_PATH"].clear(); |
605 | } | 647 | } |
606 | QString currentDir = QDir::currentDirPath(); | 648 | QString currentDir = QDir::currentDirPath(); |
607 | QString dirs[] = { QString("OBJECTS_DIR"), QString("MOC_DIR"), QString("UI_HEADERS_DIR"), | 649 | QString dirs[] = { QString("OBJECTS_DIR"), QString("MOC_DIR"), QString("UI_HEADERS_DIR"), |
608 | QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString("DESTDIR"), | 650 | QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString("DESTDIR"), |
609 | QString("SUBLIBS_DIR"), QString::null }; | 651 | QString("SUBLIBS_DIR"), QString("DLLDESTDIR"), QString::null }; |
610 | for(int x = 0; dirs[x] != QString::null; x++) { | 652 | for(int x = 0; dirs[x] != QString::null; x++) { |
611 | if ( !v[dirs[x]].isEmpty() ) { | 653 | if ( !v[dirs[x]].isEmpty() ) { |
612 | QString orig_path = v[dirs[x]].first(); | 654 | QString orig_path = v[dirs[x]].first(); |
655 | #ifdef Q_WS_WIN | ||
656 | // We don't want to add a separator for DLLDESTDIR on Windows | ||
657 | if (!(dirs[x] == "DLLDESTDIR")) | ||
658 | #endif | ||
613 | { | 659 | { |
614 | QString &path = v[dirs[x]].first(); | 660 | QString &path = v[dirs[x]].first(); |
615 | path = fileFixify(path, Option::output_dir, Option::output_dir); | 661 | path = fileFixify(path, Option::output_dir, Option::output_dir); |
616 | if(path.right(Option::dir_sep.length()) != Option::dir_sep) | 662 | if(path.right(Option::dir_sep.length()) != Option::dir_sep) |
617 | path += Option::dir_sep; | 663 | path += Option::dir_sep; |
618 | } | 664 | } |
@@ -658,12 +704,17 @@ MakefileGenerator::initOutPaths() | |||
658 | } | 704 | } |
659 | #ifdef Q_WS_WIN | 705 | #ifdef Q_WS_WIN |
660 | } | 706 | } |
661 | #endif | 707 | #endif |
662 | } | 708 | } |
663 | } | 709 | } |
710 | if ( !v["DESTDIR"].isEmpty() ) { | ||
711 | QDir d(v["DESTDIR"].first()); | ||
712 | if(Option::fixPathToLocalOS(d.absPath()) == Option::fixPathToLocalOS(Option::output_dir)) | ||
713 | v.remove("DESTDIR"); | ||
714 | } | ||
664 | QDir::current().cd( currentDir ); | 715 | QDir::current().cd( currentDir ); |
665 | } | 716 | } |
666 | 717 | ||
667 | void | 718 | void |
668 | MakefileGenerator::init() | 719 | MakefileGenerator::init() |
669 | { | 720 | { |
@@ -671,18 +722,23 @@ MakefileGenerator::init() | |||
671 | if(init_already) | 722 | if(init_already) |
672 | return; | 723 | return; |
673 | init_already = TRUE; | 724 | init_already = TRUE; |
674 | 725 | ||
675 | QMap<QString, QStringList> &v = project->variables(); | 726 | QMap<QString, QStringList> &v = project->variables(); |
676 | QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"), | 727 | QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"), |
677 | QString("HEADERS"), QString("HEADERS_ORIG"), | 728 | QString("HEADERS"), QString("HEADERS_ORIG"), QString("LEXSOURCES"), |
678 | QString("LEXSOURCES"), QString("QMAKE_INTERNAL_INCLUDED_FILES"), QString::null }; | 729 | QString("QMAKE_INTERNAL_INCLUDED_FILES"), |
730 | QString("PRECOMPILED_HEADER"), QString::null }; | ||
679 | for(int y = 0; paths[y] != QString::null; y++) { | 731 | for(int y = 0; paths[y] != QString::null; y++) { |
680 | QStringList &l = v[paths[y]]; | 732 | QStringList &l = v[paths[y]]; |
681 | if(!l.isEmpty()) | 733 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { |
682 | l = fileFixify(l); | 734 | if ((*it).isEmpty()) |
735 | continue; | ||
736 | if(QFile::exists((*it))) | ||
737 | (*it) = fileFixify((*it)); | ||
738 | } | ||
683 | } | 739 | } |
684 | 740 | ||
685 | /* get deps and mocables */ | 741 | /* get deps and mocables */ |
686 | QDict<void> cache_found_files; | 742 | QDict<void> cache_found_files; |
687 | QString cache_file(".qmake.internal.cache"); | 743 | QString cache_file(".qmake.internal.cache"); |
688 | if(!project->isEmpty("QMAKE_INTERNAL_CACHE_FILE")) | 744 | if(!project->isEmpty("QMAKE_INTERNAL_CACHE_FILE")) |
@@ -758,12 +814,13 @@ MakefileGenerator::init() | |||
758 | } | 814 | } |
759 | } | 815 | } |
760 | if(found) { | 816 | if(found) { |
761 | debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(), | 817 | debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(), |
762 | files.join(" :: ").latin1()); | 818 | files.join(" :: ").latin1()); |
763 | findDependencies(file) = files; | 819 | findDependencies(file) = files; |
820 | setProcessedDependencies(file, TRUE); | ||
764 | } | 821 | } |
765 | } | 822 | } |
766 | } else { | 823 | } else { |
767 | void *found = cache_found_files[file]; | 824 | void *found = cache_found_files[file]; |
768 | if(found != (void *)2) { | 825 | if(found != (void *)2) { |
769 | if(found) { | 826 | if(found) { |
@@ -807,24 +864,24 @@ MakefileGenerator::init() | |||
807 | } | 864 | } |
808 | } | 865 | } |
809 | } | 866 | } |
810 | if(!noIO()) { | 867 | if(!noIO()) { |
811 | QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"), | 868 | QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"), |
812 | QString("HEADERS"), QString("SOURCES"), QString("FORMS"), | 869 | QString("HEADERS"), QString("SOURCES"), QString("FORMS"), |
813 | QString::null }; | 870 | QString("PRECOMPILED_HEADER"), QString::null }; |
814 | depHeuristics.clear(); | 871 | depHeuristics.clear(); |
815 | bool write_cache = FALSE, read_cache = QFile::exists(cache_file); | 872 | bool write_cache = FALSE, read_cache = QFile::exists(cache_file); |
816 | for(int x = 0; sources[x] != QString::null; x++) { | 873 | int x; |
874 | for(x = 0; sources[x] != QString::null; x++) { | ||
817 | QStringList vpath, &l = v[sources[x]]; | 875 | QStringList vpath, &l = v[sources[x]]; |
818 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { | 876 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { |
819 | if(!(*val_it).isEmpty()) { | 877 | if(!(*val_it).isEmpty()) { |
820 | QString file = Option::fixPathToLocalOS((*val_it)); | 878 | QString file = fileFixify((*val_it), QDir::currentDirPath(), Option::output_dir); |
821 | QStringList file_list(file); | ||
822 | if(!QFile::exists(file)) { | 879 | if(!QFile::exists(file)) { |
823 | bool found = FALSE; | 880 | bool found = FALSE; |
824 | if(QDir::isRelativePath(file)) { | 881 | if(QDir::isRelativePath((*val_it))) { |
825 | if(vpath.isEmpty()) | 882 | if(vpath.isEmpty()) |
826 | vpath = v["VPATH_" + sources[x]] + v["VPATH"] + | 883 | vpath = v["VPATH_" + sources[x]] + v["VPATH"] + |
827 | v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"]; | 884 | v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"]; |
828 | 885 | ||
829 | for(QStringList::Iterator vpath_it = vpath.begin(); | 886 | for(QStringList::Iterator vpath_it = vpath.begin(); |
830 | vpath_it != vpath.end(); ++vpath_it) { | 887 | vpath_it != vpath.end(); ++vpath_it) { |
@@ -855,68 +912,69 @@ MakefileGenerator::init() | |||
855 | debug_msg(1, "%s:%d Failure to find %s in vpath (%s)", | 912 | debug_msg(1, "%s:%d Failure to find %s in vpath (%s)", |
856 | __FILE__, __LINE__, | 913 | __FILE__, __LINE__, |
857 | (*val_it).latin1(), vpath.join("::").latin1()); | 914 | (*val_it).latin1(), vpath.join("::").latin1()); |
858 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); | 915 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); |
859 | continue; | 916 | continue; |
860 | } else { | 917 | } else { |
861 | file_list.clear(); | ||
862 | for(int i = 0; i < (int)d.count(); i++) { | 918 | for(int i = 0; i < (int)d.count(); i++) { |
863 | file_list.append(dir + d[i]); | 919 | QString file = fileFixify(dir + d[i]); |
864 | if(i == (int)d.count() - 1) | 920 | if(i == (int)d.count() - 1) |
865 | (*val_it) = dir + d[i]; | 921 | (*val_it) = file; |
866 | else | 922 | else |
867 | l.insert(val_it, dir + d[i]); | 923 | l.insert(val_it, file); |
868 | } | 924 | } |
869 | } | 925 | } |
870 | } else { | 926 | } else { |
871 | debug_msg(1, "%s:%d Cannot match %s%c%s, as %s does not exist.", | 927 | debug_msg(1, "%s:%d Cannot match %s%c%s, as %s does not exist.", |
872 | __FILE__, __LINE__, | 928 | __FILE__, __LINE__, |
873 | real_dir.latin1(), QDir::separator(), regex.latin1(), | 929 | real_dir.latin1(), QDir::separator(), regex.latin1(), |
874 | real_dir.latin1()); | 930 | real_dir.latin1()); |
875 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); | 931 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); |
876 | } | 932 | } |
877 | } | 933 | } |
878 | } | 934 | } |
879 | for(QStringList::Iterator file_it = file_list.begin(); | 935 | } |
880 | file_it != file_list.end(); ++file_it) { | 936 | } |
881 | QString file_list_file = fileFixify((*file_it)); | 937 | } |
938 | for(x = 0; sources[x] != QString::null; x++) { | ||
939 | QStringList &l = v[sources[x]]; | ||
940 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { | ||
882 | bool found_cache_moc = FALSE, found_cache_dep = FALSE; | 941 | bool found_cache_moc = FALSE, found_cache_dep = FALSE; |
883 | if(read_cache && Option::output.name() != "-" && | 942 | if(read_cache && Option::output.name() != "-" && |
884 | project->isActiveConfig("qmake_cache")) { | 943 | project->isActiveConfig("qmake_cache")) { |
885 | if(!findDependencies(file_list_file).isEmpty()) | 944 | if(processedDependencies((*val_it))) |
886 | found_cache_dep = TRUE; | 945 | found_cache_dep = TRUE; |
887 | if(cache_found_files[(*file_it)] == (void *)2) | 946 | if(cache_found_files[(*val_it)] == (void *)2) |
888 | found_cache_moc = TRUE; | 947 | found_cache_moc = TRUE; |
889 | if(!found_cache_moc || !found_cache_dep) | 948 | if(!found_cache_moc || !found_cache_dep) |
890 | write_cache = TRUE; | 949 | write_cache = TRUE; |
891 | } | 950 | } |
892 | /* Do moc before dependency checking since some includes can come from | 951 | /* Do moc before dependency checking since some includes can come from |
893 | moc_*.cpp files */ | 952 | moc_*.cpp files */ |
894 | if(found_cache_moc) { | 953 | if(found_cache_moc) { |
895 | QString moc = findMocDestination(file_list_file); | 954 | QString fixed_file(fileFixify((*val_it), QDir::currentDirPath(), Option::output_dir)); |
955 | QString moc = findMocDestination(fixed_file); | ||
896 | if(!moc.isEmpty()) { | 956 | if(!moc.isEmpty()) { |
897 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); | 957 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); |
898 | cppit != Option::cpp_ext.end(); ++cppit) { | 958 | cppit != Option::cpp_ext.end(); ++cppit) { |
899 | if(file_list_file.endsWith((*cppit))) { | 959 | if(fixed_file.endsWith((*cppit))) { |
900 | QStringList &deps = findDependencies(file_list_file); | 960 | QStringList &deps = findDependencies(fixed_file); |
901 | if(!deps.contains(moc)) | 961 | if(!deps.contains(moc)) |
902 | deps.append(moc); | 962 | deps.append(moc); |
903 | break; | 963 | break; |
904 | } | 964 | } |
905 | } | 965 | } |
906 | } | 966 | } |
907 | } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") && | 967 | } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") && |
908 | (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || | 968 | (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || |
909 | Option::mkfile::do_mocs)) { | 969 | Option::mkfile::do_mocs)) { |
910 | generateMocList((*file_it)); | 970 | generateMocList((*val_it)); |
911 | } | 971 | } |
912 | if(!found_cache_dep && sources[x] != "OBJECTS") { | 972 | if(!found_cache_dep && sources[x] != "OBJECTS") { |
913 | debug_msg(5, "Looking for dependencies for %s", (*file_it).latin1()); | 973 | debug_msg(5, "Looking for dependencies for %s", (*val_it).latin1()); |
914 | generateDependencies(deplist, (*file_it), doDepends()); | 974 | generateDependencies(deplist, (*val_it), doDepends()); |
915 | } | ||
916 | } | ||
917 | } | 975 | } |
918 | } | 976 | } |
919 | } | 977 | } |
920 | if(project->isActiveConfig("qmake_cache") && (write_cache || !read_cache)) { | 978 | if(project->isActiveConfig("qmake_cache") && (write_cache || !read_cache)) { |
921 | QFile cachef(cache_file); | 979 | QFile cachef(cache_file); |
922 | if(cachef.open(IO_WriteOnly | IO_Translate)) { | 980 | if(cachef.open(IO_WriteOnly | IO_Translate)) { |
@@ -929,13 +987,13 @@ MakefileGenerator::init() | |||
929 | << "UI_DIR = " << var("UI_DIR") << "\n" | 987 | << "UI_DIR = " << var("UI_DIR") << "\n" |
930 | << "UI_HEADERS_DIR = " << var("UI_HEADERS_DIR") << "\n" | 988 | << "UI_HEADERS_DIR = " << var("UI_HEADERS_DIR") << "\n" |
931 | << "UI_SOURCES_DIR = " << var("UI_SOURCES_DIR") << "\n"; | 989 | << "UI_SOURCES_DIR = " << var("UI_SOURCES_DIR") << "\n"; |
932 | cachet << "[depend]" << endl; | 990 | cachet << "[depend]" << endl; |
933 | for(QMap<QString, QStringList>::Iterator it = depends.begin(); | 991 | for(QMap<QString, QStringList>::Iterator it = depends.begin(); |
934 | it != depends.end(); ++it) | 992 | it != depends.end(); ++it) |
935 | cachet << depKeyMap[it.key()] << " = " << it.data().join(" ") << endl; | 993 | cachet << dependencyKey(it.key()) << " = " << it.data().join(" ") << endl; |
936 | cachet << "[mocable]" << endl; | 994 | cachet << "[mocable]" << endl; |
937 | QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null }; | 995 | QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null }; |
938 | for(int x = 0; moc_sources[x] != QString::null; x++) { | 996 | for(int x = 0; moc_sources[x] != QString::null; x++) { |
939 | QStringList &l = v[moc_sources[x]]; | 997 | QStringList &l = v[moc_sources[x]]; |
940 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { | 998 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { |
941 | QString f = fileFixify((*val_it)); | 999 | QString f = fileFixify((*val_it)); |
@@ -1069,46 +1127,54 @@ MakefileGenerator::init() | |||
1069 | impl = fi.dirPath() + Option::dir_sep; | 1127 | impl = fi.dirPath() + Option::dir_sep; |
1070 | if(decl.isEmpty()) | 1128 | if(decl.isEmpty()) |
1071 | decl = fi.dirPath() + Option::dir_sep; | 1129 | decl = fi.dirPath() + Option::dir_sep; |
1072 | } | 1130 | } |
1073 | } | 1131 | } |
1074 | impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); | 1132 | impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); |
1075 | if(!impl.isEmpty()) | 1133 | if(!impl.isEmpty() && !impl.endsWith(Option::dir_sep)) |
1076 | impl += Option::dir_sep; | 1134 | impl += Option::dir_sep; |
1077 | impl += fi.baseName(TRUE) + Option::cpp_ext.first(); | 1135 | impl += fi.baseName(TRUE) + Option::cpp_ext.first(); |
1078 | if(Option::output_dir != QDir::currentDirPath() && | 1136 | if(Option::output_dir != QDir::currentDirPath() && |
1079 | project->isEmpty("UI_DIR") && project->isEmpty("UI_HEADERS_DIR")) { | 1137 | project->isEmpty("UI_DIR") && project->isEmpty("UI_HEADERS_DIR")) { |
1080 | QString decl_fixed = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); | 1138 | QString decl_fixed = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); |
1081 | if(!includepath.contains(decl_fixed)) | 1139 | if(!includepath.contains(decl_fixed)) |
1082 | includepath.append(decl_fixed); | 1140 | includepath.append(decl_fixed); |
1083 | if(!includepath.contains(decl)) | 1141 | if(!includepath.contains(decl)) |
1084 | project->variables()["INCLUDEPATH"].append(decl); | 1142 | project->variables()["INCLUDEPATH"].append(decl); |
1085 | } | 1143 | } |
1086 | decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); | 1144 | decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); |
1087 | if(!decl.isEmpty()) | 1145 | if(!decl.isEmpty() && !decl.endsWith(Option::dir_sep)) |
1088 | decl += Option::dir_sep; | 1146 | decl += Option::dir_sep; |
1089 | decl += fi.baseName(TRUE) + Option::h_ext.first(); | 1147 | decl += fi.baseName(TRUE) + Option::h_ext.first(); |
1090 | logicWarn(impl, "SOURCES"); | 1148 | logicWarn(impl, "SOURCES"); |
1091 | logicWarn(decl, "HEADERS"); | 1149 | logicWarn(decl, "HEADERS"); |
1092 | decls.append(decl); | 1150 | decls.append(decl); |
1093 | impls.append(impl); | 1151 | impls.append(impl); |
1094 | findDependencies(impl).append(decl); | 1152 | findDependencies(impl).append(decl); |
1095 | 1153 | ||
1096 | QString mocable = Option::moc_mod + fi.baseName(TRUE) + Option::cpp_ext.first(); | 1154 | QString mocable = Option::h_moc_mod + fi.baseName(TRUE) + Option::h_moc_ext; |
1097 | if(!v["MOC_DIR"].isEmpty()) | 1155 | if(!v["MOC_DIR"].isEmpty()) |
1098 | mocable.prepend(v["MOC_DIR"].first()); | 1156 | mocable.prepend(v["MOC_DIR"].first()); |
1099 | else if(fi.dirPath() != ".") | 1157 | else if(fi.dirPath() != ".") |
1100 | mocable.prepend(fi.dirPath() + Option::dir_sep); | 1158 | mocable.prepend(fi.dirPath() + Option::dir_sep); |
1101 | logicWarn(mocable, "SOURCES"); | 1159 | logicWarn(mocable, "SOURCES"); |
1102 | mocablesToMOC[cleanFilePath(decl)] = mocable; | 1160 | mocablesToMOC[cleanFilePath(decl)] = mocable; |
1103 | mocablesFromMOC[cleanFilePath(mocable)] = decl; | 1161 | mocablesFromMOC[cleanFilePath(mocable)] = decl; |
1104 | v["_UIMOC"].append(mocable); | 1162 | v["_UIMOC"].append(mocable); |
1105 | } | 1163 | } |
1106 | v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS")); | 1164 | v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS")); |
1107 | } | 1165 | } |
1108 | 1166 | ||
1167 | //Translation files | ||
1168 | if(!project->isEmpty("TRANSLATIONS")) { | ||
1169 | QStringList &trf = project->variables()["TRANSLATIONS"]; | ||
1170 | for(QStringList::Iterator it = trf.begin(); it != trf.end(); ++it) { | ||
1171 | (*it) = Option::fixPathToLocalOS((*it)); | ||
1172 | } | ||
1173 | } | ||
1174 | |||
1109 | //Image files | 1175 | //Image files |
1110 | if(!project->isEmpty("IMAGES")) { | 1176 | if(!project->isEmpty("IMAGES")) { |
1111 | if(project->isEmpty("QMAKE_IMAGE_COLLECTION")) | 1177 | if(project->isEmpty("QMAKE_IMAGE_COLLECTION")) |
1112 | v["QMAKE_IMAGE_COLLECTION"].append("qmake_image_collection" + Option::cpp_ext.first()); | 1178 | v["QMAKE_IMAGE_COLLECTION"].append("qmake_image_collection" + Option::cpp_ext.first()); |
1113 | QString imgfile = project->first("QMAKE_IMAGE_COLLECTION"); | 1179 | QString imgfile = project->first("QMAKE_IMAGE_COLLECTION"); |
1114 | Option::fixPathToTargetOS(imgfile); | 1180 | Option::fixPathToTargetOS(imgfile); |
@@ -1137,43 +1203,62 @@ MakefileGenerator::init() | |||
1137 | Option::output_dir)); | 1203 | Option::output_dir)); |
1138 | 1204 | ||
1139 | //moc files | 1205 | //moc files |
1140 | if ( mocAware() ) { | 1206 | if ( mocAware() ) { |
1141 | if(!project->isEmpty("MOC_DIR")) | 1207 | if(!project->isEmpty("MOC_DIR")) |
1142 | project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR")); | 1208 | project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR")); |
1209 | if ( Option::h_moc_ext == Option::cpp_ext.first() ) | ||
1143 | v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC"); | 1210 | v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC"); |
1144 | 1211 | ||
1145 | QStringList &l = v["SRCMOC"]; | 1212 | QStringList &l = v["SRCMOC"]; |
1146 | l = v["_HDRMOC"] + v["_UIMOC"] + v["_SRCMOC"]; | 1213 | l = v["_HDRMOC"] + v["_UIMOC"] + v["_SRCMOC"]; |
1147 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { | 1214 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { |
1148 | if(!(*val_it).isEmpty()) | 1215 | if(!(*val_it).isEmpty()) |
1149 | (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE); | 1216 | (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE); |
1150 | } | 1217 | } |
1151 | } | 1218 | } |
1219 | |||
1220 | QString fixpaths[] = { QString("PRE_TARGETDEPS"), QString("POST_TARGETDEPS"), QString::null }; | ||
1221 | for(int path = 0; !fixpaths[path].isNull(); path++) { | ||
1222 | QStringList &l = v[fixpaths[path]]; | ||
1223 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { | ||
1224 | if(!(*val_it).isEmpty()) | ||
1225 | (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE); | ||
1226 | } | ||
1227 | } | ||
1228 | |||
1229 | // Make sure the INCLUDEPATH doesn't contain any empty(/null) entries | ||
1230 | QStringList &ipl = project->variables()["INCLUDEPATH"]; | ||
1231 | for(QStringList::Iterator ipl_it = ipl.begin(); ipl_it != ipl.end();) { | ||
1232 | if ((*ipl_it).isEmpty()) | ||
1233 | ipl_it = ipl.remove(ipl_it); | ||
1234 | else | ||
1235 | ++ipl_it; | ||
1236 | } | ||
1152 | } | 1237 | } |
1153 | 1238 | ||
1154 | bool | 1239 | bool |
1155 | MakefileGenerator::processPrlFile(QString &file) | 1240 | MakefileGenerator::processPrlFile(QString &file) |
1156 | { | 1241 | { |
1157 | bool ret = FALSE, try_replace_file=FALSE; | 1242 | bool ret = FALSE, try_replace_file=FALSE; |
1158 | QString prl_file; | 1243 | QString meta_file, orig_file = file; |
1159 | if(file.endsWith(Option::prl_ext)) { | 1244 | if(QMakeMetaInfo::libExists(file)) { |
1160 | try_replace_file = TRUE; | 1245 | try_replace_file = TRUE; |
1161 | prl_file = file; | 1246 | meta_file = file; |
1162 | file = ""; | 1247 | file = ""; |
1163 | } else { | 1248 | } else { |
1164 | QString tmp = file; | 1249 | QString tmp = file; |
1165 | int ext = tmp.findRev('.'); | 1250 | int ext = tmp.findRev('.'); |
1166 | if(ext != -1) | 1251 | if(ext != -1) |
1167 | tmp = tmp.left(ext); | 1252 | tmp = tmp.left(ext); |
1168 | prl_file = tmp + Option::prl_ext; | 1253 | meta_file = tmp; |
1169 | } | 1254 | } |
1170 | prl_file = fileFixify(prl_file); | 1255 | meta_file = fileFixify(meta_file); |
1171 | if(!QFile::exists(fileFixify(prl_file, QDir::currentDirPath(), Option::output_dir)) && | 1256 | if(!QMakeMetaInfo::libExists(fileFixify(meta_file, QDir::currentDirPath(), Option::output_dir)) && |
1172 | project->isActiveConfig("qt")) { | 1257 | project->isActiveConfig("qt")) { |
1173 | QString stem = prl_file, dir, extn; | 1258 | QString stem = meta_file, dir, extn; |
1174 | int slsh = stem.findRev('/'), hadlib = 0; | 1259 | int slsh = stem.findRev('/'), hadlib = 0; |
1175 | if(slsh != -1) { | 1260 | if(slsh != -1) { |
1176 | dir = stem.left(slsh + 1); | 1261 | dir = stem.left(slsh + 1); |
1177 | stem = stem.right(stem.length() - slsh - 1); | 1262 | stem = stem.right(stem.length() - slsh - 1); |
1178 | } | 1263 | } |
1179 | if(stem.startsWith("lib")) { | 1264 | if(stem.startsWith("lib")) { |
@@ -1187,45 +1272,59 @@ MakefileGenerator::processPrlFile(QString &file) | |||
1187 | } | 1272 | } |
1188 | if(stem == "qt" || stem == "qte" || stem == "qte-mt" || stem == "qt-mt") { | 1273 | if(stem == "qt" || stem == "qte" || stem == "qte-mt" || stem == "qt-mt") { |
1189 | if(stem.endsWith("-mt")) | 1274 | if(stem.endsWith("-mt")) |
1190 | stem = stem.left(stem.length() - 3); //lose the -mt | 1275 | stem = stem.left(stem.length() - 3); //lose the -mt |
1191 | else | 1276 | else |
1192 | stem += "-mt"; //try the thread case | 1277 | stem += "-mt"; //try the thread case |
1193 | prl_file = dir; | 1278 | meta_file = dir; |
1194 | if(hadlib) | 1279 | if(hadlib) |
1195 | prl_file += "lib"; | 1280 | meta_file += "lib"; |
1196 | prl_file += stem + extn; | 1281 | meta_file += stem + extn; |
1197 | try_replace_file = TRUE; | 1282 | try_replace_file = TRUE; |
1198 | } | 1283 | } |
1199 | } | 1284 | } |
1200 | QString real_prl_file = Option::fixPathToLocalOS(prl_file); | 1285 | QString real_meta_file = Option::fixPathToLocalOS(meta_file); |
1201 | if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(prl_file) != -1) { | 1286 | if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(QMakeMetaInfo::findLib(meta_file)) != -1) { |
1202 | ret = TRUE; | 1287 | ret = TRUE; |
1203 | } else if(!real_prl_file.isEmpty() && | 1288 | } else if(!meta_file.isEmpty()) { |
1204 | QFile::exists(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir))) { | 1289 | QString f = fileFixify(real_meta_file, QDir::currentDirPath(), Option::output_dir); |
1205 | project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(prl_file); | 1290 | if(QMakeMetaInfo::libExists(f)) { |
1206 | QMakeProject proj; | 1291 | QMakeMetaInfo libinfo; |
1207 | debug_msg(1, "Processing PRL file: %s", real_prl_file.latin1()); | 1292 | debug_msg(1, "Processing PRL file: %s", real_meta_file.latin1()); |
1208 | if(!proj.read(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir), | 1293 | if(!libinfo.readLib(f)) { |
1209 | QDir::currentDirPath(), TRUE)) { | 1294 | fprintf(stderr, "Error processing meta file: %s\n", real_meta_file.latin1()); |
1210 | fprintf(stderr, "Error processing prl file: %s\n", real_prl_file.latin1()); | 1295 | } else if(project->isActiveConfig("no_read_prl_" + libinfo.type().lower())) { |
1296 | debug_msg(2, "Ignored meta file %s [%s]", real_meta_file.latin1(), libinfo.type().latin1()); | ||
1211 | } else { | 1297 | } else { |
1212 | ret = TRUE; | 1298 | ret = TRUE; |
1213 | QMap<QString, QStringList> &vars = proj.variables(); | 1299 | QMap<QString, QStringList> &vars = libinfo.variables(); |
1214 | for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) | 1300 | for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) |
1215 | processPrlVariable(it.key(), it.data()); | 1301 | processPrlVariable(it.key(), it.data()); |
1216 | if(try_replace_file && !proj.isEmpty("QMAKE_PRL_TARGET")) { | 1302 | if(try_replace_file && !libinfo.isEmpty("QMAKE_PRL_TARGET")) { |
1217 | QString dir; | 1303 | QString dir; |
1218 | int slsh = real_prl_file.findRev(Option::dir_sep); | 1304 | int slsh = real_meta_file.findRev(Option::dir_sep); |
1219 | if(slsh != -1) | 1305 | if(slsh != -1) |
1220 | dir = real_prl_file.left(slsh+1); | 1306 | dir = real_meta_file.left(slsh+1); |
1221 | file = dir + proj.first("QMAKE_PRL_TARGET"); | 1307 | file = libinfo.first("QMAKE_PRL_TARGET"); |
1308 | if(QDir::isRelativePath(file)) | ||
1309 | file.prepend(dir); | ||
1222 | } | 1310 | } |
1223 | } | 1311 | } |
1224 | if(ret) | 1312 | } |
1225 | project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(prl_file); | 1313 | if(ret) { |
1314 | QString mf = QMakeMetaInfo::findLib(meta_file); | ||
1315 | project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(mf); | ||
1316 | project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(mf); | ||
1317 | } | ||
1318 | } | ||
1319 | if(try_replace_file && file.isEmpty()) { | ||
1320 | #if 0 | ||
1321 | warn_msg(WarnLogic, "Found prl [%s] file with no target [%s]!", meta_file.latin1(), | ||
1322 | orig_file.latin1()); | ||
1323 | #endif | ||
1324 | file = orig_file; | ||
1226 | } | 1325 | } |
1227 | return ret; | 1326 | return ret; |
1228 | } | 1327 | } |
1229 | 1328 | ||
1230 | void | 1329 | void |
1231 | MakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) | 1330 | MakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) |
@@ -1293,12 +1392,16 @@ MakefileGenerator::writePrlFile(QTextStream &t) | |||
1293 | 1392 | ||
1294 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) | 1393 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) |
1295 | t << "QMAKE_PRL_SOURCE_DIR = " << project->first("QMAKE_ABSOLUTE_SOURCE_PATH") << endl; | 1394 | t << "QMAKE_PRL_SOURCE_DIR = " << project->first("QMAKE_ABSOLUTE_SOURCE_PATH") << endl; |
1296 | t << "QMAKE_PRL_TARGET = " << target << endl; | 1395 | t << "QMAKE_PRL_TARGET = " << target << endl; |
1297 | if(!project->isEmpty("PRL_EXPORT_DEFINES")) | 1396 | if(!project->isEmpty("PRL_EXPORT_DEFINES")) |
1298 | t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl; | 1397 | t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl; |
1398 | if(!project->isEmpty("PRL_EXPORT_CFLAGS")) | ||
1399 | t << "QMAKE_PRL_CFLAGS = " << project->variables()["PRL_EXPORT_CFLAGS"].join(" ") << endl; | ||
1400 | if(!project->isEmpty("PRL_EXPORT_CXXFLAGS")) | ||
1401 | t << "QMAKE_PRL_CXXFLAGS = " << project->variables()["PRL_EXPORT_CXXFLAGS"].join(" ") << endl; | ||
1299 | if(!project->isEmpty("CONFIG")) | 1402 | if(!project->isEmpty("CONFIG")) |
1300 | t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl; | 1403 | t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl; |
1301 | if(!project->isEmpty("VERSION")) | 1404 | if(!project->isEmpty("VERSION")) |
1302 | t << "QMAKE_PRL_VERSION = " << project->first("VERSION") << endl; | 1405 | t << "QMAKE_PRL_VERSION = " << project->first("VERSION") << endl; |
1303 | if(project->isActiveConfig("staticlib") || project->isActiveConfig("explicitlib")) { | 1406 | if(project->isActiveConfig("staticlib") || project->isActiveConfig("explicitlib")) { |
1304 | QStringList libs; | 1407 | QStringList libs; |
@@ -1313,16 +1416,18 @@ MakefileGenerator::writePrlFile(QTextStream &t) | |||
1313 | } | 1416 | } |
1314 | } | 1417 | } |
1315 | 1418 | ||
1316 | bool | 1419 | bool |
1317 | MakefileGenerator::write() | 1420 | MakefileGenerator::write() |
1318 | { | 1421 | { |
1422 | usePlatformDir(); | ||
1319 | init(); | 1423 | init(); |
1320 | findLibraries(); | 1424 | findLibraries(); |
1321 | if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl | 1425 | if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl |
1322 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) && | 1426 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) && |
1427 | project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty() && | ||
1323 | project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" && | 1428 | project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" && |
1324 | !project->isActiveConfig("plugin")) { | 1429 | !project->isActiveConfig("plugin")) { |
1325 | QString prl = var("TARGET"); | 1430 | QString prl = var("TARGET"); |
1326 | int slsh = prl.findRev(Option::dir_sep); | 1431 | int slsh = prl.findRev(Option::dir_sep); |
1327 | if(slsh != -1) | 1432 | if(slsh != -1) |
1328 | prl = prl.right(prl.length() - slsh); | 1433 | prl = prl.right(prl.length() - slsh); |
@@ -1343,20 +1448,75 @@ MakefileGenerator::write() | |||
1343 | } | 1448 | } |
1344 | } | 1449 | } |
1345 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE && | 1450 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE && |
1346 | project->isActiveConfig("link_prl")) //load up prl's' | 1451 | project->isActiveConfig("link_prl")) //load up prl's' |
1347 | processPrlFiles(); | 1452 | processPrlFiles(); |
1348 | 1453 | ||
1349 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || | 1454 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl file |
1350 | Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { | 1455 | Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { |
1351 | QTextStream t(&Option::output); | 1456 | QTextStream t(&Option::output); |
1352 | writeMakefile(t); | 1457 | writeMakefile(t); |
1353 | } | 1458 | } |
1354 | return TRUE; | 1459 | return TRUE; |
1355 | } | 1460 | } |
1356 | 1461 | ||
1462 | // Manipulate directories, so it's possible to build | ||
1463 | // several cross-platform targets concurrently | ||
1464 | void | ||
1465 | MakefileGenerator::usePlatformDir() | ||
1466 | { | ||
1467 | QString pltDir(project->first("QMAKE_PLATFORM_DIR")); | ||
1468 | if(pltDir.isEmpty()) | ||
1469 | return; | ||
1470 | char sep = QDir::separator(); | ||
1471 | QString slashPltDir = sep + pltDir; | ||
1472 | |||
1473 | QString filePath = project->first("DESTDIR"); | ||
1474 | project->variables()["DESTDIR"] = filePath | ||
1475 | + (filePath.isEmpty() ? pltDir : slashPltDir); | ||
1476 | |||
1477 | filePath = project->first("DLLDESTDIR"); | ||
1478 | project->variables()["DLLDESTDIR"] = filePath | ||
1479 | + (filePath.isEmpty() ? pltDir : slashPltDir); | ||
1480 | |||
1481 | filePath = project->first("OBJECTS_DIR"); | ||
1482 | project->variables()["OBJECTS_DIR"] = filePath | ||
1483 | + (filePath.isEmpty() ? pltDir : slashPltDir); | ||
1484 | |||
1485 | filePath = project->first("QMAKE_LIBDIR_QT"); | ||
1486 | project->variables()["QMAKE_LIBDIR_QT"] = filePath | ||
1487 | + (filePath.isEmpty() ? pltDir : slashPltDir); | ||
1488 | |||
1489 | filePath = project->first("QMAKE_LIBS_QT"); | ||
1490 | int fpi = filePath.findRev(sep); | ||
1491 | if (fpi == -1) | ||
1492 | project->variables()["QMAKE_LIBS_QT"].prepend(pltDir + sep); | ||
1493 | else | ||
1494 | project->variables()["QMAKE_LIBS_QT"] = filePath.left(fpi) | ||
1495 | + slashPltDir | ||
1496 | + filePath.mid(fpi); | ||
1497 | |||
1498 | filePath = project->first("QMAKE_LIBS_QT_THREAD"); | ||
1499 | fpi = filePath.findRev(sep); | ||
1500 | if (fpi == -1) | ||
1501 | project->variables()["QMAKE_LIBS_QT_THREAD"].prepend(pltDir + sep); | ||
1502 | else | ||
1503 | project->variables()["QMAKE_LIBS_QT_THREAD"] = filePath.left(fpi) | ||
1504 | + slashPltDir | ||
1505 | + filePath.mid(fpi); | ||
1506 | |||
1507 | filePath = project->first("QMAKE_LIBS_QT_ENTRY"); | ||
1508 | fpi = filePath.findRev(sep); | ||
1509 | if (fpi == -1) | ||
1510 | project->variables()["QMAKE_LIBS_QT_ENTRY"].prepend(pltDir + sep); | ||
1511 | else | ||
1512 | project->variables()["QMAKE_LIBS_QT_ENTRY"] = filePath.left(fpi) | ||
1513 | + slashPltDir | ||
1514 | + filePath.mid(fpi); | ||
1515 | } | ||
1516 | |||
1357 | void | 1517 | void |
1358 | MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src) | 1518 | MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src) |
1359 | { | 1519 | { |
1360 | QStringList &objl = project->variables()[obj]; | 1520 | QStringList &objl = project->variables()[obj]; |
1361 | QStringList &srcl = project->variables()[src]; | 1521 | QStringList &srcl = project->variables()[src]; |
1362 | 1522 | ||
@@ -1369,13 +1529,13 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s | |||
1369 | continue; | 1529 | continue; |
1370 | 1530 | ||
1371 | if(!doDepends()) { | 1531 | if(!doDepends()) { |
1372 | QString sdep, odep = (*sit) + " "; | 1532 | QString sdep, odep = (*sit) + " "; |
1373 | QStringList deps = findDependencies((*sit)); | 1533 | QStringList deps = findDependencies((*sit)); |
1374 | for(QStringList::Iterator dit = deps.begin(); dit != deps.end(); dit++) { | 1534 | for(QStringList::Iterator dit = deps.begin(); dit != deps.end(); dit++) { |
1375 | if((*dit).endsWith(Option::moc_ext)) | 1535 | if((*dit).endsWith(Option::cpp_moc_ext)) |
1376 | odep += (*dit) + " "; | 1536 | odep += (*dit) + " "; |
1377 | else | 1537 | else |
1378 | sdep += (*dit) + " "; | 1538 | sdep += (*dit) + " "; |
1379 | } | 1539 | } |
1380 | t << (*sit) << ": " << sdep << endl | 1540 | t << (*sit) << ": " << sdep << endl |
1381 | << (*oit) << ": " << odep ; | 1541 | << (*oit) << ": " << odep ; |
@@ -1403,14 +1563,14 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s | |||
1403 | int dot = (*sit).findRev('.'); | 1563 | int dot = (*sit).findRev('.'); |
1404 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) | 1564 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) |
1405 | use_implicit_rule = FALSE; | 1565 | use_implicit_rule = FALSE; |
1406 | } | 1566 | } |
1407 | } | 1567 | } |
1408 | if (!use_implicit_rule && !project->isEmpty(comp)) { | 1568 | if (!use_implicit_rule && !project->isEmpty(comp)) { |
1409 | QString p = var(comp); | 1569 | QString p = var(comp), srcf(*sit); |
1410 | p.replace(stringSrc, (*sit)); | 1570 | p.replace(stringSrc, srcf); |
1411 | p.replace(stringObj, (*oit)); | 1571 | p.replace(stringObj, (*oit)); |
1412 | t << "\n\t" << p; | 1572 | t << "\n\t" << p; |
1413 | } | 1573 | } |
1414 | t << endl << endl; | 1574 | t << endl << endl; |
1415 | } | 1575 | } |
1416 | } | 1576 | } |
@@ -1418,21 +1578,19 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s | |||
1418 | 1578 | ||
1419 | void | 1579 | void |
1420 | MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui) | 1580 | MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui) |
1421 | { | 1581 | { |
1422 | QStringList &uil = project->variables()[ui]; | 1582 | QStringList &uil = project->variables()[ui]; |
1423 | for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) { | 1583 | for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) { |
1424 | QString deps = findDependencies((*it)).join(" \\\n\t\t"), decl, impl; | 1584 | QString decl, impl; |
1425 | { | 1585 | { |
1426 | QString tmp = (*it), impl_dir, decl_dir; | 1586 | QString tmp = (*it), impl_dir, decl_dir; |
1427 | decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first()); | 1587 | decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first()); |
1428 | decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); | ||
1429 | int dlen = decl.findRev(Option::dir_sep) + 1; | 1588 | int dlen = decl.findRev(Option::dir_sep) + 1; |
1430 | tmp = (*it); | 1589 | tmp = (*it); |
1431 | impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first()); | 1590 | impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first()); |
1432 | impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); | ||
1433 | int ilen = decl.findRev(Option::dir_sep) + 1; | 1591 | int ilen = decl.findRev(Option::dir_sep) + 1; |
1434 | if(!project->isEmpty("UI_DIR")) { | 1592 | if(!project->isEmpty("UI_DIR")) { |
1435 | impl_dir = project->first("UI_DIR"); | 1593 | impl_dir = project->first("UI_DIR"); |
1436 | decl = project->first("UI_DIR") + decl.right(decl.length() - dlen); | 1594 | decl = project->first("UI_DIR") + decl.right(decl.length() - dlen); |
1437 | impl = project->first("UI_DIR") + impl.right(impl.length() - ilen); | 1595 | impl = project->first("UI_DIR") + impl.right(impl.length() - ilen); |
1438 | } else { | 1596 | } else { |
@@ -1442,31 +1600,37 @@ MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui) | |||
1442 | } | 1600 | } |
1443 | if(!project->isEmpty("UI_SOURCES_DIR")) { | 1601 | if(!project->isEmpty("UI_SOURCES_DIR")) { |
1444 | impl_dir = project->first("UI_SOURCES_DIR"); | 1602 | impl_dir = project->first("UI_SOURCES_DIR"); |
1445 | impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen); | 1603 | impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen); |
1446 | } | 1604 | } |
1447 | } | 1605 | } |
1606 | impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir); | ||
1607 | decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir); | ||
1448 | if(decl_dir.isEmpty()) | 1608 | if(decl_dir.isEmpty()) |
1449 | decl_dir = decl.left(dlen); | 1609 | decl_dir = decl.section(Option::dir_sep,0,-2); |
1450 | if(impl_dir.isEmpty()) | 1610 | if(impl_dir.isEmpty()) |
1451 | impl_dir = impl.left(ilen); | 1611 | impl_dir = impl.section(Option::dir_sep,0,-2); |
1452 | if(!impl_dir.isEmpty()) | 1612 | if (QDir::isRelativePath(impl_dir)) |
1453 | createDir(Option::output_dir + Option::dir_sep + impl_dir); | 1613 | impl_dir.prepend(Option::output_dir + Option::dir_sep); |
1454 | if(!decl_dir.isEmpty() && decl_dir != impl_dir) | 1614 | if (QDir::isRelativePath(decl_dir)) |
1455 | createDir(Option::output_dir + Option::dir_sep + decl_dir); | 1615 | decl_dir.prepend(Option::output_dir + Option::dir_sep); |
1456 | } | 1616 | createDir(impl_dir); |
1457 | t << decl << ": " << (*it) << " " << deps << "\n\t" | 1617 | createDir(decl_dir); |
1618 | } | ||
1619 | QStringList deps = findDependencies((*it)); | ||
1620 | deps.remove(decl); //avoid circular dependencies.. | ||
1621 | t << decl << ": " << (*it) << " " << deps.join(" \\\n\t\t") << "\n\t" | ||
1458 | << "$(UIC) " << (*it) << " -o " << decl << endl << endl; | 1622 | << "$(UIC) " << (*it) << " -o " << decl << endl << endl; |
1459 | 1623 | ||
1460 | QString mildDecl = decl; | 1624 | QString mildDecl = decl; |
1461 | int k = mildDecl.findRev( Option::dir_sep ); | 1625 | int k = mildDecl.findRev( Option::dir_sep ); |
1462 | if ( k != -1 ) | 1626 | if ( k != -1 ) |
1463 | mildDecl = mildDecl.mid( k + 1 ); | 1627 | mildDecl = mildDecl.mid( k + 1 ); |
1464 | 1628 | t << impl << ": " << decl << " " << (*it) << " " << deps.join(" \\\n\t\t") << "\n\t" | |
1465 | t << impl << ": " << decl << " " << (*it) << " " << deps << "\n\t" | 1629 | << "$(UIC)"; |
1466 | << "$(UIC) " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl; | 1630 | t << " " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl; |
1467 | } | 1631 | } |
1468 | } | 1632 | } |
1469 | 1633 | ||
1470 | 1634 | ||
1471 | void | 1635 | void |
1472 | MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString &src) | 1636 | MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString &src) |
@@ -1474,27 +1638,28 @@ MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString | |||
1474 | QStringList &objl = project->variables()[obj], | 1638 | QStringList &objl = project->variables()[obj], |
1475 | &srcl = project->variables()[src]; | 1639 | &srcl = project->variables()[src]; |
1476 | QStringList::Iterator oit = objl.begin(), sit = srcl.begin(); | 1640 | QStringList::Iterator oit = objl.begin(), sit = srcl.begin(); |
1477 | QString stringSrc("$src"), stringObj("$obj"); | 1641 | QString stringSrc("$src"), stringObj("$obj"); |
1478 | for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) { | 1642 | for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) { |
1479 | QString hdr = findMocSource((*sit)); | 1643 | QString hdr = findMocSource((*sit)); |
1480 | t << (*oit) << ": " << (*sit) << " " | 1644 | t << (*oit) << ": " |
1645 | << (*sit) << " " << findDependencies((*sit)).join(" \\\n\t\t") << " " | ||
1481 | << hdr << " " << findDependencies(hdr).join(" \\\n\t\t"); | 1646 | << hdr << " " << findDependencies(hdr).join(" \\\n\t\t"); |
1482 | bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP"); | 1647 | bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP"); |
1483 | if(use_implicit_rule) { | 1648 | if(use_implicit_rule) { |
1484 | if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("MOC_DIR")) { | 1649 | if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("MOC_DIR")) { |
1485 | use_implicit_rule = FALSE; | 1650 | use_implicit_rule = FALSE; |
1486 | } else { | 1651 | } else { |
1487 | int dot = (*sit).findRev('.'); | 1652 | int dot = (*sit).findRev('.'); |
1488 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) | 1653 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) |
1489 | use_implicit_rule = FALSE; | 1654 | use_implicit_rule = FALSE; |
1490 | } | 1655 | } |
1491 | } | 1656 | } |
1492 | if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { | 1657 | if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { |
1493 | QString p = var("QMAKE_RUN_CXX"); | 1658 | QString p = var("QMAKE_RUN_CXX"), srcf(*sit); |
1494 | p.replace(stringSrc, (*sit)); | 1659 | p.replace(stringSrc, srcf); |
1495 | p.replace(stringObj, (*oit)); | 1660 | p.replace(stringObj, (*oit)); |
1496 | t << "\n\t" << p; | 1661 | t << "\n\t" << p; |
1497 | } | 1662 | } |
1498 | t << endl << endl; | 1663 | t << endl << endl; |
1499 | } | 1664 | } |
1500 | } | 1665 | } |
@@ -1509,13 +1674,14 @@ MakefileGenerator::writeMocSrc(QTextStream &t, const QString &src) | |||
1509 | if ( !m.isEmpty()) { | 1674 | if ( !m.isEmpty()) { |
1510 | QString deps; | 1675 | QString deps; |
1511 | if(!project->isActiveConfig("no_mocdepend")) | 1676 | if(!project->isActiveConfig("no_mocdepend")) |
1512 | deps += "$(MOC) "; | 1677 | deps += "$(MOC) "; |
1513 | deps += (*it); | 1678 | deps += (*it); |
1514 | t << m << ": " << deps << "\n\t" | 1679 | t << m << ": " << deps << "\n\t" |
1515 | << "$(MOC) " << (*it) << " -o " << m << endl << endl; | 1680 | << "$(MOC)"; |
1681 | t << " " << (*it) << " -o " << m << endl << endl; | ||
1516 | } | 1682 | } |
1517 | } | 1683 | } |
1518 | } | 1684 | } |
1519 | 1685 | ||
1520 | void | 1686 | void |
1521 | MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src) | 1687 | MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src) |
@@ -1542,12 +1708,15 @@ MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src) | |||
1542 | QString impl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first(); | 1708 | QString impl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first(); |
1543 | QString decl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first(); | 1709 | QString decl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first(); |
1544 | 1710 | ||
1545 | QString yaccflags = "$(YACCFLAGS)", mangle = "y"; | 1711 | QString yaccflags = "$(YACCFLAGS)", mangle = "y"; |
1546 | if(!project->isActiveConfig("yacc_no_name_mangle")) { | 1712 | if(!project->isActiveConfig("yacc_no_name_mangle")) { |
1547 | mangle = fi.baseName(TRUE); | 1713 | mangle = fi.baseName(TRUE); |
1714 | if(!project->isEmpty("QMAKE_YACCFLAGS_MANGLE")) | ||
1715 | yaccflags += " " + var("QMAKE_YACCFLAGS_MANGLE").replace(stringBase, mangle); | ||
1716 | else | ||
1548 | yaccflags += " -p " + mangle; | 1717 | yaccflags += " -p " + mangle; |
1549 | } | 1718 | } |
1550 | QString out_h = default_out_h, out_c = default_out_c; | 1719 | QString out_h = default_out_h, out_c = default_out_c; |
1551 | if(!mangle.isEmpty()) { | 1720 | if(!mangle.isEmpty()) { |
1552 | out_h.replace(stringBase, mangle); | 1721 | out_h.replace(stringBase, mangle); |
1553 | out_c.replace(stringBase, mangle); | 1722 | out_c.replace(stringBase, mangle); |
@@ -1618,14 +1787,14 @@ MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj) | |||
1618 | int dot = src.findRev('.'); | 1787 | int dot = src.findRev('.'); |
1619 | if(dot == -1 || (src.left(dot) + Option::obj_ext != (*oit))) | 1788 | if(dot == -1 || (src.left(dot) + Option::obj_ext != (*oit))) |
1620 | use_implicit_rule = FALSE; | 1789 | use_implicit_rule = FALSE; |
1621 | } | 1790 | } |
1622 | } | 1791 | } |
1623 | if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { | 1792 | if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) { |
1624 | QString p = var("QMAKE_RUN_CXX"); | 1793 | QString p = var("QMAKE_RUN_CXX"), srcf(src); |
1625 | p.replace( stringSrc, src); | 1794 | p.replace(stringSrc, srcf); |
1626 | p.replace( stringObj, (*oit)); | 1795 | p.replace( stringObj, (*oit)); |
1627 | t << "\n\t" << p; | 1796 | t << "\n\t" << p; |
1628 | } | 1797 | } |
1629 | t << endl << endl; | 1798 | t << endl << endl; |
1630 | } | 1799 | } |
1631 | } | 1800 | } |
@@ -1658,27 +1827,28 @@ void | |||
1658 | MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) | 1827 | MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) |
1659 | { | 1828 | { |
1660 | QString all_installs, all_uninstalls; | 1829 | QString all_installs, all_uninstalls; |
1661 | QStringList &l = project->variables()[installs]; | 1830 | QStringList &l = project->variables()[installs]; |
1662 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { | 1831 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { |
1663 | QString pvar = (*it) + ".path"; | 1832 | QString pvar = (*it) + ".path"; |
1664 | if(project->variables()[pvar].isEmpty()) { | 1833 | if(project->variables()[(*it) + ".CONFIG"].findIndex("no_path") == -1 && |
1834 | project->variables()[pvar].isEmpty()) { | ||
1665 | warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1()); | 1835 | warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1()); |
1666 | continue; | 1836 | continue; |
1667 | } | 1837 | } |
1668 | 1838 | ||
1669 | bool do_default = TRUE; | 1839 | bool do_default = TRUE; |
1670 | const QString root = "$(INSTALL_ROOT)"; | 1840 | const QString root = "$(INSTALL_ROOT)"; |
1671 | QString target, dst= fileFixify(project->variables()[pvar].first()); | 1841 | QString target, dst= fileFixify(project->variables()[pvar].first()); |
1672 | #ifndef Q_WS_WIN | ||
1673 | if(dst.right(1) != Option::dir_sep) | 1842 | if(dst.right(1) != Option::dir_sep) |
1674 | dst += Option::dir_sep; | 1843 | dst += Option::dir_sep; |
1675 | #endif | 1844 | QStringList tmp, uninst = project->variables()[(*it) + ".uninstall"]; |
1676 | QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"]; | ||
1677 | //other | 1845 | //other |
1678 | tmp = project->variables()[(*it) + ".extra"]; | 1846 | tmp = project->variables()[(*it) + ".extra"]; |
1847 | if(tmp.isEmpty()) | ||
1848 | tmp = project->variables()[(*it) + ".commands"]; //to allow compatible name | ||
1679 | if(!tmp.isEmpty()) { | 1849 | if(!tmp.isEmpty()) { |
1680 | do_default = FALSE; | 1850 | do_default = FALSE; |
1681 | if(!target.isEmpty()) | 1851 | if(!target.isEmpty()) |
1682 | target += "\n\t"; | 1852 | target += "\n\t"; |
1683 | target += tmp.join(" "); | 1853 | target += tmp.join(" "); |
1684 | } | 1854 | } |
@@ -1700,28 +1870,34 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) | |||
1700 | dirstr += Option::dir_sep; | 1870 | dirstr += Option::dir_sep; |
1701 | if(QFile::exists(wild)) { //real file | 1871 | if(QFile::exists(wild)) { //real file |
1702 | QString file = wild; | 1872 | QString file = wild; |
1703 | QFileInfo fi(wild); | 1873 | QFileInfo fi(wild); |
1704 | if(!target.isEmpty()) | 1874 | if(!target.isEmpty()) |
1705 | target += "\t"; | 1875 | target += "\t"; |
1706 | target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + | 1876 | QString cmd = QString(fi.isDir() ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" + |
1707 | Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + root + dst + "\"\n"; | 1877 | Option::fixPathToTargetOS(fileFixify(wild, QString::null, |
1878 | QString::null, FALSE, FALSE), FALSE) + | ||
1879 | "\" \"" + root + dst + "\"\n"; | ||
1880 | target += cmd; | ||
1708 | if(!project->isActiveConfig("debug") && | 1881 | if(!project->isActiveConfig("debug") && |
1709 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) | 1882 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) |
1710 | target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + filestr) + "\"\n"; | 1883 | target += QString("\t-") + var("QMAKE_STRIP") + " \"" + |
1884 | root + fileFixify(dst + filestr, QString::null, QString::null, FALSE, FALSE) + | ||
1885 | "\"\n"; | ||
1711 | if(!uninst.isEmpty()) | 1886 | if(!uninst.isEmpty()) |
1712 | uninst.append("\n\t"); | 1887 | uninst.append("\n\t"); |
1713 | uninst.append( | 1888 | uninst.append( |
1714 | #ifdef Q_WS_WIN | 1889 | #ifdef Q_WS_WIN |
1715 | QString("-$(DEL_FILE)") | 1890 | QString("-$(DEL_FILE)") |
1716 | #else | 1891 | #else |
1717 | QString("-$(DEL_FILE) -r") | 1892 | QString("-$(DEL_FILE) -r") |
1718 | #endif | 1893 | #endif |
1719 | + " \"" + root + fileFixify(dst + filestr) + "\""); | 1894 | + " \"" + root + fileFixify(dst + filestr, QString::null, QString::null, FALSE, FALSE) + "\""); |
1720 | continue; | 1895 | continue; |
1721 | } | 1896 | } |
1897 | fixEnvVariables(dirstr); | ||
1722 | QDir dir(dirstr, filestr); //wild | 1898 | QDir dir(dirstr, filestr); //wild |
1723 | for(uint x = 0; x < dir.count(); x++) { | 1899 | for(uint x = 0; x < dir.count(); x++) { |
1724 | QString file = dir[x]; | 1900 | QString file = dir[x]; |
1725 | if(file == "." || file == "..") //blah | 1901 | if(file == "." || file == "..") //blah |
1726 | continue; | 1902 | continue; |
1727 | if(!uninst.isEmpty()) | 1903 | if(!uninst.isEmpty()) |
@@ -1729,55 +1905,76 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) | |||
1729 | uninst.append( | 1905 | uninst.append( |
1730 | #ifdef Q_WS_WIN | 1906 | #ifdef Q_WS_WIN |
1731 | QString("-$(DEL_FILE)") | 1907 | QString("-$(DEL_FILE)") |
1732 | #else | 1908 | #else |
1733 | QString("-$(DEL_FILE) -r") | 1909 | QString("-$(DEL_FILE) -r") |
1734 | #endif | 1910 | #endif |
1735 | + " \"" + root + fileFixify(dst + file) + "\""); | 1911 | + " \"" + root + fileFixify(dst + file, QString::null, QString::null, FALSE, FALSE) + |
1736 | QFileInfo fi(file); | 1912 | "\""); |
1913 | QFileInfo fi(Option::fixPathToTargetOS(fileFixify(dirstr + file), TRUE)); | ||
1737 | if(!target.isEmpty()) | 1914 | if(!target.isEmpty()) |
1738 | target += "\t"; | 1915 | target += "\t"; |
1739 | target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" + | 1916 | QString cmd = QString(fi.isDir() ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" + |
1740 | Option::fixPathToTargetOS(fileFixify(dirstr + file), FALSE) + | 1917 | Option::fixPathToTargetOS(fileFixify(dirstr + file, QString::null, |
1741 | "\" \"" + root + fileFixify(dst) + "\"\n"; | 1918 | QString::null, FALSE, FALSE), FALSE) + |
1919 | "\" \"" + root + dst + "\"\n"; | ||
1920 | target += cmd; | ||
1742 | if(!project->isActiveConfig("debug") && | 1921 | if(!project->isActiveConfig("debug") && |
1743 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) | 1922 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) |
1744 | target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + file) + "\"\n"; | 1923 | target += QString("\t-") + var("QMAKE_STRIP") + " \"" + |
1924 | root + fileFixify(dst + file, QString::null, QString::null, FALSE, FALSE) + | ||
1925 | "\"\n"; | ||
1745 | } | 1926 | } |
1746 | } | 1927 | } |
1747 | } | 1928 | } |
1748 | //default? | 1929 | //default? |
1749 | if(do_default) | 1930 | if(do_default) { |
1750 | target = defaultInstall((*it)); | 1931 | target = defaultInstall((*it)); |
1932 | uninst = project->variables()[(*it) + ".uninstall"]; | ||
1933 | } | ||
1751 | 1934 | ||
1752 | if(!target.isEmpty()) { | 1935 | if(!target.isEmpty()) { |
1753 | t << "install_" << (*it) << ": " << "\n\t"; | 1936 | t << "install_" << (*it) << ": all "; |
1937 | const QStringList &deps = project->variables()[(*it) + ".depends"]; | ||
1938 | if(!deps.isEmpty()) { | ||
1939 | for(QStringList::ConstIterator dep_it = deps.begin(); dep_it != deps.end(); ++dep_it) { | ||
1940 | QString targ = var((*dep_it) + ".target"); | ||
1941 | if(targ.isEmpty()) | ||
1942 | targ = (*dep_it); | ||
1943 | t << targ; | ||
1944 | } | ||
1945 | } | ||
1946 | t << "\n\t"; | ||
1754 | const QStringList &dirs = project->variables()[pvar]; | 1947 | const QStringList &dirs = project->variables()[pvar]; |
1755 | for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) { | 1948 | for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) { |
1756 | QString tmp_dst = fileFixify((*pit)); | 1949 | QString tmp_dst = fileFixify((*pit)); |
1757 | #ifndef Q_WS_WIN | 1950 | #ifndef Q_WS_WIN |
1758 | if(tmp_dst.right(1) != Option::dir_sep) | 1951 | if(tmp_dst.right(1) != Option::dir_sep) |
1759 | tmp_dst += Option::dir_sep; | 1952 | tmp_dst += Option::dir_sep; |
1760 | #endif | 1953 | #endif |
1761 | t << mkdir_p_asstring(root+tmp_dst) << "\n\t"; | 1954 | t << mkdir_p_asstring(root+tmp_dst) << "\n\t"; |
1762 | } | 1955 | } |
1763 | t << target << endl << endl; | 1956 | t << target << endl << endl; |
1764 | all_installs += QString("install_") + (*it) + " "; | ||
1765 | if(!uninst.isEmpty()) { | 1957 | if(!uninst.isEmpty()) { |
1766 | t << "uninstall_" << (*it) << ": " << "\n\t" | 1958 | t << "uninstall_" << (*it) << ": " << "\n\t" |
1767 | << uninst.join("") << "\n\t" | 1959 | << uninst.join("") << "\n\t" |
1768 | << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl; | 1960 | << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl; |
1769 | all_uninstalls += "uninstall_" + (*it) + " "; | ||
1770 | } | 1961 | } |
1771 | t << endl; | 1962 | t << endl; |
1963 | |||
1964 | if(project->variables()[(*it) + ".CONFIG"].findIndex("no_default_install") == -1) { | ||
1965 | all_installs += QString("install_") + (*it) + " "; | ||
1966 | if(!uninst.isEmpty()) | ||
1967 | all_uninstalls += "uninstall_" + (*it) + " "; | ||
1968 | } | ||
1772 | } else { | 1969 | } else { |
1773 | debug_msg(1, "no definition for install %s: install target not created",(*it).latin1()); | 1970 | debug_msg(1, "no definition for install %s: install target not created",(*it).latin1()); |
1774 | } | 1971 | } |
1775 | } | 1972 | } |
1776 | t << "install: all " << all_installs << "\n\n"; | 1973 | t << "install: " << all_installs << " " << var("INSTALLDEPS") << "\n\n"; |
1777 | t << "uninstall: " << all_uninstalls << "\n\n"; | 1974 | t << "uninstall: " << all_uninstalls << " " << var("UNINSTALLDEPS") << "\n\n"; |
1778 | } | 1975 | } |
1779 | 1976 | ||
1780 | QString | 1977 | QString |
1781 | MakefileGenerator::var(const QString &var) | 1978 | MakefileGenerator::var(const QString &var) |
1782 | { | 1979 | { |
1783 | return val(project->variables()[var]); | 1980 | return val(project->variables()[var]); |
@@ -1968,14 +2165,18 @@ MakefileGenerator::writeMakeQmake(QTextStream &t) | |||
1968 | if(pfile != "(stdin)") { | 2165 | if(pfile != "(stdin)") { |
1969 | QString qmake = build_args(); | 2166 | QString qmake = build_args(); |
1970 | if(!ofile.isEmpty() && !project->isActiveConfig("no_autoqmake")) { | 2167 | if(!ofile.isEmpty() && !project->isActiveConfig("no_autoqmake")) { |
1971 | t << ofile << ": " << fileFixify(pfile) << " "; | 2168 | t << ofile << ": " << fileFixify(pfile) << " "; |
1972 | if(Option::mkfile::do_cache) | 2169 | if(Option::mkfile::do_cache) |
1973 | t << fileFixify(Option::mkfile::cachefile) << " "; | 2170 | t << fileFixify(Option::mkfile::cachefile) << " "; |
1974 | if(!specdir().isEmpty()) | 2171 | if(!specdir().isEmpty()) { |
2172 | if (QFile::exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"qmake.conf"))) | ||
1975 | t << specdir() << Option::dir_sep << "qmake.conf" << " "; | 2173 | t << specdir() << Option::dir_sep << "qmake.conf" << " "; |
2174 | else if (QFile::exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"tmake.conf"))) | ||
2175 | t << specdir() << Option::dir_sep << "tmake.conf" << " "; | ||
2176 | } | ||
1976 | t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t" | 2177 | t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t" |
1977 | << qmake <<endl; | 2178 | << qmake <<endl; |
1978 | } | 2179 | } |
1979 | if(project->first("QMAKE_ORIG_TARGET") != "qmake") { | 2180 | if(project->first("QMAKE_ORIG_TARGET") != "qmake") { |
1980 | t << "qmake: " << | 2181 | t << "qmake: " << |
1981 | project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].join(" \\\n\t\t") << "\n\t" | 2182 | project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].join(" \\\n\t\t") << "\n\t" |
@@ -1983,32 +2184,37 @@ MakefileGenerator::writeMakeQmake(QTextStream &t) | |||
1983 | } | 2184 | } |
1984 | } | 2185 | } |
1985 | return TRUE; | 2186 | return TRUE; |
1986 | } | 2187 | } |
1987 | 2188 | ||
1988 | QStringList | 2189 | QStringList |
1989 | MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir, bool force_fix) const | 2190 | MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir, |
2191 | bool force_fix, bool canon) const | ||
1990 | { | 2192 | { |
1991 | if(files.isEmpty()) | 2193 | if(files.isEmpty()) |
1992 | return files; | 2194 | return files; |
1993 | QStringList ret; | 2195 | QStringList ret; |
1994 | for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) { | 2196 | for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) { |
1995 | if(!(*it).isEmpty()) | 2197 | if(!(*it).isEmpty()) |
1996 | ret << fileFixify((*it), out_dir, in_dir, force_fix); | 2198 | ret << fileFixify((*it), out_dir, in_dir, force_fix, canon); |
1997 | } | 2199 | } |
1998 | return ret; | 2200 | return ret; |
1999 | } | 2201 | } |
2000 | 2202 | ||
2001 | QString | 2203 | QString |
2002 | MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const QString &in_d, bool force_fix) const | 2204 | MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, |
2205 | const QString &in_d, bool force_fix, bool canon) const | ||
2003 | { | 2206 | { |
2004 | if(file0.isEmpty()) | 2207 | if(file0.isEmpty()) |
2005 | return file0; | 2208 | return file0; |
2006 | QString key = file0; | 2209 | QString key = file0; |
2007 | if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix) | 2210 | if(QDir::isRelativePath(file0)) |
2008 | key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "-"); | 2211 | key.prepend(QDir::currentDirPath() + "--"); |
2212 | if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix || !canon) | ||
2213 | key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "--" + | ||
2214 | QString::number((int)canon) + "-"); | ||
2009 | if(fileFixed.contains(key)) | 2215 | if(fileFixed.contains(key)) |
2010 | return fileFixed[key]; | 2216 | return fileFixed[key]; |
2011 | 2217 | ||
2012 | QString file = file0; | 2218 | QString file = file0; |
2013 | int depth = 4; | 2219 | int depth = 4; |
2014 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || | 2220 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || |
@@ -2024,28 +2230,31 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const | |||
2024 | quote = file.at(0); | 2230 | quote = file.at(0); |
2025 | file = file.mid(1, file.length() - 2); | 2231 | file = file.mid(1, file.length() - 2); |
2026 | } | 2232 | } |
2027 | QString orig_file = file; | 2233 | QString orig_file = file; |
2028 | if(!force_fix && project->isActiveConfig("no_fixpath")) { | 2234 | if(!force_fix && project->isActiveConfig("no_fixpath")) { |
2029 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it | 2235 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it |
2030 | QString qfile = Option::fixPathToLocalOS(file); | 2236 | QString qfile = Option::fixPathToLocalOS(file, TRUE, canon); |
2031 | if(QDir::isRelativePath(file)) { //already absolute | 2237 | if(QDir::isRelativePath(file)) { //already absolute |
2032 | QFileInfo fi(qfile); | 2238 | QFileInfo fi(qfile); |
2033 | if(!fi.convertToAbs()) //strange | 2239 | if(!fi.convertToAbs()) //strange |
2034 | file = fi.filePath(); | 2240 | file = fi.filePath(); |
2035 | } | 2241 | } |
2036 | } | 2242 | } |
2037 | } else { //fix it.. | 2243 | } else { //fix it.. |
2038 | QString qfile(Option::fixPathToLocalOS(file, TRUE)), in_dir(in_d), out_dir(out_d); | 2244 | QString qfile(Option::fixPathToLocalOS(file, TRUE, canon)), in_dir(in_d), out_dir(out_d); |
2039 | { | 2245 | { |
2040 | if(out_dir.isNull()) | 2246 | if(out_dir.isNull() || QDir::isRelativePath(out_dir)) |
2041 | out_dir = Option::output_dir; | 2247 | out_dir.prepend(Option::output_dir + QDir::separator()); |
2042 | if(out_dir == ".") | 2248 | if(out_dir == ".") |
2043 | out_dir = QDir::currentDirPath(); | 2249 | out_dir = QDir::currentDirPath(); |
2044 | if(in_dir.isEmpty() || in_dir == ".") | 2250 | if(in_dir.isEmpty() || QDir::isRelativePath(in_dir)) |
2251 | in_dir.prepend(QDir::currentDirPath() + QDir::separator()); | ||
2252 | if(in_dir == ".") | ||
2045 | in_dir = QDir::currentDirPath(); | 2253 | in_dir = QDir::currentDirPath(); |
2254 | |||
2046 | if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) { | 2255 | if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) { |
2047 | QFileInfo in_fi(in_dir); | 2256 | QFileInfo in_fi(in_dir); |
2048 | if(!in_fi.convertToAbs()) | 2257 | if(!in_fi.convertToAbs()) |
2049 | in_dir = in_fi.filePath(); | 2258 | in_dir = in_fi.filePath(); |
2050 | QFileInfo out_fi(out_dir); | 2259 | QFileInfo out_fi(out_dir); |
2051 | if(!out_fi.convertToAbs()) | 2260 | if(!out_fi.convertToAbs()) |
@@ -2062,19 +2271,19 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const | |||
2062 | if(QDir::isRelativePath(qfile)) { | 2271 | if(QDir::isRelativePath(qfile)) { |
2063 | if(file.left(Option::dir_sep.length()) != Option::dir_sep && | 2272 | if(file.left(Option::dir_sep.length()) != Option::dir_sep && |
2064 | in_dir.right(Option::dir_sep.length()) != Option::dir_sep) | 2273 | in_dir.right(Option::dir_sep.length()) != Option::dir_sep) |
2065 | file.prepend(Option::dir_sep); | 2274 | file.prepend(Option::dir_sep); |
2066 | file.prepend(in_dir); | 2275 | file.prepend(in_dir); |
2067 | } | 2276 | } |
2068 | file = Option::fixPathToTargetOS(file, FALSE); | 2277 | file = Option::fixPathToTargetOS(file, FALSE, canon); |
2069 | if(QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE)) { | 2278 | if(canon && QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE, canon)) { |
2070 | QString real_file = QDir(file).canonicalPath(); | 2279 | QString real_file = QDir(file).canonicalPath(); |
2071 | if(!real_file.isEmpty()) | 2280 | if(!real_file.isEmpty()) |
2072 | file = real_file; | 2281 | file = real_file; |
2073 | } | 2282 | } |
2074 | QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE); | 2283 | QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE, canon); |
2075 | if(file == match_dir) { | 2284 | if(file == match_dir) { |
2076 | file = ""; | 2285 | file = ""; |
2077 | } else if(file.startsWith(match_dir) && | 2286 | } else if(file.startsWith(match_dir) && |
2078 | file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) { | 2287 | file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) { |
2079 | file = file.right(file.length() - (match_dir.length() + 1)); | 2288 | file = file.right(file.length() - (match_dir.length() + 1)); |
2080 | } else { | 2289 | } else { |
@@ -2097,18 +2306,19 @@ MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const | |||
2097 | file.prepend(".." + Option::dir_sep); | 2306 | file.prepend(".." + Option::dir_sep); |
2098 | } | 2307 | } |
2099 | } | 2308 | } |
2100 | } | 2309 | } |
2101 | } | 2310 | } |
2102 | } | 2311 | } |
2103 | file = Option::fixPathToTargetOS(file, FALSE); | 2312 | file = Option::fixPathToTargetOS(file, FALSE, canon); |
2104 | if(file.isEmpty()) | 2313 | if(file.isEmpty()) |
2105 | file = "."; | 2314 | file = "."; |
2106 | if(!quote.isNull()) | 2315 | if(!quote.isNull()) |
2107 | file = quote + file + quote; | 2316 | file = quote + file + quote; |
2108 | debug_msg(3, "Fixed %s :: to :: %s (%d)", orig_file.latin1(), file.latin1(), depth); | 2317 | debug_msg(3, "Fixed %s :: to :: %s (%d) [%s::%s]", orig_file.latin1(), file.latin1(), depth, |
2318 | in_d.latin1(), out_d.latin1()); | ||
2109 | ((MakefileGenerator*)this)->fileFixed.insert(key, file); | 2319 | ((MakefileGenerator*)this)->fileFixed.insert(key, file); |
2110 | return file; | 2320 | return file; |
2111 | } | 2321 | } |
2112 | 2322 | ||
2113 | QString | 2323 | QString |
2114 | MakefileGenerator::cleanFilePath(const QString &file) const | 2324 | MakefileGenerator::cleanFilePath(const QString &file) const |
@@ -2135,33 +2345,52 @@ void MakefileGenerator::logicWarn(const QString &f, const QString &w) | |||
2135 | file.latin1(), (*val_it).latin1(), w.latin1()); | 2345 | file.latin1(), (*val_it).latin1(), w.latin1()); |
2136 | break; | 2346 | break; |
2137 | } | 2347 | } |
2138 | } | 2348 | } |
2139 | } | 2349 | } |
2140 | 2350 | ||
2141 | QStringList | 2351 | QString |
2142 | &MakefileGenerator::findDependencies(const QString &file) | 2352 | MakefileGenerator::dependencyKey(const QString &file) const |
2143 | { | 2353 | { |
2144 | QString key = file; | 2354 | QString key = file; |
2145 | Option::fixPathToTargetOS(key); | 2355 | Option::fixPathToTargetOS(key); |
2146 | if(key.find(Option::dir_sep)) | 2356 | if(key.find(Option::dir_sep)) |
2147 | key = key.right(key.length() - key.findRev(Option::dir_sep) - 1); | 2357 | key = key.right(key.length() - key.findRev(Option::dir_sep) - 1); |
2148 | if(!depKeyMap.contains(key)) | 2358 | return key; |
2149 | depKeyMap.insert(key, file); | 2359 | } |
2150 | return depends[key]; | 2360 | |
2361 | void | ||
2362 | MakefileGenerator::setProcessedDependencies(const QString &file, bool b) | ||
2363 | { | ||
2364 | depProcessed[dependencyKey(file)] = b; | ||
2365 | } | ||
2366 | |||
2367 | bool | ||
2368 | MakefileGenerator::processedDependencies(const QString &file) | ||
2369 | { | ||
2370 | QString key = dependencyKey(file); | ||
2371 | if(!depProcessed.contains(key)) | ||
2372 | return FALSE; | ||
2373 | return depProcessed[key]; | ||
2374 | } | ||
2375 | |||
2376 | QStringList | ||
2377 | &MakefileGenerator::findDependencies(const QString &file) | ||
2378 | { | ||
2379 | return depends[dependencyKey(file)]; | ||
2151 | } | 2380 | } |
2152 | 2381 | ||
2153 | 2382 | ||
2154 | QString | 2383 | QString |
2155 | MakefileGenerator::specdir() | 2384 | MakefileGenerator::specdir() |
2156 | { | 2385 | { |
2157 | if(!spec.isEmpty()) | 2386 | if(!spec.isEmpty()) |
2158 | return spec; | 2387 | return spec; |
2159 | spec = Option::mkfile::qmakespec; | 2388 | spec = Option::mkfile::qmakespec; |
2160 | const char *d = getenv("QTDIR"); | 2389 | #if 0 |
2161 | if(d) { | 2390 | if(const char *d = getenv("QTDIR")) { |
2162 | QString qdir = Option::fixPathToTargetOS(QString(d)); | 2391 | QString qdir = Option::fixPathToTargetOS(QString(d)); |
2163 | if(qdir.endsWith(QString(QChar(QDir::separator())))) | 2392 | if(qdir.endsWith(QString(QChar(QDir::separator())))) |
2164 | qdir.truncate(qdir.length()-1); | 2393 | qdir.truncate(qdir.length()-1); |
2165 | //fix path | 2394 | //fix path |
2166 | QFileInfo fi(spec); | 2395 | QFileInfo fi(spec); |
2167 | QString absSpec(fi.absFilePath()); | 2396 | QString absSpec(fi.absFilePath()); |
@@ -2169,21 +2398,26 @@ MakefileGenerator::specdir() | |||
2169 | //replace what you can | 2398 | //replace what you can |
2170 | if(absSpec.startsWith(qdir)) { | 2399 | if(absSpec.startsWith(qdir)) { |
2171 | absSpec.replace(0, qdir.length(), "$(QTDIR)"); | 2400 | absSpec.replace(0, qdir.length(), "$(QTDIR)"); |
2172 | spec = absSpec; | 2401 | spec = absSpec; |
2173 | } | 2402 | } |
2174 | } | 2403 | } |
2404 | #else | ||
2405 | spec = Option::fixPathToTargetOS(spec); | ||
2406 | #endif | ||
2175 | return spec; | 2407 | return spec; |
2176 | } | 2408 | } |
2177 | 2409 | ||
2178 | bool | 2410 | bool |
2179 | MakefileGenerator::openOutput(QFile &file) const | 2411 | MakefileGenerator::openOutput(QFile &file) const |
2180 | { | 2412 | { |
2181 | { | 2413 | { |
2182 | QString outdir; | 2414 | QString outdir; |
2183 | if(!file.name().isEmpty()) { | 2415 | if(!file.name().isEmpty()) { |
2416 | if(QDir::isRelativePath(file.name())) | ||
2417 | file.setName(Option::output_dir + file.name()); //pwd when qmake was run | ||
2184 | QFileInfo fi(file); | 2418 | QFileInfo fi(file); |
2185 | if(fi.isDir()) | 2419 | if(fi.isDir()) |
2186 | outdir = file.name() + QDir::separator(); | 2420 | outdir = file.name() + QDir::separator(); |
2187 | } | 2421 | } |
2188 | if(!outdir.isEmpty() || file.name().isEmpty()) { | 2422 | if(!outdir.isEmpty() || file.name().isEmpty()) { |
2189 | QString fname = "Makefile"; | 2423 | QString fname = "Makefile"; |