1 | /****************************************************************************
|
---|
2 | ** $Id: makefile.cpp 8 2005-11-16 19:36:46Z dmik $
|
---|
3 | **
|
---|
4 | ** Implementation of MakefileGenerator class.
|
---|
5 | **
|
---|
6 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
|
---|
7 | **
|
---|
8 | ** This file is part of qmake.
|
---|
9 | **
|
---|
10 | ** This file may be distributed under the terms of the Q Public License
|
---|
11 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
12 | ** LICENSE.QPL included in the packaging of this file.
|
---|
13 | **
|
---|
14 | ** This file may be distributed and/or modified under the terms of the
|
---|
15 | ** GNU General Public License version 2 as published by the Free Software
|
---|
16 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
17 | ** packaging of this file.
|
---|
18 | **
|
---|
19 | ** Licensees holding valid Qt Enterprise Edition licenses may use this
|
---|
20 | ** file in accordance with the Qt Commercial License Agreement provided
|
---|
21 | ** with the Software.
|
---|
22 | **
|
---|
23 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
24 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
25 | **
|
---|
26 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
27 | ** information about Qt Commercial License Agreements.
|
---|
28 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
30 | **
|
---|
31 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
32 | ** not clear to you.
|
---|
33 | **
|
---|
34 | **********************************************************************/
|
---|
35 |
|
---|
36 | #include "makefile.h"
|
---|
37 | #include "option.h"
|
---|
38 | #include "meta.h"
|
---|
39 | #include <qdir.h>
|
---|
40 | #include <qfile.h>
|
---|
41 | #include <qtextstream.h>
|
---|
42 | #include <qregexp.h>
|
---|
43 | #include <qdict.h>
|
---|
44 | #if defined(Q_OS_UNIX)
|
---|
45 | #include <unistd.h>
|
---|
46 | #else
|
---|
47 | #include <io.h>
|
---|
48 | #endif
|
---|
49 | #include <stdio.h>
|
---|
50 | #include <stdlib.h>
|
---|
51 | #include <time.h>
|
---|
52 | #include <fcntl.h>
|
---|
53 | #include <sys/types.h>
|
---|
54 | #include <sys/stat.h>
|
---|
55 |
|
---|
56 | // Well, Windows doesn't have this, so here's the macro
|
---|
57 | #ifndef S_ISDIR
|
---|
58 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | QString mkdir_p_asstring(const QString &dir)
|
---|
62 | {
|
---|
63 | //@@TODO (dmik): OS/2 cannot create multiple subdirs in mkdir.
|
---|
64 | //@@TODO (dmik): fix it here? (mkdir a\b\c = mkdir a;a\b;a\b\c)
|
---|
65 | QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" ";
|
---|
66 | if(Option::target_mode == Option::TARG_WIN_MODE ||
|
---|
67 | Option::target_mode == Option::TARG_OS2_MODE
|
---|
68 | )
|
---|
69 | ret += "$(MKDIR)";
|
---|
70 | else
|
---|
71 | ret += "|| $(MKDIR)";
|
---|
72 | ret += " \"" + dir + "\"";
|
---|
73 | return ret;
|
---|
74 | }
|
---|
75 |
|
---|
76 | static bool createDir(const QString& fullPath)
|
---|
77 | {
|
---|
78 | if(QFile::exists(fullPath))
|
---|
79 | return FALSE;
|
---|
80 | QDir dirTmp;
|
---|
81 | bool ret = TRUE;
|
---|
82 | QString pathComponent, tmpPath;
|
---|
83 | QStringList hierarchy = QStringList::split(QString(Option::dir_sep), fullPath, TRUE);
|
---|
84 | for(QStringList::Iterator it = hierarchy.begin(); it != hierarchy.end(); ++it) {
|
---|
85 | pathComponent = *it + QDir::separator();
|
---|
86 | tmpPath += pathComponent;
|
---|
87 | if(!dirTmp.mkdir(tmpPath)) {
|
---|
88 | ret = FALSE;
|
---|
89 | // break;
|
---|
90 | }
|
---|
91 | }
|
---|
92 | return ret;
|
---|
93 | }
|
---|
94 |
|
---|
95 |
|
---|
96 | MakefileGenerator::MakefileGenerator(QMakeProject *p) : init_opath_already(FALSE),
|
---|
97 | init_already(FALSE), moc_aware(FALSE),
|
---|
98 | no_io(FALSE), project(p)
|
---|
99 | {
|
---|
100 | }
|
---|
101 |
|
---|
102 | static char *gimme_buffer(off_t s)
|
---|
103 | {
|
---|
104 | static char *big_buffer = NULL;
|
---|
105 | static int big_buffer_size = 0;
|
---|
106 | if(!big_buffer || big_buffer_size < s)
|
---|
107 | big_buffer = (char *)realloc(big_buffer, s);
|
---|
108 | return big_buffer;
|
---|
109 | }
|
---|
110 |
|
---|
111 | bool
|
---|
112 | MakefileGenerator::generateMocList(const QString &fn_target)
|
---|
113 | {
|
---|
114 | if(!findMocDestination(fn_target).isEmpty())
|
---|
115 | return TRUE;
|
---|
116 |
|
---|
117 | QString fn_local = Option::fixPathToLocalOS(fileFixify(fn_target, QDir::currentDirPath(), Option::output_dir));
|
---|
118 |
|
---|
119 | int file = open(fn_local.latin1(), O_RDONLY);
|
---|
120 | if(file == -1)
|
---|
121 | return FALSE;
|
---|
122 |
|
---|
123 | struct stat fst;
|
---|
124 | if(fstat(file, &fst) || S_ISDIR(fst.st_mode))
|
---|
125 | return FALSE; //shouldn't happen
|
---|
126 | char *big_buffer = gimme_buffer(fst.st_size);
|
---|
127 |
|
---|
128 | int total_size_read;
|
---|
129 | for(int have_read = total_size_read = 0;
|
---|
130 | (have_read = read(file, big_buffer + total_size_read,
|
---|
131 | fst.st_size - total_size_read));
|
---|
132 | total_size_read += have_read);
|
---|
133 | close(file);
|
---|
134 |
|
---|
135 | bool ignore_qobject = FALSE;
|
---|
136 | int line_count = 1;
|
---|
137 | /* qmake ignore Q_OBJECT */
|
---|
138 | #define COMP_LEN 8 //strlen("Q_OBJECT")
|
---|
139 | #define OBJ_LEN 8 //strlen("Q_OBJECT")
|
---|
140 | #define DIS_LEN 10 //strlen("Q_DISPATCH")
|
---|
141 | int x;
|
---|
142 | for(x = 0; x < (total_size_read-COMP_LEN); x++) {
|
---|
143 | if(*(big_buffer + x) == '/') {
|
---|
144 | x++;
|
---|
145 | if(total_size_read >= x) {
|
---|
146 | if(*(big_buffer + x) == '/') { //c++ style comment
|
---|
147 | for( ;x < total_size_read && *(big_buffer + x) != '\n'; x++);
|
---|
148 | line_count++;
|
---|
149 | } else if(*(big_buffer + x) == '*') { //c style comment
|
---|
150 | for( ;x < total_size_read; x++) {
|
---|
151 | if(*(big_buffer + x) == 't' || *(big_buffer + x) == 'q') { //ignore
|
---|
152 | if(total_size_read >= (x + 20)) {
|
---|
153 | if(!strncmp(big_buffer + x + 1, "make ignore Q_OBJECT", 20)) {
|
---|
154 | debug_msg(2, "Mocgen: %s:%d Found \"qmake ignore Q_OBJECT\"",
|
---|
155 | fn_target.latin1(), line_count);
|
---|
156 | x += 20;
|
---|
157 | ignore_qobject = TRUE;
|
---|
158 | }
|
---|
159 | }
|
---|
160 | } else if(*(big_buffer + x) == '*') {
|
---|
161 | if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') {
|
---|
162 | x += 2;
|
---|
163 | break;
|
---|
164 | }
|
---|
165 | } else if(*(big_buffer + x) == '\n') {
|
---|
166 | line_count++;
|
---|
167 | }
|
---|
168 | }
|
---|
169 | }
|
---|
170 | }
|
---|
171 | }
|
---|
172 | #define SYMBOL_CHAR(x) ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') || \
|
---|
173 | (x <= '0' && x >= '9') || x == '_')
|
---|
174 |
|
---|
175 | bool interesting = *(big_buffer+x) == 'Q' && (!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN) ||
|
---|
176 | !strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN));
|
---|
177 | if(interesting) {
|
---|
178 | int len = 0;
|
---|
179 | if(!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN)) {
|
---|
180 | if(ignore_qobject) {
|
---|
181 | debug_msg(2, "Mocgen: %s:%d Ignoring Q_OBJECT", fn_target.latin1(), line_count);
|
---|
182 | interesting = FALSE;
|
---|
183 | }
|
---|
184 | len=OBJ_LEN;
|
---|
185 | } else if(!strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN)) {
|
---|
186 | len=DIS_LEN;
|
---|
187 | }
|
---|
188 | if(SYMBOL_CHAR(*(big_buffer+x+len)))
|
---|
189 | interesting = FALSE;
|
---|
190 | if(interesting) {
|
---|
191 | *(big_buffer+x+len) = '\0';
|
---|
192 | debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", fn_target.latin1(),
|
---|
193 | line_count, big_buffer+x);
|
---|
194 |
|
---|
195 | int ext_pos = fn_target.findRev('.');
|
---|
196 | int ext_len = fn_target.length() - ext_pos;
|
---|
197 | int dir_pos = fn_target.findRev(Option::dir_sep, ext_pos);
|
---|
198 | QString mocFile;
|
---|
199 | if(!project->isEmpty("MOC_DIR"))
|
---|
200 | mocFile = project->first("MOC_DIR");
|
---|
201 | else if(dir_pos != -1)
|
---|
202 | mocFile = fn_target.left(dir_pos+1);
|
---|
203 |
|
---|
204 | bool cpp_ext = FALSE;
|
---|
205 | for(QStringList::Iterator cppit = Option::cpp_ext.begin();
|
---|
206 | cppit != Option::cpp_ext.end(); ++cppit) {
|
---|
207 | if((cpp_ext = (fn_target.right(ext_len) == (*cppit))))
|
---|
208 | break;
|
---|
209 | }
|
---|
210 | if(cpp_ext) {
|
---|
211 | mocFile += Option::cpp_moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::cpp_moc_ext;
|
---|
212 | project->variables()["_SRCMOC"].append(mocFile);
|
---|
213 | } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) {
|
---|
214 | for(QStringList::Iterator hit = Option::h_ext.begin();
|
---|
215 | hit != Option::h_ext.end(); ++hit) {
|
---|
216 | if((fn_target.right(ext_len) == (*hit))) {
|
---|
217 | mocFile += Option::h_moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) +
|
---|
218 | Option::h_moc_ext;
|
---|
219 | logicWarn(mocFile, "SOURCES");
|
---|
220 | project->variables()["_HDRMOC"].append(mocFile);
|
---|
221 | break;
|
---|
222 | }
|
---|
223 | }
|
---|
224 | }
|
---|
225 |
|
---|
226 | if(!mocFile.isEmpty()) {
|
---|
227 | mocFile = Option::fixPathToTargetOS(mocFile);
|
---|
228 | mocablesToMOC[cleanFilePath(fn_target)] = mocFile;
|
---|
229 | mocablesFromMOC[cleanFilePath(mocFile)] = fn_target;
|
---|
230 | }
|
---|
231 | break;
|
---|
232 | }
|
---|
233 | }
|
---|
234 |
|
---|
235 | while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x)))
|
---|
236 | x++;
|
---|
237 | if(*(big_buffer+x) == '\n')
|
---|
238 | line_count++;
|
---|
239 | }
|
---|
240 | #undef OBJ_LEN
|
---|
241 | #undef DIS_LEN
|
---|
242 | return TRUE;
|
---|
243 | }
|
---|
244 |
|
---|
245 | bool
|
---|
246 | MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse)
|
---|
247 | {
|
---|
248 | if(processedDependencies(f))
|
---|
249 | return TRUE;
|
---|
250 | setProcessedDependencies(f, TRUE);
|
---|
251 |
|
---|
252 | QStringList &fndeps = findDependencies(f);
|
---|
253 | QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir);
|
---|
254 | fn = Option::fixPathToLocalOS(fn, FALSE);
|
---|
255 | QString fix_env_fn = Option::fixPathToLocalOS(fn);
|
---|
256 | int file = open(fix_env_fn.latin1(), O_RDONLY);
|
---|
257 | if(file == -1)
|
---|
258 | return FALSE;
|
---|
259 | struct stat fst;
|
---|
260 | if(fstat(file, &fst) || S_ISDIR(fst.st_mode))
|
---|
261 | return FALSE; //shouldn't happen
|
---|
262 |
|
---|
263 | QString fndir, fix_env_fndir;
|
---|
264 | int dl = fn.findRev(Option::dir_sep);
|
---|
265 | if(dl != -1)
|
---|
266 | fndir = fn.left(dl+1);
|
---|
267 | dl = fix_env_fn.findRev(Option::dir_sep);
|
---|
268 | if(dl != -1)
|
---|
269 | fix_env_fndir = fix_env_fn.left(dl + 1);
|
---|
270 |
|
---|
271 | int line_count = 1;
|
---|
272 | char *big_buffer = gimme_buffer(fst.st_size);
|
---|
273 |
|
---|
274 | int total_size_read;
|
---|
275 | for(int have_read = total_size_read = 0;
|
---|
276 | (have_read = read(file, big_buffer + total_size_read,
|
---|
277 | fst.st_size - total_size_read));
|
---|
278 | total_size_read += have_read);
|
---|
279 | close(file);
|
---|
280 |
|
---|
281 | bool ui_file = fn.endsWith(Option::ui_ext);
|
---|
282 | for(int x = 0; x < total_size_read; x++) {
|
---|
283 | QStringList *outdeps=&fndeps;
|
---|
284 | QString inc;
|
---|
285 | if(!ui_file) {
|
---|
286 | if(*(big_buffer + x) == '/') {
|
---|
287 | x++;
|
---|
288 | if(total_size_read >= x) {
|
---|
289 | if(*(big_buffer + x) == '/') { //c++ style comment
|
---|
290 | for( ; x < total_size_read && *(big_buffer + x) != '\n'; x++);
|
---|
291 | } else if(*(big_buffer + x) == '*') { //c style comment
|
---|
292 | for( ; x < total_size_read; x++) {
|
---|
293 | if(*(big_buffer + x) == '*') {
|
---|
294 | if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') {
|
---|
295 | x += 2;
|
---|
296 | break;
|
---|
297 | }
|
---|
298 | } else if(*(big_buffer + x) == '\n') {
|
---|
299 | line_count++;
|
---|
300 | }
|
---|
301 | }
|
---|
302 | }
|
---|
303 | }
|
---|
304 | }
|
---|
305 | if(*(big_buffer + x) == '#') {
|
---|
306 | x++;
|
---|
307 | while(x < total_size_read && //Skip spaces after hash
|
---|
308 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'))
|
---|
309 | x++;
|
---|
310 | if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) &&
|
---|
311 | (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '\t' ||
|
---|
312 | *(big_buffer + x + 7) == '<' || *(big_buffer + x + 7) == '"')) {
|
---|
313 | for(x+=7; //skip spaces after keyword
|
---|
314 | x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t');
|
---|
315 | x++);
|
---|
316 | char term = *(big_buffer + x);
|
---|
317 | if(term == '"');
|
---|
318 | else if(term == '<')
|
---|
319 | term = '>';
|
---|
320 | else
|
---|
321 | continue; //wtf?
|
---|
322 | x++;
|
---|
323 |
|
---|
324 | int inc_len;
|
---|
325 | for(inc_len = 0; *(big_buffer + x + inc_len) != term &&
|
---|
326 | *(big_buffer + x + inc_len) != '\n'; inc_len++);
|
---|
327 | *(big_buffer + x + inc_len) = '\0';
|
---|
328 | inc = big_buffer + x;
|
---|
329 | } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) {
|
---|
330 | for(x+=14; //skip spaces after keyword
|
---|
331 | x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t');
|
---|
332 | x++);
|
---|
333 | char term = '\n';
|
---|
334 | if(*(big_buffer + x) == '"')
|
---|
335 | term = '"';
|
---|
336 | if(*(big_buffer + x) == '\'')
|
---|
337 | term = '\'';
|
---|
338 | if(term != '\n')
|
---|
339 | x++;
|
---|
340 |
|
---|
341 | int msg_len;
|
---|
342 | for(msg_len = 0; *(big_buffer + x + msg_len) != term &&
|
---|
343 | *(big_buffer + x + msg_len) != '\n'; msg_len++);
|
---|
344 | *(big_buffer + x + msg_len) = '\0';
|
---|
345 | QString msg = big_buffer + x;
|
---|
346 | debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(),
|
---|
347 | line_count, msg.latin1());
|
---|
348 | *(big_buffer + x + msg_len) = term; //put it back
|
---|
349 | }
|
---|
350 | }
|
---|
351 | } else if(ui_file) {
|
---|
352 | // skip whitespaces
|
---|
353 | while(x < total_size_read &&
|
---|
354 | (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'))
|
---|
355 | x++;
|
---|
356 | if(*(big_buffer + x) == '<') {
|
---|
357 | x++;
|
---|
358 | if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) &&
|
---|
359 | (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) {
|
---|
360 | for(x += 12; *(big_buffer + x) != '>'; x++);
|
---|
361 | int inc_len = 0;
|
---|
362 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
|
---|
363 | *(big_buffer + x + inc_len) = '\0';
|
---|
364 | inc = big_buffer + x;
|
---|
365 | } else if(total_size_read >= x + 13 && !strncmp(big_buffer + x, "customwidget", 12) &&
|
---|
366 | (*(big_buffer + x + 12) == ' ' || *(big_buffer + x + 12) == '>')) {
|
---|
367 | for(x += 13; *(big_buffer + x) != '>'; x++); //skip up to >
|
---|
368 | while(x < total_size_read) {
|
---|
369 | for(x++; *(big_buffer + x) != '<'; x++); //skip up to <
|
---|
370 | x++;
|
---|
371 | if(total_size_read >= x + 7 && !strncmp(big_buffer+x, "header", 6) &&
|
---|
372 | (*(big_buffer + x + 6) == ' ' || *(big_buffer + x + 6) == '>')) {
|
---|
373 | for(x += 7; *(big_buffer + x) != '>'; x++); //skip up to >
|
---|
374 | int inc_len = 0;
|
---|
375 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
|
---|
376 | *(big_buffer + x + inc_len) = '\0';
|
---|
377 | inc = big_buffer + x;
|
---|
378 | break;
|
---|
379 | } else if(total_size_read >= x + 14 && !strncmp(big_buffer+x, "/customwidget", 13) &&
|
---|
380 | (*(big_buffer + x + 13) == ' ' || *(big_buffer + x + 13) == '>')) {
|
---|
381 | x += 14;
|
---|
382 | break;
|
---|
383 | }
|
---|
384 | }
|
---|
385 | } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) &&
|
---|
386 | (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) {
|
---|
387 | for(x += 8; *(big_buffer + x) != '>'; x++) {
|
---|
388 | if(total_size_read >= x + 9 && *(big_buffer + x) == 'i' &&
|
---|
389 | !strncmp(big_buffer + x, "impldecl", 8)) {
|
---|
390 | for(x += 8; *(big_buffer + x) != '='; x++);
|
---|
391 | if(*(big_buffer + x) != '=')
|
---|
392 | continue;
|
---|
393 | for(x++; *(big_buffer+x) == '\t' || *(big_buffer+x) == ' '; x++);
|
---|
394 | char quote = 0;
|
---|
395 | if(*(big_buffer+x) == '\'' || *(big_buffer+x) == '"') {
|
---|
396 | quote = *(big_buffer + x);
|
---|
397 | x++;
|
---|
398 | }
|
---|
399 | int val_len;
|
---|
400 | for(val_len = 0; TRUE; val_len++) {
|
---|
401 | if(quote) {
|
---|
402 | if(*(big_buffer+x+val_len) == quote)
|
---|
403 | break;
|
---|
404 | } else if(*(big_buffer + x + val_len) == '>' ||
|
---|
405 | *(big_buffer + x + val_len) == ' ') {
|
---|
406 | break;
|
---|
407 | }
|
---|
408 | }
|
---|
409 | char saved = *(big_buffer + x + val_len);
|
---|
410 | *(big_buffer + x + val_len) = '\0';
|
---|
411 | QString where = big_buffer + x;
|
---|
412 | *(big_buffer + x + val_len) = saved;
|
---|
413 | if(where == "in implementation") {
|
---|
414 | QString cpp = fn.left(fn.length() - Option::ui_ext.length()) +
|
---|
415 | Option::cpp_ext.first();
|
---|
416 | outdeps = &findDependencies(cpp);
|
---|
417 | }
|
---|
418 | }
|
---|
419 | }
|
---|
420 | int inc_len = 0;
|
---|
421 | for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
|
---|
422 | *(big_buffer + x + inc_len) = '\0';
|
---|
423 | inc = big_buffer + x;
|
---|
424 | }
|
---|
425 | }
|
---|
426 | }
|
---|
427 |
|
---|
428 | if(!inc.isEmpty()) {
|
---|
429 | bool from_source_dir = TRUE;
|
---|
430 | debug_msg(5, "%s:%d Found dependency to %s", fix_env_fn.latin1(),
|
---|
431 | line_count, inc.latin1());
|
---|
432 | if(!project->isEmpty("SKIP_DEPENDS")) {
|
---|
433 | bool found = FALSE;
|
---|
434 | QStringList &nodeplist = project->values("SKIP_DEPENDS");
|
---|
435 | for(QStringList::Iterator it = nodeplist.begin();
|
---|
436 | it != nodeplist.end(); ++it) {
|
---|
437 | QRegExp regx((*it));
|
---|
438 | if(regx.search(inc) != -1) {
|
---|
439 | found = TRUE;
|
---|
440 | break;
|
---|
441 | }
|
---|
442 | }
|
---|
443 | if(found)
|
---|
444 | continue;
|
---|
445 | }
|
---|
446 | QString fqn;
|
---|
447 | if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") &&
|
---|
448 | !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) {
|
---|
449 | fqn = fndir + inc;
|
---|
450 | goto handle_fqn;
|
---|
451 | } else {
|
---|
452 | if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) ||
|
---|
453 | ((Option::target_mode == Option::TARG_WIN_MODE ||
|
---|
454 | Option::target_mode == Option::TARG_OS2_MODE) && inc[1] != ':') ||
|
---|
455 | ((Option::target_mode == Option::TARG_UNIX_MODE ||
|
---|
456 | Option::target_mode == Option::TARG_QNX6_MODE ||
|
---|
457 | Option::target_mode == Option::TARG_MACX_MODE) &&
|
---|
458 | inc[0] != '/')) {
|
---|
459 | for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) {
|
---|
460 | if(!stat(mdd->local_dir + QDir::separator() + inc, &fst) &&
|
---|
461 | !S_ISDIR(fst.st_mode)) {
|
---|
462 | fqn = mdd->real_dir + QDir::separator() + inc;
|
---|
463 | goto handle_fqn;
|
---|
464 | }
|
---|
465 | }
|
---|
466 | }
|
---|
467 | }
|
---|
468 | if(fqn.isEmpty() && Option::mkfile::do_dep_heuristics) {
|
---|
469 | //these are some hacky heuristics it will try to do on an include
|
---|
470 | //however these can be turned off at runtime, I'm not sure how
|
---|
471 | //reliable these will be, most likely when problems arise turn it off
|
---|
472 | //and see if they go away..
|
---|
473 | if(depHeuristics.contains(inc)) {
|
---|
474 | fqn = depHeuristics[inc];
|
---|
475 | from_source_dir = FALSE;
|
---|
476 | } else if(Option::mkfile::do_dep_heuristics) { //some heuristics..
|
---|
477 | //is it a file from a .ui?
|
---|
478 | QString inc_file = inc.section(Option::dir_sep, -1);
|
---|
479 | int extn = inc_file.findRev('.');
|
---|
480 | if(extn != -1 &&
|
---|
481 | (inc_file.right(inc_file.length()-extn) == Option::cpp_ext.first() ||
|
---|
482 | inc_file.right(inc_file.length()-extn) == Option::h_ext.first())) {
|
---|
483 | QString uip = inc_file.left(extn) + Option::ui_ext;
|
---|
484 | QStringList uil = project->variables()["FORMS"];
|
---|
485 | for(QStringList::Iterator it = uil.begin(); it != uil.end(); ++it) {
|
---|
486 | if((*it).section(Option::dir_sep, -1) == uip) {
|
---|
487 | if(!project->isEmpty("UI_DIR"))
|
---|
488 | fqn = project->first("UI_DIR");
|
---|
489 | else if(!project->isEmpty("UI_HEADERS_DIR"))
|
---|
490 | fqn = project->first("UI_HEADERS_DIR");
|
---|
491 | else
|
---|
492 | fqn = (*it).section(Option::dir_sep, 0, -2);
|
---|
493 | if(!fqn.isEmpty() && !fqn.endsWith(Option::dir_sep))
|
---|
494 | fqn += Option::dir_sep;
|
---|
495 | fqn += inc_file;
|
---|
496 | from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
|
---|
497 | fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
|
---|
498 | goto cache_fqn;
|
---|
499 | }
|
---|
500 | }
|
---|
501 | }
|
---|
502 | if(project->isActiveConfig("lex_included")) { //is this the lex file?
|
---|
503 | QString rhs = Option::lex_mod + Option::cpp_ext.first();
|
---|
504 | if(inc.endsWith(rhs)) {
|
---|
505 | QString lhs = inc.left(inc.length() - rhs.length()) + Option::lex_ext;
|
---|
506 | QStringList ll = project->variables()["LEXSOURCES"];
|
---|
507 | for(QStringList::Iterator it = ll.begin(); it != ll.end(); ++it) {
|
---|
508 | QString s = (*it), d;
|
---|
509 | int slsh = s.findRev(Option::dir_sep);
|
---|
510 | if(slsh != -1) {
|
---|
511 | d = s.left(slsh + 1);
|
---|
512 | s = s.right(s.length() - slsh - 1);
|
---|
513 | }
|
---|
514 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
|
---|
515 | d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH");
|
---|
516 | if(s == lhs) {
|
---|
517 | fqn = d + inc;
|
---|
518 | from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
|
---|
519 | fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
|
---|
520 | goto cache_fqn;
|
---|
521 | }
|
---|
522 | }
|
---|
523 | }
|
---|
524 | }
|
---|
525 | { //is it from a .y?
|
---|
526 | QString rhs = Option::yacc_mod + Option::h_ext.first();
|
---|
527 | if(inc.endsWith(rhs)) {
|
---|
528 | QString lhs = inc.left(inc.length() - rhs.length()) + Option::yacc_ext;
|
---|
529 | QStringList yl = project->variables()["YACCSOURCES"];
|
---|
530 | for(QStringList::Iterator it = yl.begin(); it != yl.end(); ++it) {
|
---|
531 | QString s = (*it), d;
|
---|
532 | int slsh = s.findRev(Option::dir_sep);
|
---|
533 | if(slsh != -1) {
|
---|
534 | d = s.left(slsh + 1);
|
---|
535 | s = s.right(s.length() - slsh - 1);
|
---|
536 | }
|
---|
537 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
|
---|
538 | d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH");
|
---|
539 | if(s == lhs) {
|
---|
540 | fqn = d + inc;
|
---|
541 | from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
|
---|
542 | fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
|
---|
543 | goto cache_fqn;
|
---|
544 | }
|
---|
545 | }
|
---|
546 | }
|
---|
547 | }
|
---|
548 | if( mocAware() && //is it a moc file?
|
---|
549 | ( inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::cpp_moc_ext) )
|
---|
550 | || ( (Option::cpp_ext.first() != Option::h_moc_ext) && inc.endsWith(Option::h_moc_ext) )) {
|
---|
551 | QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null };
|
---|
552 | for(int moc = 0; !mocs[moc].isNull(); moc++) {
|
---|
553 | QStringList &l = project->variables()[mocs[moc]];
|
---|
554 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
555 | QString file = Option::fixPathToTargetOS((*it));
|
---|
556 | if(file.section(Option::dir_sep, -(inc.contains('/')+1)) == inc) {
|
---|
557 | fqn = (*it);
|
---|
558 | if(mocs[moc] == "_HDRMOC") {
|
---|
559 | //Since it is include, no need to link it in as well
|
---|
560 | project->variables()["_SRCMOC"].append((*it));
|
---|
561 | l.remove(it);
|
---|
562 | } else if(!findMocSource(fqn).endsWith(fileFixify(fn))) {
|
---|
563 | /* Not really a very good test, but this will at least avoid
|
---|
564 | confusion if it really does happen (since tmake/qmake
|
---|
565 | previously didn't even allow this the test is mostly accurate) */
|
---|
566 | warn_msg(WarnLogic,
|
---|
567 | "Found potential multiple MOC include %s (%s) in '%s'",
|
---|
568 | inc.latin1(), fqn.latin1(), fix_env_fn.latin1());
|
---|
569 | }
|
---|
570 | from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them)
|
---|
571 | goto cache_fqn;
|
---|
572 | }
|
---|
573 | }
|
---|
574 | }
|
---|
575 | }
|
---|
576 | fqn = findDependency(inc); //all else fails..
|
---|
577 | cache_fqn:
|
---|
578 | if(from_source_dir) {
|
---|
579 | fqn = fileFixify(fqn);
|
---|
580 | from_source_dir = FALSE;
|
---|
581 | }
|
---|
582 | depHeuristics.insert(inc, fqn);
|
---|
583 | }
|
---|
584 | }
|
---|
585 | handle_fqn:
|
---|
586 | if(fqn.isEmpty()) //I give up
|
---|
587 | continue;
|
---|
588 | fqn = Option::fixPathToTargetOS(fqn, FALSE);
|
---|
589 | if(from_source_dir)
|
---|
590 | fqn = fileFixify(fqn);
|
---|
591 | debug_msg(4, "Resolved dependency of %s to %s", inc.latin1(), fqn.latin1());
|
---|
592 | if(outdeps && outdeps->findIndex(fqn) == -1)
|
---|
593 | outdeps->append(fqn);
|
---|
594 | }
|
---|
595 | //read past new line now..
|
---|
596 | for( ; x < total_size_read && (*(big_buffer + x) != '\n'); x++);
|
---|
597 | line_count++;
|
---|
598 | }
|
---|
599 |
|
---|
600 | if(recurse) {
|
---|
601 | for(QStringList::Iterator fnit = fndeps.begin(); fnit != fndeps.end(); ++fnit) {
|
---|
602 | generateDependencies(dirs, (*fnit), recurse);
|
---|
603 | QStringList &deplist = findDependencies((*fnit));
|
---|
604 | for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it)
|
---|
605 | if(fndeps.findIndex((*it)) == -1 && (*it) != fn)
|
---|
606 | fndeps.append((*it));
|
---|
607 | }
|
---|
608 | }
|
---|
609 | debug_msg(2, "Dependencies: %s -> %s", fn.latin1(), fndeps.join(" :: ").latin1());
|
---|
610 | return TRUE;
|
---|
611 | }
|
---|
612 |
|
---|
613 | void
|
---|
614 | MakefileGenerator::initOutPaths()
|
---|
615 | {
|
---|
616 | if(init_opath_already)
|
---|
617 | return;
|
---|
618 | init_opath_already = TRUE;
|
---|
619 | QMap<QString, QStringList> &v = project->variables();
|
---|
620 | if(!v.contains("QMAKE_ABSOLUTE_SOURCE_PATH")) {
|
---|
621 | if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty() &&
|
---|
622 | v.contains("QMAKE_ABSOLUTE_SOURCE_ROOT")) {
|
---|
623 | QString root = v["QMAKE_ABSOLUTE_SOURCE_ROOT"].first();
|
---|
624 | root = Option::fixPathToTargetOS( root );
|
---|
625 | if(!root.isEmpty()) {
|
---|
626 | QFileInfo fi(Option::mkfile::cachefile);
|
---|
627 | if(!fi.convertToAbs()) {
|
---|
628 | QString cache_r = fi.dirPath(), pwd = Option::output_dir;
|
---|
629 | if ( pwd.startsWith(cache_r) && !pwd.startsWith(root) ) {
|
---|
630 | pwd = Option::fixPathToTargetOS(root + pwd.mid(cache_r.length()));
|
---|
631 | if(QFile::exists(pwd))
|
---|
632 | v.insert("QMAKE_ABSOLUTE_SOURCE_PATH", pwd);
|
---|
633 | }
|
---|
634 | }
|
---|
635 | }
|
---|
636 | }
|
---|
637 | }
|
---|
638 | if(!v["QMAKE_ABSOLUTE_SOURCE_PATH"].isEmpty()) {
|
---|
639 | QString &asp = v["QMAKE_ABSOLUTE_SOURCE_PATH"].first();
|
---|
640 | asp = Option::fixPathToTargetOS( asp );
|
---|
641 | if(asp.isEmpty() || asp == Option::output_dir) //if they're the same, why bother?
|
---|
642 | v["QMAKE_ABSOLUTE_SOURCE_PATH"].clear();
|
---|
643 | }
|
---|
644 | QString currentDir = QDir::currentDirPath();
|
---|
645 | QString dirs[] = { QString("OBJECTS_DIR"), QString("MOC_DIR"), QString("UI_HEADERS_DIR"),
|
---|
646 | QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString("DESTDIR"),
|
---|
647 | QString("SUBLIBS_DIR"), QString("DLLDESTDIR"), QString::null };
|
---|
648 | for(int x = 0; dirs[x] != QString::null; x++) {
|
---|
649 | if ( !v[dirs[x]].isEmpty() ) {
|
---|
650 | QString orig_path = v[dirs[x]].first();
|
---|
651 | #ifdef Q_WS_WIN
|
---|
652 | // We don't want to add a separator for DLLDESTDIR on Windows
|
---|
653 | if (!(dirs[x] == "DLLDESTDIR"))
|
---|
654 | #endif
|
---|
655 | {
|
---|
656 | QString &path = v[dirs[x]].first();
|
---|
657 | path = fileFixify(path, Option::output_dir, Option::output_dir);
|
---|
658 | if(path.right(Option::dir_sep.length()) != Option::dir_sep)
|
---|
659 | path += Option::dir_sep;
|
---|
660 | }
|
---|
661 | if(noIO())
|
---|
662 | continue;
|
---|
663 |
|
---|
664 | QString path = project->first(dirs[x]); //not to be changed any further
|
---|
665 | path = Option::fixPathToTargetOS(fileFixify(path, QDir::currentDirPath(), Option::output_dir));
|
---|
666 | debug_msg(3, "Fixed output_dir %s (%s) into %s (%s)", dirs[x].latin1(), orig_path.latin1(),
|
---|
667 | v[dirs[x]].join("::").latin1(), path.latin1());
|
---|
668 |
|
---|
669 | QDir d;
|
---|
670 | if(path.startsWith(Option::dir_sep)) {
|
---|
671 | d.cd(Option::dir_sep);
|
---|
672 | path = path.right(path.length() - 1);
|
---|
673 | }
|
---|
674 | #if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
---|
675 | bool driveExists = TRUE;
|
---|
676 | if ( !QDir::isRelativePath( path ) ) {
|
---|
677 | if ( QFile::exists( path.left( 3 ) ) ) {
|
---|
678 | d.cd( path.left( 3 ) );
|
---|
679 | path = path.right( path.length() - 3 );
|
---|
680 | } else {
|
---|
681 | warn_msg(WarnLogic, "%s: Cannot access drive '%s' (%s)", dirs[x].latin1(),
|
---|
682 | path.left( 3 ).latin1(), path.latin1() );
|
---|
683 | driveExists = FALSE;
|
---|
684 | }
|
---|
685 | }
|
---|
686 | if ( driveExists ) {
|
---|
687 | #endif
|
---|
688 | QStringList subs = QStringList::split(Option::dir_sep, path);
|
---|
689 | for(QStringList::Iterator subit = subs.begin(); subit != subs.end(); ++subit) {
|
---|
690 | if(!d.cd(*subit)) {
|
---|
691 | d.mkdir((*subit));
|
---|
692 | if ( d.exists( (*subit) ) )
|
---|
693 | d.cd((*subit));
|
---|
694 | else {
|
---|
695 | warn_msg(WarnLogic, "%s: Cannot access directory '%s' (%s)", dirs[x].latin1(),
|
---|
696 | (*subit).latin1(), path.latin1() );
|
---|
697 | break;
|
---|
698 | }
|
---|
699 | }
|
---|
700 | }
|
---|
701 | #if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
---|
702 | }
|
---|
703 | #endif
|
---|
704 | }
|
---|
705 | }
|
---|
706 | if ( !v["DESTDIR"].isEmpty() ) {
|
---|
707 | QDir d(v["DESTDIR"].first());
|
---|
708 | if(Option::fixPathToLocalOS(d.absPath()) == Option::fixPathToLocalOS(Option::output_dir))
|
---|
709 | v.remove("DESTDIR");
|
---|
710 | }
|
---|
711 | QDir::current().cd( currentDir );
|
---|
712 | }
|
---|
713 |
|
---|
714 | void
|
---|
715 | MakefileGenerator::init()
|
---|
716 | {
|
---|
717 | initOutPaths();
|
---|
718 | if(init_already)
|
---|
719 | return;
|
---|
720 | init_already = TRUE;
|
---|
721 |
|
---|
722 | QMap<QString, QStringList> &v = project->variables();
|
---|
723 | QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"),
|
---|
724 | QString("HEADERS"), QString("HEADERS_ORIG"), QString("LEXSOURCES"),
|
---|
725 | QString("QMAKE_INTERNAL_INCLUDED_FILES"),
|
---|
726 | QString("PRECOMPILED_HEADER"), QString::null };
|
---|
727 | for(int y = 0; paths[y] != QString::null; y++) {
|
---|
728 | QStringList &l = v[paths[y]];
|
---|
729 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
730 | if ((*it).isEmpty())
|
---|
731 | continue;
|
---|
732 | if(QFile::exists((*it)))
|
---|
733 | (*it) = fileFixify((*it));
|
---|
734 | }
|
---|
735 | }
|
---|
736 |
|
---|
737 | /* get deps and mocables */
|
---|
738 | QDict<void> cache_found_files;
|
---|
739 | QString cache_file(".qmake.internal.cache");
|
---|
740 | if(!project->isEmpty("QMAKE_INTERNAL_CACHE_FILE"))
|
---|
741 | cache_file = Option::fixPathToLocalOS(project->first("QMAKE_INTERNAL_CACHE_FILE"));
|
---|
742 | if(cache_file.find(QDir::separator()) == -1) //guess they know what they are doing..
|
---|
743 | cache_file.prepend(Option::output_dir + QDir::separator());
|
---|
744 | if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT ||
|
---|
745 | Option::mkfile::do_deps || Option::mkfile::do_mocs) && !noIO()) {
|
---|
746 | QPtrList<MakefileDependDir> deplist;
|
---|
747 | deplist.setAutoDelete(TRUE);
|
---|
748 | if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || Option::mkfile::do_deps) &&
|
---|
749 | doDepends()) {
|
---|
750 | QStringList incDirs = v["DEPENDPATH"] + v["QMAKE_ABSOLUTE_SOURCE_PATH"];
|
---|
751 | if(project->isActiveConfig("depend_includepath"))
|
---|
752 | incDirs += v["INCLUDEPATH"];
|
---|
753 | for(QStringList::Iterator it = incDirs.begin(); it != incDirs.end(); ++it) {
|
---|
754 | QString r = (*it), l = Option::fixPathToLocalOS((*it));
|
---|
755 | deplist.append(new MakefileDependDir(r.replace("\"",""),
|
---|
756 | l.replace("\"","")));
|
---|
757 | }
|
---|
758 | debug_msg(1, "Dependency Directories: %s", incDirs.join(" :: ").latin1());
|
---|
759 | if(Option::output.name() != "-" && project->isActiveConfig("qmake_cache")) {
|
---|
760 | QFile cachef(cache_file);
|
---|
761 | if(cachef.open(IO_ReadOnly | IO_Translate)) {
|
---|
762 | QFileInfo cachefi(cache_file);
|
---|
763 | debug_msg(2, "Trying internal cache information: %s", cache_file.latin1());
|
---|
764 | QTextStream cachet(&cachef);
|
---|
765 | QString line, file;
|
---|
766 | enum { CacheInfo, CacheDepend, CacheMoc } state = CacheInfo;
|
---|
767 | while (!cachet.eof()) {
|
---|
768 | line = cachet.readLine().stripWhiteSpace();
|
---|
769 | int sep = line.find('=');
|
---|
770 | if(line == "[depend]") {
|
---|
771 | state = CacheDepend;
|
---|
772 | } else if(line == "[mocable]") {
|
---|
773 | state = CacheMoc;
|
---|
774 | } else if(line == "[check]") {
|
---|
775 | state = CacheInfo;
|
---|
776 | } else if(!line.isEmpty() && sep != -1) {
|
---|
777 | file = line.left(sep).stripWhiteSpace();
|
---|
778 | line = line.right(line.length() - sep - 1).stripWhiteSpace();
|
---|
779 | if(state == CacheInfo) {
|
---|
780 | if(file == "QMAKE_CACHE_VERSION") {
|
---|
781 | if(line != qmake_version())
|
---|
782 | break;
|
---|
783 | } else {
|
---|
784 | const QStringList &l = project->variables()[file];
|
---|
785 | if(!l.isEmpty() && !line.isEmpty() && l.join(" ") != line)
|
---|
786 | break;
|
---|
787 | }
|
---|
788 | } else if(state == CacheDepend) {
|
---|
789 | bool found = (bool)cache_found_files[file];
|
---|
790 | QStringList files = QStringList::split(" ", line);
|
---|
791 | if(!found) {
|
---|
792 | QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir));
|
---|
793 | if(fi.exists() && fi.lastModified() < cachefi.lastModified()) {
|
---|
794 | cache_found_files.insert(file, (void *)1);
|
---|
795 | found = TRUE;
|
---|
796 | }
|
---|
797 | }
|
---|
798 | if(found) {
|
---|
799 | for(QStringList::Iterator dep_it = files.begin();
|
---|
800 | dep_it != files.end(); ++dep_it) {
|
---|
801 | if(!cache_found_files[(*dep_it)]) {
|
---|
802 | QFileInfo fi(fileFixify((*dep_it), QDir::currentDirPath(), Option::output_dir));
|
---|
803 | if(fi.exists() &&
|
---|
804 | fi.lastModified() < cachefi.lastModified()) {
|
---|
805 | cache_found_files.insert((*dep_it), (void *)1);
|
---|
806 | } else {
|
---|
807 | found = FALSE;
|
---|
808 | break;
|
---|
809 | }
|
---|
810 | }
|
---|
811 | }
|
---|
812 | if(found) {
|
---|
813 | debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(),
|
---|
814 | files.join(" :: ").latin1());
|
---|
815 | findDependencies(file) = files;
|
---|
816 | setProcessedDependencies(file, TRUE);
|
---|
817 | }
|
---|
818 | }
|
---|
819 | } else {
|
---|
820 | void *found = cache_found_files[file];
|
---|
821 | if(found != (void *)2) {
|
---|
822 | if(found) {
|
---|
823 | cache_found_files.replace(file, (void *)2);
|
---|
824 | } else {
|
---|
825 | QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir));
|
---|
826 | if(fi.exists() && fi.lastModified() < cachefi.lastModified()) {
|
---|
827 | cache_found_files.insert(file, (void *)2);
|
---|
828 | found = (void*)1;
|
---|
829 | }
|
---|
830 | }
|
---|
831 | }
|
---|
832 | if(found && line != "*qmake_ignore*") {
|
---|
833 | int ext_len = file.length() - file.findRev('.');
|
---|
834 | bool cpp_ext = FALSE;
|
---|
835 | for(QStringList::Iterator cppit = Option::cpp_ext.begin();
|
---|
836 | cppit != Option::cpp_ext.end(); ++cppit) {
|
---|
837 | if((cpp_ext = (file.right(ext_len) == (*cppit))))
|
---|
838 | break;
|
---|
839 | }
|
---|
840 | if(cpp_ext) {
|
---|
841 | project->variables()["_SRCMOC"].append(line);
|
---|
842 | } else if(project->variables()["HEADERS"].findIndex(file) != -1) {
|
---|
843 | for(QStringList::Iterator hit = Option::h_ext.begin();
|
---|
844 | hit != Option::h_ext.end(); ++hit) {
|
---|
845 | if((file.right(ext_len) == (*hit))) {
|
---|
846 | project->variables()["_HDRMOC"].append(line);
|
---|
847 | break;
|
---|
848 | }
|
---|
849 | }
|
---|
850 | }
|
---|
851 | debug_msg(2, "Mocgen (cached): %s -> %s", file.latin1(),
|
---|
852 | line.latin1());
|
---|
853 | mocablesToMOC[file] = line;
|
---|
854 | mocablesFromMOC[line] = file;
|
---|
855 | }
|
---|
856 | }
|
---|
857 | }
|
---|
858 | }
|
---|
859 | cachef.close();
|
---|
860 | }
|
---|
861 | }
|
---|
862 | }
|
---|
863 | if(!noIO()) {
|
---|
864 | QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"),
|
---|
865 | QString("HEADERS"), QString("SOURCES"), QString("FORMS"),
|
---|
866 | QString("PRECOMPILED_HEADER"), QString::null };
|
---|
867 | depHeuristics.clear();
|
---|
868 | bool write_cache = FALSE, read_cache = QFile::exists(cache_file);
|
---|
869 | int x;
|
---|
870 | for(x = 0; sources[x] != QString::null; x++) {
|
---|
871 | QStringList vpath, &l = v[sources[x]];
|
---|
872 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
|
---|
873 | if(!(*val_it).isEmpty()) {
|
---|
874 | QString file = fileFixify((*val_it), QDir::currentDirPath(), Option::output_dir);
|
---|
875 | if(!QFile::exists(file)) {
|
---|
876 | bool found = FALSE;
|
---|
877 | if(QDir::isRelativePath((*val_it))) {
|
---|
878 | if(vpath.isEmpty())
|
---|
879 | vpath = v["VPATH_" + sources[x]] + v["VPATH"] +
|
---|
880 | v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"];
|
---|
881 |
|
---|
882 | for(QStringList::Iterator vpath_it = vpath.begin();
|
---|
883 | vpath_it != vpath.end(); ++vpath_it) {
|
---|
884 | QString real_dir = Option::fixPathToLocalOS((*vpath_it));
|
---|
885 | if(QFile::exists(real_dir + QDir::separator() + (*val_it))) {
|
---|
886 | QString dir = (*vpath_it);
|
---|
887 | if(dir.right(Option::dir_sep.length()) != Option::dir_sep)
|
---|
888 | dir += Option::dir_sep;
|
---|
889 | (*val_it) = fileFixify(dir + (*val_it));
|
---|
890 | found = TRUE;
|
---|
891 | debug_msg(1, "Found file through vpath %s -> %s",
|
---|
892 | file.latin1(), (*val_it).latin1());
|
---|
893 | break;
|
---|
894 | }
|
---|
895 | }
|
---|
896 | }
|
---|
897 | if(!found) {
|
---|
898 | QString dir, regex = (*val_it), real_dir;
|
---|
899 | if(regex.findRev(Option::dir_sep) != -1) {
|
---|
900 | dir = regex.left(regex.findRev(Option::dir_sep) + 1);
|
---|
901 | real_dir = fileFixify(Option::fixPathToLocalOS(dir),
|
---|
902 | QDir::currentDirPath(), Option::output_dir);
|
---|
903 | regex = regex.right(regex.length() - dir.length());
|
---|
904 | }
|
---|
905 | if(real_dir.isEmpty() || QFile::exists(real_dir)) {
|
---|
906 | QDir d(real_dir, regex);
|
---|
907 | if(!d.count()) {
|
---|
908 | debug_msg(1, "%s:%d Failure to find %s in vpath (%s)",
|
---|
909 | __FILE__, __LINE__,
|
---|
910 | (*val_it).latin1(), vpath.join("::").latin1());
|
---|
911 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1());
|
---|
912 | continue;
|
---|
913 | } else {
|
---|
914 | for(int i = 0; i < (int)d.count(); i++) {
|
---|
915 | QString file = fileFixify(dir + d[i]);
|
---|
916 | if(i == (int)d.count() - 1)
|
---|
917 | (*val_it) = file;
|
---|
918 | else
|
---|
919 | l.insert(val_it, file);
|
---|
920 | }
|
---|
921 | }
|
---|
922 | } else {
|
---|
923 | debug_msg(1, "%s:%d Cannot match %s%c%s, as %s does not exist.",
|
---|
924 | __FILE__, __LINE__,
|
---|
925 | real_dir.latin1(), QDir::separator(), regex.latin1(),
|
---|
926 | real_dir.latin1());
|
---|
927 | warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1());
|
---|
928 | }
|
---|
929 | }
|
---|
930 | }
|
---|
931 | }
|
---|
932 | }
|
---|
933 | }
|
---|
934 | for(x = 0; sources[x] != QString::null; x++) {
|
---|
935 | QStringList &l = v[sources[x]];
|
---|
936 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
|
---|
937 | bool found_cache_moc = FALSE, found_cache_dep = FALSE;
|
---|
938 | if(read_cache && Option::output.name() != "-" &&
|
---|
939 | project->isActiveConfig("qmake_cache")) {
|
---|
940 | if(processedDependencies((*val_it)))
|
---|
941 | found_cache_dep = TRUE;
|
---|
942 | if(cache_found_files[(*val_it)] == (void *)2)
|
---|
943 | found_cache_moc = TRUE;
|
---|
944 | if(!found_cache_moc || !found_cache_dep)
|
---|
945 | write_cache = TRUE;
|
---|
946 | }
|
---|
947 | /* Do moc before dependency checking since some includes can come from
|
---|
948 | moc_*.cpp files */
|
---|
949 | if(found_cache_moc) {
|
---|
950 | QString fixed_file(fileFixify((*val_it), QDir::currentDirPath(), Option::output_dir));
|
---|
951 | QString moc = findMocDestination(fixed_file);
|
---|
952 | if(!moc.isEmpty()) {
|
---|
953 | for(QStringList::Iterator cppit = Option::cpp_ext.begin();
|
---|
954 | cppit != Option::cpp_ext.end(); ++cppit) {
|
---|
955 | if(fixed_file.endsWith((*cppit))) {
|
---|
956 | QStringList &deps = findDependencies(fixed_file);
|
---|
957 | if(!deps.contains(moc))
|
---|
958 | deps.append(moc);
|
---|
959 | break;
|
---|
960 | }
|
---|
961 | }
|
---|
962 | }
|
---|
963 | } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") &&
|
---|
964 | (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT ||
|
---|
965 | Option::mkfile::do_mocs)) {
|
---|
966 | generateMocList((*val_it));
|
---|
967 | }
|
---|
968 | if(!found_cache_dep && sources[x] != "OBJECTS") {
|
---|
969 | debug_msg(5, "Looking for dependencies for %s", (*val_it).latin1());
|
---|
970 | generateDependencies(deplist, (*val_it), doDepends());
|
---|
971 | }
|
---|
972 | }
|
---|
973 | }
|
---|
974 | if(project->isActiveConfig("qmake_cache") && (write_cache || !read_cache)) {
|
---|
975 | QFile cachef(cache_file);
|
---|
976 | if(cachef.open(IO_WriteOnly | IO_Translate)) {
|
---|
977 | debug_msg(2, "Writing internal cache information: %s", cache_file.latin1());
|
---|
978 | QTextStream cachet(&cachef);
|
---|
979 | cachet << "[check]" << "\n"
|
---|
980 | << "QMAKE_CACHE_VERSION = " << qmake_version() << "\n"
|
---|
981 | << "QMAKE_ABSOLUTE_SOURCE_PATH = " << var("QMAKE_ABSOLUTE_SOURCE_PATH") << "\n"
|
---|
982 | << "MOC_DIR = " << var("MOC_DIR") << "\n"
|
---|
983 | << "UI_DIR = " << var("UI_DIR") << "\n"
|
---|
984 | << "UI_HEADERS_DIR = " << var("UI_HEADERS_DIR") << "\n"
|
---|
985 | << "UI_SOURCES_DIR = " << var("UI_SOURCES_DIR") << "\n";
|
---|
986 | cachet << "[depend]" << endl;
|
---|
987 | for(QMap<QString, QStringList>::Iterator it = depends.begin();
|
---|
988 | it != depends.end(); ++it)
|
---|
989 | cachet << dependencyKey(it.key()) << " = " << it.data().join(" ") << endl;
|
---|
990 | cachet << "[mocable]" << endl;
|
---|
991 | QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null };
|
---|
992 | for(int x = 0; moc_sources[x] != QString::null; x++) {
|
---|
993 | QStringList &l = v[moc_sources[x]];
|
---|
994 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
|
---|
995 | QString f = fileFixify((*val_it));
|
---|
996 | if(!f.isEmpty()) {
|
---|
997 | mc = mocablesToMOC[f];
|
---|
998 | if(mc.isEmpty())
|
---|
999 | mc = "*qmake_ignore*";
|
---|
1000 | cachet << f << " = " << mc << endl;
|
---|
1001 | }
|
---|
1002 | }
|
---|
1003 | }
|
---|
1004 | cachef.close();
|
---|
1005 | }
|
---|
1006 | }
|
---|
1007 | }
|
---|
1008 | }
|
---|
1009 | v["OBJECTS"] = createObjectList("SOURCES") + v["OBJECTS"]; // init variables
|
---|
1010 |
|
---|
1011 | //lex files
|
---|
1012 | {
|
---|
1013 | QStringList &impls = v["LEXIMPLS"];
|
---|
1014 | QStringList &l = v["LEXSOURCES"];
|
---|
1015 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1016 | QString dir;
|
---|
1017 | QFileInfo fi((*it));
|
---|
1018 | if(fi.dirPath() != ".")
|
---|
1019 | dir = fi.dirPath() + Option::dir_sep;
|
---|
1020 | dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
|
---|
1021 | if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
|
---|
1022 | dir += Option::dir_sep;
|
---|
1023 | QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
|
---|
1024 | logicWarn(impl, "SOURCES");
|
---|
1025 | logicWarn(impl, "SOURCES");
|
---|
1026 | impls.append(impl);
|
---|
1027 | if( ! project->isActiveConfig("lex_included")) {
|
---|
1028 | v["SOURCES"].append(impl);
|
---|
1029 | // attribute deps of lex file to impl file
|
---|
1030 | QStringList &lexdeps = findDependencies((*it));
|
---|
1031 | QStringList &impldeps = findDependencies(impl);
|
---|
1032 | for(QStringList::ConstIterator d = lexdeps.begin(); d != lexdeps.end(); ++d) {
|
---|
1033 | if(!impldeps.contains(*d))
|
---|
1034 | impldeps.append(*d);
|
---|
1035 | }
|
---|
1036 | lexdeps.clear();
|
---|
1037 | }
|
---|
1038 | }
|
---|
1039 | if( ! project->isActiveConfig("lex_included"))
|
---|
1040 | v["OBJECTS"] += (v["LEXOBJECTS"] = createObjectList("LEXIMPLS"));
|
---|
1041 | }
|
---|
1042 | //yacc files
|
---|
1043 | {
|
---|
1044 | QStringList &decls = v["YACCCDECLS"], &impls = v["YACCIMPLS"];
|
---|
1045 | QStringList &l = v["YACCSOURCES"];
|
---|
1046 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1047 | QString dir;
|
---|
1048 | QFileInfo fi((*it));
|
---|
1049 | if(fi.dirPath() != ".")
|
---|
1050 | dir = fi.dirPath() + Option::dir_sep;
|
---|
1051 | dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
|
---|
1052 | if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
|
---|
1053 | dir += Option::dir_sep;
|
---|
1054 | QString impl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first();
|
---|
1055 | logicWarn(impl, "SOURCES");
|
---|
1056 | QString decl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first();
|
---|
1057 | logicWarn(decl, "HEADERS");
|
---|
1058 |
|
---|
1059 | decls.append(decl);
|
---|
1060 | impls.append(impl);
|
---|
1061 | v["SOURCES"].append(impl);
|
---|
1062 | QStringList &impldeps = findDependencies(impl);
|
---|
1063 | impldeps.append(decl);
|
---|
1064 | // attribute deps of yacc file to impl file
|
---|
1065 | QStringList &yaccdeps = findDependencies((*it));
|
---|
1066 | for(QStringList::ConstIterator d = yaccdeps.begin(); d != yaccdeps.end(); ++d) {
|
---|
1067 | if(!impldeps.contains(*d))
|
---|
1068 | impldeps.append(*d);
|
---|
1069 | }
|
---|
1070 | if( project->isActiveConfig("lex_included")) {
|
---|
1071 | // is there a matching lex file ? Transfer its dependencies.
|
---|
1072 | QString lexsrc = fi.baseName(TRUE) + Option::lex_ext;
|
---|
1073 | if(fi.dirPath() != ".")
|
---|
1074 | lexsrc.prepend(fi.dirPath() + Option::dir_sep);
|
---|
1075 | if(v["LEXSOURCES"].findIndex(lexsrc) != -1) {
|
---|
1076 | QString trg = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
|
---|
1077 | impldeps.append(trg);
|
---|
1078 | impldeps += findDependencies(lexsrc);
|
---|
1079 | depends[lexsrc].clear();
|
---|
1080 | }
|
---|
1081 | }
|
---|
1082 | yaccdeps.clear();
|
---|
1083 | }
|
---|
1084 | v["OBJECTS"] += (v["YACCOBJECTS"] = createObjectList("YACCIMPLS"));
|
---|
1085 | }
|
---|
1086 |
|
---|
1087 | //UI files
|
---|
1088 | {
|
---|
1089 | QStringList &includepath = project->variables()["INCLUDEPATH"];
|
---|
1090 | if(!project->isEmpty("UI_DIR"))
|
---|
1091 | includepath.append(project->first("UI_DIR"));
|
---|
1092 | else if(!project->isEmpty("UI_HEADERS_DIR"))
|
---|
1093 | includepath.append(project->first("UI_HEADERS_DIR"));
|
---|
1094 | QStringList &decls = v["UICDECLS"], &impls = v["UICIMPLS"];
|
---|
1095 | QStringList &l = v["FORMS"];
|
---|
1096 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1097 | QString impl, decl;
|
---|
1098 | QFileInfo fi(Option::fixPathToLocalOS((*it)));
|
---|
1099 | if ( !project->isEmpty("UI_DIR") ) {
|
---|
1100 | impl = decl = project->first("UI_DIR");
|
---|
1101 | QString d = fi.dirPath();
|
---|
1102 | if( d == ".")
|
---|
1103 | d = QDir::currentDirPath();
|
---|
1104 | d = fileFixify(d, QDir::currentDirPath(), Option::output_dir);
|
---|
1105 | if(!includepath.contains(d))
|
---|
1106 | includepath.append(d);
|
---|
1107 | } else {
|
---|
1108 | if(decl.isEmpty() && !project->isEmpty("UI_HEADERS_DIR"))
|
---|
1109 | decl = project->first("UI_HEADERS_DIR");
|
---|
1110 | if(!decl.isEmpty() || (project->isEmpty("UI_HEADERS_DIR") &&
|
---|
1111 | !project->isEmpty("UI_SOURCES_DIR")) ) {
|
---|
1112 | QString d = fi.dirPath();
|
---|
1113 | if( d == ".")
|
---|
1114 | d = QDir::currentDirPath();
|
---|
1115 | d = fileFixify(d, QDir::currentDirPath(), Option::output_dir);
|
---|
1116 | if(includepath.contains(d))
|
---|
1117 | includepath.append(d);
|
---|
1118 | }
|
---|
1119 | if(impl.isEmpty() && !project->isEmpty("UI_SOURCES_DIR"))
|
---|
1120 | impl = project->first("UI_SOURCES_DIR");
|
---|
1121 | if(fi.dirPath() != ".") {
|
---|
1122 | if(impl.isEmpty())
|
---|
1123 | impl = fi.dirPath() + Option::dir_sep;
|
---|
1124 | if(decl.isEmpty())
|
---|
1125 | decl = fi.dirPath() + Option::dir_sep;
|
---|
1126 | }
|
---|
1127 | }
|
---|
1128 | impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir);
|
---|
1129 | if(!impl.isEmpty() && !impl.endsWith(Option::dir_sep))
|
---|
1130 | impl += Option::dir_sep;
|
---|
1131 | impl += fi.baseName(TRUE) + Option::cpp_ext.first();
|
---|
1132 | if(Option::output_dir != QDir::currentDirPath() &&
|
---|
1133 | project->isEmpty("UI_DIR") && project->isEmpty("UI_HEADERS_DIR")) {
|
---|
1134 | QString decl_fixed = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
|
---|
1135 | if(!includepath.contains(decl_fixed))
|
---|
1136 | includepath.append(decl_fixed);
|
---|
1137 | if(!includepath.contains(decl))
|
---|
1138 | project->variables()["INCLUDEPATH"].append(decl);
|
---|
1139 | }
|
---|
1140 | decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
|
---|
1141 | if(!decl.isEmpty() && !decl.endsWith(Option::dir_sep))
|
---|
1142 | decl += Option::dir_sep;
|
---|
1143 | decl += fi.baseName(TRUE) + Option::h_ext.first();
|
---|
1144 | logicWarn(impl, "SOURCES");
|
---|
1145 | logicWarn(decl, "HEADERS");
|
---|
1146 | decls.append(decl);
|
---|
1147 | impls.append(impl);
|
---|
1148 | findDependencies(impl).append(decl);
|
---|
1149 |
|
---|
1150 | QString mocable = Option::h_moc_mod + fi.baseName(TRUE) + Option::h_moc_ext;
|
---|
1151 | if(!v["MOC_DIR"].isEmpty())
|
---|
1152 | mocable.prepend(v["MOC_DIR"].first());
|
---|
1153 | else if(fi.dirPath() != ".")
|
---|
1154 | mocable.prepend(fi.dirPath() + Option::dir_sep);
|
---|
1155 | logicWarn(mocable, "SOURCES");
|
---|
1156 | mocablesToMOC[cleanFilePath(decl)] = mocable;
|
---|
1157 | mocablesFromMOC[cleanFilePath(mocable)] = decl;
|
---|
1158 | v["_UIMOC"].append(mocable);
|
---|
1159 | }
|
---|
1160 | v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS"));
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | //Translation files
|
---|
1164 | if(!project->isEmpty("TRANSLATIONS")) {
|
---|
1165 | QStringList &trf = project->variables()["TRANSLATIONS"];
|
---|
1166 | for(QStringList::Iterator it = trf.begin(); it != trf.end(); ++it) {
|
---|
1167 | (*it) = Option::fixPathToLocalOS((*it));
|
---|
1168 | }
|
---|
1169 | }
|
---|
1170 |
|
---|
1171 | //Image files
|
---|
1172 | if(!project->isEmpty("IMAGES")) {
|
---|
1173 | if(project->isEmpty("QMAKE_IMAGE_COLLECTION"))
|
---|
1174 | v["QMAKE_IMAGE_COLLECTION"].append("qmake_image_collection" + Option::cpp_ext.first());
|
---|
1175 | QString imgfile = project->first("QMAKE_IMAGE_COLLECTION");
|
---|
1176 | Option::fixPathToTargetOS(imgfile);
|
---|
1177 | if(!project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) {
|
---|
1178 | if(imgfile.find(Option::dir_sep) != -1)
|
---|
1179 | imgfile = imgfile.right(imgfile.findRev(Option::dir_sep) + 1);
|
---|
1180 | imgfile.prepend( (project->isEmpty("UI_DIR") ? project->first("UI_SOURCES_DIR") :
|
---|
1181 | project->first("UI_DIR")) );
|
---|
1182 | v["QMAKE_IMAGE_COLLECTION"] = QStringList(imgfile);
|
---|
1183 | }
|
---|
1184 | logicWarn(imgfile, "SOURCES");
|
---|
1185 | if(!noIO()) {
|
---|
1186 | QStringList &l = v["IMAGES"];
|
---|
1187 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1188 | if(!QFile::exists((*it))) {
|
---|
1189 | warn_msg(WarnLogic, "Failure to open: %s", (*it).latin1());
|
---|
1190 | continue;
|
---|
1191 | }
|
---|
1192 | findDependencies(imgfile).append(fileFixify((*it)));
|
---|
1193 | }
|
---|
1194 | }
|
---|
1195 | v["OBJECTS"] += (v["IMAGEOBJECTS"] = createObjectList("QMAKE_IMAGE_COLLECTION"));
|
---|
1196 | }
|
---|
1197 | if(Option::output_dir != QDir::currentDirPath())
|
---|
1198 | project->variables()["INCLUDEPATH"].append(fileFixify(Option::output_dir, Option::output_dir,
|
---|
1199 | Option::output_dir));
|
---|
1200 |
|
---|
1201 | //moc files
|
---|
1202 | if ( mocAware() ) {
|
---|
1203 | if(!project->isEmpty("MOC_DIR"))
|
---|
1204 | project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR"));
|
---|
1205 | if ( Option::h_moc_ext == Option::cpp_ext.first() )
|
---|
1206 | v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC");
|
---|
1207 |
|
---|
1208 | QStringList &l = v["SRCMOC"];
|
---|
1209 | l = v["_HDRMOC"] + v["_UIMOC"] + v["_SRCMOC"];
|
---|
1210 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
|
---|
1211 | if(!(*val_it).isEmpty())
|
---|
1212 | (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE);
|
---|
1213 | }
|
---|
1214 | }
|
---|
1215 |
|
---|
1216 | QString fixpaths[] = { QString("PRE_TARGETDEPS"), QString("POST_TARGETDEPS"), QString::null };
|
---|
1217 | for(int path = 0; !fixpaths[path].isNull(); path++) {
|
---|
1218 | QStringList &l = v[fixpaths[path]];
|
---|
1219 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
|
---|
1220 | if(!(*val_it).isEmpty())
|
---|
1221 | (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE);
|
---|
1222 | }
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 | // Make sure the INCLUDEPATH doesn't contain any empty(/null) entries
|
---|
1226 | QStringList &ipl = project->variables()["INCLUDEPATH"];
|
---|
1227 | for(QStringList::Iterator ipl_it = ipl.begin(); ipl_it != ipl.end();) {
|
---|
1228 | if ((*ipl_it).isEmpty())
|
---|
1229 | ipl_it = ipl.remove(ipl_it);
|
---|
1230 | else
|
---|
1231 | ++ipl_it;
|
---|
1232 | }
|
---|
1233 | }
|
---|
1234 |
|
---|
1235 | bool
|
---|
1236 | MakefileGenerator::processPrlFile(QString &file)
|
---|
1237 | {
|
---|
1238 | bool ret = FALSE, try_replace_file=FALSE;
|
---|
1239 | QString meta_file, orig_file = file;
|
---|
1240 | if(QMakeMetaInfo::libExists(file)) {
|
---|
1241 | try_replace_file = TRUE;
|
---|
1242 | meta_file = file;
|
---|
1243 | file = "";
|
---|
1244 | } else {
|
---|
1245 | QString tmp = file;
|
---|
1246 | int ext = tmp.findRev('.');
|
---|
1247 | if(ext != -1)
|
---|
1248 | tmp = tmp.left(ext);
|
---|
1249 | meta_file = tmp;
|
---|
1250 | }
|
---|
1251 | meta_file = fileFixify(meta_file);
|
---|
1252 | if(!QMakeMetaInfo::libExists(fileFixify(meta_file, QDir::currentDirPath(), Option::output_dir)) &&
|
---|
1253 | project->isActiveConfig("qt")) {
|
---|
1254 | QString stem = meta_file, dir, extn;
|
---|
1255 | int slsh = stem.findRev('/'), hadlib = 0;
|
---|
1256 | if(slsh != -1) {
|
---|
1257 | dir = stem.left(slsh + 1);
|
---|
1258 | stem = stem.right(stem.length() - slsh - 1);
|
---|
1259 | }
|
---|
1260 | if(stem.startsWith("lib")) {
|
---|
1261 | hadlib = 1;
|
---|
1262 | stem = stem.right(stem.length() - 3);
|
---|
1263 | }
|
---|
1264 | int dot = stem.find('.');
|
---|
1265 | if(dot != -1) {
|
---|
1266 | extn = stem.right(stem.length() - dot);
|
---|
1267 | stem = stem.left(dot);
|
---|
1268 | }
|
---|
1269 | if(stem == "qt" || stem == "qte" || stem == "qte-mt" || stem == "qt-mt") {
|
---|
1270 | if(stem.endsWith("-mt"))
|
---|
1271 | stem = stem.left(stem.length() - 3); //lose the -mt
|
---|
1272 | else
|
---|
1273 | stem += "-mt"; //try the thread case
|
---|
1274 | meta_file = dir;
|
---|
1275 | if(hadlib)
|
---|
1276 | meta_file += "lib";
|
---|
1277 | meta_file += stem + extn;
|
---|
1278 | try_replace_file = TRUE;
|
---|
1279 | }
|
---|
1280 | }
|
---|
1281 | QString real_meta_file = Option::fixPathToLocalOS(meta_file);
|
---|
1282 | if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(QMakeMetaInfo::findLib(meta_file)) != -1) {
|
---|
1283 | ret = TRUE;
|
---|
1284 | } else if(!meta_file.isEmpty()) {
|
---|
1285 | QString f = fileFixify(real_meta_file, QDir::currentDirPath(), Option::output_dir);
|
---|
1286 | if(QMakeMetaInfo::libExists(f)) {
|
---|
1287 | QMakeMetaInfo libinfo;
|
---|
1288 | debug_msg(1, "Processing PRL file: %s", real_meta_file.latin1());
|
---|
1289 | if(!libinfo.readLib(f)) {
|
---|
1290 | fprintf(stderr, "Error processing meta file: %s\n", real_meta_file.latin1());
|
---|
1291 | } else if(project->isActiveConfig("no_read_prl_" + libinfo.type().lower())) {
|
---|
1292 | debug_msg(2, "Ignored meta file %s [%s]", real_meta_file.latin1(), libinfo.type().latin1());
|
---|
1293 | } else {
|
---|
1294 | ret = TRUE;
|
---|
1295 | QMap<QString, QStringList> &vars = libinfo.variables();
|
---|
1296 | for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it)
|
---|
1297 | processPrlVariable(it.key(), it.data());
|
---|
1298 | if(try_replace_file && !libinfo.isEmpty("QMAKE_PRL_TARGET")) {
|
---|
1299 | QString dir;
|
---|
1300 | int slsh = real_meta_file.findRev(Option::dir_sep);
|
---|
1301 | if(slsh != -1)
|
---|
1302 | dir = real_meta_file.left(slsh+1);
|
---|
1303 | file = libinfo.first("QMAKE_PRL_TARGET");
|
---|
1304 | if(QDir::isRelativePath(file))
|
---|
1305 | file.prepend(dir);
|
---|
1306 | }
|
---|
1307 | }
|
---|
1308 | }
|
---|
1309 | if(ret) {
|
---|
1310 | QString mf = QMakeMetaInfo::findLib(meta_file);
|
---|
1311 | project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(mf);
|
---|
1312 | project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(mf);
|
---|
1313 | }
|
---|
1314 | }
|
---|
1315 | if(try_replace_file && file.isEmpty()) {
|
---|
1316 | #if 0
|
---|
1317 | warn_msg(WarnLogic, "Found prl [%s] file with no target [%s]!", meta_file.latin1(),
|
---|
1318 | orig_file.latin1());
|
---|
1319 | #endif
|
---|
1320 | file = orig_file;
|
---|
1321 | }
|
---|
1322 | return ret;
|
---|
1323 | }
|
---|
1324 |
|
---|
1325 | void
|
---|
1326 | MakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
|
---|
1327 | {
|
---|
1328 | if(var == "QMAKE_PRL_LIBS") {
|
---|
1329 | QString where = "QMAKE_LIBS";
|
---|
1330 | if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
|
---|
1331 | where = project->first("QMAKE_INTERNAL_PRL_LIBS");
|
---|
1332 | QStringList &out = project->variables()[where];
|
---|
1333 | for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
|
---|
1334 | if( out.findIndex((*it)) == -1)
|
---|
1335 | out.append((*it));
|
---|
1336 | }
|
---|
1337 | } else if(var == "QMAKE_PRL_DEFINES") {
|
---|
1338 | QStringList &out = project->variables()["DEFINES"];
|
---|
1339 | for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
|
---|
1340 | if(out.findIndex((*it)) == -1 &&
|
---|
1341 | project->variables()["PRL_EXPORT_DEFINES"].findIndex((*it)) == -1)
|
---|
1342 | out.append((*it));
|
---|
1343 | }
|
---|
1344 | }
|
---|
1345 | }
|
---|
1346 |
|
---|
1347 | void
|
---|
1348 | MakefileGenerator::processPrlFiles()
|
---|
1349 | {
|
---|
1350 | QDict<void> processed;
|
---|
1351 | for(bool ret = FALSE; TRUE; ret = FALSE) {
|
---|
1352 | //read in any prl files included..
|
---|
1353 | QStringList l_out;
|
---|
1354 | QString where = "QMAKE_LIBS";
|
---|
1355 | if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
|
---|
1356 | where = project->first("QMAKE_INTERNAL_PRL_LIBS");
|
---|
1357 | QStringList &l = project->variables()[where];
|
---|
1358 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1359 | QString file = (*it);
|
---|
1360 | if(!processed[file] && processPrlFile(file)) {
|
---|
1361 | processed.insert(file, (void*)1);
|
---|
1362 | ret = TRUE;
|
---|
1363 | }
|
---|
1364 | if(!file.isEmpty())
|
---|
1365 | l_out.append(file);
|
---|
1366 | }
|
---|
1367 | if(ret)
|
---|
1368 | l = l_out;
|
---|
1369 | else
|
---|
1370 | break;
|
---|
1371 | }
|
---|
1372 | }
|
---|
1373 |
|
---|
1374 | void
|
---|
1375 | MakefileGenerator::writePrlFile(QTextStream &t)
|
---|
1376 | {
|
---|
1377 | QString target = project->first("TARGET");
|
---|
1378 | int slsh = target.findRev(Option::dir_sep);
|
---|
1379 | if(slsh != -1)
|
---|
1380 | target = target.right(target.length() - slsh - 1);
|
---|
1381 | QString bdir = Option::output_dir;
|
---|
1382 | if(bdir.isEmpty())
|
---|
1383 | bdir = QDir::currentDirPath();
|
---|
1384 | t << "QMAKE_PRL_BUILD_DIR = " << bdir << endl;
|
---|
1385 |
|
---|
1386 | if(!project->projectFile().isEmpty() && project->projectFile() != "-")
|
---|
1387 | t << "QMAKE_PRO_INPUT = " << project->projectFile().section('/', -1) << endl;
|
---|
1388 |
|
---|
1389 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
|
---|
1390 | t << "QMAKE_PRL_SOURCE_DIR = " << project->first("QMAKE_ABSOLUTE_SOURCE_PATH") << endl;
|
---|
1391 | t << "QMAKE_PRL_TARGET = " << target << endl;
|
---|
1392 | if(!project->isEmpty("PRL_EXPORT_DEFINES"))
|
---|
1393 | t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl;
|
---|
1394 | if(!project->isEmpty("PRL_EXPORT_CFLAGS"))
|
---|
1395 | t << "QMAKE_PRL_CFLAGS = " << project->variables()["PRL_EXPORT_CFLAGS"].join(" ") << endl;
|
---|
1396 | if(!project->isEmpty("PRL_EXPORT_CXXFLAGS"))
|
---|
1397 | t << "QMAKE_PRL_CXXFLAGS = " << project->variables()["PRL_EXPORT_CXXFLAGS"].join(" ") << endl;
|
---|
1398 | if(!project->isEmpty("CONFIG"))
|
---|
1399 | t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl;
|
---|
1400 | if(!project->isEmpty("VERSION"))
|
---|
1401 | t << "QMAKE_PRL_VERSION = " << project->first("VERSION") << endl;
|
---|
1402 | if(project->isActiveConfig("staticlib") || project->isActiveConfig("explicitlib")) {
|
---|
1403 | QStringList libs;
|
---|
1404 | if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
|
---|
1405 | libs = project->variables()["QMAKE_INTERNAL_PRL_LIBS"];
|
---|
1406 | else
|
---|
1407 | libs << "QMAKE_LIBS"; //obvious one
|
---|
1408 | t << "QMAKE_PRL_LIBS = ";
|
---|
1409 | for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it)
|
---|
1410 | t << project->variables()[(*it)].join(" ") << " ";
|
---|
1411 | t << endl;
|
---|
1412 | }
|
---|
1413 | }
|
---|
1414 |
|
---|
1415 | bool
|
---|
1416 | MakefileGenerator::write()
|
---|
1417 | {
|
---|
1418 | usePlatformDir();
|
---|
1419 | init();
|
---|
1420 | findLibraries();
|
---|
1421 | if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl
|
---|
1422 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) &&
|
---|
1423 | project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty() &&
|
---|
1424 | project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" &&
|
---|
1425 | !project->isActiveConfig("plugin")) {
|
---|
1426 | QString prl = var("TARGET");
|
---|
1427 | int slsh = prl.findRev(Option::dir_sep);
|
---|
1428 | if(slsh != -1)
|
---|
1429 | prl = prl.right(prl.length() - slsh);
|
---|
1430 | int dot = prl.find('.');
|
---|
1431 | if(dot != -1)
|
---|
1432 | prl = prl.left(dot);
|
---|
1433 | prl += Option::prl_ext;
|
---|
1434 | if(!project->isEmpty("DESTDIR"))
|
---|
1435 | prl.prepend(var("DESTDIR"));
|
---|
1436 | QString local_prl = Option::fixPathToLocalOS(fileFixify(prl, QDir::currentDirPath(), Option::output_dir));
|
---|
1437 | QFile ft(local_prl);
|
---|
1438 | if(ft.open(IO_WriteOnly)) {
|
---|
1439 | project->variables()["ALL_DEPS"].append(prl);
|
---|
1440 | project->variables()["QMAKE_INTERNAL_PRL_FILE"].append(prl);
|
---|
1441 | QTextStream t(&ft);
|
---|
1442 | writePrlFile(t);
|
---|
1443 | ft.close();
|
---|
1444 | }
|
---|
1445 | }
|
---|
1446 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE &&
|
---|
1447 | project->isActiveConfig("link_prl")) //load up prl's'
|
---|
1448 | processPrlFiles();
|
---|
1449 |
|
---|
1450 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl file
|
---|
1451 | Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
|
---|
1452 | QTextStream t(&Option::output);
|
---|
1453 | writeMakefile(t);
|
---|
1454 | }
|
---|
1455 | return TRUE;
|
---|
1456 | }
|
---|
1457 |
|
---|
1458 | // Manipulate directories, so it's possible to build
|
---|
1459 | // several cross-platform targets concurrently
|
---|
1460 | void
|
---|
1461 | MakefileGenerator::usePlatformDir()
|
---|
1462 | {
|
---|
1463 | QString pltDir(project->first("QMAKE_PLATFORM_DIR"));
|
---|
1464 | if(pltDir.isEmpty())
|
---|
1465 | return;
|
---|
1466 | char sep = QDir::separator();
|
---|
1467 | QString slashPltDir = sep + pltDir;
|
---|
1468 |
|
---|
1469 | QString filePath = project->first("DESTDIR");
|
---|
1470 | project->variables()["DESTDIR"] = filePath
|
---|
1471 | + (filePath.isEmpty() ? pltDir : slashPltDir);
|
---|
1472 |
|
---|
1473 | filePath = project->first("DLLDESTDIR");
|
---|
1474 | project->variables()["DLLDESTDIR"] = filePath
|
---|
1475 | + (filePath.isEmpty() ? pltDir : slashPltDir);
|
---|
1476 |
|
---|
1477 | filePath = project->first("OBJECTS_DIR");
|
---|
1478 | project->variables()["OBJECTS_DIR"] = filePath
|
---|
1479 | + (filePath.isEmpty() ? pltDir : slashPltDir);
|
---|
1480 |
|
---|
1481 | filePath = project->first("QMAKE_LIBDIR_QT");
|
---|
1482 | project->variables()["QMAKE_LIBDIR_QT"] = filePath
|
---|
1483 | + (filePath.isEmpty() ? pltDir : slashPltDir);
|
---|
1484 |
|
---|
1485 | filePath = project->first("QMAKE_LIBS_QT");
|
---|
1486 | int fpi = filePath.findRev(sep);
|
---|
1487 | if (fpi == -1)
|
---|
1488 | project->variables()["QMAKE_LIBS_QT"].prepend(pltDir + sep);
|
---|
1489 | else
|
---|
1490 | project->variables()["QMAKE_LIBS_QT"] = filePath.left(fpi)
|
---|
1491 | + slashPltDir
|
---|
1492 | + filePath.mid(fpi);
|
---|
1493 |
|
---|
1494 | filePath = project->first("QMAKE_LIBS_QT_THREAD");
|
---|
1495 | fpi = filePath.findRev(sep);
|
---|
1496 | if (fpi == -1)
|
---|
1497 | project->variables()["QMAKE_LIBS_QT_THREAD"].prepend(pltDir + sep);
|
---|
1498 | else
|
---|
1499 | project->variables()["QMAKE_LIBS_QT_THREAD"] = filePath.left(fpi)
|
---|
1500 | + slashPltDir
|
---|
1501 | + filePath.mid(fpi);
|
---|
1502 |
|
---|
1503 | filePath = project->first("QMAKE_LIBS_QT_ENTRY");
|
---|
1504 | fpi = filePath.findRev(sep);
|
---|
1505 | if (fpi == -1)
|
---|
1506 | project->variables()["QMAKE_LIBS_QT_ENTRY"].prepend(pltDir + sep);
|
---|
1507 | else
|
---|
1508 | project->variables()["QMAKE_LIBS_QT_ENTRY"] = filePath.left(fpi)
|
---|
1509 | + slashPltDir
|
---|
1510 | + filePath.mid(fpi);
|
---|
1511 | }
|
---|
1512 |
|
---|
1513 | void
|
---|
1514 | MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src)
|
---|
1515 | {
|
---|
1516 | QStringList &objl = project->variables()[obj];
|
---|
1517 | QStringList &srcl = project->variables()[src];
|
---|
1518 |
|
---|
1519 | QStringList::Iterator oit = objl.begin();
|
---|
1520 | QStringList::Iterator sit = srcl.begin();
|
---|
1521 | QString stringSrc("$src");
|
---|
1522 | QString stringObj("$obj");
|
---|
1523 | for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) {
|
---|
1524 | if((*sit).isEmpty())
|
---|
1525 | continue;
|
---|
1526 |
|
---|
1527 | if(!doDepends()) {
|
---|
1528 | QString sdep, odep = (*sit) + " ";
|
---|
1529 | QStringList deps = findDependencies((*sit));
|
---|
1530 | for(QStringList::Iterator dit = deps.begin(); dit != deps.end(); dit++) {
|
---|
1531 | if((*dit).endsWith(Option::cpp_moc_ext))
|
---|
1532 | odep += (*dit) + " ";
|
---|
1533 | else
|
---|
1534 | sdep += (*dit) + " ";
|
---|
1535 | }
|
---|
1536 | t << (*sit) << ": " << sdep << endl
|
---|
1537 | << (*oit) << ": " << odep ;
|
---|
1538 | } else {
|
---|
1539 | t << (*oit) << ": " << (*sit) << " " << findDependencies((*sit)).join(" \\\n\t\t");
|
---|
1540 | }
|
---|
1541 |
|
---|
1542 | QString comp, cimp;
|
---|
1543 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) {
|
---|
1544 | if((*sit).endsWith((*cppit))) {
|
---|
1545 | comp = "QMAKE_RUN_CXX";
|
---|
1546 | cimp = "QMAKE_RUN_CXX_IMP";
|
---|
1547 | break;
|
---|
1548 | }
|
---|
1549 | }
|
---|
1550 | if(comp.isEmpty()) {
|
---|
1551 | comp = "QMAKE_RUN_CC";
|
---|
1552 | cimp = "QMAKE_RUN_CC_IMP";
|
---|
1553 | }
|
---|
1554 | bool use_implicit_rule = !project->isEmpty(cimp) && !project->isActiveConfig("compile_absolute_path");
|
---|
1555 | if(use_implicit_rule) {
|
---|
1556 | if(!project->isEmpty("OBJECTS_DIR")) {
|
---|
1557 | use_implicit_rule = FALSE;
|
---|
1558 | } else {
|
---|
1559 | int dot = (*sit).findRev('.');
|
---|
1560 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit)))
|
---|
1561 | use_implicit_rule = FALSE;
|
---|
1562 | }
|
---|
1563 | }
|
---|
1564 | if (!use_implicit_rule && !project->isEmpty(comp)) {
|
---|
1565 | QString p = var(comp), srcf(*sit);
|
---|
1566 | if(project->isActiveConfig("compile_absolute_path") && QDir::isRelativePath(srcf))
|
---|
1567 | srcf.prepend("$(PWD)" + Option::dir_sep);
|
---|
1568 | p.replace(stringSrc, srcf);
|
---|
1569 | p.replace(stringObj, (*oit));
|
---|
1570 | t << "\n\t" << p;
|
---|
1571 | }
|
---|
1572 | t << endl << endl;
|
---|
1573 | }
|
---|
1574 | }
|
---|
1575 |
|
---|
1576 |
|
---|
1577 | void
|
---|
1578 | MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui)
|
---|
1579 | {
|
---|
1580 | QStringList &uil = project->variables()[ui];
|
---|
1581 | for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) {
|
---|
1582 | QString decl, impl;
|
---|
1583 | {
|
---|
1584 | QString tmp = (*it), impl_dir, decl_dir;
|
---|
1585 | decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first());
|
---|
1586 | int dlen = decl.findRev(Option::dir_sep) + 1;
|
---|
1587 | tmp = (*it);
|
---|
1588 | impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first());
|
---|
1589 | int ilen = decl.findRev(Option::dir_sep) + 1;
|
---|
1590 | if(!project->isEmpty("UI_DIR")) {
|
---|
1591 | impl_dir = project->first("UI_DIR");
|
---|
1592 | decl = project->first("UI_DIR") + decl.right(decl.length() - dlen);
|
---|
1593 | impl = project->first("UI_DIR") + impl.right(impl.length() - ilen);
|
---|
1594 | } else {
|
---|
1595 | if(!project->isEmpty("UI_HEADERS_DIR")) {
|
---|
1596 | decl_dir = project->first("UI_HEADERS_DIR");
|
---|
1597 | decl = project->first("UI_HEADERS_DIR") + decl.right(decl.length() - dlen);
|
---|
1598 | }
|
---|
1599 | if(!project->isEmpty("UI_SOURCES_DIR")) {
|
---|
1600 | impl_dir = project->first("UI_SOURCES_DIR");
|
---|
1601 | impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen);
|
---|
1602 | }
|
---|
1603 | }
|
---|
1604 | impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir);
|
---|
1605 | decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
|
---|
1606 | if(decl_dir.isEmpty())
|
---|
1607 | decl_dir = decl.section(Option::dir_sep,0,-2);
|
---|
1608 | if(impl_dir.isEmpty())
|
---|
1609 | impl_dir = impl.section(Option::dir_sep,0,-2);
|
---|
1610 | if (QDir::isRelativePath(impl_dir))
|
---|
1611 | impl_dir.prepend(Option::output_dir + Option::dir_sep);
|
---|
1612 | if (QDir::isRelativePath(decl_dir))
|
---|
1613 | decl_dir.prepend(Option::output_dir + Option::dir_sep);
|
---|
1614 | createDir(impl_dir);
|
---|
1615 | createDir(decl_dir);
|
---|
1616 | }
|
---|
1617 | QStringList deps = findDependencies((*it));
|
---|
1618 | deps.remove(decl); //avoid circular dependencies..
|
---|
1619 | t << decl << ": " << (*it) << " " << deps.join(" \\\n\t\t") << "\n\t"
|
---|
1620 | << "$(UIC) " << (*it) << " -o " << decl << endl << endl;
|
---|
1621 |
|
---|
1622 | QString mildDecl = decl;
|
---|
1623 | int k = mildDecl.findRev(Option::dir_sep);
|
---|
1624 | if ( k != -1 )
|
---|
1625 | mildDecl = mildDecl.mid( k + 1 );
|
---|
1626 | t << impl << ": " << decl << " " << (*it) << " " << deps.join(" \\\n\t\t") << "\n\t"
|
---|
1627 | << "$(UIC)";
|
---|
1628 | t << " " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl;
|
---|
1629 | }
|
---|
1630 | }
|
---|
1631 |
|
---|
1632 |
|
---|
1633 | void
|
---|
1634 | MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString &src)
|
---|
1635 | {
|
---|
1636 | QStringList &objl = project->variables()[obj],
|
---|
1637 | &srcl = project->variables()[src];
|
---|
1638 | QStringList::Iterator oit = objl.begin(), sit = srcl.begin();
|
---|
1639 | QString stringSrc("$src"), stringObj("$obj");
|
---|
1640 | for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) {
|
---|
1641 | QString hdr = findMocSource((*sit));
|
---|
1642 | t << (*oit) << ": "
|
---|
1643 | << (*sit) << " " << findDependencies((*sit)).join(" \\\n\t\t") << " "
|
---|
1644 | << hdr << " " << findDependencies(hdr).join(" \\\n\t\t");
|
---|
1645 | bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP") && !project->isActiveConfig("compile_absolute_path");
|
---|
1646 | if(use_implicit_rule) {
|
---|
1647 | if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("MOC_DIR")) {
|
---|
1648 | use_implicit_rule = FALSE;
|
---|
1649 | } else {
|
---|
1650 | int dot = (*sit).findRev('.');
|
---|
1651 | if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit)))
|
---|
1652 | use_implicit_rule = FALSE;
|
---|
1653 | }
|
---|
1654 | }
|
---|
1655 | if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) {
|
---|
1656 | QString p = var("QMAKE_RUN_CXX"), srcf(*sit);
|
---|
1657 | if(project->isActiveConfig("compile_absolute_path") && QDir::isRelativePath(srcf))
|
---|
1658 | srcf.prepend("$(PWD)" + Option::dir_sep);
|
---|
1659 | p.replace(stringSrc, srcf);
|
---|
1660 | p.replace(stringObj, (*oit));
|
---|
1661 | t << "\n\t" << p;
|
---|
1662 | }
|
---|
1663 | t << endl << endl;
|
---|
1664 | }
|
---|
1665 | }
|
---|
1666 |
|
---|
1667 |
|
---|
1668 | void
|
---|
1669 | MakefileGenerator::writeMocSrc(QTextStream &t, const QString &src)
|
---|
1670 | {
|
---|
1671 | QStringList &l = project->variables()[src];
|
---|
1672 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1673 | QString m = Option::fixPathToTargetOS(findMocDestination(*it));
|
---|
1674 | if ( !m.isEmpty()) {
|
---|
1675 | QString deps;
|
---|
1676 | if(!project->isActiveConfig("no_mocdepend"))
|
---|
1677 | deps += "$(MOC) ";
|
---|
1678 | deps += (*it);
|
---|
1679 | t << m << ": " << deps << "\n\t"
|
---|
1680 | << "$(MOC)";
|
---|
1681 | t << " " << (*it) << " -o " << m << endl << endl;
|
---|
1682 | }
|
---|
1683 | }
|
---|
1684 | }
|
---|
1685 |
|
---|
1686 | void
|
---|
1687 | MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src)
|
---|
1688 | {
|
---|
1689 | QStringList &l = project->variables()[src];
|
---|
1690 | if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1)
|
---|
1691 | warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected."
|
---|
1692 | "This can lead to link problems.\n");
|
---|
1693 | QString default_out_h = "y.tab.h", default_out_c = "y.tab.c";
|
---|
1694 | if(!project->isEmpty("QMAKE_YACC_HEADER"))
|
---|
1695 | default_out_h = project->first("QMAKE_YACC_HEADER");
|
---|
1696 | if(!project->isEmpty("QMAKE_YACC_SOURCE"))
|
---|
1697 | default_out_c = project->first("QMAKE_YACC_SOURCE");
|
---|
1698 | QString stringBase("$base");
|
---|
1699 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1700 | QFileInfo fi((*it));
|
---|
1701 | QString dir;
|
---|
1702 | if(fi.dirPath() != ".")
|
---|
1703 | dir = fi.dirPath() + Option::dir_sep;
|
---|
1704 | dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
|
---|
1705 | if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
|
---|
1706 | dir += Option::dir_sep;
|
---|
1707 |
|
---|
1708 | QString impl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first();
|
---|
1709 | QString decl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first();
|
---|
1710 |
|
---|
1711 | QString yaccflags = "$(YACCFLAGS)", mangle = "y";
|
---|
1712 | if(!project->isActiveConfig("yacc_no_name_mangle")) {
|
---|
1713 | mangle = fi.baseName(TRUE);
|
---|
1714 | if(!project->isEmpty("QMAKE_YACCFLAGS_MANGLE"))
|
---|
1715 | yaccflags += " " + var("QMAKE_YACCFLAGS_MANGLE").replace(stringBase, mangle);
|
---|
1716 | else
|
---|
1717 | yaccflags += " -p " + mangle;
|
---|
1718 | }
|
---|
1719 | QString out_h = default_out_h, out_c = default_out_c;
|
---|
1720 | if(!mangle.isEmpty()) {
|
---|
1721 | out_h.replace(stringBase, mangle);
|
---|
1722 | out_c.replace(stringBase, mangle);
|
---|
1723 | }
|
---|
1724 |
|
---|
1725 | t << impl << ": " << (*it) << "\n\t"
|
---|
1726 | << "$(YACC) " << yaccflags << " " << (*it) << "\n\t"
|
---|
1727 | << "-$(DEL_FILE) " << impl << " " << decl << "\n\t"
|
---|
1728 | << "-$(MOVE) " << out_h << " " << decl << "\n\t"
|
---|
1729 | << "-$(MOVE) " << out_c << " " << impl << endl << endl;
|
---|
1730 | t << decl << ": " << impl << endl << endl;
|
---|
1731 | }
|
---|
1732 | }
|
---|
1733 |
|
---|
1734 | void
|
---|
1735 | MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src)
|
---|
1736 | {
|
---|
1737 | QStringList &l = project->variables()[src];
|
---|
1738 | if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1)
|
---|
1739 | warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected.\n"
|
---|
1740 | "This can lead to link problems.\n");
|
---|
1741 | QString default_out_c = "lex.$base.c";
|
---|
1742 | if(!project->isEmpty("QMAKE_LEX_SOURCE"))
|
---|
1743 | default_out_c = project->first("QMAKE_LEX_SOURCE");
|
---|
1744 | QString stringBase("$base");
|
---|
1745 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1746 | QFileInfo fi((*it));
|
---|
1747 | QString dir;
|
---|
1748 | if(fi.dirPath() != ".")
|
---|
1749 | dir = fi.dirPath() + Option::dir_sep;
|
---|
1750 | dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
|
---|
1751 | if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
|
---|
1752 | dir += Option::dir_sep;
|
---|
1753 | QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
|
---|
1754 |
|
---|
1755 | QString lexflags = "$(LEXFLAGS)", stub="yy";
|
---|
1756 | if(!project->isActiveConfig("yacc_no_name_mangle")) {
|
---|
1757 | stub = fi.baseName(TRUE);
|
---|
1758 | lexflags += " -P" + stub;
|
---|
1759 | }
|
---|
1760 | QString out_c = default_out_c;
|
---|
1761 | if(!stub.isEmpty())
|
---|
1762 | out_c.replace(stringBase, stub);
|
---|
1763 |
|
---|
1764 | t << impl << ": " << (*it) << " " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
|
---|
1765 | << ( "$(LEX) " + lexflags + " " ) << (*it) << "\n\t"
|
---|
1766 | << "-$(DEL_FILE) " << impl << " " << "\n\t"
|
---|
1767 | << "-$(MOVE) " << out_c << " " << impl << endl << endl;
|
---|
1768 | }
|
---|
1769 | }
|
---|
1770 |
|
---|
1771 | void
|
---|
1772 | MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj)
|
---|
1773 | {
|
---|
1774 | QStringList &objl = project->variables()[obj];
|
---|
1775 | QString stringSrc("$src");
|
---|
1776 | QString stringObj("$obj");
|
---|
1777 |
|
---|
1778 | QString uidir;
|
---|
1779 | for(QStringList::Iterator oit = objl.begin(); oit != objl.end(); oit++) {
|
---|
1780 | QString src(project->first("QMAKE_IMAGE_COLLECTION"));
|
---|
1781 | t << (*oit) << ": " << src;
|
---|
1782 | bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP") && !project->isActiveConfig("compile_absolute_path");
|
---|
1783 | if(use_implicit_rule) {
|
---|
1784 | if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) {
|
---|
1785 | use_implicit_rule = FALSE;
|
---|
1786 | } else {
|
---|
1787 | int dot = src.findRev('.');
|
---|
1788 | if(dot == -1 || (src.left(dot) + Option::obj_ext != (*oit)))
|
---|
1789 | use_implicit_rule = FALSE;
|
---|
1790 | }
|
---|
1791 | }
|
---|
1792 | if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) {
|
---|
1793 | QString p = var("QMAKE_RUN_CXX"), srcf(src);
|
---|
1794 | if(project->isActiveConfig("compile_absolute_path") && QDir::isRelativePath(srcf))
|
---|
1795 | srcf.prepend("$(PWD)" + Option::dir_sep);
|
---|
1796 | p.replace(stringSrc, srcf);
|
---|
1797 | p.replace(stringObj, (*oit));
|
---|
1798 | t << "\n\t" << p;
|
---|
1799 | }
|
---|
1800 | t << endl << endl;
|
---|
1801 | }
|
---|
1802 | }
|
---|
1803 |
|
---|
1804 |
|
---|
1805 | void
|
---|
1806 | MakefileGenerator::writeImageSrc(QTextStream &t, const QString &src)
|
---|
1807 | {
|
---|
1808 | QStringList &l = project->variables()[src];
|
---|
1809 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1810 | QString gen = project->first("MAKEFILE_GENERATOR");
|
---|
1811 | if ( gen == "MSVC" ) {
|
---|
1812 | t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
|
---|
1813 | << "$(UIC) -o " << (*it) << " -embed " << project->first("QMAKE_ORIG_TARGET")
|
---|
1814 | << " -f <<\n" << findDependencies((*it)).join(" ") << "\n<<" << endl << endl;
|
---|
1815 | } else if ( gen == "BMAKE" ) {
|
---|
1816 | t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
|
---|
1817 | << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET")
|
---|
1818 | << " -f &&|\n" << findDependencies((*it)).join(" ") << "\n| -o " << (*it) << endl << endl;
|
---|
1819 | } else {
|
---|
1820 | t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
|
---|
1821 | << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET")
|
---|
1822 | << " " << findDependencies((*it)).join(" ") << " -o " << (*it) << endl << endl;
|
---|
1823 | }
|
---|
1824 | }
|
---|
1825 | }
|
---|
1826 |
|
---|
1827 |
|
---|
1828 | void
|
---|
1829 | MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
|
---|
1830 | {
|
---|
1831 | QString all_installs, all_uninstalls;
|
---|
1832 | QStringList &l = project->variables()[installs];
|
---|
1833 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
1834 | QString pvar = (*it) + ".path";
|
---|
1835 | if(project->variables()[(*it) + ".CONFIG"].findIndex("no_path") == -1 &&
|
---|
1836 | project->variables()[pvar].isEmpty()) {
|
---|
1837 | warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1());
|
---|
1838 | continue;
|
---|
1839 | }
|
---|
1840 |
|
---|
1841 | bool do_default = TRUE;
|
---|
1842 | const QString root = "$(INSTALL_ROOT)";
|
---|
1843 | QString target, dst= fileFixify(project->variables()[pvar].first());
|
---|
1844 | if(dst.right(1) != Option::dir_sep)
|
---|
1845 | dst += Option::dir_sep;
|
---|
1846 | QStringList tmp, uninst = project->variables()[(*it) + ".uninstall"];
|
---|
1847 | //other
|
---|
1848 | tmp = project->variables()[(*it) + ".extra"];
|
---|
1849 | if(tmp.isEmpty())
|
---|
1850 | tmp = project->variables()[(*it) + ".commands"]; //to allow compatible name
|
---|
1851 | if(!tmp.isEmpty()) {
|
---|
1852 | do_default = FALSE;
|
---|
1853 | if(!target.isEmpty())
|
---|
1854 | target += "\n\t";
|
---|
1855 | target += tmp.join(" ");
|
---|
1856 | }
|
---|
1857 | //masks
|
---|
1858 | tmp = project->variables()[(*it) + ".files"];
|
---|
1859 | if(!tmp.isEmpty()) {
|
---|
1860 | if(!target.isEmpty())
|
---|
1861 | target += "\n";
|
---|
1862 | do_default = FALSE;
|
---|
1863 | for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) {
|
---|
1864 | QString wild = Option::fixPathToLocalOS((*wild_it), FALSE), wild_var = fileFixify(wild);
|
---|
1865 | QString dirstr = QDir::currentDirPath(), filestr = wild;
|
---|
1866 | int slsh = filestr.findRev(Option::dir_sep);
|
---|
1867 | if(slsh != -1) {
|
---|
1868 | dirstr = filestr.left(slsh+1);
|
---|
1869 | filestr = filestr.right(filestr.length() - slsh - 1);
|
---|
1870 | }
|
---|
1871 | if(dirstr.right(Option::dir_sep.length()) != Option::dir_sep)
|
---|
1872 | dirstr += Option::dir_sep;
|
---|
1873 | if(QFile::exists(wild)) { //real file
|
---|
1874 | QString file = wild;
|
---|
1875 | QFileInfo fi(wild);
|
---|
1876 | if(!target.isEmpty())
|
---|
1877 | target += "\t";
|
---|
1878 | QString cmd = QString(fi.isDir() ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" +
|
---|
1879 | Option::fixPathToTargetOS(fileFixify(wild, QString::null,
|
---|
1880 | QString::null, FALSE, FALSE), FALSE) +
|
---|
1881 | "\" \"" + root + dst + "\"\n";
|
---|
1882 | target += cmd;
|
---|
1883 | if(!project->isActiveConfig("debug") &&
|
---|
1884 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
|
---|
1885 | target += QString("\t-") + var("QMAKE_STRIP") + " \"" +
|
---|
1886 | root + fileFixify(dst + filestr, QString::null, QString::null, FALSE, FALSE) +
|
---|
1887 | "\"\n";
|
---|
1888 | if(!uninst.isEmpty())
|
---|
1889 | uninst.append("\n\t");
|
---|
1890 | uninst.append(
|
---|
1891 | #if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
---|
1892 | QString("-$(DEL_FILE)")
|
---|
1893 | #else
|
---|
1894 | QString("-$(DEL_FILE) -r")
|
---|
1895 | #endif
|
---|
1896 | + " \"" + root + fileFixify(dst + filestr, QString::null, QString::null, FALSE, FALSE) + "\"");
|
---|
1897 | continue;
|
---|
1898 | }
|
---|
1899 | fixEnvVariables(dirstr);
|
---|
1900 | QDir dir(dirstr, filestr); //wild
|
---|
1901 | for(uint x = 0; x < dir.count(); x++) {
|
---|
1902 | QString file = dir[x];
|
---|
1903 | if(file == "." || file == "..") //blah
|
---|
1904 | continue;
|
---|
1905 | if(!uninst.isEmpty())
|
---|
1906 | uninst.append("\n\t");
|
---|
1907 | uninst.append(
|
---|
1908 | #if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
---|
1909 | QString("-$(DEL_FILE)")
|
---|
1910 | #else
|
---|
1911 | QString("-$(DEL_FILE) -r")
|
---|
1912 | #endif
|
---|
1913 | + " \"" + root + fileFixify(dst + file, QString::null, QString::null, FALSE, FALSE) +
|
---|
1914 | "\"");
|
---|
1915 | QFileInfo fi(Option::fixPathToTargetOS(fileFixify(dirstr + file), TRUE));
|
---|
1916 | if(!target.isEmpty())
|
---|
1917 | target += "\t";
|
---|
1918 | QString cmd = QString(fi.isDir() ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" +
|
---|
1919 | Option::fixPathToTargetOS(fileFixify(dirstr + file, QString::null,
|
---|
1920 | QString::null, FALSE, FALSE), FALSE) +
|
---|
1921 | "\" \"" + root + fileFixify(dst) + "\"\n";
|
---|
1922 | target += cmd;
|
---|
1923 | if(!project->isActiveConfig("debug") &&
|
---|
1924 | !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
|
---|
1925 | target += QString("\t-") + var("QMAKE_STRIP") + " \"" +
|
---|
1926 | root + fileFixify(dst + file, QString::null, QString::null, FALSE, FALSE) +
|
---|
1927 | "\"\n";
|
---|
1928 | }
|
---|
1929 | }
|
---|
1930 | }
|
---|
1931 | //default?
|
---|
1932 | if(do_default) {
|
---|
1933 | target = defaultInstall((*it));
|
---|
1934 | uninst = project->variables()[(*it) + ".uninstall"];
|
---|
1935 | }
|
---|
1936 |
|
---|
1937 | if(!target.isEmpty()) {
|
---|
1938 | t << "install_" << (*it) << ": all ";
|
---|
1939 | const QStringList &deps = project->variables()[(*it) + ".depends"];
|
---|
1940 | if(!deps.isEmpty()) {
|
---|
1941 | for(QStringList::ConstIterator dep_it = deps.begin(); dep_it != deps.end(); ++dep_it) {
|
---|
1942 | QString targ = var((*dep_it) + ".target");
|
---|
1943 | if(targ.isEmpty())
|
---|
1944 | targ = (*dep_it);
|
---|
1945 | t << targ;
|
---|
1946 | }
|
---|
1947 | }
|
---|
1948 | t << "\n\t";
|
---|
1949 | const QStringList &dirs = project->variables()[pvar];
|
---|
1950 | for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) {
|
---|
1951 | QString tmp_dst = fileFixify((*pit));
|
---|
1952 | #ifndef Q_WS_WIN
|
---|
1953 | if(tmp_dst.right(1) != Option::dir_sep)
|
---|
1954 | tmp_dst += Option::dir_sep;
|
---|
1955 | #endif
|
---|
1956 | t << mkdir_p_asstring(root+tmp_dst) << "\n\t";
|
---|
1957 | }
|
---|
1958 | t << target << endl << endl;
|
---|
1959 | if(!uninst.isEmpty()) {
|
---|
1960 | t << "uninstall_" << (*it) << ": " << "\n\t"
|
---|
1961 | << uninst.join("") << "\n\t"
|
---|
1962 | << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl;
|
---|
1963 | }
|
---|
1964 | t << endl;
|
---|
1965 |
|
---|
1966 | if(project->variables()[(*it) + ".CONFIG"].findIndex("no_default_install") == -1) {
|
---|
1967 | all_installs += QString("install_") + (*it) + " ";
|
---|
1968 | if(!uninst.isEmpty())
|
---|
1969 | all_uninstalls += "uninstall_" + (*it) + " ";
|
---|
1970 | }
|
---|
1971 | } else {
|
---|
1972 | debug_msg(1, "no definition for install %s: install target not created",(*it).latin1());
|
---|
1973 | }
|
---|
1974 | }
|
---|
1975 | t << "install: " << all_installs << " " << var("INSTALLDEPS") << "\n\n";
|
---|
1976 | t << "uninstall: " << all_uninstalls << " " << var("UNINSTALLDEPS") << "\n\n";
|
---|
1977 | }
|
---|
1978 |
|
---|
1979 | QString
|
---|
1980 | MakefileGenerator::var(const QString &var)
|
---|
1981 | {
|
---|
1982 | return val(project->variables()[var]);
|
---|
1983 | }
|
---|
1984 |
|
---|
1985 | QString
|
---|
1986 | MakefileGenerator::val(const QStringList &varList)
|
---|
1987 | {
|
---|
1988 | return valGlue(varList, "", " ", "");
|
---|
1989 | }
|
---|
1990 |
|
---|
1991 | QString
|
---|
1992 | MakefileGenerator::varGlue(const QString &var, const QString &before, const QString &glue, const QString &after)
|
---|
1993 | {
|
---|
1994 | return valGlue(project->variables()[var], before, glue, after);
|
---|
1995 | }
|
---|
1996 |
|
---|
1997 | QString
|
---|
1998 | MakefileGenerator::valGlue(const QStringList &varList, const QString &before, const QString &glue, const QString &after)
|
---|
1999 | {
|
---|
2000 | QString ret;
|
---|
2001 | for(QStringList::ConstIterator it = varList.begin(); it != varList.end(); ++it) {
|
---|
2002 | if(!(*it).isEmpty()) {
|
---|
2003 | if(!ret.isEmpty())
|
---|
2004 | ret += glue;
|
---|
2005 | ret += (*it);
|
---|
2006 | }
|
---|
2007 | }
|
---|
2008 | return ret.isEmpty() ? QString("") : before + ret + after;
|
---|
2009 | }
|
---|
2010 |
|
---|
2011 |
|
---|
2012 | QString
|
---|
2013 | MakefileGenerator::varList(const QString &var)
|
---|
2014 | {
|
---|
2015 | return valList(project->variables()[var]);
|
---|
2016 | }
|
---|
2017 |
|
---|
2018 | QString
|
---|
2019 | MakefileGenerator::valList(const QStringList &varList)
|
---|
2020 | {
|
---|
2021 | return valGlue(varList, "", " \\\n\t\t", "");
|
---|
2022 | }
|
---|
2023 |
|
---|
2024 |
|
---|
2025 | QStringList
|
---|
2026 | MakefileGenerator::createObjectList(const QString &var)
|
---|
2027 | {
|
---|
2028 | QStringList &l = project->variables()[var], ret;
|
---|
2029 | QString objdir, dir;
|
---|
2030 | if(!project->variables()["OBJECTS_DIR"].isEmpty())
|
---|
2031 | objdir = project->first("OBJECTS_DIR");
|
---|
2032 | for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
---|
2033 | QFileInfo fi(Option::fixPathToLocalOS((*it)));
|
---|
2034 | if(objdir.isEmpty() && project->isActiveConfig("object_with_source")) {
|
---|
2035 | QString fName = Option::fixPathToTargetOS((*it), FALSE);
|
---|
2036 | int dl = fName.findRev(Option::dir_sep);
|
---|
2037 | if(dl != -1)
|
---|
2038 | dir = fName.left(dl + 1);
|
---|
2039 | } else {
|
---|
2040 | dir = objdir;
|
---|
2041 | }
|
---|
2042 | ret.append(dir + fi.baseName(TRUE) + Option::obj_ext);
|
---|
2043 | }
|
---|
2044 | return ret;
|
---|
2045 | }
|
---|
2046 |
|
---|
2047 | bool
|
---|
2048 | MakefileGenerator::writeMakefile(QTextStream &t)
|
---|
2049 | {
|
---|
2050 | t << "####### Compile" << endl << endl;
|
---|
2051 | writeObj(t, "OBJECTS", "SOURCES");
|
---|
2052 | writeUicSrc(t, "FORMS");
|
---|
2053 | writeObj(t, "UICOBJECTS", "UICIMPLS");
|
---|
2054 | writeMocObj(t, "OBJMOC", "SRCMOC" );
|
---|
2055 | writeMocSrc(t, "HEADERS");
|
---|
2056 | writeMocSrc(t, "SOURCES");
|
---|
2057 | writeMocSrc(t, "UICDECLS");
|
---|
2058 | writeYaccSrc(t, "YACCSOURCES");
|
---|
2059 | writeLexSrc(t, "LEXSOURCES");
|
---|
2060 | writeImageObj(t, "IMAGEOBJECTS");
|
---|
2061 | writeImageSrc(t, "QMAKE_IMAGE_COLLECTION");
|
---|
2062 |
|
---|
2063 | t << "####### Install" << endl << endl;
|
---|
2064 | writeInstalls(t, "INSTALLS");
|
---|
2065 | return TRUE;
|
---|
2066 | }
|
---|
2067 |
|
---|
2068 | QString MakefileGenerator::buildArgs()
|
---|
2069 | {
|
---|
2070 | static QString ret;
|
---|
2071 | if(ret.isEmpty()) {
|
---|
2072 | //special variables
|
---|
2073 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
|
---|
2074 | ret += " QMAKE_ABSOLUTE_SOURCE_PATH=\"" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + "\"";
|
---|
2075 |
|
---|
2076 | //warnings
|
---|
2077 | else if(Option::warn_level == WarnNone)
|
---|
2078 | ret += " -Wnone";
|
---|
2079 | else if(Option::warn_level == WarnAll)
|
---|
2080 | ret += " -Wall";
|
---|
2081 | else if(Option::warn_level & WarnParser)
|
---|
2082 | ret += " -Wparser";
|
---|
2083 | //other options
|
---|
2084 | if(!Option::user_template.isEmpty())
|
---|
2085 | ret += " -t " + Option::user_template;
|
---|
2086 | if(!Option::mkfile::do_cache)
|
---|
2087 | ret += " -nocache";
|
---|
2088 | if(!Option::mkfile::do_deps)
|
---|
2089 | ret += " -nodepend";
|
---|
2090 | if(!Option::mkfile::do_mocs)
|
---|
2091 | ret += " -nomoc";
|
---|
2092 | if(!Option::mkfile::do_dep_heuristics)
|
---|
2093 | ret += " -nodependheuristics";
|
---|
2094 | if(!Option::mkfile::qmakespec_commandline.isEmpty())
|
---|
2095 | ret += " -spec " + Option::mkfile::qmakespec_commandline;
|
---|
2096 |
|
---|
2097 | //arguments
|
---|
2098 | for(QStringList::Iterator it = Option::before_user_vars.begin();
|
---|
2099 | it != Option::before_user_vars.end(); ++it) {
|
---|
2100 | if((*it).left(qstrlen("QMAKE_ABSOLUTE_SOURCE_PATH")) != "QMAKE_ABSOLUTE_SOURCE_PATH")
|
---|
2101 | ret += " \"" + (*it) + "\"";
|
---|
2102 | }
|
---|
2103 | if(Option::after_user_vars.count()) {
|
---|
2104 | ret += " -after ";
|
---|
2105 | for(QStringList::Iterator it = Option::after_user_vars.begin();
|
---|
2106 | it != Option::after_user_vars.end(); ++it) {
|
---|
2107 | if((*it).left(qstrlen("QMAKE_ABSOLUTE_SOURCE_PATH")) != "QMAKE_ABSOLUTE_SOURCE_PATH")
|
---|
2108 | ret += " \"" + (*it) + "\"";
|
---|
2109 | }
|
---|
2110 | }
|
---|
2111 | }
|
---|
2112 | return ret;
|
---|
2113 | }
|
---|
2114 |
|
---|
2115 | //could get stored argv, but then it would have more options than are
|
---|
2116 | //probably necesary this will try to guess the bare minimum..
|
---|
2117 | QString MakefileGenerator::build_args()
|
---|
2118 | {
|
---|
2119 | static QString ret;
|
---|
2120 | if(ret.isEmpty()) {
|
---|
2121 | ret = "$(QMAKE)";
|
---|
2122 |
|
---|
2123 | // general options and arguments
|
---|
2124 | ret += buildArgs();
|
---|
2125 |
|
---|
2126 | //output
|
---|
2127 | QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name()));
|
---|
2128 | if (!ofile.isEmpty() && ofile != project->first("QMAKE_MAKEFILE"))
|
---|
2129 | ret += " -o " + ofile;
|
---|
2130 |
|
---|
2131 | //inputs
|
---|
2132 | QStringList files = fileFixify(Option::mkfile::project_files);
|
---|
2133 | ret += " " + files.join(" ");
|
---|
2134 | }
|
---|
2135 | return ret;
|
---|
2136 | }
|
---|
2137 |
|
---|
2138 | bool
|
---|
2139 | MakefileGenerator::writeHeader(QTextStream &t)
|
---|
2140 | {
|
---|
2141 | time_t foo = time(NULL);
|
---|
2142 | t << "#############################################################################" << endl;
|
---|
2143 | t << "# Makefile for building: " << var("TARGET") << endl;
|
---|
2144 | t << "# Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: " << ctime(&foo);
|
---|
2145 | t << "# Project: " << fileFixify(project->projectFile()) << endl;
|
---|
2146 | t << "# Template: " << var("TEMPLATE") << endl;
|
---|
2147 | t << "# Command: " << build_args() << endl;
|
---|
2148 | t << "#############################################################################" << endl;
|
---|
2149 | t << endl;
|
---|
2150 | return TRUE;
|
---|
2151 | }
|
---|
2152 |
|
---|
2153 |
|
---|
2154 | //makes my life easier..
|
---|
2155 | bool
|
---|
2156 | MakefileGenerator::writeMakeQmake(QTextStream &t)
|
---|
2157 | {
|
---|
2158 | QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name()));
|
---|
2159 | if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isActiveConfig("no_autoqmake") &&
|
---|
2160 | !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) {
|
---|
2161 | QStringList files = fileFixify(Option::mkfile::project_files);
|
---|
2162 | t << project->first("QMAKE_INTERNAL_PRL_FILE") << ": " << "\n\t"
|
---|
2163 | << "@$(QMAKE) -prl " << buildArgs() << " " << files.join(" ") << endl;
|
---|
2164 | }
|
---|
2165 |
|
---|
2166 | QString pfile = project->projectFile();
|
---|
2167 | if(pfile != "(stdin)") {
|
---|
2168 | QString qmake = build_args();
|
---|
2169 | if(!ofile.isEmpty() && !project->isActiveConfig("no_autoqmake")) {
|
---|
2170 | t << ofile << ": " << fileFixify(pfile) << " ";
|
---|
2171 | if(Option::mkfile::do_cache)
|
---|
2172 | t << fileFixify(Option::mkfile::cachefile) << " ";
|
---|
2173 | if(!specdir().isEmpty()) {
|
---|
2174 | if (QFile::exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"qmake.conf")))
|
---|
2175 | t << specdir() << Option::dir_sep << "qmake.conf" << " ";
|
---|
2176 | else if (QFile::exists(Option::fixPathToLocalOS(specdir()+QDir::separator()+"tmake.conf")))
|
---|
2177 | t << specdir() << Option::dir_sep << "tmake.conf" << " ";
|
---|
2178 | }
|
---|
2179 | t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t"
|
---|
2180 | << qmake <<endl;
|
---|
2181 | }
|
---|
2182 | if(project->first("QMAKE_ORIG_TARGET") != "qmake") {
|
---|
2183 | t << "qmake: " <<
|
---|
2184 | project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].join(" \\\n\t\t") << "\n\t"
|
---|
2185 | << "@" << qmake << endl << endl;
|
---|
2186 | }
|
---|
2187 | }
|
---|
2188 | return TRUE;
|
---|
2189 | }
|
---|
2190 |
|
---|
2191 | QStringList
|
---|
2192 | MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir,
|
---|
2193 | bool force_fix, bool canon) const
|
---|
2194 | {
|
---|
2195 | if(files.isEmpty())
|
---|
2196 | return files;
|
---|
2197 | QStringList ret;
|
---|
2198 | for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
|
---|
2199 | if(!(*it).isEmpty())
|
---|
2200 | ret << fileFixify((*it), out_dir, in_dir, force_fix, canon);
|
---|
2201 | }
|
---|
2202 | return ret;
|
---|
2203 | }
|
---|
2204 |
|
---|
2205 | QString
|
---|
2206 | MakefileGenerator::fileFixify(const QString& file0, const QString &out_d,
|
---|
2207 | const QString &in_d, bool force_fix, bool canon) const
|
---|
2208 | {
|
---|
2209 | if(file0.isEmpty())
|
---|
2210 | return file0;
|
---|
2211 | QString key = file0;
|
---|
2212 | if(QDir::isRelativePath(file0))
|
---|
2213 | key.prepend(QDir::currentDirPath() + "--");
|
---|
2214 | if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix || !canon)
|
---|
2215 | key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "--" +
|
---|
2216 | QString::number((int)canon) + "-");
|
---|
2217 | if(fileFixed.contains(key))
|
---|
2218 | return fileFixed[key];
|
---|
2219 |
|
---|
2220 | QString file = file0;
|
---|
2221 | int depth = 4;
|
---|
2222 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
|
---|
2223 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
|
---|
2224 | if(project && !project->isEmpty("QMAKE_PROJECT_DEPTH"))
|
---|
2225 | depth = project->first("QMAKE_PROJECT_DEPTH").toInt();
|
---|
2226 | else if(Option::mkfile::cachefile_depth != -1)
|
---|
2227 | depth = Option::mkfile::cachefile_depth;
|
---|
2228 | }
|
---|
2229 |
|
---|
2230 | QChar quote;
|
---|
2231 | if((file.startsWith("'") || file.startsWith("\"")) && file.startsWith(file.right(1))) {
|
---|
2232 | quote = file.at(0);
|
---|
2233 | file = file.mid(1, file.length() - 2);
|
---|
2234 | }
|
---|
2235 | QString orig_file = file;
|
---|
2236 | if(!force_fix && project->isActiveConfig("no_fixpath")) {
|
---|
2237 | if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it
|
---|
2238 | QString qfile = Option::fixPathToLocalOS(file, TRUE, canon);
|
---|
2239 | if(QDir::isRelativePath(file)) { //already absolute
|
---|
2240 | QFileInfo fi(qfile);
|
---|
2241 | if(!fi.convertToAbs()) //strange
|
---|
2242 | file = fi.filePath();
|
---|
2243 | }
|
---|
2244 | }
|
---|
2245 | } else { //fix it..
|
---|
2246 | QString qfile(Option::fixPathToLocalOS(file, TRUE, canon)), in_dir(in_d), out_dir(out_d);
|
---|
2247 | {
|
---|
2248 | if(out_dir.isNull() || QDir::isRelativePath(out_dir))
|
---|
2249 | out_dir.prepend(Option::output_dir + QDir::separator());
|
---|
2250 | if(out_dir == ".")
|
---|
2251 | out_dir = QDir::currentDirPath();
|
---|
2252 | if(in_dir.isEmpty() || QDir::isRelativePath(in_dir))
|
---|
2253 | in_dir.prepend(QDir::currentDirPath() + QDir::separator());
|
---|
2254 | if(in_dir == ".")
|
---|
2255 | in_dir = QDir::currentDirPath();
|
---|
2256 |
|
---|
2257 | if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) {
|
---|
2258 | QFileInfo in_fi(in_dir);
|
---|
2259 | if(!in_fi.convertToAbs())
|
---|
2260 | in_dir = in_fi.filePath();
|
---|
2261 | QFileInfo out_fi(out_dir);
|
---|
2262 | if(!out_fi.convertToAbs())
|
---|
2263 | out_dir = out_fi.filePath();
|
---|
2264 | }
|
---|
2265 | QString in_canonical_dir = QDir(in_dir).canonicalPath(),
|
---|
2266 | out_canonical_dir = QDir(out_dir).canonicalPath();
|
---|
2267 | if(!in_canonical_dir.isEmpty())
|
---|
2268 | in_dir = in_canonical_dir;
|
---|
2269 | if(!out_canonical_dir.isEmpty())
|
---|
2270 | out_dir = out_canonical_dir;
|
---|
2271 | }
|
---|
2272 | if(out_dir != in_dir || !QDir::isRelativePath(qfile)) {
|
---|
2273 | if(QDir::isRelativePath(qfile)) {
|
---|
2274 | if(file.left(Option::dir_sep.length()) != Option::dir_sep &&
|
---|
2275 | in_dir.right(Option::dir_sep.length()) != Option::dir_sep)
|
---|
2276 | file.prepend(Option::dir_sep);
|
---|
2277 | file.prepend(in_dir);
|
---|
2278 | }
|
---|
2279 | file = Option::fixPathToTargetOS(file, FALSE, canon);
|
---|
2280 | if(canon && QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE, canon)) {
|
---|
2281 | QString real_file = QDir(file).canonicalPath();
|
---|
2282 | if(!real_file.isEmpty())
|
---|
2283 | file = real_file;
|
---|
2284 | }
|
---|
2285 | QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE, canon);
|
---|
2286 | if(file == match_dir) {
|
---|
2287 | file = "";
|
---|
2288 | } else if(file.startsWith(match_dir) &&
|
---|
2289 | file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) {
|
---|
2290 | file = file.right(file.length() - (match_dir.length() + 1));
|
---|
2291 | } else {
|
---|
2292 | for(int i = 1; i <= depth; i++) {
|
---|
2293 | int sl = match_dir.findRev(Option::dir_sep);
|
---|
2294 | if(sl == -1)
|
---|
2295 | break;
|
---|
2296 | match_dir = match_dir.left(sl);
|
---|
2297 | if(match_dir.isEmpty())
|
---|
2298 | break;
|
---|
2299 | if(file.startsWith(match_dir) &&
|
---|
2300 | file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) {
|
---|
2301 | //concat
|
---|
2302 | int remlen = file.length() - (match_dir.length() + 1);
|
---|
2303 | if (remlen < 0)
|
---|
2304 | remlen = 0;
|
---|
2305 | file = file.right(remlen);
|
---|
2306 | //prepend
|
---|
2307 | for(int o = 0; o < i; o++)
|
---|
2308 | file.prepend(".." + Option::dir_sep);
|
---|
2309 | }
|
---|
2310 | }
|
---|
2311 | }
|
---|
2312 | }
|
---|
2313 | }
|
---|
2314 | file = Option::fixPathToTargetOS(file, FALSE, canon);
|
---|
2315 | if(file.isEmpty())
|
---|
2316 | file = ".";
|
---|
2317 | if(!quote.isNull())
|
---|
2318 | file = quote + file + quote;
|
---|
2319 | debug_msg(3, "Fixed %s :: to :: %s (%d) [%s::%s]", orig_file.latin1(), file.latin1(), depth,
|
---|
2320 | in_d.latin1(), out_d.latin1());
|
---|
2321 | ((MakefileGenerator*)this)->fileFixed.insert(key, file);
|
---|
2322 | return file;
|
---|
2323 | }
|
---|
2324 |
|
---|
2325 | QString
|
---|
2326 | MakefileGenerator::cleanFilePath(const QString &file) const
|
---|
2327 | {
|
---|
2328 | return fileFixify(Option::fixPathToTargetOS(file));
|
---|
2329 | }
|
---|
2330 |
|
---|
2331 | void MakefileGenerator::logicWarn(const QString &f, const QString &w)
|
---|
2332 | {
|
---|
2333 | if(!(Option::warn_level & WarnLogic))
|
---|
2334 | return;
|
---|
2335 | QString file = f;
|
---|
2336 | int slsh = f.findRev(Option::dir_sep);
|
---|
2337 | if(slsh != -1)
|
---|
2338 | file = file.right(file.length() - slsh - 1);
|
---|
2339 | QStringList &l = project->variables()[w];
|
---|
2340 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
|
---|
2341 | QString file2((*val_it));
|
---|
2342 | slsh = file2.findRev(Option::dir_sep);
|
---|
2343 | if(slsh != -1)
|
---|
2344 | file2 = file2.right(file2.length() - slsh - 1);
|
---|
2345 | if(file2 == file) {
|
---|
2346 | warn_msg(WarnLogic, "Found potential symbol conflict of %s (%s) in %s",
|
---|
2347 | file.latin1(), (*val_it).latin1(), w.latin1());
|
---|
2348 | break;
|
---|
2349 | }
|
---|
2350 | }
|
---|
2351 | }
|
---|
2352 |
|
---|
2353 | QString
|
---|
2354 | MakefileGenerator::dependencyKey(const QString &file) const
|
---|
2355 | {
|
---|
2356 | QString key = file;
|
---|
2357 | Option::fixPathToTargetOS(key);
|
---|
2358 | if(key.find(Option::dir_sep))
|
---|
2359 | key = key.right(key.length() - key.findRev(Option::dir_sep) - 1);
|
---|
2360 | return key;
|
---|
2361 | }
|
---|
2362 |
|
---|
2363 | void
|
---|
2364 | MakefileGenerator::setProcessedDependencies(const QString &file, bool b)
|
---|
2365 | {
|
---|
2366 | depProcessed[dependencyKey(file)] = b;
|
---|
2367 | }
|
---|
2368 |
|
---|
2369 | bool
|
---|
2370 | MakefileGenerator::processedDependencies(const QString &file)
|
---|
2371 | {
|
---|
2372 | QString key = dependencyKey(file);
|
---|
2373 | if(!depProcessed.contains(key))
|
---|
2374 | return FALSE;
|
---|
2375 | return depProcessed[key];
|
---|
2376 | }
|
---|
2377 |
|
---|
2378 | QStringList
|
---|
2379 | &MakefileGenerator::findDependencies(const QString &file)
|
---|
2380 | {
|
---|
2381 | return depends[dependencyKey(file)];
|
---|
2382 | }
|
---|
2383 |
|
---|
2384 |
|
---|
2385 | QString
|
---|
2386 | MakefileGenerator::specdir()
|
---|
2387 | {
|
---|
2388 | if(!spec.isEmpty())
|
---|
2389 | return spec;
|
---|
2390 | spec = Option::mkfile::qmakespec;
|
---|
2391 | #if 0
|
---|
2392 | if(const char *d = getenv("QTDIR")) {
|
---|
2393 | QString qdir = Option::fixPathToTargetOS(QString(d));
|
---|
2394 | if(qdir.endsWith(QString(QChar(QDir::separator()))))
|
---|
2395 | qdir.truncate(qdir.length()-1);
|
---|
2396 | //fix path
|
---|
2397 | QFileInfo fi(spec);
|
---|
2398 | QString absSpec(fi.absFilePath());
|
---|
2399 | absSpec = Option::fixPathToTargetOS(absSpec);
|
---|
2400 | //replace what you can
|
---|
2401 | if(absSpec.startsWith(qdir)) {
|
---|
2402 | absSpec.replace(0, qdir.length(), "$(QTDIR)");
|
---|
2403 | spec = absSpec;
|
---|
2404 | }
|
---|
2405 | }
|
---|
2406 | #else
|
---|
2407 | spec = Option::fixPathToTargetOS(spec);
|
---|
2408 | #endif
|
---|
2409 | return spec;
|
---|
2410 | }
|
---|
2411 |
|
---|
2412 | bool
|
---|
2413 | MakefileGenerator::openOutput(QFile &file) const
|
---|
2414 | {
|
---|
2415 | {
|
---|
2416 | QString outdir;
|
---|
2417 | if(!file.name().isEmpty()) {
|
---|
2418 | if(QDir::isRelativePath(file.name()))
|
---|
2419 | file.setName(Option::output_dir + file.name()); //pwd when qmake was run
|
---|
2420 | QFileInfo fi(file);
|
---|
2421 | if(fi.isDir())
|
---|
2422 | outdir = file.name() + QDir::separator();
|
---|
2423 | }
|
---|
2424 | if(!outdir.isEmpty() || file.name().isEmpty()) {
|
---|
2425 | QString fname = "Makefile";
|
---|
2426 | if(!project->isEmpty("MAKEFILE"))
|
---|
2427 | fname = project->first("MAKEFILE");
|
---|
2428 | file.setName(outdir + fname);
|
---|
2429 | }
|
---|
2430 | }
|
---|
2431 | if(QDir::isRelativePath(file.name()))
|
---|
2432 | file.setName(Option::output_dir + file.name()); //pwd when qmake was run
|
---|
2433 | if(project->isEmpty("QMAKE_MAKEFILE"))
|
---|
2434 | project->variables()["QMAKE_MAKEFILE"].append(file.name());
|
---|
2435 | int slsh = file.name().findRev(Option::dir_sep);
|
---|
2436 | if(slsh != -1)
|
---|
2437 | createDir(file.name().left(slsh));
|
---|
2438 | if(file.open(IO_WriteOnly | IO_Translate)) {
|
---|
2439 | QFileInfo fi(Option::output);
|
---|
2440 | QString od = Option::fixPathToTargetOS((fi.isSymLink() ? fi.readLink() : fi.dirPath()) );
|
---|
2441 | if(QDir::isRelativePath(od))
|
---|
2442 | od.prepend(Option::output_dir);
|
---|
2443 | Option::output_dir = od;
|
---|
2444 | return TRUE;
|
---|
2445 | }
|
---|
2446 | return FALSE;
|
---|
2447 | }
|
---|
2448 |
|
---|
2449 |
|
---|
2450 |
|
---|
2451 | //Factory thing
|
---|
2452 | #include "unixmake.h"
|
---|
2453 | #include "msvc_nmake.h"
|
---|
2454 | #include "borland_bmake.h"
|
---|
2455 | #include "mingw_make.h"
|
---|
2456 | #include "gnumake.h"
|
---|
2457 | #include "msvc_dsp.h"
|
---|
2458 | #include "msvc_vcproj.h"
|
---|
2459 | #include "metrowerks_xml.h"
|
---|
2460 | #include "pbuilder_pbx.h"
|
---|
2461 | #include "projectgenerator.h"
|
---|
2462 |
|
---|
2463 | MakefileGenerator *
|
---|
2464 | MakefileGenerator::create(QMakeProject *proj)
|
---|
2465 | {
|
---|
2466 | if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT)
|
---|
2467 | return new ProjectGenerator(proj);
|
---|
2468 |
|
---|
2469 | MakefileGenerator *mkfile = NULL;
|
---|
2470 | QString gen = proj->first("MAKEFILE_GENERATOR");
|
---|
2471 | if(gen.isEmpty()) {
|
---|
2472 | fprintf(stderr, "No generator specified in config file: %s\n",
|
---|
2473 | proj->projectFile().latin1());
|
---|
2474 | } else if(gen == "UNIX") {
|
---|
2475 | mkfile = new UnixMakefileGenerator(proj);
|
---|
2476 | } else if(gen == "MSVC") {
|
---|
2477 | // Visual Studio =< v6.0
|
---|
2478 | if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1)
|
---|
2479 | mkfile = new DspMakefileGenerator(proj);
|
---|
2480 | else
|
---|
2481 | mkfile = new NmakeMakefileGenerator(proj);
|
---|
2482 | } else if(gen == "MSVC.NET") {
|
---|
2483 | // Visual Studio >= v7.0
|
---|
2484 | if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1)
|
---|
2485 | mkfile = new VcprojGenerator(proj);
|
---|
2486 | else
|
---|
2487 | mkfile = new NmakeMakefileGenerator(proj);
|
---|
2488 | } else if(gen == "BMAKE") {
|
---|
2489 | mkfile = new BorlandMakefileGenerator(proj);
|
---|
2490 | } else if(gen == "MINGW") {
|
---|
2491 | mkfile = new MingwMakefileGenerator(proj);
|
---|
2492 | } else if(gen == "GNUMAKE") {
|
---|
2493 | mkfile = new GNUMakefileGenerator(proj);
|
---|
2494 | } else if(gen == "METROWERKS") {
|
---|
2495 | mkfile = new MetrowerksMakefileGenerator(proj);
|
---|
2496 | } else if(gen == "PROJECTBUILDER") {
|
---|
2497 | mkfile = new ProjectBuilderMakefileGenerator(proj);
|
---|
2498 | } else {
|
---|
2499 | fprintf(stderr, "Unknown generator specified: %s\n", gen.latin1());
|
---|
2500 | }
|
---|
2501 | return mkfile;
|
---|
2502 | }
|
---|