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