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 | |||
@@ -39,12 +39,28 @@ | |||
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 |
@@ -64,27 +80,19 @@ ProjectGenerator::init() | |||
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)); |
@@ -137,15 +145,14 @@ ProjectGenerator::init() | |||
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) |
@@ -238,18 +245,25 @@ ProjectGenerator::init() | |||
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()) { |
@@ -257,17 +271,19 @@ ProjectGenerator::init() | |||
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) |
@@ -334,20 +350,22 @@ ProjectGenerator::writeMakefile(QTextStream &t) | |||
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 | ||
@@ -400,12 +418,14 @@ ProjectGenerator::addFile(QString file) | |||
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; |