Diffstat (limited to 'qmake/generators/projectgenerator.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/projectgenerator.cpp | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp index 5ff6250..1515216 100644 --- a/qmake/generators/projectgenerator.cpp +++ b/qmake/generators/projectgenerator.cpp | |||
@@ -21,88 +21,96 @@ | |||
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 "projectgenerator.h" | 38 | #include "projectgenerator.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 <qfileinfo.h> | 42 | #include <qfileinfo.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | QString project_builtin_regx() //calculate the builtin regular expression.. | ||
46 | { | ||
47 | QString ret; | ||
48 | QStringList builtin_exts(".c"); | ||
49 | builtin_exts << Option::ui_ext << Option::yacc_ext << Option::lex_ext << ".ts"; | ||
50 | builtin_exts += Option::h_ext + Option::cpp_ext; | ||
51 | for(QStringList::Iterator ext_it = builtin_exts.begin(); | ||
52 | ext_it != builtin_exts.end(); ++ext_it) { | ||
53 | if(!ret.isEmpty()) | ||
54 | ret += "; "; | ||
55 | ret += QString("*") + (*ext_it); | ||
56 | } | ||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | |||
45 | 61 | ||
46 | ProjectGenerator::ProjectGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE) | 62 | ProjectGenerator::ProjectGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE) |
47 | { | 63 | { |
48 | } | 64 | } |
49 | 65 | ||
50 | void | 66 | void |
51 | ProjectGenerator::init() | 67 | ProjectGenerator::init() |
52 | { | 68 | { |
53 | if(init_flag) | 69 | if(init_flag) |
54 | return; | 70 | return; |
55 | int file_count = 0; | 71 | int file_count = 0; |
56 | init_flag = TRUE; | 72 | init_flag = TRUE; |
57 | 73 | ||
58 | QMap<QString, QStringList> &v = project->variables(); | 74 | QMap<QString, QStringList> &v = project->variables(); |
59 | QString templ = Option::user_template.isEmpty() ? QString("app") : Option::user_template; | 75 | QString templ = Option::user_template.isEmpty() ? QString("app") : Option::user_template; |
60 | if(!Option::user_template_prefix.isEmpty()) | 76 | if(!Option::user_template_prefix.isEmpty()) |
61 | templ.prepend(Option::user_template_prefix); | 77 | templ.prepend(Option::user_template_prefix); |
62 | v["TEMPLATE_ASSIGN"] += templ; | 78 | v["TEMPLATE_ASSIGN"] += templ; |
63 | 79 | ||
64 | //figure out target | 80 | //figure out target |
65 | if(Option::output.name() == "-" || Option::output.name().isEmpty()) | 81 | if(Option::output.name() == "-" || Option::output.name().isEmpty()) |
66 | v["TARGET"] = QStringList("unknown"); | 82 | v["TARGET"] = QStringList("unknown"); |
67 | 83 | ||
68 | //the scary stuff | 84 | //the scary stuff |
69 | if(project->first("TEMPLATE_ASSIGN") != "subdirs") { | 85 | if(project->first("TEMPLATE_ASSIGN") != "subdirs") { |
70 | QString builtin_regex; | 86 | QString builtin_regex = project_builtin_regx(); |
71 | { //calculate the builtin regular expression.. | ||
72 | QStringList builtin_exts(".c"); | ||
73 | builtin_exts << Option::ui_ext << Option::yacc_ext << Option::lex_ext; | ||
74 | builtin_exts += Option::h_ext + Option::cpp_ext; | ||
75 | for(QStringList::Iterator ext_it = builtin_exts.begin(); | ||
76 | ext_it != builtin_exts.end(); ++ext_it) { | ||
77 | if(!builtin_regex.isEmpty()) | ||
78 | builtin_regex += "; "; | ||
79 | builtin_regex += QString("*") + (*ext_it); | ||
80 | } | ||
81 | } | ||
82 | QStringList dirs = Option::projfile::project_dirs; | 87 | QStringList dirs = Option::projfile::project_dirs; |
83 | if(Option::projfile::do_pwd) | 88 | if(Option::projfile::do_pwd) { |
89 | if(!v["INCLUDEPATH"].contains(".")) | ||
90 | v["INCLUDEPATH"] += "."; | ||
84 | dirs.prepend(QDir::currentDirPath()); | 91 | dirs.prepend(QDir::currentDirPath()); |
92 | } | ||
85 | 93 | ||
86 | for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) { | 94 | for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) { |
87 | QString dir, regex; | 95 | QString dir, regex; |
88 | bool add_depend = FALSE; | 96 | bool add_depend = FALSE; |
89 | if(QFile::exists((*pd))) { | 97 | if(QFile::exists((*pd))) { |
90 | QFileInfo fi((*pd)); | 98 | QFileInfo fi((*pd)); |
91 | if(fi.isDir()) { | 99 | if(fi.isDir()) { |
92 | dir = (*pd); | 100 | dir = (*pd); |
93 | add_depend = TRUE; | 101 | add_depend = TRUE; |
94 | if(dir.right(1) != Option::dir_sep) | 102 | if(dir.right(1) != Option::dir_sep) |
95 | dir += Option::dir_sep; | 103 | dir += Option::dir_sep; |
96 | if(Option::projfile::do_recursive) { | 104 | if(Option::projfile::do_recursive) { |
97 | QDir d(dir); | 105 | QDir d(dir); |
98 | d.setFilter(QDir::Dirs); | 106 | d.setFilter(QDir::Dirs); |
99 | for(int i = 0; i < (int)d.count(); i++) { | 107 | for(int i = 0; i < (int)d.count(); i++) { |
100 | if(d[i] != "." && d[i] != "..") | 108 | if(d[i] != "." && d[i] != "..") |
101 | dirs.append(dir + d[i] + QDir::separator() + builtin_regex); | 109 | dirs.append(dir + d[i] + QDir::separator() + builtin_regex); |
102 | } | 110 | } |
103 | } | 111 | } |
104 | regex = builtin_regex; | 112 | regex = builtin_regex; |
105 | } else { | 113 | } else { |
106 | QString file = (*pd); | 114 | QString file = (*pd); |
107 | int s = file.findRev(Option::dir_sep); | 115 | int s = file.findRev(Option::dir_sep); |
108 | if(s != -1) | 116 | if(s != -1) |
@@ -119,51 +127,50 @@ ProjectGenerator::init() | |||
119 | int s = regex.findRev(Option::dir_sep); | 127 | int s = regex.findRev(Option::dir_sep); |
120 | if(s != -1) { | 128 | if(s != -1) { |
121 | dir = regex.left(s+1); | 129 | dir = regex.left(s+1); |
122 | regex = regex.right(regex.length() - (s+1)); | 130 | regex = regex.right(regex.length() - (s+1)); |
123 | } | 131 | } |
124 | if(Option::projfile::do_recursive) { | 132 | if(Option::projfile::do_recursive) { |
125 | QDir d(dir); | 133 | QDir d(dir); |
126 | d.setFilter(QDir::Dirs); | 134 | d.setFilter(QDir::Dirs); |
127 | for(int i = 0; i < (int)d.count(); i++) { | 135 | for(int i = 0; i < (int)d.count(); i++) { |
128 | if(d[i] != "." && d[i] != "..") | 136 | if(d[i] != "." && d[i] != "..") |
129 | dirs.append(dir + d[i] + QDir::separator() + regex); | 137 | dirs.append(dir + d[i] + QDir::separator() + regex); |
130 | } | 138 | } |
131 | } | 139 | } |
132 | QDir d(dir, regex); | 140 | QDir d(dir, regex); |
133 | for(int i = 0; i < (int)d.count(); i++) { | 141 | for(int i = 0; i < (int)d.count(); i++) { |
134 | QString file = dir + d[i]; | 142 | QString file = dir + d[i]; |
135 | if (addFile(file)) { | 143 | if (addFile(file)) { |
136 | add_depend = TRUE; | 144 | add_depend = TRUE; |
137 | file_count++; | 145 | file_count++; |
138 | } | 146 | } |
139 | } | 147 | } |
140 | } | 148 | } |
141 | if(add_depend && !dir.isEmpty() && !v["DEPENDPATH"].contains(dir)) { | 149 | if(add_depend && !dir.isEmpty() && !v["DEPENDPATH"].contains(dir)) { |
142 | QFileInfo fi(dir); | 150 | QFileInfo fi(dir); |
143 | if(fi.absFilePath() != QDir::currentDirPath()) { | 151 | if(fi.absFilePath() != QDir::currentDirPath()) |
144 | v["DEPENDPATH"] += fileFixify(dir); | 152 | v["DEPENDPATH"] += fileFixify(dir); |
145 | } | ||
146 | } | 153 | } |
147 | } | 154 | } |
148 | } | 155 | } |
149 | if(!file_count) { //shall we try a subdir? | 156 | if(!file_count) { //shall we try a subdir? |
150 | QStringList dirs = Option::projfile::project_dirs; | 157 | QStringList dirs = Option::projfile::project_dirs; |
151 | if(Option::projfile::do_pwd) | 158 | if(Option::projfile::do_pwd) |
152 | dirs.prepend("."); | 159 | dirs.prepend("."); |
153 | for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) { | 160 | for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) { |
154 | if(QFile::exists((*pd))) { | 161 | if(QFile::exists((*pd))) { |
155 | QString newdir = (*pd); | 162 | QString newdir = (*pd); |
156 | QFileInfo fi(newdir); | 163 | QFileInfo fi(newdir); |
157 | if(fi.isDir()) { | 164 | if(fi.isDir()) { |
158 | newdir = fileFixify(newdir); | 165 | newdir = fileFixify(newdir); |
159 | QStringList &subdirs = v["SUBDIRS"]; | 166 | QStringList &subdirs = v["SUBDIRS"]; |
160 | if(QFile::exists(fi.filePath() + QDir::separator() + fi.fileName() + ".pro") && | 167 | if(QFile::exists(fi.filePath() + QDir::separator() + fi.fileName() + ".pro") && |
161 | !subdirs.contains(newdir)) { | 168 | !subdirs.contains(newdir)) { |
162 | subdirs.append(newdir); | 169 | subdirs.append(newdir); |
163 | } else { | 170 | } else { |
164 | QDir d(newdir, "*.pro"); | 171 | QDir d(newdir, "*.pro"); |
165 | d.setFilter(QDir::Files); | 172 | d.setFilter(QDir::Files); |
166 | for(int i = 0; i < (int)d.count(); i++) { | 173 | for(int i = 0; i < (int)d.count(); i++) { |
167 | QString nd = newdir + QDir::separator() + d[i]; | 174 | QString nd = newdir + QDir::separator() + d[i]; |
168 | fileFixify(nd); | 175 | fileFixify(nd); |
169 | if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd)) { | 176 | if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd)) { |
@@ -220,72 +227,81 @@ ProjectGenerator::init() | |||
220 | } | 227 | } |
221 | v["TEMPLATE_ASSIGN"] = "subdirs"; | 228 | v["TEMPLATE_ASSIGN"] = "subdirs"; |
222 | return; | 229 | return; |
223 | } | 230 | } |
224 | 231 | ||
225 | QPtrList<MakefileDependDir> deplist; | 232 | QPtrList<MakefileDependDir> deplist; |
226 | deplist.setAutoDelete(TRUE); | 233 | deplist.setAutoDelete(TRUE); |
227 | { | 234 | { |
228 | QStringList &d = v["DEPENDPATH"]; | 235 | QStringList &d = v["DEPENDPATH"]; |
229 | for(QStringList::Iterator it = d.begin(); it != d.end(); ++it) { | 236 | for(QStringList::Iterator it = d.begin(); it != d.end(); ++it) { |
230 | QString r = (*it), l = Option::fixPathToLocalOS((*it)); | 237 | QString r = (*it), l = Option::fixPathToLocalOS((*it)); |
231 | deplist.append(new MakefileDependDir(r, l)); | 238 | deplist.append(new MakefileDependDir(r, l)); |
232 | } | 239 | } |
233 | } | 240 | } |
234 | QStringList &h = v["HEADERS"]; | 241 | QStringList &h = v["HEADERS"]; |
235 | bool no_qt_files = TRUE; | 242 | bool no_qt_files = TRUE; |
236 | QString srcs[] = { "SOURCES", "YACCSOURCES", "LEXSOURCES", "INTERFACES", QString::null }; | 243 | QString srcs[] = { "SOURCES", "YACCSOURCES", "LEXSOURCES", "INTERFACES", QString::null }; |
237 | for(int i = 0; !srcs[i].isNull(); i++) { | 244 | for(int i = 0; !srcs[i].isNull(); i++) { |
238 | QStringList &l = v[srcs[i]]; | 245 | QStringList &l = v[srcs[i]]; |
239 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { | 246 | for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { |
240 | if(generateDependencies(deplist, (*val_it), TRUE)) { | 247 | if(generateDependencies(deplist, (*val_it), TRUE)) { |
241 | QStringList &tmp = findDependencies((*val_it)); | 248 | QStringList &tmp = findDependencies((*val_it)); |
242 | if(!tmp.isEmpty()) { | 249 | if(!tmp.isEmpty()) { |
243 | for(QStringList::Iterator dep_it = tmp.begin(); dep_it != tmp.end(); ++dep_it) { | 250 | for(QStringList::Iterator dep_it = tmp.begin(); dep_it != tmp.end(); ++dep_it) { |
244 | QString file_no_path = (*dep_it).right( | 251 | QString file_dir = (*dep_it).section(Option::dir_sep, 0, -2), |
245 | (*dep_it).length() - ((*dep_it).findRev(Option::dir_sep)+1)); | 252 | file_no_path = (*dep_it).section(Option::dir_sep, -1); |
253 | if(!file_dir.isEmpty()) { | ||
254 | for(MakefileDependDir *mdd = deplist.first(); mdd; mdd = deplist.next()) { | ||
255 | if(mdd->local_dir == file_dir && !v["INCLUDEPATH"].contains(mdd->real_dir)) | ||
256 | v["INCLUDEPATH"] += mdd->real_dir; | ||
257 | } | ||
258 | } | ||
246 | if(no_qt_files && file_no_path.find(QRegExp("^q[a-z_0-9].h$")) != -1) | 259 | if(no_qt_files && file_no_path.find(QRegExp("^q[a-z_0-9].h$")) != -1) |
247 | no_qt_files = FALSE; | 260 | no_qt_files = FALSE; |
248 | QString h_ext; | 261 | QString h_ext; |
249 | for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { | 262 | for(QStringList::Iterator hit = Option::h_ext.begin(); |
263 | hit != Option::h_ext.end(); ++hit) { | ||
250 | if((*dep_it).endsWith((*hit))) { | 264 | if((*dep_it).endsWith((*hit))) { |
251 | h_ext = (*hit); | 265 | h_ext = (*hit); |
252 | break; | 266 | break; |
253 | } | 267 | } |
254 | } | 268 | } |
255 | if(!h_ext.isEmpty()) { | 269 | if(!h_ext.isEmpty()) { |
256 | if((*dep_it).left(1).lower() == "q") { | 270 | if((*dep_it).left(1).lower() == "q") { |
257 | QString qhdr = (*dep_it).lower(); | 271 | QString qhdr = (*dep_it).lower(); |
258 | if(file_no_path == "qthread.h") | 272 | if(file_no_path == "qthread.h") |
259 | addConfig("thread"); | 273 | addConfig("thread"); |
260 | } | 274 | } |
261 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); | 275 | for(QStringList::Iterator cppit = Option::cpp_ext.begin(); |
262 | cppit != Option::cpp_ext.end(); ++cppit) { | 276 | cppit != Option::cpp_ext.end(); ++cppit) { |
263 | QString src((*dep_it).left((*dep_it).length() - h_ext.length()) + (*cppit)); | 277 | QString src((*dep_it).left((*dep_it).length() - h_ext.length()) + |
278 | (*cppit)); | ||
264 | if(QFile::exists(src)) { | 279 | if(QFile::exists(src)) { |
265 | bool exists = FALSE; | 280 | bool exists = FALSE; |
266 | QStringList &srcl = v["SOURCES"]; | 281 | QStringList &srcl = v["SOURCES"]; |
267 | for(QStringList::Iterator src_it = srcl.begin(); src_it != srcl.end(); ++src_it) { | 282 | for(QStringList::Iterator src_it = srcl.begin(); |
283 | src_it != srcl.end(); ++src_it) { | ||
268 | if((*src_it).lower() == src.lower()) { | 284 | if((*src_it).lower() == src.lower()) { |
269 | exists = TRUE; | 285 | exists = TRUE; |
270 | break; | 286 | break; |
271 | } | 287 | } |
272 | } | 288 | } |
273 | if(!exists) | 289 | if(!exists) |
274 | srcl.append(src); | 290 | srcl.append(src); |
275 | } | 291 | } |
276 | } | 292 | } |
277 | } else if((*dep_it).endsWith(Option::lex_ext) && | 293 | } else if((*dep_it).endsWith(Option::lex_ext) && |
278 | file_no_path.startsWith(Option::lex_mod)) { | 294 | file_no_path.startsWith(Option::lex_mod)) { |
279 | addConfig("lex_included"); | 295 | addConfig("lex_included"); |
280 | } | 296 | } |
281 | if(!h.contains((*dep_it))) { | 297 | if(!h.contains((*dep_it))) { |
282 | if(generateMocList((*dep_it)) && !findMocDestination((*dep_it)).isEmpty()) | 298 | if(generateMocList((*dep_it)) && !findMocDestination((*dep_it)).isEmpty()) |
283 | h += (*dep_it); | 299 | h += (*dep_it); |
284 | } | 300 | } |
285 | } | 301 | } |
286 | } | 302 | } |
287 | } | 303 | } |
288 | } | 304 | } |
289 | } | 305 | } |
290 | if(h.isEmpty()) | 306 | if(h.isEmpty()) |
291 | addConfig("moc", FALSE); | 307 | addConfig("moc", FALSE); |
@@ -316,56 +332,58 @@ ProjectGenerator::init() | |||
316 | ++val_it; | 332 | ++val_it; |
317 | } | 333 | } |
318 | } | 334 | } |
319 | } | 335 | } |
320 | } | 336 | } |
321 | 337 | ||
322 | 338 | ||
323 | bool | 339 | bool |
324 | ProjectGenerator::writeMakefile(QTextStream &t) | 340 | ProjectGenerator::writeMakefile(QTextStream &t) |
325 | { | 341 | { |
326 | t << "######################################################################" << endl; | 342 | t << "######################################################################" << endl; |
327 | t << "# Automatically generated by qmake (" << qmake_version() << ") " << QDateTime::currentDateTime().toString() << endl; | 343 | t << "# Automatically generated by qmake (" << qmake_version() << ") " << QDateTime::currentDateTime().toString() << endl; |
328 | t << "######################################################################" << endl << endl; | 344 | t << "######################################################################" << endl << endl; |
329 | QStringList::Iterator it; | 345 | QStringList::Iterator it; |
330 | for(it = Option::before_user_vars.begin(); it != Option::before_user_vars.end(); ++it) | 346 | for(it = Option::before_user_vars.begin(); it != Option::before_user_vars.end(); ++it) |
331 | t << (*it) << endl; | 347 | t << (*it) << endl; |
332 | t << getWritableVar("TEMPLATE_ASSIGN", FALSE); | 348 | t << getWritableVar("TEMPLATE_ASSIGN", FALSE); |
333 | if(project->first("TEMPLATE_ASSIGN") == "subdirs") { | 349 | if(project->first("TEMPLATE_ASSIGN") == "subdirs") { |
334 | t << endl << "# Directories" << "\n" | 350 | t << endl << "# Directories" << "\n" |
335 | << getWritableVar("SUBDIRS"); | 351 | << getWritableVar("SUBDIRS"); |
336 | } else { | 352 | } else { |
337 | t << getWritableVar("TARGET") | 353 | t << getWritableVar("TARGET") |
338 | << getWritableVar("CONFIG", FALSE) | 354 | << getWritableVar("CONFIG", FALSE) |
339 | << getWritableVar("CONFIG_REMOVE", FALSE) | 355 | << getWritableVar("CONFIG_REMOVE", FALSE) |
340 | << getWritableVar("DEPENDPATH") << endl; | 356 | << getWritableVar("DEPENDPATH") |
357 | << getWritableVar("INCLUDEPATH") << endl; | ||
341 | 358 | ||
342 | t << "# Input" << "\n"; | 359 | t << "# Input" << "\n"; |
343 | t << getWritableVar("HEADERS") | 360 | t << getWritableVar("HEADERS") |
344 | << getWritableVar("INTERFACES") | 361 | << getWritableVar("INTERFACES") |
345 | << getWritableVar("LEXSOURCES") | 362 | << getWritableVar("LEXSOURCES") |
346 | << getWritableVar("YACCSOURCES") | 363 | << getWritableVar("YACCSOURCES") |
347 | << getWritableVar("SOURCES"); | 364 | << getWritableVar("SOURCES") |
365 | << getWritableVar("TRANSLATIONS"); | ||
348 | } | 366 | } |
349 | for(it = Option::after_user_vars.begin(); it != Option::after_user_vars.end(); ++it) | 367 | for(it = Option::after_user_vars.begin(); it != Option::after_user_vars.end(); ++it) |
350 | t << (*it) << endl; | 368 | t << (*it) << endl; |
351 | return TRUE; | 369 | return TRUE; |
352 | } | 370 | } |
353 | 371 | ||
354 | bool | 372 | bool |
355 | ProjectGenerator::addConfig(const QString &cfg, bool add) | 373 | ProjectGenerator::addConfig(const QString &cfg, bool add) |
356 | { | 374 | { |
357 | QString where = "CONFIG"; | 375 | QString where = "CONFIG"; |
358 | if(!add) | 376 | if(!add) |
359 | where = "CONFIG_REMOVE"; | 377 | where = "CONFIG_REMOVE"; |
360 | if(!project->variables()[where].contains(cfg)) { | 378 | if(!project->variables()[where].contains(cfg)) { |
361 | project->variables()[where] += cfg; | 379 | project->variables()[where] += cfg; |
362 | return TRUE; | 380 | return TRUE; |
363 | } | 381 | } |
364 | return FALSE; | 382 | return FALSE; |
365 | } | 383 | } |
366 | 384 | ||
367 | 385 | ||
368 | bool | 386 | bool |
369 | ProjectGenerator::addFile(QString file) | 387 | ProjectGenerator::addFile(QString file) |
370 | { | 388 | { |
371 | file = fileFixify(file, QDir::currentDirPath()); | 389 | file = fileFixify(file, QDir::currentDirPath()); |
@@ -382,48 +400,50 @@ ProjectGenerator::addFile(QString file) | |||
382 | if(QFile::exists(file.left(file.length() - (*cppit).length()) + Option::ui_ext)) | 400 | if(QFile::exists(file.left(file.length() - (*cppit).length()) + Option::ui_ext)) |
383 | return FALSE; | 401 | return FALSE; |
384 | else | 402 | else |
385 | where = "SOURCES"; | 403 | where = "SOURCES"; |
386 | break; | 404 | break; |
387 | } | 405 | } |
388 | } | 406 | } |
389 | if(where.isEmpty()) { | 407 | if(where.isEmpty()) { |
390 | for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { | 408 | for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { |
391 | if(file.endsWith((*hit))) { | 409 | if(file.endsWith((*hit))) { |
392 | where = "HEADERS"; | 410 | where = "HEADERS"; |
393 | break; | 411 | break; |
394 | } | 412 | } |
395 | } | 413 | } |
396 | } | 414 | } |
397 | if(where.isEmpty()) { | 415 | if(where.isEmpty()) { |
398 | if(file.endsWith(Option::ui_ext)) | 416 | if(file.endsWith(Option::ui_ext)) |
399 | where = "INTERFACES"; | 417 | where = "INTERFACES"; |
400 | else if(file.endsWith(".c")) | 418 | else if(file.endsWith(".c")) |
401 | where = "SOURCES"; | 419 | where = "SOURCES"; |
402 | else if(file.endsWith(Option::lex_ext)) | 420 | else if(file.endsWith(Option::lex_ext)) |
403 | where = "LEXSOURCES"; | 421 | where = "LEXSOURCES"; |
404 | else if(file.endsWith(Option::yacc_ext)) | 422 | else if(file.endsWith(Option::yacc_ext)) |
405 | where = "YACCSOURCES"; | 423 | where = "YACCSOURCES"; |
424 | else if(file.endsWith(".ts")) | ||
425 | where = "TRANSLATIONS"; | ||
406 | } | 426 | } |
407 | 427 | ||
408 | QString newfile = fileFixify(file); | 428 | QString newfile = fileFixify(file); |
409 | if(!where.isEmpty() && !project->variables()[where].contains(file)) { | 429 | if(!where.isEmpty() && !project->variables()[where].contains(file)) { |
410 | project->variables()[where] += newfile; | 430 | project->variables()[where] += newfile; |
411 | return TRUE; | 431 | return TRUE; |
412 | } | 432 | } |
413 | return FALSE; | 433 | return FALSE; |
414 | } | 434 | } |
415 | 435 | ||
416 | 436 | ||
417 | QString | 437 | QString |
418 | ProjectGenerator::getWritableVar(const QString &v, bool /*fixPath*/) | 438 | ProjectGenerator::getWritableVar(const QString &v, bool /*fixPath*/) |
419 | { | 439 | { |
420 | QStringList &vals = project->variables()[v]; | 440 | QStringList &vals = project->variables()[v]; |
421 | if(vals.isEmpty()) | 441 | if(vals.isEmpty()) |
422 | return ""; | 442 | return ""; |
423 | 443 | ||
424 | QString ret; | 444 | QString ret; |
425 | if(v.endsWith("_REMOVE")) | 445 | if(v.endsWith("_REMOVE")) |
426 | ret = v.left(v.length() - 7) + " -= "; | 446 | ret = v.left(v.length() - 7) + " -= "; |
427 | else if(v.endsWith("_ASSIGN")) | 447 | else if(v.endsWith("_ASSIGN")) |
428 | ret = v.left(v.length() - 7) + " = "; | 448 | ret = v.left(v.length() - 7) + " = "; |
429 | else | 449 | else |