1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the qmake application of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include "cachekeys.h"
46 #include "generators/metamakefile.h"
48 #include <qdatetime.h>
50 #include <qfileinfo.h>
53 #include <qtextstream.h>
62 #include <sys/utsname.h>
63 #elif defined(Q_OS_WIN32)
70 #define QT_POPEN _popen
71 #define QT_PCLOSE _pclose
73 #define QT_POPEN popen
74 #define QT_PCLOSE pclose
80 enum ExpandFunc { E_MEMBER=1, E_FIRST, E_LAST, E_CAT, E_FROMFILE, E_EVAL, E_LIST,
81 E_SPRINTF, E_FORMAT_NUMBER, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION,
82 E_FIND, E_SYSTEM, E_UNIQUE, E_REVERSE, E_QUOTE, E_ESCAPE_EXPAND,
83 E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE, E_REPLACE,
84 E_SIZE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS,
85 E_SHADOWED, E_ABSOLUTE_PATH, E_RELATIVE_PATH, E_CLEAN_PATH, E_NATIVE_PATH,
87 QHash<QString, ExpandFunc> qmake_expandFunctions()
89 static QHash<QString, ExpandFunc> *qmake_expand_functions = 0;
90 if(!qmake_expand_functions) {
91 qmake_expand_functions = new QHash<QString, ExpandFunc>;
92 qmakeAddCacheClear(qmakeDeleteCacheClear<QHash<QString, ExpandFunc> >, (void**)&qmake_expand_functions);
93 qmake_expand_functions->insert("member", E_MEMBER);
94 qmake_expand_functions->insert("first", E_FIRST);
95 qmake_expand_functions->insert("last", E_LAST);
96 qmake_expand_functions->insert("cat", E_CAT);
97 qmake_expand_functions->insert("fromfile", E_FROMFILE);
98 qmake_expand_functions->insert("eval", E_EVAL);
99 qmake_expand_functions->insert("list", E_LIST);
100 qmake_expand_functions->insert("sprintf", E_SPRINTF);
101 qmake_expand_functions->insert("format_number", E_FORMAT_NUMBER);
102 qmake_expand_functions->insert("join", E_JOIN);
103 qmake_expand_functions->insert("split", E_SPLIT);
104 qmake_expand_functions->insert("basename", E_BASENAME);
105 qmake_expand_functions->insert("dirname", E_DIRNAME);
106 qmake_expand_functions->insert("section", E_SECTION);
107 qmake_expand_functions->insert("find", E_FIND);
108 qmake_expand_functions->insert("system", E_SYSTEM);
109 qmake_expand_functions->insert("unique", E_UNIQUE);
110 qmake_expand_functions->insert("reverse", E_REVERSE);
111 qmake_expand_functions->insert("quote", E_QUOTE);
112 qmake_expand_functions->insert("escape_expand", E_ESCAPE_EXPAND);
113 qmake_expand_functions->insert("upper", E_UPPER);
114 qmake_expand_functions->insert("lower", E_LOWER);
115 qmake_expand_functions->insert("re_escape", E_RE_ESCAPE);
116 qmake_expand_functions->insert("val_escape", E_VAL_ESCAPE);
117 qmake_expand_functions->insert("files", E_FILES);
118 qmake_expand_functions->insert("prompt", E_PROMPT);
119 qmake_expand_functions->insert("replace", E_REPLACE);
120 qmake_expand_functions->insert("size", E_SIZE);
121 qmake_expand_functions->insert("sort_depends", E_SORT_DEPENDS);
122 qmake_expand_functions->insert("resolve_depends", E_RESOLVE_DEPENDS);
123 qmake_expand_functions->insert("enumerate_vars", E_ENUMERATE_VARS);
124 qmake_expand_functions->insert("shadowed", E_SHADOWED);
125 qmake_expand_functions->insert("absolute_path", E_ABSOLUTE_PATH);
126 qmake_expand_functions->insert("relative_path", E_RELATIVE_PATH);
127 qmake_expand_functions->insert("clean_path", E_CLEAN_PATH);
128 qmake_expand_functions->insert("native_path", E_NATIVE_PATH);
129 qmake_expand_functions->insert("shell_quote", E_SHELL_QUOTE);
131 return *qmake_expand_functions;
134 enum TestFunc { T_REQUIRES=1, T_GREATERTHAN, T_LESSTHAN, T_EQUALS,
135 T_EXISTS, T_EXPORT, T_CLEAR, T_UNSET, T_EVAL, T_CONFIG, T_SYSTEM,
136 T_RETURN, T_BREAK, T_NEXT, T_DEFINED, T_CONTAINS, T_INFILE,
137 T_COUNT, T_ISEMPTY, T_INCLUDE, T_LOAD,
138 T_DEBUG, T_ERROR, T_MESSAGE, T_WARNING, T_LOG,
139 T_IF, T_OPTION, T_CACHE, T_MKPATH, T_WRITE_FILE, T_TOUCH };
140 QHash<QString, TestFunc> qmake_testFunctions()
142 static QHash<QString, TestFunc> *qmake_test_functions = 0;
143 if(!qmake_test_functions) {
144 qmake_test_functions = new QHash<QString, TestFunc>;
145 qmake_test_functions->insert("requires", T_REQUIRES);
146 qmake_test_functions->insert("greaterThan", T_GREATERTHAN);
147 qmake_test_functions->insert("lessThan", T_LESSTHAN);
148 qmake_test_functions->insert("equals", T_EQUALS);
149 qmake_test_functions->insert("isEqual", T_EQUALS);
150 qmake_test_functions->insert("exists", T_EXISTS);
151 qmake_test_functions->insert("export", T_EXPORT);
152 qmake_test_functions->insert("clear", T_CLEAR);
153 qmake_test_functions->insert("unset", T_UNSET);
154 qmake_test_functions->insert("eval", T_EVAL);
155 qmake_test_functions->insert("CONFIG", T_CONFIG);
156 qmake_test_functions->insert("if", T_IF);
157 qmake_test_functions->insert("isActiveConfig", T_CONFIG);
158 qmake_test_functions->insert("system", T_SYSTEM);
159 qmake_test_functions->insert("return", T_RETURN);
160 qmake_test_functions->insert("break", T_BREAK);
161 qmake_test_functions->insert("next", T_NEXT);
162 qmake_test_functions->insert("defined", T_DEFINED);
163 qmake_test_functions->insert("contains", T_CONTAINS);
164 qmake_test_functions->insert("infile", T_INFILE);
165 qmake_test_functions->insert("count", T_COUNT);
166 qmake_test_functions->insert("isEmpty", T_ISEMPTY);
167 qmake_test_functions->insert("include", T_INCLUDE);
168 qmake_test_functions->insert("load", T_LOAD);
169 qmake_test_functions->insert("debug", T_DEBUG);
170 qmake_test_functions->insert("error", T_ERROR);
171 qmake_test_functions->insert("message", T_MESSAGE);
172 qmake_test_functions->insert("warning", T_WARNING);
173 qmake_test_functions->insert("log", T_LOG);
174 qmake_test_functions->insert("option", T_OPTION);
175 qmake_test_functions->insert("cache", T_CACHE);
176 qmake_test_functions->insert("mkpath", T_MKPATH);
177 qmake_test_functions->insert("write_file", T_WRITE_FILE);
178 qmake_test_functions->insert("touch", T_TOUCH);
180 return *qmake_test_functions;
189 static QString cached_source_root;
190 static QString cached_build_root;
191 static QStringList cached_qmakepath;
192 static QStringList cached_qmakefeatures;
194 static QStringList *all_feature_roots[2] = { 0, 0 };
197 invalidateFeatureRoots()
199 for (int i = 0; i < 2; i++)
200 if (all_feature_roots[i])
201 all_feature_roots[i]->clear();
204 static QString remove_quotes(const QString &arg)
206 const ushort SINGLEQUOTE = '\'';
207 const ushort DOUBLEQUOTE = '"';
209 const QChar *arg_data = arg.data();
210 const ushort first = arg_data->unicode();
211 const int arg_len = arg.length();
212 if(first == SINGLEQUOTE || first == DOUBLEQUOTE) {
213 const ushort last = (arg_data+arg_len-1)->unicode();
215 return arg.mid(1, arg_len-2);
220 static QString varMap(const QString &x)
223 if(ret == "INTERFACES")
225 else if(ret == "QMAKE_POST_BUILD")
226 ret = "QMAKE_POST_LINK";
227 else if(ret == "TARGETDEPS")
228 ret = "POST_TARGETDEPS";
229 else if(ret == "LIBPATH")
230 ret = "QMAKE_LIBDIR";
231 else if(ret == "QMAKE_EXT_MOC")
232 ret = "QMAKE_EXT_CPP_MOC";
233 else if(ret == "QMAKE_MOD_MOC")
234 ret = "QMAKE_H_MOD_MOC";
235 else if(ret == "QMAKE_LFLAGS_SHAPP")
236 ret = "QMAKE_LFLAGS_APP";
237 else if(ret == "PRECOMPH")
238 ret = "PRECOMPILED_HEADER";
239 else if(ret == "PRECOMPCPP")
240 ret = "PRECOMPILED_SOURCE";
241 else if(ret == "INCPATH")
243 else if(ret == "QMAKE_EXTRA_WIN_COMPILERS" || ret == "QMAKE_EXTRA_UNIX_COMPILERS")
244 ret = "QMAKE_EXTRA_COMPILERS";
245 else if(ret == "QMAKE_EXTRA_WIN_TARGETS" || ret == "QMAKE_EXTRA_UNIX_TARGETS")
246 ret = "QMAKE_EXTRA_TARGETS";
247 else if(ret == "QMAKE_EXTRA_UNIX_INCLUDES")
248 ret = "QMAKE_EXTRA_INCLUDES";
249 else if(ret == "QMAKE_EXTRA_UNIX_VARIABLES")
250 ret = "QMAKE_EXTRA_VARIABLES";
251 else if(ret == "QMAKE_RPATH")
252 ret = "QMAKE_LFLAGS_RPATH";
253 else if(ret == "QMAKE_FRAMEWORKDIR")
254 ret = "QMAKE_FRAMEWORKPATH";
255 else if(ret == "QMAKE_FRAMEWORKDIR_FLAGS")
256 ret = "QMAKE_FRAMEWORKPATH_FLAGS";
259 warn_msg(WarnDeprecated, "%s:%d: Variable %s is deprecated; use %s instead.",
260 parser.file.toLatin1().constData(), parser.line_no,
261 x.toLatin1().constData(), ret.toLatin1().constData());
265 static QStringList split_arg_list(const QString ¶ms)
270 const ushort LPAREN = '(';
271 const ushort RPAREN = ')';
272 const ushort SINGLEQUOTE = '\'';
273 const ushort DOUBLEQUOTE = '"';
274 const ushort BACKSLASH = '\\';
275 const ushort COMMA = ',';
276 const ushort SPACE = ' ';
277 //const ushort TAB = '\t';
279 const QChar *params_data = params.data();
280 const int params_len = params.length();
281 for(int last = 0; ;) {
282 while(last < params_len && (params_data[last].unicode() == SPACE
283 /*|| params_data[last].unicode() == TAB*/))
285 for(int x = last, parens = 0; ; x++) {
286 if(x == params_len) {
287 while(x > last && params_data[x-1].unicode() == SPACE)
289 args << params.mid(last, x - last);
290 // Could do a check for unmatched parens here, but split_value_list()
291 // is called on all our output, so mistakes will be caught anyway.
294 ushort unicode = params_data[x].unicode();
295 if(x != (int)params_len-1 && unicode == BACKSLASH &&
296 (params_data[x+1].unicode() == SINGLEQUOTE || params_data[x+1].unicode() == DOUBLEQUOTE)) {
297 x++; //get that 'escape'
298 } else if(quote && unicode == quote) {
300 } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
302 } else if(unicode == RPAREN) {
304 } else if(unicode == LPAREN) {
307 if(!parens && !quote && unicode == COMMA) {
310 while(x > prev && params_data[x-1].unicode() == SPACE)
312 args << params.mid(prev, x - prev);
319 static QStringList split_value_list(const QString &vals)
326 const ushort LPAREN = '(';
327 const ushort RPAREN = ')';
328 const ushort SINGLEQUOTE = '\'';
329 const ushort DOUBLEQUOTE = '"';
330 const ushort BACKSLASH = '\\';
333 const QChar *vals_data = vals.data();
334 const int vals_len = vals.length();
335 for(int x = 0; x < vals_len; x++) {
336 unicode = vals_data[x].unicode();
337 if(x != (int)vals_len-1 && unicode == BACKSLASH &&
338 (vals_data[x+1].unicode() == SINGLEQUOTE || vals_data[x+1].unicode() == DOUBLEQUOTE)) {
339 build += vals_data[x++]; //get that 'escape'
340 } else if(quote && unicode == quote) {
342 } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
344 } else if(unicode == RPAREN) {
346 } else if(unicode == LPAREN) {
350 if(!parens && !quote && (vals_data[x] == Option::field_sep)) {
354 build += vals_data[x];
360 warn_msg(WarnDeprecated, "%s:%d: Unmatched parentheses are deprecated.",
361 parser.file.toLatin1().constData(), parser.line_no);
362 // Could do a check for unmatched quotes here, but doVariableReplaceExpand()
363 // is called on all our output, so mistakes will be caught anyway.
367 //just a parsable entity
370 ParsableBlock() : ref_cnt(1) { }
371 virtual ~ParsableBlock() { }
376 Parse(const QString &t) : text(t){ pi = parser; }
378 QList<Parse> parselist;
380 inline int ref() { return ++ref_cnt; }
381 inline int deref() { return --ref_cnt; }
385 virtual bool continueBlock() = 0;
386 bool eval(QMakeProject *p, QHash<QString, QStringList> &place);
389 bool ParsableBlock::eval(QMakeProject *p, QHash<QString, QStringList> &place)
392 parser_info pi = parser;
393 const int block_count = p->scope_blocks.count();
397 for(int i = 0; i < parselist.count(); i++) {
398 parser = parselist.at(i).pi;
399 if(!(ret = p->parse(parselist.at(i).text, place)) || !continueBlock())
405 while(p->scope_blocks.count() > block_count)
406 p->scope_blocks.pop();
411 struct FunctionBlock : public ParsableBlock
413 FunctionBlock() : calling_place(0), scope_level(1), cause_return(false) { }
415 QHash<QString, QStringList> vars;
416 QHash<QString, QStringList> *calling_place;
417 QStringList return_value;
421 bool exec(const QList<QStringList> &args,
422 QMakeProject *p, QHash<QString, QStringList> &place, QStringList &functionReturn);
423 virtual bool continueBlock() { return !cause_return; }
426 bool FunctionBlock::exec(const QList<QStringList> &args,
427 QMakeProject *proj, QHash<QString, QStringList> &place,
428 QStringList &functionReturn)
432 calling_place = &place;
434 calling_place = &proj->variables();
436 return_value.clear();
437 cause_return = false;
441 vars = proj->variables(); // should be place so that local variables can be inherited
445 vars["ARGS"].clear();
446 for(int i = 0; i < args.count(); i++) {
447 vars["ARGS"] += args[i];
448 vars[QString::number(i+1)] = args[i];
450 bool ret = ParsableBlock::eval(proj, vars);
451 functionReturn = return_value;
455 return_value.clear();
461 struct IteratorBlock : public ParsableBlock
463 IteratorBlock() : scope_level(1), loop_forever(false), cause_break(false), cause_next(false) { }
472 Test(const QString &f, QStringList &a, bool i) : func(f), args(a), invert(i) { pi = parser; }
478 bool loop_forever, cause_break, cause_next;
481 bool exec(QMakeProject *p, QHash<QString, QStringList> &place);
482 virtual bool continueBlock() { return !cause_next && !cause_break; }
484 bool IteratorBlock::exec(QMakeProject *p, QHash<QString, QStringList> &place)
487 QStringList::Iterator it;
490 int iterate_count = 0;
492 IteratorBlock *saved_iterator = p->iterator;
496 while(loop_forever || it != list.end()) {
497 cause_next = cause_break = false;
498 if(!loop_forever && (*it).isEmpty()) { //ignore empty items
503 //set up the loop variable
505 if(!variable.isEmpty()) {
506 va = place[variable];
508 place[variable] = QStringList(QString::number(iterate_count));
510 place[variable] = QStringList(*it);
514 for(QList<Test>::Iterator test_it = test.begin(); test_it != test.end(); ++test_it) {
515 parser = (*test_it).pi;
516 succeed = p->doProjectTest((*test_it).func, (*test_it).args, place);
517 if((*test_it).invert)
523 ret = ParsableBlock::eval(p, place);
524 //restore the variable in the map
525 if(!variable.isEmpty())
526 place[variable] = va;
531 if(!ret || cause_break)
536 p->iterator = saved_iterator;
540 QMakeProject::ScopeBlock::~ScopeBlock()
548 static void qmake_error_msg(const QString &msg)
550 fprintf(stderr, "%s:%d: %s\n", parser.file.toLatin1().constData(), parser.line_no,
551 msg.toLatin1().constData());
555 1) environment variable QMAKEFEATURES (as separated by colons)
556 2) property variable QMAKEFEATURES (as separated by colons)
557 3) <project_root> (where .qmake.cache lives) + FEATURES_DIR
558 4) environment variable QMAKEPATH (as separated by colons) + /mkspecs/FEATURES_DIR
559 5) your QMAKESPEC/features dir
560 6) your data_install/mkspecs/FEATURES_DIR
561 7) your QMAKESPEC/../FEATURES_DIR dir
563 FEATURES_DIR is defined as:
565 1) features/(unix|win32|macx)/
568 QStringList qmake_feature_paths(QMakeProperty *prop, bool host_build)
570 const QString mkspecs_concat = QLatin1String("/mkspecs");
571 const QString base_concat = QLatin1String("/features");
574 switch(Option::target_mode) {
575 case Option::TARG_MACX_MODE: //also a unix
576 concat << base_concat + QLatin1String("/mac");
577 concat << base_concat + QLatin1String("/macx");
578 concat << base_concat + QLatin1String("/unix");
580 default: // Can't happen, just make the compiler shut up
581 case Option::TARG_UNIX_MODE:
582 concat << base_concat + QLatin1String("/unix");
584 case Option::TARG_WIN_MODE:
585 concat << base_concat + QLatin1String("/win32");
588 concat << base_concat;
591 QStringList feature_roots = splitPathList(QString::fromLocal8Bit(qgetenv("QMAKEFEATURES")));
592 feature_roots += cached_qmakefeatures;
594 feature_roots += splitPathList(prop->value("QMAKEFEATURES"));
595 if (!cached_build_root.isEmpty())
596 for(QStringList::Iterator concat_it = concat.begin();
597 concat_it != concat.end(); ++concat_it)
598 feature_roots << (cached_build_root + (*concat_it));
599 QStringList qmakepath = splitPathList(QString::fromLocal8Bit(qgetenv("QMAKEPATH")));
600 qmakepath += cached_qmakepath;
601 foreach (const QString &path, qmakepath)
602 foreach (const QString &cat, concat)
603 feature_roots << (path + mkspecs_concat + cat);
604 QString *specp = host_build ? &Option::mkfile::qmakespec : &Option::mkfile::xqmakespec;
605 if (!specp->isEmpty()) {
606 // The spec is already platform-dependent, so no subdirs here.
607 feature_roots << *specp + base_concat;
609 // Also check directly under the root directory of the mkspecs collection
610 QFileInfo specfi(*specp);
611 QDir specrootdir(specfi.absolutePath());
612 while (!specrootdir.isRoot()) {
613 const QString specrootpath = specrootdir.path();
614 if (specrootpath.endsWith(mkspecs_concat)) {
615 if (QFile::exists(specrootpath + base_concat))
616 for (QStringList::Iterator concat_it = concat.begin();
617 concat_it != concat.end(); ++concat_it)
618 feature_roots << (specrootpath + (*concat_it));
624 for(QStringList::Iterator concat_it = concat.begin();
625 concat_it != concat.end(); ++concat_it)
626 feature_roots << (QLibraryInfo::rawLocation(QLibraryInfo::HostDataPath,
627 QLibraryInfo::EffectivePaths) +
628 mkspecs_concat + (*concat_it));
629 feature_roots.removeDuplicates();
630 return feature_roots;
633 QStringList qmake_mkspec_paths()
636 const QString concat = QLatin1String("/mkspecs");
638 QStringList qmakepath = splitPathList(QString::fromLocal8Bit(qgetenv("QMAKEPATH")));
639 qmakepath += cached_qmakepath;
640 foreach (const QString &path, qmakepath)
641 ret << (path + concat);
642 if (!cached_build_root.isEmpty())
643 ret << cached_build_root + concat;
644 if (!cached_source_root.isEmpty())
645 ret << cached_source_root + concat;
646 ret << QLibraryInfo::rawLocation(QLibraryInfo::HostDataPath, QLibraryInfo::EffectivePaths) + concat;
647 ret.removeDuplicates();
652 QMakeProject::~QMakeProject()
661 QMakeProject::init(QMakeProperty *p)
664 prop = new QMakeProperty;
676 QMakeProject::cleanup()
678 for (QHash<QString, FunctionBlock*>::iterator it = replaceFunctions.begin(); it != replaceFunctions.end(); ++it)
679 if (!it.value()->deref())
681 replaceFunctions.clear();
682 for (QHash<QString, FunctionBlock*>::iterator it = testFunctions.begin(); it != testFunctions.end(); ++it)
683 if (!it.value()->deref())
685 testFunctions.clear();
688 // Duplicate project. It is *not* allowed to call the complex read() functions on the copy.
689 QMakeProject::QMakeProject(QMakeProject *p, const QHash<QString, QStringList> *_vars)
691 init(p->properties());
692 vars = _vars ? *_vars : p->variables();
693 host_build = p->host_build;
694 for(QHash<QString, FunctionBlock*>::iterator it = p->replaceFunctions.begin(); it != p->replaceFunctions.end(); ++it) {
696 replaceFunctions.insert(it.key(), it.value());
698 for(QHash<QString, FunctionBlock*>::iterator it = p->testFunctions.begin(); it != p->testFunctions.end(); ++it) {
700 testFunctions.insert(it.key(), it.value());
705 QMakeProject::reset()
707 // scope_blocks starts with one non-ignoring entity
708 scope_blocks.clear();
709 scope_blocks.push(ScopeBlock());
712 backslashWarned = false;
713 need_restart = false;
717 QMakeProject::parse(const QString &t, QHash<QString, QStringList> &place, int numLines)
719 // To preserve the integrity of any UTF-8 characters in .pro file, temporarily replace the
720 // non-breaking space (0xA0) characters with another non-space character, so that
721 // QString::simplified() call will not replace it with space.
722 // Note: There won't be any two byte characters in .pro files, so 0x10A0 should be a safe
723 // replacement character.
724 static QChar nbsp(0xA0);
725 static QChar nbspFix(0x01A0);
727 if (t.indexOf(nbsp) != -1) {
729 s.replace(nbsp, nbspFix);
731 s.replace(nbspFix, nbsp);
736 int hash_mark = s.indexOf("#");
737 if(hash_mark != -1) //good bye comments
738 s = s.left(hash_mark);
739 if(s.isEmpty()) // blank_line
742 if(scope_blocks.top().ignore) {
743 bool continue_parsing = false;
744 // adjust scope for each block which appears on a single line
745 for(int i = 0; i < s.length(); i++) {
747 scope_blocks.push(ScopeBlock(true));
748 } else if(s[i] == '}') {
749 if(scope_blocks.count() == 1) {
750 fprintf(stderr, "Braces mismatch %s:%d\n", parser.file.toLatin1().constData(), parser.line_no);
753 ScopeBlock sb = scope_blocks.pop();
755 sb.iterate->exec(this, place);
759 if(!scope_blocks.top().ignore) {
760 debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.toLatin1().constData(),
761 parser.line_no, scope_blocks.count()+1);
762 s = s.mid(i+1).trimmed();
763 continue_parsing = !s.isEmpty();
768 if(!continue_parsing) {
769 debug_msg(1, "Project Parser: %s:%d : Ignored due to block being false.",
770 parser.file.toLatin1().constData(), parser.line_no);
778 const QChar *d = s.unicode();
779 bool function_finished = false;
780 while(d_off < s.length()) {
781 if(*(d+d_off) == QLatin1Char('}')) {
782 function->scope_level--;
783 if(!function->scope_level) {
784 function_finished = true;
787 } else if(*(d+d_off) == QLatin1Char('{')) {
788 function->scope_level++;
790 append += *(d+d_off);
793 if(!append.isEmpty())
794 function->parselist.append(IteratorBlock::Parse(append));
795 if(function_finished) {
797 s = QString(d+d_off, s.length()-d_off);
801 } else if(IteratorBlock *it = scope_blocks.top().iterate) {
804 const QChar *d = s.unicode();
805 bool iterate_finished = false;
806 while(d_off < s.length()) {
807 if(*(d+d_off) == QLatin1Char('}')) {
809 if(!it->scope_level) {
810 iterate_finished = true;
813 } else if(*(d+d_off) == QLatin1Char('{')) {
816 append += *(d+d_off);
819 if(!append.isEmpty())
820 scope_blocks.top().iterate->parselist.append(IteratorBlock::Parse(append));
821 if(iterate_finished) {
822 scope_blocks.top().iterate = 0;
823 bool ret = it->exec(this, place);
833 QString scope, var, op;
835 #define SKIP_WS(d, o, l) while(o < l && (*(d+o) == QLatin1Char(' ') || *(d+o) == QLatin1Char('\t'))) ++o
836 const QChar *d = s.unicode();
838 SKIP_WS(d, d_off, s.length());
839 IteratorBlock *iterator = 0;
840 bool scope_failed = false, else_line = false, or_op=false;
842 int parens = 0, scope_count=0, start_block = 0;
843 while(d_off < s.length()) {
845 if(*(d+d_off) == QLatin1Char('='))
847 if(*(d+d_off) == QLatin1Char('+') || *(d+d_off) == QLatin1Char('-') ||
848 *(d+d_off) == QLatin1Char('*') || *(d+d_off) == QLatin1Char('~')) {
849 if(*(d+d_off+1) == QLatin1Char('=')) {
851 } else if(*(d+d_off+1) == QLatin1Char(' ')) {
852 const QChar *k = d+d_off+1;
854 SKIP_WS(k, k_off, s.length()-d_off);
855 if(*(k+k_off) == QLatin1Char('=')) {
857 qmake_error_msg(QString(d+d_off, 1) + "must be followed immediately by =");
864 if(!quote.isNull()) {
865 if(*(d+d_off) == quote)
867 } else if(*(d+d_off) == '(') {
869 } else if(*(d+d_off) == ')') {
871 } else if(*(d+d_off) == '"' /*|| *(d+d_off) == '\''*/) {
875 if(!parens && quote.isNull() &&
876 (*(d+d_off) == QLatin1Char(':') || *(d+d_off) == QLatin1Char('{') ||
877 *(d+d_off) == QLatin1Char(')') || *(d+d_off) == QLatin1Char('|'))) {
879 scope = var.trimmed();
880 if(*(d+d_off) == QLatin1Char(')'))
881 scope += *(d+d_off); // need this
884 bool test = scope_failed;
885 if(scope.isEmpty()) {
887 } else if(scope.toLower() == "else") { //else is a builtin scope here as it modifies state
888 if(scope_count != 1 || scope_blocks.top().else_status == ScopeBlock::TestNone) {
889 qmake_error_msg(("Unexpected " + scope + " ('" + s + "')").toLatin1());
893 test = (scope_blocks.top().else_status == ScopeBlock::TestSeek);
894 debug_msg(1, "Project Parser: %s:%d : Else%s %s.", parser.file.toLatin1().constData(), parser.line_no,
895 scope == "else" ? "" : QString(" (" + scope + ")").toLatin1().constData(),
896 test ? "considered" : "excluded");
898 QString comp_scope = scope;
899 bool invert_test = (comp_scope.at(0) == QLatin1Char('!'));
901 comp_scope = comp_scope.mid(1);
902 int lparen = comp_scope.indexOf('(');
903 if(or_op == scope_failed) {
904 if(lparen != -1) { // if there is an lparen in the scope, it IS a function
905 int rparen = comp_scope.lastIndexOf(')');
907 qmake_error_msg("Function missing right paren: " + comp_scope);
910 QString func = comp_scope.left(lparen);
911 QStringList args = split_arg_list(comp_scope.mid(lparen+1, rparen - lparen - 1));
913 fprintf(stderr, "%s:%d: No tests can come after a function definition!\n",
914 parser.file.toLatin1().constData(), parser.line_no);
916 } else if(func == "for") { //for is a builtin function here, as it modifies state
917 if(args.count() > 2 || args.count() < 1) {
918 fprintf(stderr, "%s:%d: for(iterate, list) requires two arguments.\n",
919 parser.file.toLatin1().constData(), parser.line_no);
921 } else if(iterator) {
922 fprintf(stderr, "%s:%d unexpected nested for()\n",
923 parser.file.toLatin1().constData(), parser.line_no);
927 iterator = new IteratorBlock;
929 if(args.count() == 1) {
930 doVariableReplace(args[0], place);
932 if(args[0] != "ever") {
935 fprintf(stderr, "%s:%d: for(iterate, list) requires two arguments.\n",
936 parser.file.toLatin1().constData(), parser.line_no);
940 } else if(args.count() == 2) {
941 iterator->variable = args[0];
942 doVariableReplace(args[1], place);
945 QStringList list = place[it_list];
947 if(it_list == "forever") {
948 iterator->loop_forever = true;
950 int dotdot = it_list.indexOf("..");
953 int start = it_list.left(dotdot).toInt(&ok);
955 int end = it_list.mid(dotdot+2).toInt(&ok);
958 for(int i = start; i <= end; i++)
959 list << QString::number(i);
961 for(int i = start; i >= end; i--)
962 list << QString::number(i);
969 iterator->list = list;
971 } else if(iterator) {
972 iterator->test.append(IteratorBlock::Test(func, args, invert_test));
974 } else if(func == "defineTest" || func == "defineReplace") {
975 if(!function_blocks.isEmpty()) {
977 "%s:%d: cannot define a function within another definition.\n",
978 parser.file.toLatin1().constData(), parser.line_no);
981 if(args.count() != 1) {
982 fprintf(stderr, "%s:%d: %s(function_name) requires one argument.\n",
983 parser.file.toLatin1().constData(), parser.line_no, func.toLatin1().constData());
986 QHash<QString, FunctionBlock*> *map = 0;
987 if(func == "defineTest")
988 map = &testFunctions;
990 map = &replaceFunctions;
992 if(!map || map->contains(args[0])) {
993 fprintf(stderr, "%s:%d: Function[%s] multiply defined.\n",
994 parser.file.toLatin1().constData(), parser.line_no, args[0].toLatin1().constData());
998 function = new FunctionBlock;
999 map->insert(args[0], function);
1002 test = doProjectTest(func, args, place);
1003 if(*(d+d_off) == QLatin1Char(')') && d_off == s.length()-1) {
1006 scope_blocks.top().else_status =
1007 (test ? ScopeBlock::TestFound : ScopeBlock::TestSeek);
1008 return true; // assume we are done
1012 QString cscope = comp_scope.trimmed();
1013 doVariableReplace(cscope, place);
1014 test = isActiveConfig(cscope.trimmed(), true, &place);
1020 if(!test && !scope_failed)
1021 debug_msg(1, "Project Parser: %s:%d : Test (%s) failed.", parser.file.toLatin1().constData(),
1022 parser.line_no, scope.toLatin1().constData());
1024 scope_failed = !test;
1025 or_op = (*(d+d_off) == QLatin1Char('|'));
1027 if(*(d+d_off) == QLatin1Char('{')) { // scoping block
1030 for(int off = 0, braces = 0; true; ++off) {
1031 if(*(d+d_off+off) == QLatin1Char('{'))
1033 else if(*(d+d_off+off) == QLatin1Char('}') && braces)
1035 if(!braces || d_off+off == s.length()) {
1036 iterator->parselist.append(s.mid(d_off, off-1));
1038 iterator->scope_level += braces-1;
1045 } else if(!parens && *(d+d_off) == QLatin1Char('}')) {
1048 } else if(!scope_blocks.count()) {
1049 warn_msg(WarnParser, "Possible braces mismatch %s:%d", parser.file.toLatin1().constData(), parser.line_no);
1051 if(scope_blocks.count() == 1) {
1052 fprintf(stderr, "Braces mismatch %s:%d\n", parser.file.toLatin1().constData(), parser.line_no);
1055 debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.toLatin1().constData(),
1056 parser.line_no, scope_blocks.count());
1057 ScopeBlock sb = scope_blocks.pop();
1059 sb.iterate->exec(this, place);
1066 var = var.trimmed();
1068 if(!else_line || (else_line && !scope_failed))
1069 scope_blocks.top().else_status = (!scope_failed ? ScopeBlock::TestFound : ScopeBlock::TestSeek);
1071 ScopeBlock next_block(scope_failed);
1072 next_block.iterate = iterator;
1074 next_block.else_status = ScopeBlock::TestNone;
1075 else if(scope_failed)
1076 next_block.else_status = ScopeBlock::TestSeek;
1078 next_block.else_status = ScopeBlock::TestFound;
1079 scope_blocks.push(next_block);
1080 debug_msg(1, "Project Parser: %s:%d : Entering block %d (%d). [%s]", parser.file.toLatin1().constData(),
1081 parser.line_no, scope_blocks.count(), scope_failed, s.toLatin1().constData());
1082 } else if(iterator) {
1083 iterator->parselist.append(QString(var+s.mid(d_off)));
1084 bool ret = iterator->exec(this, place);
1089 if((!scope_count && !var.isEmpty()) || (scope_count == 1 && else_line))
1090 scope_blocks.top().else_status = ScopeBlock::TestNone;
1091 if(d_off == s.length()) {
1092 if(!var.trimmed().isEmpty())
1093 qmake_error_msg(("Parse Error ('" + s + "')").toLatin1());
1094 return var.isEmpty(); // allow just a scope
1097 SKIP_WS(d, d_off, s.length());
1098 for(; d_off < s.length() && op.indexOf('=') == -1; op += *(d+(d_off++)))
1100 op.replace(QRegExp("\\s"), "");
1102 SKIP_WS(d, d_off, s.length());
1103 QString vals = s.mid(d_off); // vals now contains the space separated list of values
1104 int rbraces = vals.count('}'), lbraces = vals.count('{');
1105 if(scope_blocks.count() > 1 && rbraces - lbraces == 1 && vals.endsWith('}')) {
1106 debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.toLatin1().constData(),
1107 parser.line_no, scope_blocks.count());
1108 ScopeBlock sb = scope_blocks.pop();
1110 sb.iterate->exec(this, place);
1111 vals.truncate(vals.length()-1);
1112 } else if(rbraces != lbraces) {
1113 warn_msg(WarnParser, "Possible braces mismatch {%s} %s:%d",
1114 vals.toLatin1().constData(), parser.file.toLatin1().constData(), parser.line_no);
1117 return true; // oh well
1120 doVariableReplace(var, place);
1121 var = varMap(var); //backwards compatibility
1122 if(!var.isEmpty() && Option::mkfile::do_preprocess) {
1123 static QString last_file("*none*");
1124 if(parser.file != last_file) {
1125 fprintf(stdout, "#file %s:%d\n", parser.file.toLatin1().constData(), parser.line_no);
1126 last_file = parser.file;
1128 fprintf(stdout, "%s %s %s\n", var.toLatin1().constData(), op.toLatin1().constData(), vals.toLatin1().constData());
1131 if(vals.contains('=') && numLines > 1)
1132 warn_msg(WarnParser, "Possible accidental line continuation: {%s} at %s:%d",
1133 var.toLatin1().constData(), parser.file.toLatin1().constData(), parser.line_no);
1135 QStringList &varlist = place[var]; // varlist is the list in the symbol table
1137 if(Option::debug_level >= 1) {
1138 QString tmp_vals = vals;
1139 doVariableReplace(tmp_vals, place);
1140 debug_msg(1, "Project Parser: %s:%d :%s: :%s: (%s)", parser.file.toLatin1().constData(), parser.line_no,
1141 var.toLatin1().constData(), op.toLatin1().constData(), tmp_vals.toLatin1().constData());
1144 // now do the operation
1146 doVariableReplace(vals, place);
1147 if(vals.length() < 4 || vals.at(0) != 's') {
1148 qmake_error_msg(("~= operator only can handle s/// function ('" +
1149 s + "')").toLatin1());
1152 QChar sep = vals.at(1);
1153 QStringList func = vals.split(sep);
1154 if(func.count() < 3 || func.count() > 4) {
1155 qmake_error_msg(("~= operator only can handle s/// function ('" +
1156 s + "')").toLatin1());
1159 bool global = false, case_sense = true, quote = false;
1160 if(func.count() == 4) {
1161 global = func[3].indexOf('g') != -1;
1162 case_sense = func[3].indexOf('i') == -1;
1163 quote = func[3].indexOf('q') != -1;
1165 QString from = func[1], to = func[2];
1167 from = QRegExp::escape(from);
1168 QRegExp regexp(from, case_sense ? Qt::CaseSensitive : Qt::CaseInsensitive);
1169 for(QStringList::Iterator varit = varlist.begin(); varit != varlist.end();) {
1170 if((*varit).contains(regexp)) {
1171 (*varit) = (*varit).replace(regexp, to);
1172 if ((*varit).isEmpty())
1173 varit = varlist.erase(varit);
1182 QStringList vallist;
1184 //doVariableReplace(vals, place);
1185 QStringList tmp = split_value_list(vals);
1186 for(int i = 0; i < tmp.size(); ++i)
1187 vallist += doVariableReplaceExpand(tmp[i], place);
1191 if(!varlist.isEmpty()) {
1192 bool send_warning = false;
1193 if(var != "TEMPLATE" && var != "TARGET") {
1194 QSet<QString> incoming_vals = vallist.toSet();
1195 for(int i = 0; i < varlist.size(); ++i) {
1196 const QString var = varlist.at(i).trimmed();
1197 if(!var.isEmpty() && !incoming_vals.contains(var)) {
1198 send_warning = true;
1204 warn_msg(WarnParser, "Operator=(%s) clears variables previously set: %s:%d",
1205 var.toLatin1().constData(), parser.file.toLatin1().constData(), parser.line_no);
1209 for(QStringList::ConstIterator valit = vallist.begin();
1210 valit != vallist.end(); ++valit) {
1211 if((*valit).isEmpty())
1213 if((op == "*=" && !varlist.contains((*valit))) ||
1214 op == "=" || op == "+=")
1215 varlist.append((*valit));
1217 varlist.removeAll((*valit));
1219 if(var == "REQUIRES") // special case to get communicated to backends!
1220 doProjectCheckReqs(vallist, place);
1226 QMakeProject::read(QTextStream &file, QHash<QString, QStringList> &place)
1231 while(!file.atEnd()) {
1233 QString line = file.readLine().trimmed();
1234 int prelen = line.length();
1236 int hash_mark = line.indexOf("#");
1237 if(hash_mark != -1) //good bye comments
1238 line = line.left(hash_mark).trimmed();
1239 if(!line.isEmpty() && line.right(1) == "\\") {
1240 if(!line.startsWith("#")) {
1241 line.truncate(line.length() - 1);
1242 s += line + Option::field_sep;
1245 } else if(!line.isEmpty() || (line.isEmpty() && !prelen)) {
1246 if(s.isEmpty() && line.isEmpty())
1248 if(!line.isEmpty()) {
1253 if(!(ret = parse(s, place, numLines))) {
1266 ret = parse(s, place, numLines);
1271 QMakeProject::read(const QString &file, QHash<QString, QStringList> &place)
1273 parser_info pi = parser;
1276 const QString oldpwd = qmake_getpwd();
1277 QString filename = Option::normalizePath(file, false);
1278 bool ret = false, using_stdin = false;
1280 if(filename == QLatin1String("-")) {
1281 qfile.setFileName("");
1282 ret = qfile.open(stdin, QIODevice::ReadOnly);
1284 } else if(QFileInfo(file).isDir()) {
1287 qfile.setFileName(filename);
1288 ret = qfile.open(QIODevice::ReadOnly);
1289 qmake_setpwd(QFileInfo(filename).absolutePath());
1292 parser_info pi = parser;
1293 parser.from_file = true;
1294 parser.file = filename;
1296 if (qfile.peek(3) == QByteArray("\xef\xbb\xbf")) {
1297 //UTF-8 BOM will cause subtle errors
1298 qmake_error_msg("Unexpected UTF-8 BOM found");
1301 QTextStream t(&qfile);
1302 ret = read(t, place);
1307 if (!need_restart && scope_blocks.count() != 1) {
1308 qmake_error_msg("Unterminated conditional block at end of file");
1312 qmake_setpwd(oldpwd);
1317 QMakeProject::read(const QString &project, uchar cmd)
1319 pfile = QFileInfo(project).absoluteFilePath();
1324 QMakeProject::read(uchar cmd)
1327 if ((cmd & ReadSetup) && base_vars.isEmpty()) {
1328 // hack to get the Option stuff in there
1329 base_vars["QMAKE_EXT_CPP"] = Option::cpp_ext;
1330 base_vars["QMAKE_EXT_C"] = Option::c_ext;
1331 base_vars["QMAKE_EXT_H"] = Option::h_ext;
1332 base_vars["QMAKE_SH"] = Option::shellPath;
1333 if(!Option::user_template_prefix.isEmpty())
1334 base_vars["TEMPLATE_PREFIX"] = QStringList(Option::user_template_prefix);
1336 QString project_root;
1337 QString project_build_root;
1338 QStringList qmakepath;
1339 QStringList qmakefeatures;
1340 if (Option::mkfile::do_cache) { // parse the cache
1341 if (Option::mkfile::cachefile.isEmpty()) { //find it as it has not been specified
1342 QString dir = Option::output_dir;
1344 QFileInfo qfi(dir, QLatin1String(".qmake.cache"));
1346 cachefile = qfi.filePath();
1347 project_build_root = dir;
1350 QFileInfo qdfi(dir);
1356 QFileInfo fi(Option::mkfile::cachefile);
1357 cachefile = QDir::cleanPath(fi.absoluteFilePath());
1358 project_build_root = QDir::cleanPath(fi.absolutePath());
1361 QHash<QString, QStringList> cache;
1362 if (!read(cachefile, cache)) {
1366 if (Option::mkfile::xqmakespec.isEmpty() && !cache["XQMAKESPEC"].isEmpty())
1367 Option::mkfile::xqmakespec = cache["XQMAKESPEC"].first();
1368 if (Option::mkfile::qmakespec.isEmpty() && !cache["QMAKESPEC"].isEmpty()) {
1369 Option::mkfile::qmakespec = cache["QMAKESPEC"].first();
1370 if (Option::mkfile::xqmakespec.isEmpty())
1371 Option::mkfile::xqmakespec = Option::mkfile::qmakespec;
1373 qmakepath = cache.value(QLatin1String("QMAKEPATH"));
1374 qmakefeatures = cache.value(QLatin1String("QMAKEFEATURES"));
1376 if (Option::output_dir.startsWith(project_build_root))
1377 Option::mkfile::cachefile_depth =
1378 Option::output_dir.mid(project_build_root.length()).count('/');
1382 if (qmake_getpwd() != Option::output_dir || project_build_root.isEmpty()) {
1383 QDir srcdir(qmake_getpwd());
1384 QDir dstdir(Option::output_dir);
1386 if (!project_build_root.isEmpty()) {
1387 // If we already know the build root, just match up the source root with it.
1388 if (dstdir.path() == project_build_root) {
1389 project_root = srcdir.path();
1393 // Look for mkspecs/ in source and build. First to win determines the root.
1394 if (dstdir.exists("mkspecs") || srcdir.exists("mkspecs")) {
1395 project_build_root = dstdir.path();
1396 project_root = srcdir.path();
1397 if (project_root == project_build_root)
1398 project_root.clear();
1402 } while (!srcdir.isRoot() && srcdir.cdUp() && !dstdir.isRoot() && dstdir.cdUp());
1404 project_root.clear();
1407 if (qmakepath != cached_qmakepath || qmakefeatures != cached_qmakefeatures
1408 || project_build_root != cached_build_root) { // No need to check source dir, as it goes in sync
1409 cached_source_root = project_root;
1410 cached_build_root = project_build_root;
1411 cached_qmakepath = qmakepath;
1412 cached_qmakefeatures = qmakefeatures;
1413 invalidateFeatureRoots();
1417 QString *specp = host_build ? &Option::mkfile::qmakespec : &Option::mkfile::xqmakespec;
1418 QString qmakespec = *specp;
1419 if (qmakespec.isEmpty())
1420 qmakespec = host_build ? "default-host" : "default";
1421 if (QDir::isRelativePath(qmakespec)) {
1422 QStringList mkspec_roots = qmake_mkspec_paths();
1423 debug_msg(2, "Looking for mkspec %s in (%s)", qmakespec.toLatin1().constData(),
1424 mkspec_roots.join("::").toLatin1().constData());
1425 bool found_mkspec = false;
1426 for (QStringList::ConstIterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) {
1427 QString mkspec = (*it) + QLatin1Char('/') + qmakespec;
1428 if (QFile::exists(mkspec)) {
1429 found_mkspec = true;
1430 *specp = qmakespec = mkspec;
1434 if (!found_mkspec) {
1435 fprintf(stderr, "Could not find mkspecs for your QMAKESPEC(%s) after trying:\n\t%s\n",
1436 qmakespec.toLatin1().constData(), mkspec_roots.join("\n\t").toLatin1().constData());
1441 // parse qmake configuration
1442 while(qmakespec.endsWith(QLatin1Char('/')))
1443 qmakespec.truncate(qmakespec.length()-1);
1444 QString spec = qmakespec + QLatin1String("/qmake.conf");
1445 debug_msg(1, "QMAKESPEC conf: reading %s", spec.toLatin1().constData());
1446 if(!read(spec, base_vars)) {
1447 fprintf(stderr, "Failure to read QMAKESPEC conf file %s.\n", spec.toLatin1().constData());
1452 if (!cachefile.isEmpty()) {
1453 debug_msg(1, "QMAKECACHE file: reading %s", cachefile.toLatin1().constData());
1454 read(cachefile, base_vars);
1459 vars = base_vars; // start with the base
1461 for (QHash<QString, QStringList>::ConstIterator it = extra_vars.constBegin();
1462 it != extra_vars.constEnd(); ++it)
1463 vars.insert(it.key(), it.value());
1465 if(cmd & ReadFeatures) {
1466 debug_msg(1, "Processing default_pre: %s", vars["CONFIG"].join("::").toLatin1().constData());
1467 doProjectInclude("default_pre", IncludeFlagFeature, vars);
1471 if(pfile != "-" && vars["TARGET"].isEmpty())
1472 vars["TARGET"].append(QFileInfo(pfile).baseName());
1474 //before commandline
1475 if (cmd & ReadSetup) {
1476 parser.file = "(internal)";
1477 parser.from_file = false;
1478 parser.line_no = 1; //really arg count now.. duh
1480 for(QStringList::ConstIterator it = Option::before_user_vars.begin();
1481 it != Option::before_user_vars.end(); ++it) {
1482 if(!parse((*it), vars)) {
1483 fprintf(stderr, "Argument failed to parse: %s\n", (*it).toLatin1().constData());
1490 // After user configs, to override them
1491 if (!extra_configs.isEmpty()) {
1492 parser.file = "(extra configs)";
1493 parser.from_file = false;
1494 parser.line_no = 1; //really arg count now.. duh
1495 parse("CONFIG += " + extra_configs.join(" "), vars);
1498 if(cmd & ReadProFile) { // parse project file
1499 debug_msg(1, "Project file: reading %s", pfile.toLatin1().constData());
1500 if(pfile != "-" && !QFile::exists(pfile) && !pfile.endsWith(Option::pro_ext))
1501 pfile += Option::pro_ext;
1502 if(!read(pfile, vars))
1511 if (cmd & ReadSetup) {
1512 parser.file = "(internal)";
1513 parser.from_file = false;
1514 parser.line_no = 1; //really arg count now.. duh
1516 for(QStringList::ConstIterator it = Option::after_user_vars.begin();
1517 it != Option::after_user_vars.end(); ++it) {
1518 if(!parse((*it), vars)) {
1519 fprintf(stderr, "Argument failed to parse: %s\n", (*it).toLatin1().constData());
1526 // Again, to ensure the project does not mess with us.
1527 // Specifically, do not allow a project to override debug/release within a
1528 // debug_and_release build pass - it's too late for that at this point anyway.
1529 if (!extra_configs.isEmpty()) {
1530 parser.file = "(extra configs)";
1531 parser.from_file = false;
1532 parser.line_no = 1; //really arg count now.. duh
1533 parse("CONFIG += " + extra_configs.join(" "), vars);
1536 if(cmd & ReadFeatures) {
1537 debug_msg(1, "Processing default_post: %s", vars["CONFIG"].join("::").toLatin1().constData());
1538 doProjectInclude("default_post", IncludeFlagFeature, vars);
1540 QHash<QString, bool> processed;
1541 const QStringList &configs = vars["CONFIG"];
1542 debug_msg(1, "Processing CONFIG features: %s", configs.join("::").toLatin1().constData());
1544 bool finished = true;
1545 for(int i = configs.size()-1; i >= 0; --i) {
1546 const QString config = configs[i].toLower();
1547 if(!processed.contains(config)) {
1548 processed.insert(config, true);
1549 if(doProjectInclude(config, IncludeFlagFeature, vars) == IncludeSuccess) {
1562 void QMakeProject::validateModes()
1564 if (Option::host_mode == Option::HOST_UNKNOWN_MODE
1565 || Option::target_mode == Option::TARG_UNKNOWN_MODE) {
1566 Option::HOST_MODE host_mode;
1567 Option::TARG_MODE target_mode;
1568 const QStringList &gen = base_vars.value("MAKEFILE_GENERATOR");
1569 if (gen.isEmpty()) {
1570 fprintf(stderr, "%s:%d: Using OS scope before setting MAKEFILE_GENERATOR\n",
1571 parser.file.toLatin1().constData(), parser.line_no);
1572 } else if (MetaMakefileGenerator::modesForGenerator(gen.first(),
1573 &host_mode, &target_mode)) {
1574 if (Option::host_mode == Option::HOST_UNKNOWN_MODE) {
1575 Option::host_mode = host_mode;
1576 Option::applyHostMode();
1579 if (Option::target_mode == Option::TARG_UNKNOWN_MODE) {
1580 const QStringList &tgt = base_vars.value("TARGET_PLATFORM");
1581 if (!tgt.isEmpty()) {
1582 const QString &os = tgt.first();
1584 Option::target_mode = Option::TARG_UNIX_MODE;
1585 else if (os == "macx")
1586 Option::target_mode = Option::TARG_MACX_MODE;
1587 else if (os == "win32")
1588 Option::target_mode = Option::TARG_WIN_MODE;
1590 fprintf(stderr, "Unknown target platform specified: %s\n",
1591 os.toLatin1().constData());
1593 Option::target_mode = target_mode;
1601 QMakeProject::resolveSpec(QString *spec, const QString &qmakespec)
1603 if (spec->isEmpty()) {
1604 *spec = QFileInfo(qmakespec).fileName();
1605 if (*spec == "default" || *spec == "default-host") {
1608 int l = readlink(qmakespec.toLatin1().constData(), buffer, 1023);
1611 *spec = QString::fromLatin1(buffer);
1613 // We can't resolve symlinks as they do on Unix, so configure.exe puts the source of the
1614 // qmake.conf at the end of the default/qmake.conf in the QMAKESPEC_ORG variable.
1615 const QStringList &spec_org = base_vars["QMAKESPEC_ORIGINAL"];
1616 if (spec_org.isEmpty()) {
1617 // try again the next time around
1620 *spec = spec_org.at(0);
1622 int lastSlash = spec->lastIndexOf(QLatin1Char('/'));
1623 if (lastSlash != -1)
1624 spec->remove(0, lastSlash + 1);
1631 QMakeProject::isActiveConfig(const QString &x, bool regex, QHash<QString, QStringList> *place)
1636 //magic types for easy flipping
1639 else if(x == "false")
1644 return Option::target_mode == Option::TARG_UNIX_MODE
1645 || Option::target_mode == Option::TARG_MACX_MODE;
1646 } else if (x == "macx" || x == "mac") {
1648 return Option::target_mode == Option::TARG_MACX_MODE;
1649 } else if (x == "win32") {
1651 return Option::target_mode == Option::TARG_WIN_MODE;
1654 if (x == "host_build")
1655 return host_build ? "true" : "false";
1658 static QString hspec, xspec;
1659 resolveSpec(&hspec, Option::mkfile::qmakespec);
1660 resolveSpec(&xspec, Option::mkfile::xqmakespec);
1661 const QString &spec = host_build ? hspec : xspec;
1662 QRegExp re(x, Qt::CaseSensitive, QRegExp::Wildcard);
1663 if((regex && re.exactMatch(spec)) || (!regex && spec == x))
1667 const QStringList &configs = (place ? (*place)["CONFIG"] : vars["CONFIG"]);
1668 for(QStringList::ConstIterator it = configs.begin(); it != configs.end(); ++it) {
1669 if(((regex && re.exactMatch((*it))) || (!regex && (*it) == x)) && re.exactMatch((*it)))
1676 QMakeProject::doProjectTest(QString str, QHash<QString, QStringList> &place)
1678 QString chk = remove_quotes(str);
1681 bool invert_test = (chk.left(1) == "!");
1686 int lparen = chk.indexOf('(');
1687 if(lparen != -1) { // if there is an lparen in the chk, it IS a function
1688 int rparen = chk.indexOf(')', lparen);
1690 qmake_error_msg("Function missing right paren: " + chk);
1692 QString func = chk.left(lparen);
1693 test = doProjectTest(func, chk.mid(lparen+1, rparen - lparen - 1), place);
1696 test = isActiveConfig(chk, true, &place);
1704 QMakeProject::doProjectTest(QString func, const QString ¶ms,
1705 QHash<QString, QStringList> &place)
1707 return doProjectTest(func, split_arg_list(params), place);
1710 QMakeProject::IncludeStatus
1711 QMakeProject::doProjectInclude(QString file, uchar flags, QHash<QString, QStringList> &place)
1713 if(flags & IncludeFlagFeature) {
1714 if(!file.endsWith(Option::prf_ext))
1715 file += Option::prf_ext;
1716 validateModes(); // init dir_sep
1717 if(file.indexOf(QLatin1Char('/')) == -1 || !QFile::exists(file)) {
1718 QStringList *&feature_roots = all_feature_roots[host_build];
1719 if(!feature_roots) {
1720 feature_roots = new QStringList;
1721 qmakeAddCacheClear(qmakeDeleteCacheClear<QStringList>, (void**)&feature_roots);
1723 if (feature_roots->isEmpty())
1724 *feature_roots = qmake_feature_paths(prop, host_build);
1725 debug_msg(2, "Looking for feature '%s' in (%s)", file.toLatin1().constData(),
1726 feature_roots->join("::").toLatin1().constData());
1728 if(parser.from_file) {
1729 QFileInfo currFile(parser.file), prfFile(file);
1730 if(currFile.fileName() == prfFile.fileName()) {
1731 currFile = QFileInfo(currFile.canonicalFilePath());
1732 for(int root = 0; root < feature_roots->size(); ++root) {
1733 prfFile = QFileInfo(feature_roots->at(root) +
1734 QLatin1Char('/') + file).canonicalFilePath();
1735 if(prfFile == currFile) {
1736 start_root = root+1;
1742 for(int root = start_root; root < feature_roots->size(); ++root) {
1743 QString prf(feature_roots->at(root) + QLatin1Char('/') + file);
1744 if (QFile::exists(prf)) {
1749 return IncludeNoExist;
1752 if(place["QMAKE_INTERNAL_INCLUDED_FEATURES"].indexOf(file) != -1)
1753 return IncludeFeatureAlreadyLoaded;
1754 place["QMAKE_INTERNAL_INCLUDED_FEATURES"].append(file);
1756 if(QDir::isRelativePath(file)) {
1757 QStringList include_roots;
1758 if(Option::output_dir != qmake_getpwd())
1759 include_roots << qmake_getpwd();
1760 include_roots << Option::output_dir;
1761 for(int root = 0; root < include_roots.size(); ++root) {
1762 QString testName = QDir::fromNativeSeparators(include_roots[root]);
1763 if (!testName.endsWith(QLatin1Char('/')))
1764 testName += QLatin1Char('/');
1766 if(QFile::exists(testName)) {
1771 return IncludeNoExist;
1773 } else if (!QFile::exists(file)) {
1774 return IncludeNoExist;
1776 if(Option::mkfile::do_preprocess) //nice to see this first..
1777 fprintf(stderr, "#switching file %s(%s) - %s:%d\n", (flags & IncludeFlagFeature) ? "load" : "include",
1778 file.toLatin1().constData(),
1779 parser.file.toLatin1().constData(), parser.line_no);
1780 debug_msg(1, "Project Parser: %s'ing file %s.", (flags & IncludeFlagFeature) ? "load" : "include",
1781 file.toLatin1().constData());
1783 QString orig_file = file;
1784 int di = file.lastIndexOf(QLatin1Char('/'));
1785 QString oldpwd = qmake_getpwd();
1787 if(!qmake_setpwd(file.left(file.lastIndexOf(QLatin1Char('/'))))) {
1788 fprintf(stderr, "Cannot find directory: %s\n", file.left(di).toLatin1().constData());
1789 return IncludeFailure;
1792 bool parsed = false;
1793 parser_info pi = parser;
1795 if(flags & (IncludeFlagNewProject|IncludeFlagNewParser)) {
1796 // The "project's variables" are used in other places (eg. export()) so it's not
1797 // possible to use "place" everywhere. Instead just set variables and grab them later
1798 QMakeProject proj(prop);
1799 if(flags & IncludeFlagNewParser) {
1800 parsed = proj.read(file, proj.variables()); // parse just that file (fromfile, infile)
1802 parsed = proj.read(file); // parse all aux files (load/include into)
1804 place = proj.variables();
1806 QStack<ScopeBlock> sc = scope_blocks;
1807 IteratorBlock *it = iterator;
1808 FunctionBlock *fu = function;
1809 parsed = read(file, place);
1816 if(place["QMAKE_INTERNAL_INCLUDED_FILES"].indexOf(orig_file) == -1)
1817 place["QMAKE_INTERNAL_INCLUDED_FILES"].append(orig_file);
1819 warn_msg(WarnParser, "%s:%d: Failure to include file %s.",
1820 pi.file.toLatin1().constData(), pi.line_no, orig_file.toLatin1().constData());
1823 qmake_setpwd(oldpwd);
1825 return IncludeParseFailure;
1826 return IncludeSuccess;
1830 subAll(QStringList *val, const QStringList &diffval)
1832 foreach (const QString &dv, diffval)
1837 bool isSpecialChar(ushort c)
1839 // Chars that should be quoted (TM). This includes:
1841 // - control chars & space
1842 // - the shell meta chars "&()<>^|
1843 // - the potential separators ,;=
1844 static const uchar iqm[] = {
1845 0xff, 0xff, 0xff, 0xff, 0x45, 0x13, 0x00, 0x78,
1846 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10
1849 static const uchar iqm[] = {
1850 0xff, 0xff, 0xff, 0xff, 0xdf, 0x07, 0x00, 0xd8,
1851 0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78
1852 }; // 0-32 \'"$`<>|;&(){}*?#!~[]
1855 return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7)));
1859 bool hasSpecialChars(const QString &arg)
1861 for (int x = arg.length() - 1; x >= 0; --x)
1862 if (isSpecialChar(arg.unicode()[x].unicode()))
1868 shellQuote(const QString &arg)
1871 return QString::fromLatin1("\"\"");
1874 if (hasSpecialChars(ret)) {
1876 // Quotes are escaped and their preceding backslashes are doubled.
1877 // It's impossible to escape anything inside a quoted string on cmd
1878 // level, so the outer quoting must be "suspended".
1879 ret.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\"\\1\\1\\^\"\""));
1880 // The argument must not end with a \ since this would be interpreted
1881 // as escaping the quote -- rather put the \ behind the quote: e.g.
1882 // rather use "foo"\ than "foo\"
1883 int i = ret.length();
1884 while (i > 0 && ret.at(i - 1) == QLatin1Char('\\'))
1886 ret.insert(i, QLatin1Char('"'));
1887 ret.prepend(QLatin1Char('"'));
1889 ret.replace(QLatin1Char('\''), QLatin1String("'\\''"));
1890 ret.prepend(QLatin1Char('\''));
1891 ret.append(QLatin1Char('\''));
1898 quoteValue(const QString &val)
1901 ret.reserve(val.length());
1902 bool quote = val.isEmpty();
1903 bool escaping = false;
1904 for (int i = 0, l = val.length(); i < l; i++) {
1905 QChar c = val.unicode()[i];
1906 ushort uc = c.unicode();
1910 ret += QLatin1String("$$escape_expand(");
1914 ret += QLatin1String("\\\\r");
1917 ret += QLatin1String("\\\\n");
1920 ret += QLatin1String("\\\\t");
1923 ret += QString::fromLatin1("\\\\x%1").arg(uc, 2, 16, QLatin1Char('0'));
1929 ret += QLatin1Char(')');
1933 ret += QLatin1String("\\\\");
1936 ret += QLatin1String("\\\"");
1939 ret += QLatin1String("\\'");
1942 ret += QLatin1String("\\$");
1945 ret += QLatin1String("$${LITERAL_HASH}");
1957 ret += QLatin1Char(')');
1959 ret.prepend(QLatin1Char('"'));
1960 ret.append(QLatin1Char('"'));
1966 writeFile(const QString &name, QIODevice::OpenMode mode, const QString &contents, QString *errStr)
1968 QByteArray bytes = contents.toLocal8Bit();
1970 if (!(mode & QIODevice::Append) && cfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
1971 if (cfile.readAll() == bytes)
1975 if (!cfile.open(mode | QIODevice::WriteOnly | QIODevice::Text)) {
1976 *errStr = cfile.errorString();
1981 if (cfile.error() != QFile::NoError) {
1982 *errStr = cfile.errorString();
1989 getCommandOutput(const QString &args)
1992 if (FILE *proc = QT_POPEN(args.toLatin1().constData(), "r")) {
1993 while (!feof(proc)) {
1994 char buff[10 * 1024];
1995 int read_in = int(fread(buff, 1, sizeof(buff), proc));
1998 out += QByteArray(buff, read_in);
2006 static QString windowsErrorCode()
2008 wchar_t *string = 0;
2009 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
2012 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
2016 QString ret = QString::fromWCharArray(string);
2017 LocalFree((HLOCAL)string);
2023 QMakeProject::doProjectExpand(QString func, const QString ¶ms,
2024 QHash<QString, QStringList> &place)
2026 return doProjectExpand(func, split_arg_list(params), place);
2030 QMakeProject::doProjectExpand(QString func, QStringList args,
2031 QHash<QString, QStringList> &place)
2033 QList<QStringList> args_list;
2034 for(int i = 0; i < args.size(); ++i) {
2035 QStringList arg = split_value_list(args[i]), tmp;
2036 for(int i = 0; i < arg.size(); ++i)
2037 tmp += doVariableReplaceExpand(arg[i], place);;
2040 return doProjectExpand(func, args_list, place);
2044 populateDeps(const QStringList &deps, const QString &prefix,
2045 QHash<QString, QSet<QString> > &dependencies, QHash<QString, QStringList> &dependees,
2046 QStringList &rootSet, QHash<QString, QStringList> &place)
2048 foreach (const QString &item, deps)
2049 if (!dependencies.contains(item)) {
2050 QSet<QString> &dset = dependencies[item]; // Always create entry
2051 QStringList depends = place.value(prefix + item + ".depends");
2052 if (depends.isEmpty()) {
2055 foreach (const QString &dep, depends) {
2057 dependees[dep] << item;
2059 populateDeps(depends, prefix, dependencies, dependees, rootSet, place);
2065 QMakeProject::doProjectExpand(QString func, QList<QStringList> args_list,
2066 QHash<QString, QStringList> &place)
2068 func = func.trimmed();
2069 if(replaceFunctions.contains(func)) {
2070 FunctionBlock *defined = replaceFunctions[func];
2071 function_blocks.push(defined);
2073 defined->exec(args_list, this, place, ret);
2074 bool correct = function_blocks.pop() == defined;
2075 Q_ASSERT(correct); Q_UNUSED(correct);
2079 QStringList args; //why don't the builtin functions just use args_list? --Sam
2080 for(int i = 0; i < args_list.size(); ++i)
2081 args += args_list[i].join(QString(Option::field_sep));
2083 ExpandFunc func_t = qmake_expandFunctions().value(func);
2084 if (!func_t && (func_t = qmake_expandFunctions().value(func.toLower())))
2085 warn_msg(WarnDeprecated, "%s:%d: Using uppercased builtin functions is deprecated.",
2086 parser.file.toLatin1().constData(), parser.line_no);
2087 debug_msg(1, "Running project expand: %s(%s) [%d]",
2088 func.toLatin1().constData(), args.join("::").toLatin1().constData(), func_t);
2093 if(args.count() < 1 || args.count() > 3) {
2094 fprintf(stderr, "%s:%d: member(var, start, end) requires three arguments.\n",
2095 parser.file.toLatin1().constData(), parser.line_no);
2098 const QStringList &var = values(args.first(), place);
2099 int start = 0, end = 0;
2100 if(args.count() >= 2) {
2101 QString start_str = args[1];
2102 start = start_str.toInt(&ok);
2104 if(args.count() == 2) {
2105 int dotdot = start_str.indexOf("..");
2107 start = start_str.left(dotdot).toInt(&ok);
2109 end = start_str.mid(dotdot+2).toInt(&ok);
2113 fprintf(stderr, "%s:%d: member() argument 2 (start) '%s' invalid.\n",
2114 parser.file.toLatin1().constData(), parser.line_no,
2115 start_str.toLatin1().constData());
2118 if(args.count() == 3)
2119 end = args[2].toInt(&ok);
2121 fprintf(stderr, "%s:%d: member() argument 3 (end) '%s' invalid.\n",
2122 parser.file.toLatin1().constData(), parser.line_no,
2123 args[2].toLatin1().constData());
2128 start += var.count();
2131 if(start < 0 || start >= var.count() || end < 0 || end >= var.count()) {
2133 } else if(start < end) {
2134 for(int i = start; i <= end && (int)var.count() >= i; i++)
2137 for(int i = start; i >= end && (int)var.count() >= i && i >= 0; i--)
2145 if(args.count() != 1) {
2146 fprintf(stderr, "%s:%d: %s(var) requires one argument.\n",
2147 parser.file.toLatin1().constData(), parser.line_no, func.toLatin1().constData());
2149 const QStringList &var = values(args.first(), place);
2150 if(!var.isEmpty()) {
2151 if(func_t == E_FIRST)
2152 ret = QStringList(var[0]);
2154 ret = QStringList(var[var.size()-1]);
2159 if(args.count() < 1 || args.count() > 2) {
2160 fprintf(stderr, "%s:%d: cat(file) requires one argument.\n",
2161 parser.file.toLatin1().constData(), parser.line_no);
2163 QString file = Option::normalizePath(args[0]);
2167 bool singleLine = true;
2168 if (args.count() > 1) {
2169 if (!args.at(1).compare(QLatin1String("false"), Qt::CaseInsensitive))
2171 else if (!args.at(1).compare(QLatin1String("blob"), Qt::CaseInsensitive))
2173 else if (!args.at(1).compare(QLatin1String("lines"), Qt::CaseInsensitive))
2177 if(qfile.open(QIODevice::ReadOnly)) {
2178 QTextStream stream(&qfile);
2180 ret += stream.readAll();
2182 while (!stream.atEnd()) {
2184 ret += stream.readLine();
2186 ret += split_value_list(stream.readLine().trimmed());
2196 if(args.count() != 2) {
2197 fprintf(stderr, "%s:%d: fromfile(file, variable) requires two arguments.\n",
2198 parser.file.toLatin1().constData(), parser.line_no);
2200 QString seek_var = args[1], file = Option::normalizePath(args[0]);
2202 QHash<QString, QStringList> tmp;
2203 if(doProjectInclude(file, IncludeFlagNewParser, tmp) == IncludeSuccess) {
2204 if(tmp.contains("QMAKE_INTERNAL_INCLUDED_FILES")) {
2205 QStringList &out = place["QMAKE_INTERNAL_INCLUDED_FILES"];
2206 const QStringList &in = tmp["QMAKE_INTERNAL_INCLUDED_FILES"];
2207 for(int i = 0; i < in.size(); ++i) {
2208 if(out.indexOf(in[i]) == -1)
2212 ret = tmp[seek_var];
2217 if(args.count() < 1 || args.count() > 2) {
2218 fprintf(stderr, "%s:%d: eval(variable) requires one argument.\n",
2219 parser.file.toLatin1().constData(), parser.line_no);
2222 const QHash<QString, QStringList> *source = &place;
2223 if(args.count() == 2) {
2224 if(args.at(1) == "Global") {
2226 } else if(args.at(1) == "Local") {
2229 fprintf(stderr, "%s:%d: unexpected source to eval.\n", parser.file.toLatin1().constData(),
2233 ret += source->value(args.at(0));
2239 tmp.sprintf(".QMAKE_INTERNAL_TMP_VAR_%d", x++);
2240 ret = QStringList(tmp);
2241 QStringList &lst = (*((QHash<QString, QStringList>*)&place))[tmp];
2243 for(QStringList::ConstIterator arg_it = args.begin();
2244 arg_it != args.end(); ++arg_it)
2245 lst += split_value_list((*arg_it));
2248 if(args.count() < 1) {
2249 fprintf(stderr, "%s:%d: sprintf(format, ...) requires one argument.\n",
2250 parser.file.toLatin1().constData(), parser.line_no);
2252 QString tmp = args.at(0);
2253 for(int i = 1; i < args.count(); ++i)
2254 tmp = tmp.arg(args.at(i));
2255 ret = split_value_list(tmp);
2258 case E_FORMAT_NUMBER:
2259 if (args.count() > 2) {
2260 fprintf(stderr, "%s:%d: format_number(number[, options...]) requires one or two arguments.\n",
2261 parser.file.toLatin1().constData(), parser.line_no);
2266 bool zeropad = false;
2267 bool leftalign = false;
2268 enum { DefaultSign, PadSign, AlwaysSign } sign = DefaultSign;
2269 if (args.count() >= 2) {
2270 foreach (const QString &opt, split_value_list(args.at(1))) {
2271 if (opt.startsWith(QLatin1String("ibase="))) {
2272 ibase = opt.mid(6).toInt();
2273 } else if (opt.startsWith(QLatin1String("obase="))) {
2274 obase = opt.mid(6).toInt();
2275 } else if (opt.startsWith(QLatin1String("width="))) {
2276 width = opt.mid(6).toInt();
2277 } else if (opt == QLatin1String("zeropad")) {
2279 } else if (opt == QLatin1String("padsign")) {
2281 } else if (opt == QLatin1String("alwayssign")) {
2283 } else if (opt == QLatin1String("leftalign")) {
2286 fprintf(stderr, "%s:%d: format_number(): invalid format option %s.\n",
2287 parser.file.toLatin1().constData(), parser.line_no,
2288 opt.toLatin1().constData());
2293 if (args.at(0).contains(QLatin1Char('.'))) {
2294 fprintf(stderr, "%s:%d: format_number(): floats are currently not supported.\n",
2295 parser.file.toLatin1().constData(), parser.line_no);
2299 qlonglong num = args.at(0).toLongLong(&ok, ibase);
2301 fprintf(stderr, "%s:%d: format_number(): malformed number %s for base %d.\n",
2302 parser.file.toLatin1().constData(), parser.line_no,
2303 args.at(0).toLatin1().constData(), ibase);
2309 outstr = QLatin1Char('-');
2310 } else if (sign == AlwaysSign) {
2311 outstr = QLatin1Char('+');
2312 } else if (sign == PadSign) {
2313 outstr = QLatin1Char(' ');
2315 QString numstr = QString::number(num, obase);
2316 int space = width - outstr.length() - numstr.length();
2319 } else if (leftalign) {
2320 outstr += numstr + QString(space, QLatin1Char(' '));
2321 } else if (zeropad) {
2322 outstr += QString(space, QLatin1Char('0')) + numstr;
2324 outstr.prepend(QString(space, QLatin1Char(' ')));
2332 if(args.count() < 1 || args.count() > 4) {
2333 fprintf(stderr, "%s:%d: join(var, glue, before, after) requires four"
2334 "arguments.\n", parser.file.toLatin1().constData(), parser.line_no);
2336 QString glue, before, after;
2337 if(args.count() >= 2)
2339 if(args.count() >= 3)
2341 if(args.count() == 4)
2343 const QStringList &var = values(args.first(), place);
2345 ret = split_value_list(before + var.join(glue) + after);
2349 if(args.count() < 1 || args.count() > 2) {
2350 fprintf(stderr, "%s:%d split(var, sep) requires one or two arguments\n",
2351 parser.file.toLatin1().constData(), parser.line_no);
2353 QString sep = QString(Option::field_sep);
2354 if(args.count() >= 2)
2356 QStringList var = values(args.first(), place);
2357 for(QStringList::ConstIterator vit = var.begin(); vit != var.end(); ++vit) {
2358 QStringList lst = (*vit).split(sep);
2359 for(QStringList::ConstIterator spltit = lst.begin(); spltit != lst.end(); ++spltit)
2367 bool regexp = false;
2370 if(func_t == E_SECTION) {
2371 if(args.count() != 3 && args.count() != 4) {
2372 fprintf(stderr, "%s:%d section(var, sep, begin, end) requires three argument\n",
2373 parser.file.toLatin1().constData(), parser.line_no);
2377 beg = args[2].toInt();
2378 if(args.count() == 4)
2379 end = args[3].toInt();
2382 if(args.count() != 1) {
2383 fprintf(stderr, "%s:%d %s(var) requires one argument.\n",
2384 parser.file.toLatin1().constData(), parser.line_no, func.toLatin1().constData());
2388 sep = "[" + QRegExp::escape(Option::dir_sep) + "/]";
2389 if(func_t == E_DIRNAME)
2396 const QStringList &l = values(var, place);
2397 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
2398 QString separator = sep;
2400 ret += (*it).section(QRegExp(separator), beg, end);
2402 ret += (*it).section(separator, beg, end);
2407 if(args.count() != 2) {
2408 fprintf(stderr, "%s:%d find(var, str) requires two arguments\n",
2409 parser.file.toLatin1().constData(), parser.line_no);
2411 QRegExp regx(args[1]);
2412 const QStringList &var = values(args.first(), place);
2413 for(QStringList::ConstIterator vit = var.begin();
2414 vit != var.end(); ++vit) {
2415 if(regx.indexIn(*vit) != -1)
2421 if(args.count() < 1 || args.count() > 2) {
2422 fprintf(stderr, "%s:%d system(execut) requires one argument.\n",
2423 parser.file.toLatin1().constData(), parser.line_no);
2427 bool singleLine = true;
2428 if (args.count() > 1) {
2429 if (!args.at(1).compare(QLatin1String("false"), Qt::CaseInsensitive))
2431 else if (!args.at(1).compare(QLatin1String("blob"), Qt::CaseInsensitive))
2433 else if (!args.at(1).compare(QLatin1String("lines"), Qt::CaseInsensitive))
2436 QByteArray bytes = getCommandOutput(args.at(0));
2438 QTextStream stream(bytes);
2439 while (!stream.atEnd())
2440 ret += stream.readLine();
2442 QString output = QString::fromLocal8Bit(bytes);
2446 output.replace(QLatin1Char('\t'), QLatin1Char(' '));
2448 output.replace(QLatin1Char('\n'), QLatin1Char(' '));
2449 ret += split_value_list(output);
2455 if(args.count() != 1) {
2456 fprintf(stderr, "%s:%d unique(var) requires one argument.\n",
2457 parser.file.toLatin1().constData(), parser.line_no);
2459 const QStringList &var = values(args.first(), place);
2460 for(int i = 0; i < var.count(); i++) {
2461 if(!ret.contains(var[i]))
2467 if (args.count() != 1) {
2468 fprintf(stderr, "%s:%d reverse(var) requires one argument.\n",
2469 parser.file.toLatin1().constData(), parser.line_no);
2471 QStringList var = values(args.first(), place);
2472 for (int i = 0; i < var.size() / 2; i++)
2473 var.swap(i, var.size() - i - 1);
2480 case E_ESCAPE_EXPAND: {
2481 for(int i = 0; i < args.size(); ++i) {
2482 QChar *i_data = args[i].data();
2483 int i_len = args[i].length();
2484 for(int x = 0; x < i_len; ++x) {
2485 if(*(i_data+x) == '\\' && x < i_len-1) {
2486 if(*(i_data+x+1) == '\\') {
2491 } mapped_quotes[] = {
2497 for(int i = 0; mapped_quotes[i].in; ++i) {
2498 if(*(i_data+x+1) == mapped_quotes[i].in) {
2499 *(i_data+x) = mapped_quotes[i].out;
2501 memmove(i_data+x+1, i_data+x+2, (i_len-x-2)*sizeof(QChar));
2509 ret.append(QString(i_data, i_len));
2513 for(int i = 0; i < args.size(); ++i)
2514 ret += QRegExp::escape(args[i]);
2517 if (args.count() != 1) {
2518 fprintf(stderr, "%s:%d val_escape(var) requires one argument.\n",
2519 parser.file.toLatin1().constData(), parser.line_no);
2521 QStringList vals = values(args.at(0), place);
2522 ret.reserve(vals.length());
2523 foreach (const QString &str, vals)
2524 ret += quoteValue(str);
2529 for(int i = 0; i < args.size(); ++i) {
2530 if(func_t == E_UPPER)
2531 ret += args[i].toUpper();
2533 ret += args[i].toLower();
2537 if(args.count() != 1 && args.count() != 2) {
2538 fprintf(stderr, "%s:%d files(pattern) requires one argument.\n",
2539 parser.file.toLatin1().constData(), parser.line_no);
2541 bool recursive = false;
2542 if(args.count() == 2)
2543 recursive = (args[1].toLower() == "true" || args[1].toInt());
2545 QString r = Option::normalizePath(args[0]);
2546 int slash = r.lastIndexOf(QLatin1Char('/'));
2548 dirs.append(r.left(slash));
2554 QRegExp regex(r, Qt::CaseSensitive, QRegExp::Wildcard);
2555 for(int d = 0; d < dirs.count(); d++) {
2556 QString dir = dirs[d];
2557 if (!dir.isEmpty() && !dir.endsWith(QLatin1Char('/')))
2561 for(int i = 0; i < (int)qdir.count(); ++i) {
2562 if(qdir[i] == "." || qdir[i] == "..")
2564 QString fname = dir + qdir[i];
2565 if(QFileInfo(fname).isDir()) {
2569 if(regex.exactMatch(qdir[i]))
2576 if(args.count() != 1) {
2577 fprintf(stderr, "%s:%d prompt(question) requires one argument.\n",
2578 parser.file.toLatin1().constData(), parser.line_no);
2579 } else if(pfile == "-") {
2580 fprintf(stderr, "%s:%d prompt(question) cannot be used when '-o -' is used.\n",
2581 parser.file.toLatin1().constData(), parser.line_no);
2583 QString msg = fixEnvVariables(args.first());
2584 if(!msg.endsWith("?"))
2586 fprintf(stderr, "Project %s: %s ", func.toUpper().toLatin1().constData(),
2587 msg.toLatin1().constData());
2590 if(qfile.open(stdin, QIODevice::ReadOnly)) {
2591 QTextStream t(&qfile);
2592 ret = split_value_list(t.readLine());
2597 if(args.count() != 3 ) {
2598 fprintf(stderr, "%s:%d replace(var, before, after) requires three arguments\n",
2599 parser.file.toLatin1().constData(), parser.line_no);
2601 const QRegExp before( args[1] );
2602 const QString after( args[2] );
2603 QStringList var = values(args.first(), place);
2604 for(QStringList::Iterator it = var.begin(); it != var.end(); ++it)
2605 ret += it->replace(before, after);
2609 if(args.count() != 1) {
2610 fprintf(stderr, "%s:%d: size(var) requires one argument.\n",
2611 parser.file.toLatin1().constData(), parser.line_no);
2613 int size = values(args[0], place).size();
2614 ret += QString::number(size);
2617 case E_SORT_DEPENDS:
2618 case E_RESOLVE_DEPENDS: {
2619 if(args.count() < 1 || args.count() > 2) {
2620 fprintf(stderr, "%s:%d: %s(var, prefix) requires one or two arguments.\n",
2621 parser.file.toLatin1().constData(), parser.line_no, func.toLatin1().constData());
2623 QHash<QString, QSet<QString> > dependencies;
2624 QHash<QString, QStringList> dependees;
2625 QStringList rootSet;
2627 QStringList orgList = values(args[0], place);
2628 populateDeps(orgList, (args.count() != 2 ? QString() : args[1]),
2629 dependencies, dependees, rootSet, place);
2631 for (int i = 0; i < rootSet.size(); ++i) {
2632 const QString &item = rootSet.at(i);
2633 if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item))
2635 foreach (const QString &dep, dependees[item]) {
2636 QSet<QString> &dset = dependencies[dep];
2637 dset.remove(rootSet.at(i)); // *Don't* use 'item' - rootSet may have changed!
2644 case E_ENUMERATE_VARS:
2645 ret += place.keys();
2648 QString val = QDir::cleanPath(QFileInfo(args.at(0)).absoluteFilePath());
2649 if (Option::mkfile::source_root.isEmpty())
2651 else if (val.startsWith(Option::mkfile::source_root))
2652 ret += Option::mkfile::build_root + val.mid(Option::mkfile::source_root.length());
2654 case E_ABSOLUTE_PATH:
2655 if (args.count() > 2)
2656 fprintf(stderr, "%s:%d absolute_path(path[, base]) requires one or two arguments.\n",
2657 parser.file.toLatin1().constData(), parser.line_no);
2659 ret += QDir::cleanPath(QDir(args.count() > 1 ? args.at(1) : QString())
2660 .absoluteFilePath(args.at(0)));
2662 case E_RELATIVE_PATH:
2663 if (args.count() > 2)
2664 fprintf(stderr, "%s:%d relative_path(path[, base]) requires one or two arguments.\n",
2665 parser.file.toLatin1().constData(), parser.line_no);
2667 ret += QDir::cleanPath(QDir(args.count() > 1 ? args.at(1) : QString())
2668 .relativeFilePath(args.at(0)));
2671 if (args.count() != 1)
2672 fprintf(stderr, "%s:%d clean_path(path) requires one argument.\n",
2673 parser.file.toLatin1().constData(), parser.line_no);
2675 ret += QDir::cleanPath(args.at(0));
2678 if (args.count() != 1)
2679 fprintf(stderr, "%s:%d native_path(path) requires one argument.\n",
2680 parser.file.toLatin1().constData(), parser.line_no);
2682 ret += Option::fixPathToTargetOS(args.at(0), false);
2685 if (args.count() != 1)
2686 fprintf(stderr, "%s:%d shell_quote(args) requires one argument.\n",
2687 parser.file.toLatin1().constData(), parser.line_no);
2689 ret += shellQuote(args.at(0));
2692 fprintf(stderr, "%s:%d: Unknown replace function: %s\n",
2693 parser.file.toLatin1().constData(), parser.line_no,
2694 func.toLatin1().constData());
2701 QMakeProject::doProjectTest(QString func, QStringList args, QHash<QString, QStringList> &place)
2703 QList<QStringList> args_list;
2704 for(int i = 0; i < args.size(); ++i) {
2705 QStringList arg = split_value_list(args[i]), tmp;
2706 for(int i = 0; i < arg.size(); ++i)
2707 tmp += doVariableReplaceExpand(arg[i], place);
2710 return doProjectTest(func, args_list, place);
2714 QMakeProject::doProjectTest(QString func, QList<QStringList> args_list, QHash<QString, QStringList> &place)
2716 func = func.trimmed();
2718 if(testFunctions.contains(func)) {
2719 FunctionBlock *defined = testFunctions[func];
2721 function_blocks.push(defined);
2722 defined->exec(args_list, this, place, ret);
2723 bool correct = function_blocks.pop() == defined;
2724 Q_ASSERT(correct); Q_UNUSED(correct);
2729 if(ret.first() == "true") {
2731 } else if(ret.first() == "false") {
2735 int val = ret.first().toInt(&ok);
2738 fprintf(stderr, "%s:%d Unexpected return value from test %s [%s].\n",
2739 parser.file.toLatin1().constData(),
2740 parser.line_no, func.toLatin1().constData(),
2741 ret.join("::").toLatin1().constData());
2748 QStringList args; //why don't the builtin functions just use args_list? --Sam
2749 for(int i = 0; i < args_list.size(); ++i)
2750 args += args_list[i].join(QString(Option::field_sep));
2752 TestFunc func_t = qmake_testFunctions().value(func);
2753 debug_msg(1, "Running project test: %s(%s) [%d]",
2754 func.toLatin1().constData(), args.join("::").toLatin1().constData(), func_t);
2758 return doProjectCheckReqs(args, place);
2760 case T_GREATERTHAN: {
2761 if(args.count() != 2) {
2762 fprintf(stderr, "%s:%d: %s(variable, value) requires two arguments.\n", parser.file.toLatin1().constData(),
2763 parser.line_no, func.toLatin1().constData());
2766 QString rhs(args[1]), lhs(values(args[0], place).join(QString(Option::field_sep)));
2768 int rhs_int = rhs.toInt(&ok);
2769 if(ok) { // do integer compare
2770 int lhs_int = lhs.toInt(&ok);
2772 if(func_t == T_GREATERTHAN)
2773 return lhs_int > rhs_int;
2774 return lhs_int < rhs_int;
2777 if(func_t == T_GREATERTHAN)
2781 if(args.count() != 1) {
2782 fprintf(stderr, "%s:%d: if(condition) requires one argument.\n", parser.file.toLatin1().constData(),
2786 const QString cond = args.first();
2787 const QChar *d = cond.unicode();
2789 bool ret = true, or_op = false;
2791 for(int d_off = 0, parens = 0, d_len = cond.size(); d_off < d_len; ++d_off) {
2792 if(!quote.isNull()) {
2793 if(*(d+d_off) == quote)
2795 } else if(*(d+d_off) == '(') {
2797 } else if(*(d+d_off) == ')') {
2799 } else if(*(d+d_off) == '"' /*|| *(d+d_off) == '\''*/) {
2802 if(!parens && quote.isNull() && (*(d+d_off) == QLatin1Char(':') || *(d+d_off) == QLatin1Char('|') || d_off == d_len-1)) {
2803 if(d_off == d_len-1)
2805 if(!test.isEmpty()) {
2807 ret = doProjectTest(test, place);
2810 if(*(d+d_off) == QLatin1Char(':')) {
2812 } else if(*(d+d_off) == QLatin1Char('|')) {
2821 if(args.count() != 2) {
2822 fprintf(stderr, "%s:%d: %s(variable, value) requires two arguments.\n", parser.file.toLatin1().constData(),
2823 parser.line_no, func.toLatin1().constData());
2826 return values(args[0], place).join(QString(Option::field_sep)) == args[1];
2828 if(args.count() != 1) {
2829 fprintf(stderr, "%s:%d: exists(file) requires one argument.\n", parser.file.toLatin1().constData(),
2833 QString file = Option::normalizePath(args.first());
2835 if(QFile::exists(file))
2837 //regular expression I guess
2838 QString dirstr = qmake_getpwd();
2839 int slsh = file.lastIndexOf(QLatin1Char('/'));
2841 dirstr = file.left(slsh+1);
2842 file = file.right(file.length() - slsh - 1);
2844 return QDir(dirstr).entryList(QStringList(file)).count(); }
2846 if(args.count() != 1) {
2847 fprintf(stderr, "%s:%d: export(variable) requires one argument.\n", parser.file.toLatin1().constData(),
2851 for(int i = 0; i < function_blocks.size(); ++i) {
2852 FunctionBlock *f = function_blocks.at(i);
2853 f->vars[args[0]] = values(args[0], place);
2854 if(!i && f->calling_place)
2855 (*f->calling_place)[args[0]] = values(args[0], place);
2859 if(args.count() != 1) {
2860 fprintf(stderr, "%s:%d: clear(variable) requires one argument.\n", parser.file.toLatin1().constData(),
2864 if(!place.contains(args[0]))
2866 place[args[0]].clear();
2869 if(args.count() != 1) {
2870 fprintf(stderr, "%s:%d: unset(variable) requires one argument.\n", parser.file.toLatin1().constData(),
2874 if(!place.contains(args[0]))
2876 place.remove(args[0]);
2879 if(args.count() < 1 && 0) {
2880 fprintf(stderr, "%s:%d: eval(project) requires one argument.\n", parser.file.toLatin1().constData(),
2884 QString project = args.join(" ");
2885 parser_info pi = parser;
2886 parser.from_file = false;
2887 parser.file = "(eval)";
2889 QTextStream t(&project, QIODevice::ReadOnly);
2890 bool ret = read(t, place);
2894 if(args.count() < 1 || args.count() > 2) {
2895 fprintf(stderr, "%s:%d: CONFIG(config) requires one argument.\n", parser.file.toLatin1().constData(),
2899 if(args.count() == 1)
2900 return isActiveConfig(args[0]);
2901 const QStringList mutuals = args[1].split('|');
2902 const QStringList &configs = values("CONFIG", place);
2903 for(int i = configs.size()-1; i >= 0; i--) {
2904 for(int mut = 0; mut < mutuals.count(); mut++) {
2905 if(configs[i] == mutuals[mut].trimmed())
2906 return (configs[i] == args[0]);
2911 if(args.count() < 1 || args.count() > 2) {
2912 fprintf(stderr, "%s:%d: system(exec) requires one argument.\n", parser.file.toLatin1().constData(),
2916 if(args.count() == 2) {
2917 const QString sarg = args[1];
2918 if (sarg.toLower() == "true" || sarg.toInt())
2919 warn_msg(WarnParser, "%s:%d: system()'s second argument is now hard-wired to false.\n",
2920 parser.file.toLatin1().constData(), parser.line_no);
2922 return system(args[0].toLatin1().constData()) == 0;
2924 if(function_blocks.isEmpty()) {
2925 fprintf(stderr, "%s:%d unexpected return()\n",
2926 parser.file.toLatin1().constData(), parser.line_no);
2928 FunctionBlock *f = function_blocks.top();
2929 f->cause_return = true;
2930 if(args_list.count() >= 1)
2931 f->return_value += args_list[0];
2936 iterator->cause_break = true;
2938 fprintf(stderr, "%s:%d unexpected break()\n",
2939 parser.file.toLatin1().constData(), parser.line_no);
2943 iterator->cause_next = true;
2945 fprintf(stderr, "%s:%d unexpected next()\n",
2946 parser.file.toLatin1().constData(), parser.line_no);
2949 if(args.count() < 1 || args.count() > 2) {
2950 fprintf(stderr, "%s:%d: defined(function) requires one argument.\n",
2951 parser.file.toLatin1().constData(), parser.line_no);
2953 if(args.count() > 1) {
2954 if(args[1] == "test")
2955 return testFunctions.contains(args[0]);
2956 else if(args[1] == "replace")
2957 return replaceFunctions.contains(args[0]);
2958 else if(args[1] == "var")
2959 return place.contains(args[0]);
2960 fprintf(stderr, "%s:%d: defined(function, type): unexpected type [%s].\n",
2961 parser.file.toLatin1().constData(), parser.line_no,
2962 args[1].toLatin1().constData());
2964 if(replaceFunctions.contains(args[0]) || testFunctions.contains(args[0]))
2970 if(args.count() < 2 || args.count() > 3) {
2971 fprintf(stderr, "%s:%d: contains(var, val) requires at lesat 2 arguments.\n",
2972 parser.file.toLatin1().constData(), parser.line_no);
2975 QRegExp regx(args[1]);
2976 const QStringList &l = values(args[0], place);
2977 if(args.count() == 2) {
2978 for(int i = 0; i < l.size(); ++i) {
2979 const QString val = l[i];
2980 if(regx.exactMatch(val) || val == args[1])
2984 const QStringList mutuals = args[2].split('|');
2985 for(int i = l.size()-1; i >= 0; i--) {
2986 const QString val = l[i];
2987 for(int mut = 0; mut < mutuals.count(); mut++) {
2988 if(val == mutuals[mut].trimmed())
2989 return (regx.exactMatch(val) || val == args[1]);
2995 if(args.count() < 2 || args.count() > 3) {
2996 fprintf(stderr, "%s:%d: infile(file, var, val) requires at least 2 arguments.\n",
2997 parser.file.toLatin1().constData(), parser.line_no);
3002 QHash<QString, QStringList> tmp;
3003 if(doProjectInclude(Option::normalizePath(args[0]), IncludeFlagNewParser, tmp) == IncludeSuccess) {
3004 if(tmp.contains("QMAKE_INTERNAL_INCLUDED_FILES")) {
3005 QStringList &out = place["QMAKE_INTERNAL_INCLUDED_FILES"];
3006 const QStringList &in = tmp["QMAKE_INTERNAL_INCLUDED_FILES"];
3007 for(int i = 0; i < in.size(); ++i) {
3008 if(out.indexOf(in[i]) == -1)
3012 if(args.count() == 2) {
3013 ret = tmp.contains(args[1]);
3015 QRegExp regx(args[2]);
3016 const QStringList &l = tmp[args[1]];
3017 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
3018 if(regx.exactMatch((*it)) || (*it) == args[2]) {
3027 if(args.count() != 2 && args.count() != 3) {
3028 fprintf(stderr, "%s:%d: count(var, count) requires two arguments.\n", parser.file.toLatin1().constData(),
3032 if(args.count() == 3) {
3033 QString comp = args[2];
3034 if(comp == ">" || comp == "greaterThan")
3035 return values(args[0], place).count() > args[1].toInt();
3037 return values(args[0], place).count() >= args[1].toInt();
3038 if(comp == "<" || comp == "lessThan")
3039 return values(args[0], place).count() < args[1].toInt();
3041 return values(args[0], place).count() <= args[1].toInt();
3042 if(comp == "equals" || comp == "isEqual" || comp == "=" || comp == "==")
3043 return values(args[0], place).count() == args[1].toInt();
3044 fprintf(stderr, "%s:%d: unexpected modifier to count(%s)\n", parser.file.toLatin1().constData(),
3045 parser.line_no, comp.toLatin1().constData());
3048 return values(args[0], place).count() == args[1].toInt();
3050 if(args.count() != 1) {
3051 fprintf(stderr, "%s:%d: isEmpty(var) requires one argument.\n", parser.file.toLatin1().constData(),
3055 return values(args[0], place).isEmpty();
3059 const bool include_statement = (func_t == T_INCLUDE);
3060 bool ignore_error = false;
3061 if(args.count() >= 2) {
3062 if(func_t == T_INCLUDE) {
3063 parseInto = args[1];
3064 if (args.count() == 3){
3065 QString sarg = args[2];
3066 if (sarg.toLower() == "true" || sarg.toInt())
3067 ignore_error = true;
3070 QString sarg = args[1];
3071 ignore_error = (sarg.toLower() == "true" || sarg.toInt());
3073 } else if(args.count() != 1) {
3074 QString func_desc = "load(feature)";
3075 if(include_statement)
3076 func_desc = "include(file)";
3077 fprintf(stderr, "%s:%d: %s requires one argument.\n", parser.file.toLatin1().constData(),
3078 parser.line_no, func_desc.toLatin1().constData());
3081 QString file = Option::normalizePath(args.first());
3082 uchar flags = IncludeFlagNone;
3083 if(!include_statement)
3084 flags |= IncludeFlagFeature;
3085 IncludeStatus stat = IncludeFailure;
3086 if(!parseInto.isEmpty()) {
3087 QHash<QString, QStringList> symbols;
3088 stat = doProjectInclude(file, flags|IncludeFlagNewProject, symbols);
3089 if(stat == IncludeSuccess) {
3090 QHash<QString, QStringList> out_place;
3091 for(QHash<QString, QStringList>::ConstIterator it = place.begin(); it != place.end(); ++it) {
3092 const QString var = it.key();
3093 if(var != parseInto && !var.startsWith(parseInto + "."))
3094 out_place.insert(var, it.value());
3096 for(QHash<QString, QStringList>::ConstIterator it = symbols.begin(); it != symbols.end(); ++it) {
3097 const QString var = it.key();
3098 if(!var.startsWith("."))
3099 out_place.insert(parseInto + "." + it.key(), it.value());
3104 stat = doProjectInclude(file, flags, place);
3106 if(stat == IncludeFeatureAlreadyLoaded) {
3107 warn_msg(WarnParser, "%s:%d: Duplicate of loaded feature %s",
3108 parser.file.toLatin1().constData(), parser.line_no, file.toLatin1().constData());
3109 } else if(stat == IncludeNoExist && !ignore_error) {
3110 warn_msg(WarnAll, "%s:%d: Unable to find file for inclusion %s",
3111 parser.file.toLatin1().constData(), parser.line_no, file.toLatin1().constData());
3113 } else if(stat >= IncludeFailure) {
3115 printf("Project LOAD(): Feature %s cannot be found.\n", file.toLatin1().constData());
3117 #if defined(QT_BUILD_QMAKE_LIBRARY)
3127 if(args.count() != 2) {
3128 fprintf(stderr, "%s:%d: debug(level, message) requires one argument.\n", parser.file.toLatin1().constData(),
3132 QString msg = fixEnvVariables(args[1]);
3133 debug_msg(args[0].toInt(), "Project DEBUG: %s", msg.toLatin1().constData());
3139 if(args.count() != 1) {
3140 fprintf(stderr, "%s:%d: %s(message) requires one argument.\n", parser.file.toLatin1().constData(),
3141 parser.line_no, func.toLatin1().constData());
3144 QString msg = fixEnvVariables(args.first());
3145 if (func_t == T_LOG) {
3146 fputs(msg.toLatin1().constData(), stderr);
3148 fprintf(stderr, "Project %s: %s\n", func.toUpper().toLatin1().constData(), msg.toLatin1().constData());
3149 if (func == "error")
3150 #if defined(QT_BUILD_QMAKE_LIBRARY)
3158 if (args.count() != 1) {
3159 fprintf(stderr, "%s:%d: option() requires one argument.\n",
3160 parser.file.toLatin1().constData(), parser.line_no);
3163 if (args.first() == "recursive") {
3165 } else if (args.first() == "host_build") {
3166 if (!host_build && isActiveConfig("cross_compile")) {
3168 need_restart = true;
3171 fprintf(stderr, "%s:%d: unrecognized option() argument '%s'.\n",
3172 parser.file.toLatin1().constData(), parser.line_no,
3173 args.first().toLatin1().constData());
3178 if (args.count() > 3) {
3179 fprintf(stderr, "%s:%d: cache(var, [set|add|sub] [transient], [srcvar]) requires one to three arguments.\n",
3180 parser.file.toLatin1().constData(), parser.line_no);
3183 bool persist = true;
3184 enum { CacheSet, CacheAdd, CacheSub } mode = CacheSet;
3186 if (args.count() >= 2) {
3187 foreach (const QString &opt, split_value_list(args.at(1))) {
3188 if (opt == QLatin1String("transient")) {
3190 } else if (opt == QLatin1String("set")) {
3192 } else if (opt == QLatin1String("add")) {
3194 } else if (opt == QLatin1String("sub")) {
3197 fprintf(stderr, "%s:%d: cache(): invalid flag %s.\n",
3198 parser.file.toLatin1().constData(), parser.line_no,
3199 opt.toLatin1().constData());
3203 if (args.count() >= 3) {
3204 srcvar = args.at(2);
3205 } else if (mode != CacheSet) {
3206 fprintf(stderr, "%s:%d: cache(): modes other than 'set' require a source variable.\n",
3207 parser.file.toLatin1().constData(), parser.line_no);
3212 QString dstvar = args.at(0);
3213 if (!dstvar.isEmpty()) {
3214 if (srcvar.isEmpty())
3216 if (!place.contains(srcvar)) {
3217 fprintf(stderr, "%s:%d: variable %s is not defined.\n",
3218 parser.file.toLatin1().constData(), parser.line_no,
3219 srcvar.toLatin1().constData());
3222 // The current ("native") value can differ from the cached value, e.g., the current
3223 // CONFIG will typically have more values than the cached one. Therefore we deal with
3225 const QStringList diffval = values(srcvar, place);
3226 const QStringList oldval = base_vars.value(dstvar);
3228 if (mode == CacheSet) {
3232 if (mode == CacheAdd)
3235 subAll(&newval, diffval);
3237 // We assume that whatever got the cached value to be what it is now will do so
3238 // the next time as well, so it is OK that the early exit here will skip the
3239 // persisting as well.
3240 if (oldval == newval)
3242 base_vars[dstvar] = newval;
3244 if (dstvar == "QMAKEPATH")
3245 cached_qmakepath = newval;
3246 else if (dstvar == "QMAKEFEATURES")
3247 cached_qmakefeatures = newval;
3250 invalidateFeatureRoots();
3255 if (mode == CacheAdd)
3256 varstr += QLatin1String(" +=");
3257 else if (mode == CacheSub)
3258 varstr += QLatin1String(" -=");
3260 varstr += QLatin1String(" =");
3261 if (diffval.count() == 1) {
3262 varstr += QLatin1Char(' ');
3263 varstr += quoteValue(diffval.at(0));
3264 } else if (!diffval.isEmpty()) {
3265 foreach (const QString &vval, diffval) {
3266 varstr += QLatin1String(" \\\n ");
3267 varstr += quoteValue(vval);
3270 varstr += QLatin1Char('\n');
3272 if (cachefile.isEmpty()) {
3273 cachefile = Option::output_dir + QLatin1String("/.qmake.cache");
3274 printf("Info: creating cache file %s\n", cachefile.toLatin1().constData());
3275 cached_build_root = Option::output_dir;
3276 cached_source_root = values("_PRO_FILE_PWD_", place).first();
3277 if (cached_source_root == cached_build_root)
3278 cached_source_root.clear();
3279 invalidateFeatureRoots();
3281 QFileInfo qfi(Option::mkfile::cachefile);
3282 if (!QDir::current().mkpath(qfi.path())) {
3283 fprintf(stderr, "%s:%d: ERROR creating cache directory %s\n",
3284 parser.file.toLatin1().constData(), parser.line_no,
3285 qfi.path().toLatin1().constData());
3289 if (!writeFile(cachefile, QIODevice::Append, varstr, &errStr)) {
3290 fprintf(stderr, "ERROR writing cache file %s: %s\n",
3291 cachefile.toLatin1().constData(), errStr.toLatin1().constData());
3292 #if defined(QT_BUILD_QMAKE_LIBRARY)
3300 if (args.count() != 1) {
3301 fprintf(stderr, "%s:%d: mkpath(name) requires one argument.\n",
3302 parser.file.toLatin1().constData(), parser.line_no);
3305 if (!QDir::current().mkpath(args.at(0))) {
3306 fprintf(stderr, "%s:%d: ERROR creating directory %s\n",
3307 parser.file.toLatin1().constData(), parser.line_no,
3308 QDir::toNativeSeparators(args.at(0)).toLatin1().constData());
3312 case T_WRITE_FILE: {
3313 if (args.count() > 3) {
3314 fprintf(stderr, "%s:%d: write_file(name, [content var, [append]]) requires one to three arguments.\n",
3315 parser.file.toLatin1().constData(), parser.line_no);
3318 QIODevice::OpenMode mode = QIODevice::Truncate;
3320 if (args.count() >= 2) {
3321 QStringList vals = values(args.at(1), place);
3322 if (!vals.isEmpty())
3323 contents = vals.join(QLatin1String("\n")) + QLatin1Char('\n');
3324 if (args.count() >= 3)
3325 if (!args.at(2).compare(QLatin1String("append"), Qt::CaseInsensitive))
3326 mode = QIODevice::Append;
3328 QFileInfo qfi(args.at(0));
3329 if (!QDir::current().mkpath(qfi.path())) {
3330 fprintf(stderr, "%s:%d: ERROR creating directory %s\n",
3331 parser.file.toLatin1().constData(), parser.line_no,
3332 qfi.path().toLatin1().constData());
3336 if (!writeFile(args.at(0), mode, contents, &errStr)) {
3337 fprintf(stderr, "%s:%d ERROR writing %s: %s\n",
3338 parser.file.toLatin1().constData(), parser.line_no,
3339 args.at(0).toLatin1().constData(), errStr.toLatin1().constData());
3344 if (args.count() != 2) {
3345 fprintf(stderr, "%s:%d: touch(file, reffile) requires two arguments.\n",
3346 parser.file.toLatin1().constData(), parser.line_no);
3351 if (stat(args.at(1).toLocal8Bit().constData(), &st)) {
3352 fprintf(stderr, "%s:%d: ERROR: cannot stat() reference file %s: %s.\n",
3353 parser.file.toLatin1().constData(), parser.line_no,
3354 args.at(1).toLatin1().constData(), strerror(errno));
3358 utb.actime = time(0);
3359 utb.modtime = st.st_mtime;
3360 if (utime(args.at(0).toLocal8Bit().constData(), &utb)) {
3361 fprintf(stderr, "%s:%d: ERROR: cannot touch %s: %s.\n",
3362 parser.file.toLatin1().constData(), parser.line_no,
3363 args.at(0).toLatin1().constData(), strerror(errno));
3367 HANDLE rHand = CreateFile((wchar_t*)args.at(1).utf16(),
3368 GENERIC_READ, FILE_SHARE_READ,
3369 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
3370 if (rHand == INVALID_HANDLE_VALUE) {
3371 fprintf(stderr, "%s:%d: ERROR: cannot open() reference file %s: %s.\n",
3372 parser.file.toLatin1().constData(), parser.line_no,
3373 args.at(1).toLatin1().constData(),
3374 windowsErrorCode().toLatin1().constData());
3378 GetFileTime(rHand, 0, 0, &ft);
3380 HANDLE wHand = CreateFile((wchar_t*)args.at(0).utf16(),
3381 GENERIC_WRITE, FILE_SHARE_READ,
3382 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
3383 if (wHand == INVALID_HANDLE_VALUE) {
3384 fprintf(stderr, "%s:%d: ERROR: cannot open %s: %s.\n",
3385 parser.file.toLatin1().constData(), parser.line_no,
3386 args.at(0).toLatin1().constData(),
3387 windowsErrorCode().toLatin1().constData());
3390 SetFileTime(wHand, 0, 0, &ft);
3395 fprintf(stderr, "%s:%d: Unknown test function: %s\n", parser.file.toLatin1().constData(), parser.line_no,
3396 func.toLatin1().constData());
3402 QMakeProject::doProjectCheckReqs(const QStringList &deps, QHash<QString, QStringList> &place)
3405 for(QStringList::ConstIterator it = deps.begin(); it != deps.end(); ++it) {
3406 bool test = doProjectTest((*it), place);
3408 debug_msg(1, "Project Parser: %s:%d Failed test: REQUIRES = %s",
3409 parser.file.toLatin1().constData(), parser.line_no,
3410 (*it).toLatin1().constData());
3411 place["QMAKE_FAILED_REQUIREMENTS"].append((*it));
3419 QMakeProject::test(const QString &v)
3421 QHash<QString, QStringList> tmp = vars;
3422 return doProjectTest(v, tmp);
3426 QMakeProject::test(const QString &func, const QList<QStringList> &args)
3428 QHash<QString, QStringList> tmp = vars;
3429 return doProjectTest(func, args, tmp);
3433 QMakeProject::expand(const QString &str)
3436 QHash<QString, QStringList> tmp = vars;
3437 const QStringList ret = doVariableReplaceExpand(str, tmp, &ok);
3440 return QStringList();
3444 QMakeProject::expand(const QString &str, const QString &file, int line)
3447 parser_info pi = parser;
3449 parser.line_no = line;
3450 parser.from_file = false;
3451 QHash<QString, QStringList> tmp = vars;
3452 const QStringList ret = doVariableReplaceExpand(str, tmp, &ok);
3454 return ok ? ret.join(QString(Option::field_sep)) : QString();
3458 QMakeProject::expand(const QString &func, const QList<QStringList> &args)
3460 QHash<QString, QStringList> tmp = vars;
3461 return doProjectExpand(func, args, tmp);
3465 QMakeProject::doVariableReplace(QString &str, QHash<QString, QStringList> &place)
3468 str = doVariableReplaceExpand(str, place, &ret).join(QString(Option::field_sep));
3473 QMakeProject::doVariableReplaceExpand(const QString &str, QHash<QString, QStringList> &place, bool *ok)
3481 const ushort LSQUARE = '[';
3482 const ushort RSQUARE = ']';
3483 const ushort LCURLY = '{';
3484 const ushort RCURLY = '}';
3485 const ushort LPAREN = '(';
3486 const ushort RPAREN = ')';
3487 const ushort DOLLAR = '$';
3488 const ushort SLASH = '\\';
3489 const ushort UNDERSCORE = '_';
3490 const ushort DOT = '.';
3491 const ushort SPACE = ' ';
3492 const ushort TAB = '\t';
3493 const ushort SINGLEQUOTE = '\'';
3494 const ushort DOUBLEQUOTE = '"';
3496 ushort unicode, quote = 0;
3497 const QChar *str_data = str.data();
3498 const int str_len = str.length();
3505 for(int i = 0; i < str_len; ++i) {
3506 unicode = str_data[i].unicode();
3507 const int start_var = i;
3508 if(unicode == DOLLAR && str_len > i+2) {
3509 unicode = str_data[++i].unicode();
3510 if(unicode == DOLLAR) {
3514 enum { VAR, ENVIRON, FUNCTION, PROPERTY } var_type = VAR;
3515 unicode = str_data[++i].unicode();
3516 if(unicode == LSQUARE) {
3517 unicode = str_data[++i].unicode();
3519 var_type = PROPERTY;
3520 } else if(unicode == LCURLY) {
3521 unicode = str_data[++i].unicode();
3524 } else if(unicode == LPAREN) {
3525 unicode = str_data[++i].unicode();
3530 if(!(unicode & (0xFF<<8)) &&
3531 unicode != DOT && unicode != UNDERSCORE &&
3532 //unicode != SINGLEQUOTE && unicode != DOUBLEQUOTE &&
3533 (unicode < 'a' || unicode > 'z') && (unicode < 'A' || unicode > 'Z') &&
3534 (unicode < '0' || unicode > '9') && (!term || unicode != '/'))
3536 var.append(QChar(unicode));
3539 unicode = str_data[i].unicode();
3540 // at this point, i points to either the 'term' or 'next' character (which is in unicode)
3542 if(var_type == VAR && unicode == LPAREN) {
3543 var_type = FUNCTION;
3548 unicode = str_data[i].unicode();
3549 if(unicode == LPAREN) {
3551 } else if(unicode == RPAREN) {
3556 args.append(QChar(unicode));
3559 unicode = str_data[i].unicode();
3562 // at this point i is pointing to the 'next' character (which is in unicode)
3563 // this might actually be a term character since you can do $${func()}
3566 if(unicode != term) {
3567 qmake_error_msg("Missing " + QString(term) + " terminator [found " + (unicode?QString(unicode):QString("end-of-line")) + "]");
3570 return QStringList();
3573 // move the 'cursor' back to the last char of the thing we were looking at
3576 // since i never points to the 'next' character, there is no reason for this to be set
3579 QStringList replacement;
3580 if(var_type == ENVIRON) {
3581 replacement = split_value_list(QString::fromLocal8Bit(qgetenv(var.toLatin1().constData())));
3582 } else if(var_type == PROPERTY) {
3584 replacement = split_value_list(prop->value(var));
3585 } else if(var_type == FUNCTION) {
3586 replacement = doProjectExpand(var, args, place);
3587 } else if(var_type == VAR) {
3588 replacement = values(var, place);
3590 if(!(replaced++) && start_var)
3591 current = str.left(start_var);
3592 if(!replacement.isEmpty()) {
3594 current += replacement.join(QString(Option::field_sep));
3596 current += replacement.takeFirst();
3597 if(!replacement.isEmpty()) {
3598 if(!current.isEmpty())
3599 ret.append(current);
3600 current = replacement.takeLast();
3601 if(!replacement.isEmpty())
3606 debug_msg(2, "Project Parser [var replace]: %s -> %s",
3607 str.toLatin1().constData(), var.toLatin1().constData(),
3608 replacement.join("::").toLatin1().constData());
3611 current.append("$");
3614 if(quote && unicode == quote) {
3617 } else if(unicode == SLASH) {
3618 bool escape = false;
3619 const char *symbols = "[]{}()$\\'\"";
3620 for(const char *s = symbols; *s; ++s) {
3621 if(str_data[i+1].unicode() == (ushort)*s) {
3625 current = str.left(start_var);
3626 current.append(str.at(i));
3630 if(!escape && !backslashWarned) {
3631 backslashWarned = true;
3632 warn_msg(WarnDeprecated, "%s:%d: Unescaped backslashes are deprecated.",
3633 parser.file.toLatin1().constData(), parser.line_no);
3635 if(escape || !replaced)
3637 } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
3640 if(!(replaced++) && i)
3641 current = str.left(i);
3642 } else if(!quote && (unicode == SPACE || unicode == TAB)) {
3644 if(!current.isEmpty()) {
3645 ret.append(current);
3649 if(replaced && unicode)
3650 current.append(QChar(unicode));
3653 ret = QStringList(str);
3654 else if(!current.isEmpty())
3655 ret.append(current);
3656 //qDebug() << "REPLACE" << str << ret;
3658 warn_msg(WarnDeprecated, "%s:%d: Unmatched quotes are deprecated.",
3659 parser.file.toLatin1().constData(), parser.line_no);
3663 QStringList &QMakeProject::values(const QString &_var, QHash<QString, QStringList> &place)
3665 QString var = varMap(_var);
3666 if(var == QLatin1String("LITERAL_WHITESPACE")) { //a real space in a token)
3667 var = ".BUILTIN." + var;
3668 place[var] = QStringList(QLatin1String("\t"));
3669 } else if(var == QLatin1String("LITERAL_DOLLAR")) { //a real $
3670 var = ".BUILTIN." + var;
3671 place[var] = QStringList(QLatin1String("$"));
3672 } else if(var == QLatin1String("LITERAL_HASH")) { //a real #
3673 var = ".BUILTIN." + var;
3674 place[var] = QStringList("#");
3675 } else if(var == QLatin1String("OUT_PWD")) { //the out going dir
3676 var = ".BUILTIN." + var;
3677 place[var] = QStringList(Option::output_dir);
3678 } else if(var == QLatin1String("PWD") || //current working dir (of _FILE_)
3679 var == QLatin1String("IN_PWD")) {
3680 var = ".BUILTIN." + var;
3681 place[var] = QStringList(qmake_getpwd());
3682 } else if(var == QLatin1String("DIR_SEPARATOR")) {
3684 var = ".BUILTIN." + var;
3685 place[var] = QStringList(Option::dir_sep);
3686 } else if(var == QLatin1String("DIRLIST_SEPARATOR")) {
3687 var = ".BUILTIN." + var;
3688 place[var] = QStringList(Option::dirlist_sep);
3689 } else if(var == QLatin1String("_LINE_")) { //parser line number
3690 var = ".BUILTIN." + var;
3691 place[var] = QStringList(QString::number(parser.line_no));
3692 } else if(var == QLatin1String("_FILE_")) { //parser file
3693 var = ".BUILTIN." + var;
3694 place[var] = QStringList(parser.file);
3695 } else if(var == QLatin1String("_DATE_")) { //current date/time
3696 var = ".BUILTIN." + var;
3697 place[var] = QStringList(QDateTime::currentDateTime().toString());
3698 } else if(var == QLatin1String("_PRO_FILE_")) {
3699 var = ".BUILTIN." + var;
3700 place[var] = QStringList(pfile);
3701 } else if(var == QLatin1String("_PRO_FILE_PWD_")) {
3702 var = ".BUILTIN." + var;
3703 place[var] = QStringList(pfile.isEmpty() ? qmake_getpwd() : QFileInfo(pfile).absolutePath());
3704 } else if(var == QLatin1String("_QMAKE_CACHE_")) {
3705 var = ".BUILTIN." + var;
3706 if(Option::mkfile::do_cache)
3707 place[var] = QStringList(cachefile);
3708 } else if(var == QLatin1String("TEMPLATE")) {
3709 if(!Option::user_template.isEmpty()) {
3710 var = ".BUILTIN.USER." + var;
3711 place[var] = QStringList(Option::user_template);
3713 QString orig_template, real_template;
3714 if(!place[var].isEmpty())
3715 orig_template = place[var].first();
3716 real_template = orig_template.isEmpty() ? "app" : orig_template;
3717 if(!Option::user_template_prefix.isEmpty() && !orig_template.startsWith(Option::user_template_prefix))
3718 real_template.prepend(Option::user_template_prefix);
3719 if(real_template != orig_template) {
3720 var = ".BUILTIN." + var;
3721 place[var] = QStringList(real_template);
3724 } else if(var.startsWith(QLatin1String("QMAKE_HOST."))) {
3725 QString ret, type = var.mid(11);
3726 #if defined(Q_OS_WIN32)
3729 } else if(type == "name") {
3730 DWORD name_length = 1024;
3732 if (GetComputerName(name, &name_length))
3733 ret = QString::fromWCharArray(name);
3734 } else if(type == "version" || type == "version_string") {
3735 QSysInfo::WinVersion ver = QSysInfo::WindowsVersion;
3736 if(type == "version")
3737 ret = QString::number(ver);
3738 else if(ver == QSysInfo::WV_Me)
3740 else if(ver == QSysInfo::WV_95)
3742 else if(ver == QSysInfo::WV_98)
3744 else if(ver == QSysInfo::WV_NT)
3746 else if(ver == QSysInfo::WV_2000)
3748 else if(ver == QSysInfo::WV_2000)
3750 else if(ver == QSysInfo::WV_XP)
3752 else if(ver == QSysInfo::WV_VISTA)
3756 } else if(type == "arch") {
3758 GetSystemInfo(&info);
3759 switch(info.wProcessorArchitecture) {
3760 #ifdef PROCESSOR_ARCHITECTURE_AMD64
3761 case PROCESSOR_ARCHITECTURE_AMD64:
3765 case PROCESSOR_ARCHITECTURE_INTEL:
3768 case PROCESSOR_ARCHITECTURE_IA64:
3769 #ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
3770 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
3779 #elif defined(Q_OS_UNIX)
3780 struct utsname name;
3784 else if(type == "name")
3785 ret = name.nodename;
3786 else if(type == "version")
3788 else if(type == "version_string")
3790 else if(type == "arch")
3794 var = ".BUILTIN.HOST." + type;
3795 place[var] = QStringList(ret);
3796 } else if (var == QLatin1String("QMAKE_DIR_SEP")) {
3797 if (place[var].isEmpty())
3798 return values("DIR_SEPARATOR", place);
3799 } else if (var == QLatin1String("QMAKE_EXT_OBJ")) {
3800 if (place[var].isEmpty()) {
3801 var = ".BUILTIN." + var;
3802 place[var] = QStringList(Option::obj_ext);
3804 } else if (var == QLatin1String("QMAKE_QMAKE")) {
3805 if (place[var].isEmpty())
3806 place[var] = QStringList(Option::fixPathToTargetOS(
3807 !Option::qmake_abslocation.isEmpty()
3808 ? Option::qmake_abslocation
3809 : QLibraryInfo::rawLocation(QLibraryInfo::HostBinariesPath,
3810 QLibraryInfo::EffectivePaths) + "/qmake",
3813 #if defined(Q_OS_WIN32) && defined(Q_CC_MSVC)
3814 else if(var.startsWith(QLatin1String("QMAKE_TARGET."))) {
3815 QString ret, type = var.mid(13);
3816 if(type == "arch") {
3817 QString paths = QString::fromLocal8Bit(qgetenv("PATH"));
3818 QString vcBin64 = QString::fromLocal8Bit(qgetenv("VCINSTALLDIR"));
3819 if (!vcBin64.endsWith('\\'))
3820 vcBin64.append('\\');
3821 vcBin64.append("bin\\amd64");
3822 QString vcBinX86_64 = QString::fromLocal8Bit(qgetenv("VCINSTALLDIR"));
3823 if (!vcBinX86_64.endsWith('\\'))
3824 vcBinX86_64.append('\\');
3825 vcBinX86_64.append("bin\\x86_amd64");
3826 if(paths.contains(vcBin64,Qt::CaseInsensitive) || paths.contains(vcBinX86_64,Qt::CaseInsensitive))
3831 place[var] = QStringList(ret);
3834 //qDebug("REPLACE [%s]->[%s]", qPrintable(var), qPrintable(place[var].join("::")));
3838 bool QMakeProject::isEmpty(const QString &v)
3840 QHash<QString, QStringList>::ConstIterator it = vars.constFind(varMap(v));
3841 return it == vars.constEnd() || it->isEmpty();