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>
58 #include <sys/utsname.h>
59 #elif defined(Q_OS_WIN32)
66 #define QT_POPEN _popen
67 #define QT_PCLOSE _pclose
69 #define QT_POPEN popen
70 #define QT_PCLOSE pclose
76 enum ExpandFunc { E_MEMBER=1, E_FIRST, E_LAST, E_CAT, E_FROMFILE, E_EVAL, E_LIST,
77 E_SPRINTF, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION,
78 E_FIND, E_SYSTEM, E_UNIQUE, E_QUOTE, E_ESCAPE_EXPAND,
79 E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_REPLACE,
80 E_SIZE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS };
81 QHash<QString, ExpandFunc> qmake_expandFunctions()
83 static QHash<QString, ExpandFunc> *qmake_expand_functions = 0;
84 if(!qmake_expand_functions) {
85 qmake_expand_functions = new QHash<QString, ExpandFunc>;
86 qmakeAddCacheClear(qmakeDeleteCacheClear<QHash<QString, ExpandFunc> >, (void**)&qmake_expand_functions);
87 qmake_expand_functions->insert("member", E_MEMBER);
88 qmake_expand_functions->insert("first", E_FIRST);
89 qmake_expand_functions->insert("last", E_LAST);
90 qmake_expand_functions->insert("cat", E_CAT);
91 qmake_expand_functions->insert("fromfile", E_FROMFILE);
92 qmake_expand_functions->insert("eval", E_EVAL);
93 qmake_expand_functions->insert("list", E_LIST);
94 qmake_expand_functions->insert("sprintf", E_SPRINTF);
95 qmake_expand_functions->insert("join", E_JOIN);
96 qmake_expand_functions->insert("split", E_SPLIT);
97 qmake_expand_functions->insert("basename", E_BASENAME);
98 qmake_expand_functions->insert("dirname", E_DIRNAME);
99 qmake_expand_functions->insert("section", E_SECTION);
100 qmake_expand_functions->insert("find", E_FIND);
101 qmake_expand_functions->insert("system", E_SYSTEM);
102 qmake_expand_functions->insert("unique", E_UNIQUE);
103 qmake_expand_functions->insert("quote", E_QUOTE);
104 qmake_expand_functions->insert("escape_expand", E_ESCAPE_EXPAND);
105 qmake_expand_functions->insert("upper", E_UPPER);
106 qmake_expand_functions->insert("lower", E_LOWER);
107 qmake_expand_functions->insert("re_escape", E_RE_ESCAPE);
108 qmake_expand_functions->insert("files", E_FILES);
109 qmake_expand_functions->insert("prompt", E_PROMPT);
110 qmake_expand_functions->insert("replace", E_REPLACE);
111 qmake_expand_functions->insert("size", E_SIZE);
112 qmake_expand_functions->insert("sort_depends", E_SORT_DEPENDS);
113 qmake_expand_functions->insert("resolve_depends", E_RESOLVE_DEPENDS);
115 return *qmake_expand_functions;
118 enum TestFunc { T_REQUIRES=1, T_GREATERTHAN, T_LESSTHAN, T_EQUALS,
119 T_EXISTS, T_EXPORT, T_CLEAR, T_UNSET, T_EVAL, T_CONFIG, T_SYSTEM,
120 T_RETURN, T_BREAK, T_NEXT, T_DEFINED, T_CONTAINS, T_INFILE,
121 T_COUNT, T_ISEMPTY, T_INCLUDE, T_LOAD, T_DEBUG, T_ERROR,
122 T_MESSAGE, T_WARNING, T_IF, T_OPTION };
123 QHash<QString, TestFunc> qmake_testFunctions()
125 static QHash<QString, TestFunc> *qmake_test_functions = 0;
126 if(!qmake_test_functions) {
127 qmake_test_functions = new QHash<QString, TestFunc>;
128 qmake_test_functions->insert("requires", T_REQUIRES);
129 qmake_test_functions->insert("greaterThan", T_GREATERTHAN);
130 qmake_test_functions->insert("lessThan", T_LESSTHAN);
131 qmake_test_functions->insert("equals", T_EQUALS);
132 qmake_test_functions->insert("isEqual", T_EQUALS);
133 qmake_test_functions->insert("exists", T_EXISTS);
134 qmake_test_functions->insert("export", T_EXPORT);
135 qmake_test_functions->insert("clear", T_CLEAR);
136 qmake_test_functions->insert("unset", T_UNSET);
137 qmake_test_functions->insert("eval", T_EVAL);
138 qmake_test_functions->insert("CONFIG", T_CONFIG);
139 qmake_test_functions->insert("if", T_IF);
140 qmake_test_functions->insert("isActiveConfig", T_CONFIG);
141 qmake_test_functions->insert("system", T_SYSTEM);
142 qmake_test_functions->insert("return", T_RETURN);
143 qmake_test_functions->insert("break", T_BREAK);
144 qmake_test_functions->insert("next", T_NEXT);
145 qmake_test_functions->insert("defined", T_DEFINED);
146 qmake_test_functions->insert("contains", T_CONTAINS);
147 qmake_test_functions->insert("infile", T_INFILE);
148 qmake_test_functions->insert("count", T_COUNT);
149 qmake_test_functions->insert("isEmpty", T_ISEMPTY);
150 qmake_test_functions->insert("include", T_INCLUDE);
151 qmake_test_functions->insert("load", T_LOAD);
152 qmake_test_functions->insert("debug", T_DEBUG);
153 qmake_test_functions->insert("error", T_ERROR);
154 qmake_test_functions->insert("message", T_MESSAGE);
155 qmake_test_functions->insert("warning", T_WARNING);
156 qmake_test_functions->insert("option", T_OPTION);
158 return *qmake_test_functions;
167 static QString remove_quotes(const QString &arg)
169 const ushort SINGLEQUOTE = '\'';
170 const ushort DOUBLEQUOTE = '"';
172 const QChar *arg_data = arg.data();
173 const ushort first = arg_data->unicode();
174 const int arg_len = arg.length();
175 if(first == SINGLEQUOTE || first == DOUBLEQUOTE) {
176 const ushort last = (arg_data+arg_len-1)->unicode();
178 return arg.mid(1, arg_len-2);
183 static QString varMap(const QString &x)
186 if(ret == "INTERFACES")
188 else if(ret == "QMAKE_POST_BUILD")
189 ret = "QMAKE_POST_LINK";
190 else if(ret == "TARGETDEPS")
191 ret = "POST_TARGETDEPS";
192 else if(ret == "LIBPATH")
193 ret = "QMAKE_LIBDIR";
194 else if(ret == "QMAKE_EXT_MOC")
195 ret = "QMAKE_EXT_CPP_MOC";
196 else if(ret == "QMAKE_MOD_MOC")
197 ret = "QMAKE_H_MOD_MOC";
198 else if(ret == "QMAKE_LFLAGS_SHAPP")
199 ret = "QMAKE_LFLAGS_APP";
200 else if(ret == "PRECOMPH")
201 ret = "PRECOMPILED_HEADER";
202 else if(ret == "PRECOMPCPP")
203 ret = "PRECOMPILED_SOURCE";
204 else if(ret == "INCPATH")
206 else if(ret == "QMAKE_EXTRA_WIN_COMPILERS" || ret == "QMAKE_EXTRA_UNIX_COMPILERS")
207 ret = "QMAKE_EXTRA_COMPILERS";
208 else if(ret == "QMAKE_EXTRA_WIN_TARGETS" || ret == "QMAKE_EXTRA_UNIX_TARGETS")
209 ret = "QMAKE_EXTRA_TARGETS";
210 else if(ret == "QMAKE_EXTRA_UNIX_INCLUDES")
211 ret = "QMAKE_EXTRA_INCLUDES";
212 else if(ret == "QMAKE_EXTRA_UNIX_VARIABLES")
213 ret = "QMAKE_EXTRA_VARIABLES";
214 else if(ret == "QMAKE_RPATH")
215 ret = "QMAKE_LFLAGS_RPATH";
216 else if(ret == "QMAKE_FRAMEWORKDIR")
217 ret = "QMAKE_FRAMEWORKPATH";
218 else if(ret == "QMAKE_FRAMEWORKDIR_FLAGS")
219 ret = "QMAKE_FRAMEWORKPATH_FLAGS";
222 warn_msg(WarnDeprecated, "%s:%d: Variable %s is deprecated; use %s instead.",
223 parser.file.toLatin1().constData(), parser.line_no,
224 x.toLatin1().constData(), ret.toLatin1().constData());
228 static QStringList split_arg_list(const QString ¶ms)
233 const ushort LPAREN = '(';
234 const ushort RPAREN = ')';
235 const ushort SINGLEQUOTE = '\'';
236 const ushort DOUBLEQUOTE = '"';
237 const ushort BACKSLASH = '\\';
238 const ushort COMMA = ',';
239 const ushort SPACE = ' ';
240 //const ushort TAB = '\t';
242 const QChar *params_data = params.data();
243 const int params_len = params.length();
244 for(int last = 0; ;) {
245 while(last < params_len && (params_data[last].unicode() == SPACE
246 /*|| params_data[last].unicode() == TAB*/))
248 for(int x = last, parens = 0; ; x++) {
249 if(x == params_len) {
250 while(x > last && params_data[x-1].unicode() == SPACE)
252 args << params.mid(last, x - last);
253 // Could do a check for unmatched parens here, but split_value_list()
254 // is called on all our output, so mistakes will be caught anyway.
257 ushort unicode = params_data[x].unicode();
258 if(x != (int)params_len-1 && unicode == BACKSLASH &&
259 (params_data[x+1].unicode() == SINGLEQUOTE || params_data[x+1].unicode() == DOUBLEQUOTE)) {
260 x++; //get that 'escape'
261 } else if(quote && unicode == quote) {
263 } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
265 } else if(unicode == RPAREN) {
267 } else if(unicode == LPAREN) {
270 if(!parens && !quote && unicode == COMMA) {
273 while(x > prev && params_data[x-1].unicode() == SPACE)
275 args << params.mid(prev, x - prev);
282 static QStringList split_value_list(const QString &vals)
289 const ushort LPAREN = '(';
290 const ushort RPAREN = ')';
291 const ushort SINGLEQUOTE = '\'';
292 const ushort DOUBLEQUOTE = '"';
293 const ushort BACKSLASH = '\\';
296 const QChar *vals_data = vals.data();
297 const int vals_len = vals.length();
298 for(int x = 0; x < vals_len; x++) {
299 unicode = vals_data[x].unicode();
300 if(x != (int)vals_len-1 && unicode == BACKSLASH &&
301 (vals_data[x+1].unicode() == SINGLEQUOTE || vals_data[x+1].unicode() == DOUBLEQUOTE)) {
302 build += vals_data[x++]; //get that 'escape'
303 } else if(quote && unicode == quote) {
305 } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
307 } else if(unicode == RPAREN) {
309 } else if(unicode == LPAREN) {
313 if(!parens && !quote && (vals_data[x] == Option::field_sep)) {
317 build += vals_data[x];
323 warn_msg(WarnDeprecated, "%s:%d: Unmatched parentheses are deprecated.",
324 parser.file.toLatin1().constData(), parser.line_no);
325 // Could do a check for unmatched quotes here, but doVariableReplaceExpand()
326 // is called on all our output, so mistakes will be caught anyway.
330 //just a parsable entity
333 ParsableBlock() : ref_cnt(1) { }
334 virtual ~ParsableBlock() { }
339 Parse(const QString &t) : text(t){ pi = parser; }
341 QList<Parse> parselist;
343 inline int ref() { return ++ref_cnt; }
344 inline int deref() { return --ref_cnt; }
348 virtual bool continueBlock() = 0;
349 bool eval(QMakeProject *p, QHash<QString, QStringList> &place);
352 bool ParsableBlock::eval(QMakeProject *p, QHash<QString, QStringList> &place)
355 parser_info pi = parser;
356 const int block_count = p->scope_blocks.count();
360 for(int i = 0; i < parselist.count(); i++) {
361 parser = parselist.at(i).pi;
362 if(!(ret = p->parse(parselist.at(i).text, place)) || !continueBlock())
368 while(p->scope_blocks.count() > block_count)
369 p->scope_blocks.pop();
374 struct FunctionBlock : public ParsableBlock
376 FunctionBlock() : calling_place(0), scope_level(1), cause_return(false) { }
378 QHash<QString, QStringList> vars;
379 QHash<QString, QStringList> *calling_place;
380 QStringList return_value;
384 bool exec(const QList<QStringList> &args,
385 QMakeProject *p, QHash<QString, QStringList> &place, QStringList &functionReturn);
386 virtual bool continueBlock() { return !cause_return; }
389 bool FunctionBlock::exec(const QList<QStringList> &args,
390 QMakeProject *proj, QHash<QString, QStringList> &place,
391 QStringList &functionReturn)
395 calling_place = &place;
397 calling_place = &proj->variables();
399 return_value.clear();
400 cause_return = false;
404 vars = proj->variables(); // should be place so that local variables can be inherited
408 vars["ARGS"].clear();
409 for(int i = 0; i < args.count(); i++) {
410 vars["ARGS"] += args[i];
411 vars[QString::number(i+1)] = args[i];
413 bool ret = ParsableBlock::eval(proj, vars);
414 functionReturn = return_value;
418 return_value.clear();
424 struct IteratorBlock : public ParsableBlock
426 IteratorBlock() : scope_level(1), loop_forever(false), cause_break(false), cause_next(false) { }
435 Test(const QString &f, QStringList &a, bool i) : func(f), args(a), invert(i) { pi = parser; }
441 bool loop_forever, cause_break, cause_next;
444 bool exec(QMakeProject *p, QHash<QString, QStringList> &place);
445 virtual bool continueBlock() { return !cause_next && !cause_break; }
447 bool IteratorBlock::exec(QMakeProject *p, QHash<QString, QStringList> &place)
450 QStringList::Iterator it;
453 int iterate_count = 0;
455 IteratorBlock *saved_iterator = p->iterator;
459 while(loop_forever || it != list.end()) {
460 cause_next = cause_break = false;
461 if(!loop_forever && (*it).isEmpty()) { //ignore empty items
466 //set up the loop variable
468 if(!variable.isEmpty()) {
469 va = place[variable];
471 place[variable] = QStringList(QString::number(iterate_count));
473 place[variable] = QStringList(*it);
477 for(QList<Test>::Iterator test_it = test.begin(); test_it != test.end(); ++test_it) {
478 parser = (*test_it).pi;
479 succeed = p->doProjectTest((*test_it).func, (*test_it).args, place);
480 if((*test_it).invert)
486 ret = ParsableBlock::eval(p, place);
487 //restore the variable in the map
488 if(!variable.isEmpty())
489 place[variable] = va;
494 if(!ret || cause_break)
499 p->iterator = saved_iterator;
503 QMakeProject::ScopeBlock::~ScopeBlock()
511 static void qmake_error_msg(const QString &msg)
513 fprintf(stderr, "%s:%d: %s\n", parser.file.toLatin1().constData(), parser.line_no,
514 msg.toLatin1().constData());
518 1) environment variable QMAKEFEATURES (as separated by colons)
519 2) property variable QMAKEFEATURES (as separated by colons)
520 3) <project_root> (where .qmake.cache lives) + FEATURES_DIR
521 4) environment variable QMAKEPATH (as separated by colons) + /mkspecs/FEATURES_DIR
522 5) your QMAKESPEC/features dir
523 6) your data_install/mkspecs/FEATURES_DIR
524 7) your QMAKESPEC/../FEATURES_DIR dir
526 FEATURES_DIR is defined as:
528 1) features/(unix|win32|macx)/
531 QStringList qmake_feature_paths(QMakeProperty *prop=0)
533 const QString mkspecs_concat = QLatin1String("/mkspecs");
534 const QString base_concat = QLatin1String("/features");
537 switch(Option::target_mode) {
538 case Option::TARG_MACX_MODE: //also a unix
539 concat << base_concat + QLatin1String("/mac");
540 concat << base_concat + QLatin1String("/macx");
541 concat << base_concat + QLatin1String("/unix");
543 default: // Can't happen, just make the compiler shut up
544 case Option::TARG_UNIX_MODE:
545 concat << base_concat + QLatin1String("/unix");
547 case Option::TARG_WIN_MODE:
548 concat << base_concat + QLatin1String("/win32");
551 concat << base_concat;
554 QStringList feature_roots;
555 QByteArray mkspec_path = qgetenv("QMAKEFEATURES");
556 if(!mkspec_path.isNull())
557 feature_roots += splitPathList(QString::fromLocal8Bit(mkspec_path));
559 feature_roots += splitPathList(prop->value("QMAKEFEATURES"));
560 if(!Option::mkfile::cachefile.isEmpty()) {
562 int last_slash = Option::mkfile::cachefile.lastIndexOf(QLatin1Char('/'));
564 path = Option::normalizePath(Option::mkfile::cachefile.left(last_slash), false);
565 for(QStringList::Iterator concat_it = concat.begin();
566 concat_it != concat.end(); ++concat_it)
567 feature_roots << (path + (*concat_it));
569 QByteArray qmakepath = qgetenv("QMAKEPATH");
570 if (!qmakepath.isNull()) {
571 const QStringList lst = splitPathList(QString::fromLocal8Bit(qmakepath));
572 for(QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it) {
573 for(QStringList::Iterator concat_it = concat.begin();
574 concat_it != concat.end(); ++concat_it)
575 feature_roots << ((*it) + mkspecs_concat + (*concat_it));
578 if(!Option::mkfile::qmakespec.isEmpty()) {
579 // The spec is already platform-dependent, so no subdirs here.
580 feature_roots << Option::mkfile::qmakespec + base_concat;
582 QFileInfo specfi(Option::mkfile::qmakespec);
583 if (!specfi.isRoot()) {
584 QDir specdir(specfi.absolutePath());
585 if (specdir.exists(QLatin1String("features"))) {
586 for(QStringList::Iterator concat_it = concat.begin();
587 concat_it != concat.end(); ++concat_it)
588 feature_roots << (specdir.path() + (*concat_it));
592 for(QStringList::Iterator concat_it = concat.begin();
593 concat_it != concat.end(); ++concat_it)
594 feature_roots << (QLibraryInfo::location(QLibraryInfo::HostDataPath) +
595 mkspecs_concat + (*concat_it));
596 feature_roots.removeDuplicates();
597 return feature_roots;
600 QMakeProject::~QMakeProject()
604 for(QHash<QString, FunctionBlock*>::iterator it = replaceFunctions.begin(); it != replaceFunctions.end(); ++it) {
605 if(!it.value()->deref())
608 replaceFunctions.clear();
609 for(QHash<QString, FunctionBlock*>::iterator it = testFunctions.begin(); it != testFunctions.end(); ++it) {
610 if(!it.value()->deref())
613 testFunctions.clear();
618 QMakeProject::init(QMakeProperty *p)
621 prop = new QMakeProperty;
631 // Duplicate project. It is *not* allowed to call the complex read() functions on the copy.
632 QMakeProject::QMakeProject(QMakeProject *p, const QHash<QString, QStringList> *_vars)
634 init(p->properties());
635 vars = _vars ? *_vars : p->variables();
636 for(QHash<QString, FunctionBlock*>::iterator it = p->replaceFunctions.begin(); it != p->replaceFunctions.end(); ++it) {
638 replaceFunctions.insert(it.key(), it.value());
640 for(QHash<QString, FunctionBlock*>::iterator it = p->testFunctions.begin(); it != p->testFunctions.end(); ++it) {
642 testFunctions.insert(it.key(), it.value());
647 QMakeProject::reset()
649 // scope_blocks starts with one non-ignoring entity
650 scope_blocks.clear();
651 scope_blocks.push(ScopeBlock());
654 backslashWarned = false;
658 QMakeProject::parse(const QString &t, QHash<QString, QStringList> &place, int numLines)
660 // To preserve the integrity of any UTF-8 characters in .pro file, temporarily replace the
661 // non-breaking space (0xA0) characters with another non-space character, so that
662 // QString::simplified() call will not replace it with space.
663 // Note: There won't be any two byte characters in .pro files, so 0x10A0 should be a safe
664 // replacement character.
665 static QChar nbsp(0xA0);
666 static QChar nbspFix(0x01A0);
668 if (t.indexOf(nbsp) != -1) {
670 s.replace(nbsp, nbspFix);
672 s.replace(nbspFix, nbsp);
677 int hash_mark = s.indexOf("#");
678 if(hash_mark != -1) //good bye comments
679 s = s.left(hash_mark);
680 if(s.isEmpty()) // blank_line
683 if(scope_blocks.top().ignore) {
684 bool continue_parsing = false;
685 // adjust scope for each block which appears on a single line
686 for(int i = 0; i < s.length(); i++) {
688 scope_blocks.push(ScopeBlock(true));
689 } else if(s[i] == '}') {
690 if(scope_blocks.count() == 1) {
691 fprintf(stderr, "Braces mismatch %s:%d\n", parser.file.toLatin1().constData(), parser.line_no);
694 ScopeBlock sb = scope_blocks.pop();
696 sb.iterate->exec(this, place);
700 if(!scope_blocks.top().ignore) {
701 debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.toLatin1().constData(),
702 parser.line_no, scope_blocks.count()+1);
703 s = s.mid(i+1).trimmed();
704 continue_parsing = !s.isEmpty();
709 if(!continue_parsing) {
710 debug_msg(1, "Project Parser: %s:%d : Ignored due to block being false.",
711 parser.file.toLatin1().constData(), parser.line_no);
719 const QChar *d = s.unicode();
720 bool function_finished = false;
721 while(d_off < s.length()) {
722 if(*(d+d_off) == QLatin1Char('}')) {
723 function->scope_level--;
724 if(!function->scope_level) {
725 function_finished = true;
728 } else if(*(d+d_off) == QLatin1Char('{')) {
729 function->scope_level++;
731 append += *(d+d_off);
734 if(!append.isEmpty())
735 function->parselist.append(IteratorBlock::Parse(append));
736 if(function_finished) {
738 s = QString(d+d_off, s.length()-d_off);
742 } else if(IteratorBlock *it = scope_blocks.top().iterate) {
745 const QChar *d = s.unicode();
746 bool iterate_finished = false;
747 while(d_off < s.length()) {
748 if(*(d+d_off) == QLatin1Char('}')) {
750 if(!it->scope_level) {
751 iterate_finished = true;
754 } else if(*(d+d_off) == QLatin1Char('{')) {
757 append += *(d+d_off);
760 if(!append.isEmpty())
761 scope_blocks.top().iterate->parselist.append(IteratorBlock::Parse(append));
762 if(iterate_finished) {
763 scope_blocks.top().iterate = 0;
764 bool ret = it->exec(this, place);
774 QString scope, var, op;
776 #define SKIP_WS(d, o, l) while(o < l && (*(d+o) == QLatin1Char(' ') || *(d+o) == QLatin1Char('\t'))) ++o
777 const QChar *d = s.unicode();
779 SKIP_WS(d, d_off, s.length());
780 IteratorBlock *iterator = 0;
781 bool scope_failed = false, else_line = false, or_op=false;
783 int parens = 0, scope_count=0, start_block = 0;
784 while(d_off < s.length()) {
786 if(*(d+d_off) == QLatin1Char('='))
788 if(*(d+d_off) == QLatin1Char('+') || *(d+d_off) == QLatin1Char('-') ||
789 *(d+d_off) == QLatin1Char('*') || *(d+d_off) == QLatin1Char('~')) {
790 if(*(d+d_off+1) == QLatin1Char('=')) {
792 } else if(*(d+d_off+1) == QLatin1Char(' ')) {
793 const QChar *k = d+d_off+1;
795 SKIP_WS(k, k_off, s.length()-d_off);
796 if(*(k+k_off) == QLatin1Char('=')) {
798 qmake_error_msg(QString(d+d_off, 1) + "must be followed immediately by =");
805 if(!quote.isNull()) {
806 if(*(d+d_off) == quote)
808 } else if(*(d+d_off) == '(') {
810 } else if(*(d+d_off) == ')') {
812 } else if(*(d+d_off) == '"' /*|| *(d+d_off) == '\''*/) {
816 if(!parens && quote.isNull() &&
817 (*(d+d_off) == QLatin1Char(':') || *(d+d_off) == QLatin1Char('{') ||
818 *(d+d_off) == QLatin1Char(')') || *(d+d_off) == QLatin1Char('|'))) {
820 scope = var.trimmed();
821 if(*(d+d_off) == QLatin1Char(')'))
822 scope += *(d+d_off); // need this
825 bool test = scope_failed;
826 if(scope.isEmpty()) {
828 } else if(scope.toLower() == "else") { //else is a builtin scope here as it modifies state
829 if(scope_count != 1 || scope_blocks.top().else_status == ScopeBlock::TestNone) {
830 qmake_error_msg(("Unexpected " + scope + " ('" + s + "')").toLatin1());
834 test = (scope_blocks.top().else_status == ScopeBlock::TestSeek);
835 debug_msg(1, "Project Parser: %s:%d : Else%s %s.", parser.file.toLatin1().constData(), parser.line_no,
836 scope == "else" ? "" : QString(" (" + scope + ")").toLatin1().constData(),
837 test ? "considered" : "excluded");
839 QString comp_scope = scope;
840 bool invert_test = (comp_scope.at(0) == QLatin1Char('!'));
842 comp_scope = comp_scope.mid(1);
843 int lparen = comp_scope.indexOf('(');
844 if(or_op == scope_failed) {
845 if(lparen != -1) { // if there is an lparen in the scope, it IS a function
846 int rparen = comp_scope.lastIndexOf(')');
848 qmake_error_msg("Function missing right paren: " + comp_scope);
851 QString func = comp_scope.left(lparen);
852 QStringList args = split_arg_list(comp_scope.mid(lparen+1, rparen - lparen - 1));
854 fprintf(stderr, "%s:%d: No tests can come after a function definition!\n",
855 parser.file.toLatin1().constData(), parser.line_no);
857 } else if(func == "for") { //for is a builtin function here, as it modifies state
858 if(args.count() > 2 || args.count() < 1) {
859 fprintf(stderr, "%s:%d: for(iterate, list) requires two arguments.\n",
860 parser.file.toLatin1().constData(), parser.line_no);
862 } else if(iterator) {
863 fprintf(stderr, "%s:%d unexpected nested for()\n",
864 parser.file.toLatin1().constData(), parser.line_no);
868 iterator = new IteratorBlock;
870 if(args.count() == 1) {
871 doVariableReplace(args[0], place);
873 if(args[0] != "ever") {
876 fprintf(stderr, "%s:%d: for(iterate, list) requires two arguments.\n",
877 parser.file.toLatin1().constData(), parser.line_no);
881 } else if(args.count() == 2) {
882 iterator->variable = args[0];
883 doVariableReplace(args[1], place);
886 QStringList list = place[it_list];
888 if(it_list == "forever") {
889 iterator->loop_forever = true;
891 int dotdot = it_list.indexOf("..");
894 int start = it_list.left(dotdot).toInt(&ok);
896 int end = it_list.mid(dotdot+2).toInt(&ok);
899 for(int i = start; i <= end; i++)
900 list << QString::number(i);
902 for(int i = start; i >= end; i--)
903 list << QString::number(i);
910 iterator->list = list;
912 } else if(iterator) {
913 iterator->test.append(IteratorBlock::Test(func, args, invert_test));
915 } else if(func == "defineTest" || func == "defineReplace") {
916 if(!function_blocks.isEmpty()) {
918 "%s:%d: cannot define a function within another definition.\n",
919 parser.file.toLatin1().constData(), parser.line_no);
922 if(args.count() != 1) {
923 fprintf(stderr, "%s:%d: %s(function_name) requires one argument.\n",
924 parser.file.toLatin1().constData(), parser.line_no, func.toLatin1().constData());
927 QHash<QString, FunctionBlock*> *map = 0;
928 if(func == "defineTest")
929 map = &testFunctions;
931 map = &replaceFunctions;
933 if(!map || map->contains(args[0])) {
934 fprintf(stderr, "%s:%d: Function[%s] multiply defined.\n",
935 parser.file.toLatin1().constData(), parser.line_no, args[0].toLatin1().constData());
939 function = new FunctionBlock;
940 map->insert(args[0], function);
943 test = doProjectTest(func, args, place);
944 if(*(d+d_off) == QLatin1Char(')') && d_off == s.length()-1) {
947 scope_blocks.top().else_status =
948 (test ? ScopeBlock::TestFound : ScopeBlock::TestSeek);
949 return true; // assume we are done
953 QString cscope = comp_scope.trimmed();
954 doVariableReplace(cscope, place);
955 test = isActiveConfig(cscope.trimmed(), true, &place);
961 if(!test && !scope_failed)
962 debug_msg(1, "Project Parser: %s:%d : Test (%s) failed.", parser.file.toLatin1().constData(),
963 parser.line_no, scope.toLatin1().constData());
965 scope_failed = !test;
966 or_op = (*(d+d_off) == QLatin1Char('|'));
968 if(*(d+d_off) == QLatin1Char('{')) { // scoping block
971 for(int off = 0, braces = 0; true; ++off) {
972 if(*(d+d_off+off) == QLatin1Char('{'))
974 else if(*(d+d_off+off) == QLatin1Char('}') && braces)
976 if(!braces || d_off+off == s.length()) {
977 iterator->parselist.append(s.mid(d_off, off-1));
979 iterator->scope_level += braces-1;
986 } else if(!parens && *(d+d_off) == QLatin1Char('}')) {
989 } else if(!scope_blocks.count()) {
990 warn_msg(WarnParser, "Possible braces mismatch %s:%d", parser.file.toLatin1().constData(), parser.line_no);
992 if(scope_blocks.count() == 1) {
993 fprintf(stderr, "Braces mismatch %s:%d\n", parser.file.toLatin1().constData(), parser.line_no);
996 debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.toLatin1().constData(),
997 parser.line_no, scope_blocks.count());
998 ScopeBlock sb = scope_blocks.pop();
1000 sb.iterate->exec(this, place);
1007 var = var.trimmed();
1009 if(!else_line || (else_line && !scope_failed))
1010 scope_blocks.top().else_status = (!scope_failed ? ScopeBlock::TestFound : ScopeBlock::TestSeek);
1012 ScopeBlock next_block(scope_failed);
1013 next_block.iterate = iterator;
1015 next_block.else_status = ScopeBlock::TestNone;
1016 else if(scope_failed)
1017 next_block.else_status = ScopeBlock::TestSeek;
1019 next_block.else_status = ScopeBlock::TestFound;
1020 scope_blocks.push(next_block);
1021 debug_msg(1, "Project Parser: %s:%d : Entering block %d (%d). [%s]", parser.file.toLatin1().constData(),
1022 parser.line_no, scope_blocks.count(), scope_failed, s.toLatin1().constData());
1023 } else if(iterator) {
1024 iterator->parselist.append(var+s.mid(d_off));
1025 bool ret = iterator->exec(this, place);
1030 if((!scope_count && !var.isEmpty()) || (scope_count == 1 && else_line))
1031 scope_blocks.top().else_status = ScopeBlock::TestNone;
1032 if(d_off == s.length()) {
1033 if(!var.trimmed().isEmpty())
1034 qmake_error_msg(("Parse Error ('" + s + "')").toLatin1());
1035 return var.isEmpty(); // allow just a scope
1038 SKIP_WS(d, d_off, s.length());
1039 for(; d_off < s.length() && op.indexOf('=') == -1; op += *(d+(d_off++)))
1041 op.replace(QRegExp("\\s"), "");
1043 SKIP_WS(d, d_off, s.length());
1044 QString vals = s.mid(d_off); // vals now contains the space separated list of values
1045 int rbraces = vals.count('}'), lbraces = vals.count('{');
1046 if(scope_blocks.count() > 1 && rbraces - lbraces == 1 && vals.endsWith('}')) {
1047 debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.toLatin1().constData(),
1048 parser.line_no, scope_blocks.count());
1049 ScopeBlock sb = scope_blocks.pop();
1051 sb.iterate->exec(this, place);
1052 vals.truncate(vals.length()-1);
1053 } else if(rbraces != lbraces) {
1054 warn_msg(WarnParser, "Possible braces mismatch {%s} %s:%d",
1055 vals.toLatin1().constData(), parser.file.toLatin1().constData(), parser.line_no);
1058 return true; // oh well
1061 doVariableReplace(var, place);
1062 var = varMap(var); //backwards compatibility
1063 if(!var.isEmpty() && Option::mkfile::do_preprocess) {
1064 static QString last_file("*none*");
1065 if(parser.file != last_file) {
1066 fprintf(stdout, "#file %s:%d\n", parser.file.toLatin1().constData(), parser.line_no);
1067 last_file = parser.file;
1069 fprintf(stdout, "%s %s %s\n", var.toLatin1().constData(), op.toLatin1().constData(), vals.toLatin1().constData());
1072 if(vals.contains('=') && numLines > 1)
1073 warn_msg(WarnParser, "Possible accidental line continuation: {%s} at %s:%d",
1074 var.toLatin1().constData(), parser.file.toLatin1().constData(), parser.line_no);
1076 QStringList &varlist = place[var]; // varlist is the list in the symbol table
1078 if(Option::debug_level >= 1) {
1079 QString tmp_vals = vals;
1080 doVariableReplace(tmp_vals, place);
1081 debug_msg(1, "Project Parser: %s:%d :%s: :%s: (%s)", parser.file.toLatin1().constData(), parser.line_no,
1082 var.toLatin1().constData(), op.toLatin1().constData(), tmp_vals.toLatin1().constData());
1085 // now do the operation
1087 doVariableReplace(vals, place);
1088 if(vals.length() < 4 || vals.at(0) != 's') {
1089 qmake_error_msg(("~= operator only can handle s/// function ('" +
1090 s + "')").toLatin1());
1093 QChar sep = vals.at(1);
1094 QStringList func = vals.split(sep);
1095 if(func.count() < 3 || func.count() > 4) {
1096 qmake_error_msg(("~= operator only can handle s/// function ('" +
1097 s + "')").toLatin1());
1100 bool global = false, case_sense = true, quote = false;
1101 if(func.count() == 4) {
1102 global = func[3].indexOf('g') != -1;
1103 case_sense = func[3].indexOf('i') == -1;
1104 quote = func[3].indexOf('q') != -1;
1106 QString from = func[1], to = func[2];
1108 from = QRegExp::escape(from);
1109 QRegExp regexp(from, case_sense ? Qt::CaseSensitive : Qt::CaseInsensitive);
1110 for(QStringList::Iterator varit = varlist.begin(); varit != varlist.end();) {
1111 if((*varit).contains(regexp)) {
1112 (*varit) = (*varit).replace(regexp, to);
1113 if ((*varit).isEmpty())
1114 varit = varlist.erase(varit);
1123 QStringList vallist;
1125 //doVariableReplace(vals, place);
1126 QStringList tmp = split_value_list(vals);
1127 for(int i = 0; i < tmp.size(); ++i)
1128 vallist += doVariableReplaceExpand(tmp[i], place);
1132 if(!varlist.isEmpty()) {
1133 bool send_warning = false;
1134 if(var != "TEMPLATE" && var != "TARGET") {
1135 QSet<QString> incoming_vals = vallist.toSet();
1136 for(int i = 0; i < varlist.size(); ++i) {
1137 const QString var = varlist.at(i).trimmed();
1138 if(!var.isEmpty() && !incoming_vals.contains(var)) {
1139 send_warning = true;
1145 warn_msg(WarnParser, "Operator=(%s) clears variables previously set: %s:%d",
1146 var.toLatin1().constData(), parser.file.toLatin1().constData(), parser.line_no);
1150 for(QStringList::ConstIterator valit = vallist.begin();
1151 valit != vallist.end(); ++valit) {
1152 if((*valit).isEmpty())
1154 if((op == "*=" && !varlist.contains((*valit))) ||
1155 op == "=" || op == "+=")
1156 varlist.append((*valit));
1158 varlist.removeAll((*valit));
1160 if(var == "REQUIRES") // special case to get communicated to backends!
1161 doProjectCheckReqs(vallist, place);
1162 else if (var == "_QMAKE_CACHE_")
1163 Option::mkfile::cachefile = varlist.isEmpty() ? QString() : varlist.at(0);
1169 QMakeProject::read(QTextStream &file, QHash<QString, QStringList> &place)
1174 while(!file.atEnd()) {
1176 QString line = file.readLine().trimmed();
1177 int prelen = line.length();
1179 int hash_mark = line.indexOf("#");
1180 if(hash_mark != -1) //good bye comments
1181 line = line.left(hash_mark).trimmed();
1182 if(!line.isEmpty() && line.right(1) == "\\") {
1183 if(!line.startsWith("#")) {
1184 line.truncate(line.length() - 1);
1185 s += line + Option::field_sep;
1188 } else if(!line.isEmpty() || (line.isEmpty() && !prelen)) {
1189 if(s.isEmpty() && line.isEmpty())
1191 if(!line.isEmpty()) {
1196 if(!(ret = parse(s, place, numLines))) {
1207 ret = parse(s, place, numLines);
1212 QMakeProject::read(const QString &file, QHash<QString, QStringList> &place)
1214 parser_info pi = parser;
1217 const QString oldpwd = qmake_getpwd();
1218 QString filename = Option::normalizePath(file, false);
1219 bool ret = false, using_stdin = false;
1221 if(filename == QLatin1String("-")) {
1222 qfile.setFileName("");
1223 ret = qfile.open(stdin, QIODevice::ReadOnly);
1225 } else if(QFileInfo(file).isDir()) {
1228 qfile.setFileName(filename);
1229 ret = qfile.open(QIODevice::ReadOnly);
1230 qmake_setpwd(QFileInfo(filename).absolutePath());
1233 parser_info pi = parser;
1234 parser.from_file = true;
1235 parser.file = filename;
1237 QTextStream t(&qfile);
1238 ret = read(t, place);
1242 if(scope_blocks.count() != 1) {
1243 qmake_error_msg("Unterminated conditional block at end of file");
1247 qmake_setpwd(oldpwd);
1252 QMakeProject::read(const QString &project, uchar cmd)
1254 pfile = QFileInfo(project).absoluteFilePath();
1259 QMakeProject::read(uchar cmd)
1261 if ((cmd & ReadSetup) && base_vars.isEmpty()) {
1262 // hack to get the Option stuff in there
1263 base_vars["QMAKE_EXT_CPP"] = Option::cpp_ext;
1264 base_vars["QMAKE_EXT_C"] = Option::c_ext;
1265 base_vars["QMAKE_EXT_H"] = Option::h_ext;
1266 base_vars["QMAKE_SH"] = Option::shellPath;
1267 if(!Option::user_template_prefix.isEmpty())
1268 base_vars["TEMPLATE_PREFIX"] = QStringList(Option::user_template_prefix);
1270 if (Option::mkfile::do_cache) { // parse the cache
1271 if (Option::output_dir.startsWith(Option::mkfile::project_build_root))
1272 Option::mkfile::cachefile_depth =
1273 Option::output_dir.mid(Option::mkfile::project_build_root.length()).count('/');
1276 QString qmakespec = Option::mkfile::qmakespec;
1277 while(qmakespec.endsWith(QLatin1Char('/')))
1278 qmakespec.truncate(qmakespec.length()-1);
1279 QString spec = qmakespec + QLatin1String("/qmake.conf");
1280 debug_msg(1, "QMAKESPEC conf: reading %s", spec.toLatin1().constData());
1281 if(!read(spec, base_vars)) {
1282 fprintf(stderr, "Failure to read QMAKESPEC conf file %s.\n", spec.toLatin1().constData());
1287 if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty()) {
1288 debug_msg(1, "QMAKECACHE file: reading %s", Option::mkfile::cachefile.toLatin1().constData());
1289 read(Option::mkfile::cachefile, base_vars);
1294 vars = base_vars; // start with the base
1296 for (QHash<QString, QStringList>::ConstIterator it = extra_vars.constBegin();
1297 it != extra_vars.constEnd(); ++it)
1298 vars.insert(it.key(), it.value());
1300 if(cmd & ReadFeatures) {
1301 debug_msg(1, "Processing default_pre: %s", vars["CONFIG"].join("::").toLatin1().constData());
1302 doProjectInclude("default_pre", IncludeFlagFeature, vars);
1306 if(pfile != "-" && vars["TARGET"].isEmpty())
1307 vars["TARGET"].append(QFileInfo(pfile).baseName());
1309 //before commandline
1310 if (cmd & ReadSetup) {
1311 parser.file = "(internal)";
1312 parser.from_file = false;
1313 parser.line_no = 1; //really arg count now.. duh
1315 for(QStringList::ConstIterator it = Option::before_user_vars.begin();
1316 it != Option::before_user_vars.end(); ++it) {
1317 if(!parse((*it), vars)) {
1318 fprintf(stderr, "Argument failed to parse: %s\n", (*it).toLatin1().constData());
1325 // After user configs, to override them
1326 if (!extra_configs.isEmpty()) {
1327 parser.file = "(extra configs)";
1328 parser.from_file = false;
1329 parser.line_no = 1; //really arg count now.. duh
1330 parse("CONFIG += " + extra_configs.join(" "), vars);
1333 if(cmd & ReadProFile) { // parse project file
1334 debug_msg(1, "Project file: reading %s", pfile.toLatin1().constData());
1335 if(pfile != "-" && !QFile::exists(pfile) && !pfile.endsWith(Option::pro_ext))
1336 pfile += Option::pro_ext;
1337 if(!read(pfile, vars))
1341 if (cmd & ReadSetup) {
1342 parser.file = "(internal)";
1343 parser.from_file = false;
1344 parser.line_no = 1; //really arg count now.. duh
1346 for(QStringList::ConstIterator it = Option::after_user_vars.begin();
1347 it != Option::after_user_vars.end(); ++it) {
1348 if(!parse((*it), vars)) {
1349 fprintf(stderr, "Argument failed to parse: %s\n", (*it).toLatin1().constData());
1356 // Again, to ensure the project does not mess with us.
1357 // Specifically, do not allow a project to override debug/release within a
1358 // debug_and_release build pass - it's too late for that at this point anyway.
1359 if (!extra_configs.isEmpty()) {
1360 parser.file = "(extra configs)";
1361 parser.from_file = false;
1362 parser.line_no = 1; //really arg count now.. duh
1363 parse("CONFIG += " + extra_configs.join(" "), vars);
1366 if(cmd & ReadFeatures) {
1367 debug_msg(1, "Processing default_post: %s", vars["CONFIG"].join("::").toLatin1().constData());
1368 doProjectInclude("default_post", IncludeFlagFeature, vars);
1370 QHash<QString, bool> processed;
1371 const QStringList &configs = vars["CONFIG"];
1372 debug_msg(1, "Processing CONFIG features: %s", configs.join("::").toLatin1().constData());
1374 bool finished = true;
1375 for(int i = configs.size()-1; i >= 0; --i) {
1376 const QString config = configs[i].toLower();
1377 if(!processed.contains(config)) {
1378 processed.insert(config, true);
1379 if(doProjectInclude(config, IncludeFlagFeature, vars) == IncludeSuccess) {
1392 void QMakeProject::validateModes()
1394 if (Option::host_mode == Option::HOST_UNKNOWN_MODE
1395 || Option::target_mode == Option::TARG_UNKNOWN_MODE) {
1396 Option::HOST_MODE host_mode;
1397 Option::TARG_MODE target_mode;
1398 const QStringList &gen = base_vars.value("MAKEFILE_GENERATOR");
1399 if (gen.isEmpty()) {
1400 fprintf(stderr, "%s:%d: Using OS scope before setting MAKEFILE_GENERATOR\n",
1401 parser.file.toLatin1().constData(), parser.line_no);
1402 } else if (MetaMakefileGenerator::modesForGenerator(gen.first(),
1403 &host_mode, &target_mode)) {
1404 if (Option::host_mode == Option::HOST_UNKNOWN_MODE) {
1405 Option::host_mode = host_mode;
1406 Option::applyHostMode();
1409 if (Option::target_mode == Option::TARG_UNKNOWN_MODE) {
1410 const QStringList &tgt = base_vars.value("TARGET_PLATFORM");
1411 if (!tgt.isEmpty()) {
1412 const QString &os = tgt.first();
1414 Option::target_mode = Option::TARG_UNIX_MODE;
1415 else if (os == "macx")
1416 Option::target_mode = Option::TARG_MACX_MODE;
1417 else if (os == "win32")
1418 Option::target_mode = Option::TARG_WIN_MODE;
1420 fprintf(stderr, "Unknown target platform specified: %s\n",
1421 os.toLatin1().constData());
1423 Option::target_mode = target_mode;
1431 QMakeProject::resolveSpec(QString *spec, const QString &qmakespec)
1433 if (spec->isEmpty()) {
1434 *spec = QFileInfo(qmakespec).fileName();
1435 if (*spec == "default") {
1438 int l = readlink(qmakespec.toLatin1().constData(), buffer, 1023);
1441 *spec = QString::fromLatin1(buffer);
1443 // We can't resolve symlinks as they do on Unix, so configure.exe puts the source of the
1444 // qmake.conf at the end of the default/qmake.conf in the QMAKESPEC_ORG variable.
1445 const QStringList &spec_org = base_vars["QMAKESPEC_ORIGINAL"];
1446 if (spec_org.isEmpty()) {
1447 // try again the next time around
1450 *spec = spec_org.at(0);
1452 int lastSlash = spec->lastIndexOf(QLatin1Char('/'));
1453 if (lastSlash != -1)
1454 spec->remove(0, lastSlash + 1);
1461 QMakeProject::isActiveConfig(const QString &x, bool regex, QHash<QString, QStringList> *place)
1466 //magic types for easy flipping
1469 else if(x == "false")
1474 return Option::target_mode == Option::TARG_UNIX_MODE
1475 || Option::target_mode == Option::TARG_MACX_MODE;
1476 } else if (x == "macx" || x == "mac") {
1478 return Option::target_mode == Option::TARG_MACX_MODE;
1479 } else if (x == "win32") {
1481 return Option::target_mode == Option::TARG_WIN_MODE;
1485 static QString spec;
1486 resolveSpec(&spec, Option::mkfile::qmakespec);
1487 QRegExp re(x, Qt::CaseSensitive, QRegExp::Wildcard);
1488 if((regex && re.exactMatch(spec)) || (!regex && spec == x))
1492 const QStringList &configs = (place ? (*place)["CONFIG"] : vars["CONFIG"]);
1493 for(QStringList::ConstIterator it = configs.begin(); it != configs.end(); ++it) {
1494 if(((regex && re.exactMatch((*it))) || (!regex && (*it) == x)) && re.exactMatch((*it)))
1501 QMakeProject::doProjectTest(QString str, QHash<QString, QStringList> &place)
1503 QString chk = remove_quotes(str);
1506 bool invert_test = (chk.left(1) == "!");
1511 int lparen = chk.indexOf('(');
1512 if(lparen != -1) { // if there is an lparen in the chk, it IS a function
1513 int rparen = chk.indexOf(')', lparen);
1515 qmake_error_msg("Function missing right paren: " + chk);
1517 QString func = chk.left(lparen);
1518 test = doProjectTest(func, chk.mid(lparen+1, rparen - lparen - 1), place);
1521 test = isActiveConfig(chk, true, &place);
1529 QMakeProject::doProjectTest(QString func, const QString ¶ms,
1530 QHash<QString, QStringList> &place)
1532 return doProjectTest(func, split_arg_list(params), place);
1535 QMakeProject::IncludeStatus
1536 QMakeProject::doProjectInclude(QString file, uchar flags, QHash<QString, QStringList> &place)
1538 enum { UnknownFormat, ProFormat, JSFormat } format = UnknownFormat;
1539 if(flags & IncludeFlagFeature) {
1540 if(!file.endsWith(Option::prf_ext))
1541 file += Option::prf_ext;
1542 validateModes(); // init dir_sep
1543 if(file.indexOf(QLatin1Char('/')) == -1 || !QFile::exists(file)) {
1544 static QStringList *feature_roots = 0;
1545 if(!feature_roots) {
1546 feature_roots = new QStringList(qmake_feature_paths(prop));
1547 qmakeAddCacheClear(qmakeDeleteCacheClear<QStringList>, (void**)&feature_roots);
1549 debug_msg(2, "Looking for feature '%s' in (%s)", file.toLatin1().constData(),
1550 feature_roots->join("::").toLatin1().constData());
1552 if(parser.from_file) {
1553 QFileInfo currFile(parser.file), prfFile(file);
1554 if(currFile.fileName() == prfFile.fileName()) {
1555 currFile = QFileInfo(currFile.canonicalFilePath());
1556 for(int root = 0; root < feature_roots->size(); ++root) {
1557 prfFile = QFileInfo(feature_roots->at(root) +
1558 QLatin1Char('/') + file).canonicalFilePath();
1559 if(prfFile == currFile) {
1560 start_root = root+1;
1566 for(int root = start_root; root < feature_roots->size(); ++root) {
1567 QString prf(feature_roots->at(root) + QLatin1Char('/') + file);
1568 if(QFile::exists(prf + Option::js_ext)) {
1570 file = prf + Option::js_ext;
1572 } else if(QFile::exists(prf)) {
1578 if(format == UnknownFormat)
1579 return IncludeNoExist;
1581 if(place["QMAKE_INTERNAL_INCLUDED_FEATURES"].indexOf(file) != -1)
1582 return IncludeFeatureAlreadyLoaded;
1583 place["QMAKE_INTERNAL_INCLUDED_FEATURES"].append(file);
1585 if(QDir::isRelativePath(file)) {
1586 QStringList include_roots;
1587 if(Option::output_dir != qmake_getpwd())
1588 include_roots << qmake_getpwd();
1589 include_roots << Option::output_dir;
1590 for(int root = 0; root < include_roots.size(); ++root) {
1591 QString testName = QDir::fromNativeSeparators(include_roots[root]);
1592 if (!testName.endsWith(QLatin1Char('/')))
1593 testName += QLatin1Char('/');
1595 if(QFile::exists(testName)) {
1601 if(format == UnknownFormat) {
1602 if(QFile::exists(file)) {
1603 if(file.endsWith(Option::js_ext))
1608 return IncludeNoExist;
1611 if(Option::mkfile::do_preprocess) //nice to see this first..
1612 fprintf(stderr, "#switching file %s(%s) - %s:%d\n", (flags & IncludeFlagFeature) ? "load" : "include",
1613 file.toLatin1().constData(),
1614 parser.file.toLatin1().constData(), parser.line_no);
1615 debug_msg(1, "Project Parser: %s'ing file %s.", (flags & IncludeFlagFeature) ? "load" : "include",
1616 file.toLatin1().constData());
1618 QString orig_file = file;
1619 int di = file.lastIndexOf(QLatin1Char('/'));
1620 QString oldpwd = qmake_getpwd();
1622 if(!qmake_setpwd(file.left(file.lastIndexOf(QLatin1Char('/'))))) {
1623 fprintf(stderr, "Cannot find directory: %s\n", file.left(di).toLatin1().constData());
1624 return IncludeFailure;
1627 bool parsed = false;
1628 parser_info pi = parser;
1629 if(format == JSFormat) {
1630 warn_msg(WarnParser, "%s:%d: QtScript support disabled for %s.",
1631 pi.file.toLatin1().constData(), pi.line_no, orig_file.toLatin1().constData());
1633 if(flags & (IncludeFlagNewProject|IncludeFlagNewParser)) {
1634 // The "project's variables" are used in other places (eg. export()) so it's not
1635 // possible to use "place" everywhere. Instead just set variables and grab them later
1636 QMakeProject proj(prop);
1637 if(flags & IncludeFlagNewParser) {
1638 parsed = proj.read(file, proj.variables()); // parse just that file (fromfile, infile)
1640 parsed = proj.read(file); // parse all aux files (load/include into)
1642 place = proj.variables();
1644 QStack<ScopeBlock> sc = scope_blocks;
1645 IteratorBlock *it = iterator;
1646 FunctionBlock *fu = function;
1647 parsed = read(file, place);
1654 if(place["QMAKE_INTERNAL_INCLUDED_FILES"].indexOf(orig_file) == -1)
1655 place["QMAKE_INTERNAL_INCLUDED_FILES"].append(orig_file);
1657 warn_msg(WarnParser, "%s:%d: Failure to include file %s.",
1658 pi.file.toLatin1().constData(), pi.line_no, orig_file.toLatin1().constData());
1661 qmake_setpwd(oldpwd);
1663 return IncludeParseFailure;
1664 return IncludeSuccess;
1668 QMakeProject::doProjectExpand(QString func, const QString ¶ms,
1669 QHash<QString, QStringList> &place)
1671 return doProjectExpand(func, split_arg_list(params), place);
1675 QMakeProject::doProjectExpand(QString func, QStringList args,
1676 QHash<QString, QStringList> &place)
1678 QList<QStringList> args_list;
1679 for(int i = 0; i < args.size(); ++i) {
1680 QStringList arg = split_value_list(args[i]), tmp;
1681 for(int i = 0; i < arg.size(); ++i)
1682 tmp += doVariableReplaceExpand(arg[i], place);;
1685 return doProjectExpand(func, args_list, place);
1689 populateDeps(const QStringList &deps, const QString &prefix,
1690 QHash<QString, QSet<QString> > &dependencies, QHash<QString, QStringList> &dependees,
1691 QStringList &rootSet, QHash<QString, QStringList> &place)
1693 foreach (const QString &item, deps)
1694 if (!dependencies.contains(item)) {
1695 QSet<QString> &dset = dependencies[item]; // Always create entry
1696 QStringList depends = place.value(prefix + item + ".depends");
1697 if (depends.isEmpty()) {
1700 foreach (const QString &dep, depends) {
1702 dependees[dep] << item;
1704 populateDeps(depends, prefix, dependencies, dependees, rootSet, place);
1710 QMakeProject::doProjectExpand(QString func, QList<QStringList> args_list,
1711 QHash<QString, QStringList> &place)
1713 func = func.trimmed();
1714 if(replaceFunctions.contains(func)) {
1715 FunctionBlock *defined = replaceFunctions[func];
1716 function_blocks.push(defined);
1718 defined->exec(args_list, this, place, ret);
1719 Q_ASSERT(function_blocks.pop() == defined);
1723 QStringList args; //why don't the builtin functions just use args_list? --Sam
1724 for(int i = 0; i < args_list.size(); ++i)
1725 args += args_list[i].join(QString(Option::field_sep));
1727 ExpandFunc func_t = qmake_expandFunctions().value(func);
1728 if (!func_t && (func_t = qmake_expandFunctions().value(func.toLower())))
1729 warn_msg(WarnDeprecated, "%s:%d: Using uppercased builtin functions is deprecated.",
1730 parser.file.toLatin1().constData(), parser.line_no);
1731 debug_msg(1, "Running project expand: %s(%s) [%d]",
1732 func.toLatin1().constData(), args.join("::").toLatin1().constData(), func_t);
1737 if(args.count() < 1 || args.count() > 3) {
1738 fprintf(stderr, "%s:%d: member(var, start, end) requires three arguments.\n",
1739 parser.file.toLatin1().constData(), parser.line_no);
1742 const QStringList &var = values(args.first(), place);
1743 int start = 0, end = 0;
1744 if(args.count() >= 2) {
1745 QString start_str = args[1];
1746 start = start_str.toInt(&ok);
1748 if(args.count() == 2) {
1749 int dotdot = start_str.indexOf("..");
1751 start = start_str.left(dotdot).toInt(&ok);
1753 end = start_str.mid(dotdot+2).toInt(&ok);
1757 fprintf(stderr, "%s:%d: member() argument 2 (start) '%s' invalid.\n",
1758 parser.file.toLatin1().constData(), parser.line_no,
1759 start_str.toLatin1().constData());
1762 if(args.count() == 3)
1763 end = args[2].toInt(&ok);
1765 fprintf(stderr, "%s:%d: member() argument 3 (end) '%s' invalid.\n",
1766 parser.file.toLatin1().constData(), parser.line_no,
1767 args[2].toLatin1().constData());
1772 start += var.count();
1775 if(start < 0 || start >= var.count() || end < 0 || end >= var.count()) {
1777 } else if(start < end) {
1778 for(int i = start; i <= end && (int)var.count() >= i; i++)
1781 for(int i = start; i >= end && (int)var.count() >= i && i >= 0; i--)
1789 if(args.count() != 1) {
1790 fprintf(stderr, "%s:%d: %s(var) requires one argument.\n",
1791 parser.file.toLatin1().constData(), parser.line_no, func.toLatin1().constData());
1793 const QStringList &var = values(args.first(), place);
1794 if(!var.isEmpty()) {
1795 if(func_t == E_FIRST)
1796 ret = QStringList(var[0]);
1798 ret = QStringList(var[var.size()-1]);
1803 if(args.count() < 1 || args.count() > 2) {
1804 fprintf(stderr, "%s:%d: cat(file) requires one argument.\n",
1805 parser.file.toLatin1().constData(), parser.line_no);
1807 QString file = Option::normalizePath(args[0]);
1809 bool singleLine = true;
1810 if(args.count() > 1)
1811 singleLine = (args[1].toLower() == "true");
1814 if(qfile.open(QIODevice::ReadOnly)) {
1815 QTextStream stream(&qfile);
1816 while(!stream.atEnd()) {
1817 ret += split_value_list(stream.readLine().trimmed());
1826 if(args.count() != 2) {
1827 fprintf(stderr, "%s:%d: fromfile(file, variable) requires two arguments.\n",
1828 parser.file.toLatin1().constData(), parser.line_no);
1830 QString seek_var = args[1], file = Option::normalizePath(args[0]);
1832 QHash<QString, QStringList> tmp;
1833 if(doProjectInclude(file, IncludeFlagNewParser, tmp) == IncludeSuccess) {
1834 if(tmp.contains("QMAKE_INTERNAL_INCLUDED_FILES")) {
1835 QStringList &out = place["QMAKE_INTERNAL_INCLUDED_FILES"];
1836 const QStringList &in = tmp["QMAKE_INTERNAL_INCLUDED_FILES"];
1837 for(int i = 0; i < in.size(); ++i) {
1838 if(out.indexOf(in[i]) == -1)
1842 ret = tmp[seek_var];
1847 if(args.count() < 1 || args.count() > 2) {
1848 fprintf(stderr, "%s:%d: eval(variable) requires one argument.\n",
1849 parser.file.toLatin1().constData(), parser.line_no);
1852 const QHash<QString, QStringList> *source = &place;
1853 if(args.count() == 2) {
1854 if(args.at(1) == "Global") {
1856 } else if(args.at(1) == "Local") {
1859 fprintf(stderr, "%s:%d: unexpected source to eval.\n", parser.file.toLatin1().constData(),
1863 ret += source->value(args.at(0));
1869 tmp.sprintf(".QMAKE_INTERNAL_TMP_VAR_%d", x++);
1870 ret = QStringList(tmp);
1871 QStringList &lst = (*((QHash<QString, QStringList>*)&place))[tmp];
1873 for(QStringList::ConstIterator arg_it = args.begin();
1874 arg_it != args.end(); ++arg_it)
1875 lst += split_value_list((*arg_it));
1878 if(args.count() < 1) {
1879 fprintf(stderr, "%s:%d: sprintf(format, ...) requires one argument.\n",
1880 parser.file.toLatin1().constData(), parser.line_no);
1882 QString tmp = args.at(0);
1883 for(int i = 1; i < args.count(); ++i)
1884 tmp = tmp.arg(args.at(i));
1885 ret = split_value_list(tmp);
1889 if(args.count() < 1 || args.count() > 4) {
1890 fprintf(stderr, "%s:%d: join(var, glue, before, after) requires four"
1891 "arguments.\n", parser.file.toLatin1().constData(), parser.line_no);
1893 QString glue, before, after;
1894 if(args.count() >= 2)
1896 if(args.count() >= 3)
1898 if(args.count() == 4)
1900 const QStringList &var = values(args.first(), place);
1902 ret = split_value_list(before + var.join(glue) + after);
1906 if(args.count() < 1 || args.count() > 2) {
1907 fprintf(stderr, "%s:%d split(var, sep) requires one or two arguments\n",
1908 parser.file.toLatin1().constData(), parser.line_no);
1910 QString sep = QString(Option::field_sep);
1911 if(args.count() >= 2)
1913 QStringList var = values(args.first(), place);
1914 for(QStringList::ConstIterator vit = var.begin(); vit != var.end(); ++vit) {
1915 QStringList lst = (*vit).split(sep);
1916 for(QStringList::ConstIterator spltit = lst.begin(); spltit != lst.end(); ++spltit)
1924 bool regexp = false;
1927 if(func_t == E_SECTION) {
1928 if(args.count() != 3 && args.count() != 4) {
1929 fprintf(stderr, "%s:%d section(var, sep, begin, end) requires three argument\n",
1930 parser.file.toLatin1().constData(), parser.line_no);
1934 beg = args[2].toInt();
1935 if(args.count() == 4)
1936 end = args[3].toInt();
1939 if(args.count() != 1) {
1940 fprintf(stderr, "%s:%d %s(var) requires one argument.\n",
1941 parser.file.toLatin1().constData(), parser.line_no, func.toLatin1().constData());
1945 sep = "[" + QRegExp::escape(Option::dir_sep) + "/]";
1946 if(func_t == E_DIRNAME)
1953 const QStringList &l = values(var, place);
1954 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
1955 QString separator = sep;
1957 ret += (*it).section(QRegExp(separator), beg, end);
1959 ret += (*it).section(separator, beg, end);
1964 if(args.count() != 2) {
1965 fprintf(stderr, "%s:%d find(var, str) requires two arguments\n",
1966 parser.file.toLatin1().constData(), parser.line_no);
1968 QRegExp regx(args[1]);
1969 const QStringList &var = values(args.first(), place);
1970 for(QStringList::ConstIterator vit = var.begin();
1971 vit != var.end(); ++vit) {
1972 if(regx.indexIn(*vit) != -1)
1978 if(args.count() < 1 || args.count() > 2) {
1979 fprintf(stderr, "%s:%d system(execut) requires one argument.\n",
1980 parser.file.toLatin1().constData(), parser.line_no);
1983 bool singleLine = true;
1984 if(args.count() > 1)
1985 singleLine = (args[1].toLower() == "true");
1987 FILE *proc = QT_POPEN(args[0].toLatin1().constData(), "r");
1988 while(proc && !feof(proc)) {
1989 int read_in = int(fread(buff, 1, 255, proc));
1992 for(int i = 0; i < read_in; i++) {
1993 if((singleLine && buff[i] == '\n') || buff[i] == '\t')
1996 buff[read_in] = '\0';
1999 ret += split_value_list(output);
2005 if(args.count() != 1) {
2006 fprintf(stderr, "%s:%d unique(var) requires one argument.\n",
2007 parser.file.toLatin1().constData(), parser.line_no);
2009 const QStringList &var = values(args.first(), place);
2010 for(int i = 0; i < var.count(); i++) {
2011 if(!ret.contains(var[i]))
2019 case E_ESCAPE_EXPAND: {
2020 for(int i = 0; i < args.size(); ++i) {
2021 QChar *i_data = args[i].data();
2022 int i_len = args[i].length();
2023 for(int x = 0; x < i_len; ++x) {
2024 if(*(i_data+x) == '\\' && x < i_len-1) {
2025 if(*(i_data+x+1) == '\\') {
2030 } mapped_quotes[] = {
2036 for(int i = 0; mapped_quotes[i].in; ++i) {
2037 if(*(i_data+x+1) == mapped_quotes[i].in) {
2038 *(i_data+x) = mapped_quotes[i].out;
2040 memmove(i_data+x+1, i_data+x+2, (i_len-x-2)*sizeof(QChar));
2048 ret.append(QString(i_data, i_len));
2052 for(int i = 0; i < args.size(); ++i)
2053 ret += QRegExp::escape(args[i]);
2057 for(int i = 0; i < args.size(); ++i) {
2058 if(func_t == E_UPPER)
2059 ret += args[i].toUpper();
2061 ret += args[i].toLower();
2065 if(args.count() != 1 && args.count() != 2) {
2066 fprintf(stderr, "%s:%d files(pattern) requires one argument.\n",
2067 parser.file.toLatin1().constData(), parser.line_no);
2069 bool recursive = false;
2070 if(args.count() == 2)
2071 recursive = (args[1].toLower() == "true" || args[1].toInt());
2073 QString r = Option::normalizePath(args[0]);
2074 int slash = r.lastIndexOf(QLatin1Char('/'));
2076 dirs.append(r.left(slash));
2082 const QRegExp regex(r, Qt::CaseSensitive, QRegExp::Wildcard);
2083 for(int d = 0; d < dirs.count(); d++) {
2084 QString dir = dirs[d];
2085 if (!dir.isEmpty() && !dir.endsWith(QLatin1Char('/')))
2089 for(int i = 0; i < (int)qdir.count(); ++i) {
2090 if(qdir[i] == "." || qdir[i] == "..")
2092 QString fname = dir + qdir[i];
2093 if(QFileInfo(fname).isDir()) {
2097 if(regex.exactMatch(qdir[i]))
2104 if(args.count() != 1) {
2105 fprintf(stderr, "%s:%d prompt(question) requires one argument.\n",
2106 parser.file.toLatin1().constData(), parser.line_no);
2107 } else if(pfile == "-") {
2108 fprintf(stderr, "%s:%d prompt(question) cannot be used when '-o -' is used.\n",
2109 parser.file.toLatin1().constData(), parser.line_no);
2111 QString msg = fixEnvVariables(args.first());
2112 if(!msg.endsWith("?"))
2114 fprintf(stderr, "Project %s: %s ", func.toUpper().toLatin1().constData(),
2115 msg.toLatin1().constData());
2118 if(qfile.open(stdin, QIODevice::ReadOnly)) {
2119 QTextStream t(&qfile);
2120 ret = split_value_list(t.readLine());
2125 if(args.count() != 3 ) {
2126 fprintf(stderr, "%s:%d replace(var, before, after) requires three arguments\n",
2127 parser.file.toLatin1().constData(), parser.line_no);
2129 const QRegExp before( args[1] );
2130 const QString after( args[2] );
2131 QStringList var = values(args.first(), place);
2132 for(QStringList::Iterator it = var.begin(); it != var.end(); ++it)
2133 ret += it->replace(before, after);
2137 if(args.count() != 1) {
2138 fprintf(stderr, "%s:%d: size(var) requires one argument.\n",
2139 parser.file.toLatin1().constData(), parser.line_no);
2141 int size = values(args[0], place).size();
2142 ret += QString::number(size);
2145 case E_SORT_DEPENDS:
2146 case E_RESOLVE_DEPENDS: {
2147 if(args.count() < 1 || args.count() > 2) {
2148 fprintf(stderr, "%s:%d: %s(var, prefix) requires one or two arguments.\n",
2149 parser.file.toLatin1().constData(), parser.line_no, func.toLatin1().constData());
2151 QHash<QString, QSet<QString> > dependencies;
2152 QHash<QString, QStringList> dependees;
2153 QStringList rootSet;
2155 QStringList orgList = values(args[0], place);
2156 populateDeps(orgList, (args.count() != 2 ? QString() : args[1]),
2157 dependencies, dependees, rootSet, place);
2159 for (int i = 0; i < rootSet.size(); ++i) {
2160 const QString &item = rootSet.at(i);
2161 if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item))
2163 foreach (const QString &dep, dependees[item]) {
2164 QSet<QString> &dset = dependencies[dep];
2165 dset.remove(rootSet.at(i)); // *Don't* use 'item' - rootSet may have changed!
2173 fprintf(stderr, "%s:%d: Unknown replace function: %s\n",
2174 parser.file.toLatin1().constData(), parser.line_no,
2175 func.toLatin1().constData());
2182 QMakeProject::doProjectTest(QString func, QStringList args, QHash<QString, QStringList> &place)
2184 QList<QStringList> args_list;
2185 for(int i = 0; i < args.size(); ++i) {
2186 QStringList arg = split_value_list(args[i]), tmp;
2187 for(int i = 0; i < arg.size(); ++i)
2188 tmp += doVariableReplaceExpand(arg[i], place);
2191 return doProjectTest(func, args_list, place);
2195 QMakeProject::doProjectTest(QString func, QList<QStringList> args_list, QHash<QString, QStringList> &place)
2197 func = func.trimmed();
2199 if(testFunctions.contains(func)) {
2200 FunctionBlock *defined = testFunctions[func];
2202 function_blocks.push(defined);
2203 defined->exec(args_list, this, place, ret);
2204 Q_ASSERT(function_blocks.pop() == defined);
2209 if(ret.first() == "true") {
2211 } else if(ret.first() == "false") {
2215 int val = ret.first().toInt(&ok);
2218 fprintf(stderr, "%s:%d Unexpected return value from test %s [%s].\n",
2219 parser.file.toLatin1().constData(),
2220 parser.line_no, func.toLatin1().constData(),
2221 ret.join("::").toLatin1().constData());
2228 QStringList args; //why don't the builtin functions just use args_list? --Sam
2229 for(int i = 0; i < args_list.size(); ++i)
2230 args += args_list[i].join(QString(Option::field_sep));
2232 TestFunc func_t = qmake_testFunctions().value(func);
2233 debug_msg(1, "Running project test: %s(%s) [%d]",
2234 func.toLatin1().constData(), args.join("::").toLatin1().constData(), func_t);
2238 return doProjectCheckReqs(args, place);
2240 case T_GREATERTHAN: {
2241 if(args.count() != 2) {
2242 fprintf(stderr, "%s:%d: %s(variable, value) requires two arguments.\n", parser.file.toLatin1().constData(),
2243 parser.line_no, func.toLatin1().constData());
2246 QString rhs(args[1]), lhs(values(args[0], place).join(QString(Option::field_sep)));
2248 int rhs_int = rhs.toInt(&ok);
2249 if(ok) { // do integer compare
2250 int lhs_int = lhs.toInt(&ok);
2252 if(func_t == T_GREATERTHAN)
2253 return lhs_int > rhs_int;
2254 return lhs_int < rhs_int;
2257 if(func_t == T_GREATERTHAN)
2261 if(args.count() != 1) {
2262 fprintf(stderr, "%s:%d: if(condition) requires one argument.\n", parser.file.toLatin1().constData(),
2266 const QString cond = args.first();
2267 const QChar *d = cond.unicode();
2269 bool ret = true, or_op = false;
2271 for(int d_off = 0, parens = 0, d_len = cond.size(); d_off < d_len; ++d_off) {
2272 if(!quote.isNull()) {
2273 if(*(d+d_off) == quote)
2275 } else if(*(d+d_off) == '(') {
2277 } else if(*(d+d_off) == ')') {
2279 } else if(*(d+d_off) == '"' /*|| *(d+d_off) == '\''*/) {
2282 if(!parens && quote.isNull() && (*(d+d_off) == QLatin1Char(':') || *(d+d_off) == QLatin1Char('|') || d_off == d_len-1)) {
2283 if(d_off == d_len-1)
2285 if(!test.isEmpty()) {
2287 ret = doProjectTest(test, place);
2290 if(*(d+d_off) == QLatin1Char(':')) {
2292 } else if(*(d+d_off) == QLatin1Char('|')) {
2301 if(args.count() != 2) {
2302 fprintf(stderr, "%s:%d: %s(variable, value) requires two arguments.\n", parser.file.toLatin1().constData(),
2303 parser.line_no, func.toLatin1().constData());
2306 return values(args[0], place).join(QString(Option::field_sep)) == args[1];
2308 if(args.count() != 1) {
2309 fprintf(stderr, "%s:%d: exists(file) requires one argument.\n", parser.file.toLatin1().constData(),
2313 QString file = Option::normalizePath(args.first());
2315 if(QFile::exists(file))
2317 //regular expression I guess
2318 QString dirstr = qmake_getpwd();
2319 int slsh = file.lastIndexOf(QLatin1Char('/'));
2321 dirstr = file.left(slsh+1);
2322 file = file.right(file.length() - slsh - 1);
2324 return QDir(dirstr).entryList(QStringList(file)).count(); }
2326 if(args.count() != 1) {
2327 fprintf(stderr, "%s:%d: export(variable) requires one argument.\n", parser.file.toLatin1().constData(),
2331 for(int i = 0; i < function_blocks.size(); ++i) {
2332 FunctionBlock *f = function_blocks.at(i);
2333 f->vars[args[0]] = values(args[0], place);
2334 if(!i && f->calling_place)
2335 (*f->calling_place)[args[0]] = values(args[0], place);
2339 if(args.count() != 1) {
2340 fprintf(stderr, "%s:%d: clear(variable) requires one argument.\n", parser.file.toLatin1().constData(),
2344 if(!place.contains(args[0]))
2346 place[args[0]].clear();
2349 if(args.count() != 1) {
2350 fprintf(stderr, "%s:%d: unset(variable) requires one argument.\n", parser.file.toLatin1().constData(),
2354 if(!place.contains(args[0]))
2356 place.remove(args[0]);
2359 if(args.count() < 1 && 0) {
2360 fprintf(stderr, "%s:%d: eval(project) requires one argument.\n", parser.file.toLatin1().constData(),
2364 QString project = args.join(" ");
2365 parser_info pi = parser;
2366 parser.from_file = false;
2367 parser.file = "(eval)";
2369 QTextStream t(&project, QIODevice::ReadOnly);
2370 bool ret = read(t, place);
2374 if(args.count() < 1 || args.count() > 2) {
2375 fprintf(stderr, "%s:%d: CONFIG(config) requires one argument.\n", parser.file.toLatin1().constData(),
2379 if(args.count() == 1)
2380 return isActiveConfig(args[0]);
2381 const QStringList mutuals = args[1].split('|');
2382 const QStringList &configs = values("CONFIG", place);
2383 for(int i = configs.size()-1; i >= 0; i--) {
2384 for(int mut = 0; mut < mutuals.count(); mut++) {
2385 if(configs[i] == mutuals[mut].trimmed())
2386 return (configs[i] == args[0]);
2391 if(args.count() < 1 || args.count() > 2) {
2392 fprintf(stderr, "%s:%d: system(exec) requires one argument.\n", parser.file.toLatin1().constData(),
2396 if(args.count() == 2) {
2397 const QString sarg = args[1];
2398 if (sarg.toLower() == "true" || sarg.toInt())
2399 warn_msg(WarnParser, "%s:%d: system()'s second argument is now hard-wired to false.\n",
2400 parser.file.toLatin1().constData(), parser.line_no);
2402 return system(args[0].toLatin1().constData()) == 0;
2404 if(function_blocks.isEmpty()) {
2405 fprintf(stderr, "%s:%d unexpected return()\n",
2406 parser.file.toLatin1().constData(), parser.line_no);
2408 FunctionBlock *f = function_blocks.top();
2409 f->cause_return = true;
2410 if(args_list.count() >= 1)
2411 f->return_value += args_list[0];
2416 iterator->cause_break = true;
2418 fprintf(stderr, "%s:%d unexpected break()\n",
2419 parser.file.toLatin1().constData(), parser.line_no);
2423 iterator->cause_next = true;
2425 fprintf(stderr, "%s:%d unexpected next()\n",
2426 parser.file.toLatin1().constData(), parser.line_no);
2429 if(args.count() < 1 || args.count() > 2) {
2430 fprintf(stderr, "%s:%d: defined(function) requires one argument.\n",
2431 parser.file.toLatin1().constData(), parser.line_no);
2433 if(args.count() > 1) {
2434 if(args[1] == "test")
2435 return testFunctions.contains(args[0]);
2436 else if(args[1] == "replace")
2437 return replaceFunctions.contains(args[0]);
2438 fprintf(stderr, "%s:%d: defined(function, type): unexpected type [%s].\n",
2439 parser.file.toLatin1().constData(), parser.line_no,
2440 args[1].toLatin1().constData());
2442 if(replaceFunctions.contains(args[0]) || testFunctions.contains(args[0]))
2448 if(args.count() < 2 || args.count() > 3) {
2449 fprintf(stderr, "%s:%d: contains(var, val) requires at lesat 2 arguments.\n",
2450 parser.file.toLatin1().constData(), parser.line_no);
2453 QRegExp regx(args[1]);
2454 const QStringList &l = values(args[0], place);
2455 if(args.count() == 2) {
2456 for(int i = 0; i < l.size(); ++i) {
2457 const QString val = l[i];
2458 if(regx.exactMatch(val) || val == args[1])
2462 const QStringList mutuals = args[2].split('|');
2463 for(int i = l.size()-1; i >= 0; i--) {
2464 const QString val = l[i];
2465 for(int mut = 0; mut < mutuals.count(); mut++) {
2466 if(val == mutuals[mut].trimmed())
2467 return (regx.exactMatch(val) || val == args[1]);
2473 if(args.count() < 2 || args.count() > 3) {
2474 fprintf(stderr, "%s:%d: infile(file, var, val) requires at least 2 arguments.\n",
2475 parser.file.toLatin1().constData(), parser.line_no);
2480 QHash<QString, QStringList> tmp;
2481 if(doProjectInclude(Option::normalizePath(args[0]), IncludeFlagNewParser, tmp) == IncludeSuccess) {
2482 if(tmp.contains("QMAKE_INTERNAL_INCLUDED_FILES")) {
2483 QStringList &out = place["QMAKE_INTERNAL_INCLUDED_FILES"];
2484 const QStringList &in = tmp["QMAKE_INTERNAL_INCLUDED_FILES"];
2485 for(int i = 0; i < in.size(); ++i) {
2486 if(out.indexOf(in[i]) == -1)
2490 if(args.count() == 2) {
2491 ret = tmp.contains(args[1]);
2493 QRegExp regx(args[2]);
2494 const QStringList &l = tmp[args[1]];
2495 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
2496 if(regx.exactMatch((*it)) || (*it) == args[2]) {
2505 if(args.count() != 2 && args.count() != 3) {
2506 fprintf(stderr, "%s:%d: count(var, count) requires two arguments.\n", parser.file.toLatin1().constData(),
2510 if(args.count() == 3) {
2511 QString comp = args[2];
2512 if(comp == ">" || comp == "greaterThan")
2513 return values(args[0], place).count() > args[1].toInt();
2515 return values(args[0], place).count() >= args[1].toInt();
2516 if(comp == "<" || comp == "lessThan")
2517 return values(args[0], place).count() < args[1].toInt();
2519 return values(args[0], place).count() <= args[1].toInt();
2520 if(comp == "equals" || comp == "isEqual" || comp == "=" || comp == "==")
2521 return values(args[0], place).count() == args[1].toInt();
2522 fprintf(stderr, "%s:%d: unexpected modifier to count(%s)\n", parser.file.toLatin1().constData(),
2523 parser.line_no, comp.toLatin1().constData());
2526 return values(args[0], place).count() == args[1].toInt();
2528 if(args.count() != 1) {
2529 fprintf(stderr, "%s:%d: isEmpty(var) requires one argument.\n", parser.file.toLatin1().constData(),
2533 return values(args[0], place).isEmpty();
2537 const bool include_statement = (func_t == T_INCLUDE);
2538 bool ignore_error = false;
2539 if(args.count() >= 2) {
2540 if(func_t == T_INCLUDE) {
2541 parseInto = args[1];
2542 if (args.count() == 3){
2543 QString sarg = args[2];
2544 if (sarg.toLower() == "true" || sarg.toInt())
2545 ignore_error = true;
2548 QString sarg = args[1];
2549 ignore_error = (sarg.toLower() == "true" || sarg.toInt());
2551 } else if(args.count() != 1) {
2552 QString func_desc = "load(feature)";
2553 if(include_statement)
2554 func_desc = "include(file)";
2555 fprintf(stderr, "%s:%d: %s requires one argument.\n", parser.file.toLatin1().constData(),
2556 parser.line_no, func_desc.toLatin1().constData());
2559 QString file = Option::normalizePath(args.first());
2560 uchar flags = IncludeFlagNone;
2561 if(!include_statement)
2562 flags |= IncludeFlagFeature;
2563 IncludeStatus stat = IncludeFailure;
2564 if(!parseInto.isEmpty()) {
2565 QHash<QString, QStringList> symbols;
2566 stat = doProjectInclude(file, flags|IncludeFlagNewProject, symbols);
2567 if(stat == IncludeSuccess) {
2568 QHash<QString, QStringList> out_place;
2569 for(QHash<QString, QStringList>::ConstIterator it = place.begin(); it != place.end(); ++it) {
2570 const QString var = it.key();
2571 if(var != parseInto && !var.startsWith(parseInto + "."))
2572 out_place.insert(var, it.value());
2574 for(QHash<QString, QStringList>::ConstIterator it = symbols.begin(); it != symbols.end(); ++it) {
2575 const QString var = it.key();
2576 if(!var.startsWith("."))
2577 out_place.insert(parseInto + "." + it.key(), it.value());
2582 stat = doProjectInclude(file, flags, place);
2584 if(stat == IncludeFeatureAlreadyLoaded) {
2585 warn_msg(WarnParser, "%s:%d: Duplicate of loaded feature %s",
2586 parser.file.toLatin1().constData(), parser.line_no, file.toLatin1().constData());
2587 } else if(stat == IncludeNoExist && !ignore_error) {
2588 warn_msg(WarnAll, "%s:%d: Unable to find file for inclusion %s",
2589 parser.file.toLatin1().constData(), parser.line_no, file.toLatin1().constData());
2591 } else if(stat >= IncludeFailure) {
2593 printf("Project LOAD(): Feature %s cannot be found.\n", file.toLatin1().constData());
2595 #if defined(QT_BUILD_QMAKE_LIBRARY)
2605 if(args.count() != 2) {
2606 fprintf(stderr, "%s:%d: debug(level, message) requires one argument.\n", parser.file.toLatin1().constData(),
2610 QString msg = fixEnvVariables(args[1]);
2611 debug_msg(args[0].toInt(), "Project DEBUG: %s", msg.toLatin1().constData());
2616 if(args.count() != 1) {
2617 fprintf(stderr, "%s:%d: %s(message) requires one argument.\n", parser.file.toLatin1().constData(),
2618 parser.line_no, func.toLatin1().constData());
2621 QString msg = fixEnvVariables(args.first());
2622 fprintf(stderr, "Project %s: %s\n", func.toUpper().toLatin1().constData(), msg.toLatin1().constData());
2624 #if defined(QT_BUILD_QMAKE_LIBRARY)
2631 if (args.count() != 1) {
2632 fprintf(stderr, "%s:%d: option() requires one argument.\n",
2633 parser.file.toLatin1().constData(), parser.line_no);
2636 if (args.first() == "recursive") {
2639 fprintf(stderr, "%s:%d: unrecognized option() argument '%s'.\n",
2640 parser.file.toLatin1().constData(), parser.line_no,
2641 args.first().toLatin1().constData());
2646 fprintf(stderr, "%s:%d: Unknown test function: %s\n", parser.file.toLatin1().constData(), parser.line_no,
2647 func.toLatin1().constData());
2653 QMakeProject::doProjectCheckReqs(const QStringList &deps, QHash<QString, QStringList> &place)
2656 for(QStringList::ConstIterator it = deps.begin(); it != deps.end(); ++it) {
2657 bool test = doProjectTest((*it), place);
2659 debug_msg(1, "Project Parser: %s:%d Failed test: REQUIRES = %s",
2660 parser.file.toLatin1().constData(), parser.line_no,
2661 (*it).toLatin1().constData());
2662 place["QMAKE_FAILED_REQUIREMENTS"].append((*it));
2670 QMakeProject::test(const QString &v)
2672 QHash<QString, QStringList> tmp = vars;
2673 return doProjectTest(v, tmp);
2677 QMakeProject::test(const QString &func, const QList<QStringList> &args)
2679 QHash<QString, QStringList> tmp = vars;
2680 return doProjectTest(func, args, tmp);
2684 QMakeProject::expand(const QString &str)
2687 QHash<QString, QStringList> tmp = vars;
2688 const QStringList ret = doVariableReplaceExpand(str, tmp, &ok);
2691 return QStringList();
2695 QMakeProject::expand(const QString &str, const QString &file, int line)
2698 parser_info pi = parser;
2700 parser.line_no = line;
2701 parser.from_file = false;
2702 QHash<QString, QStringList> tmp = vars;
2703 const QStringList ret = doVariableReplaceExpand(str, tmp, &ok);
2705 return ok ? ret.join(QString(Option::field_sep)) : QString();
2709 QMakeProject::expand(const QString &func, const QList<QStringList> &args)
2711 QHash<QString, QStringList> tmp = vars;
2712 return doProjectExpand(func, args, tmp);
2716 QMakeProject::doVariableReplace(QString &str, QHash<QString, QStringList> &place)
2719 str = doVariableReplaceExpand(str, place, &ret).join(QString(Option::field_sep));
2724 QMakeProject::doVariableReplaceExpand(const QString &str, QHash<QString, QStringList> &place, bool *ok)
2732 const ushort LSQUARE = '[';
2733 const ushort RSQUARE = ']';
2734 const ushort LCURLY = '{';
2735 const ushort RCURLY = '}';
2736 const ushort LPAREN = '(';
2737 const ushort RPAREN = ')';
2738 const ushort DOLLAR = '$';
2739 const ushort SLASH = '\\';
2740 const ushort UNDERSCORE = '_';
2741 const ushort DOT = '.';
2742 const ushort SPACE = ' ';
2743 const ushort TAB = '\t';
2744 const ushort SINGLEQUOTE = '\'';
2745 const ushort DOUBLEQUOTE = '"';
2747 ushort unicode, quote = 0;
2748 const QChar *str_data = str.data();
2749 const int str_len = str.length();
2756 for(int i = 0; i < str_len; ++i) {
2757 unicode = str_data[i].unicode();
2758 const int start_var = i;
2759 if(unicode == DOLLAR && str_len > i+2) {
2760 unicode = str_data[++i].unicode();
2761 if(unicode == DOLLAR) {
2765 enum { VAR, ENVIRON, FUNCTION, PROPERTY } var_type = VAR;
2766 unicode = str_data[++i].unicode();
2767 if(unicode == LSQUARE) {
2768 unicode = str_data[++i].unicode();
2770 var_type = PROPERTY;
2771 } else if(unicode == LCURLY) {
2772 unicode = str_data[++i].unicode();
2775 } else if(unicode == LPAREN) {
2776 unicode = str_data[++i].unicode();
2781 if(!(unicode & (0xFF<<8)) &&
2782 unicode != DOT && unicode != UNDERSCORE &&
2783 //unicode != SINGLEQUOTE && unicode != DOUBLEQUOTE &&
2784 (unicode < 'a' || unicode > 'z') && (unicode < 'A' || unicode > 'Z') &&
2785 (unicode < '0' || unicode > '9') && (!term || unicode != '/'))
2787 var.append(QChar(unicode));
2790 unicode = str_data[i].unicode();
2791 // at this point, i points to either the 'term' or 'next' character (which is in unicode)
2793 if(var_type == VAR && unicode == LPAREN) {
2794 var_type = FUNCTION;
2799 unicode = str_data[i].unicode();
2800 if(unicode == LPAREN) {
2802 } else if(unicode == RPAREN) {
2807 args.append(QChar(unicode));
2810 unicode = str_data[i].unicode();
2813 // at this point i is pointing to the 'next' character (which is in unicode)
2814 // this might actually be a term character since you can do $${func()}
2817 if(unicode != term) {
2818 qmake_error_msg("Missing " + QString(term) + " terminator [found " + (unicode?QString(unicode):QString("end-of-line")) + "]");
2821 return QStringList();
2824 // move the 'cursor' back to the last char of the thing we were looking at
2827 // since i never points to the 'next' character, there is no reason for this to be set
2830 QStringList replacement;
2831 if(var_type == ENVIRON) {
2832 replacement = split_value_list(QString::fromLocal8Bit(qgetenv(var.toLatin1().constData())));
2833 } else if(var_type == PROPERTY) {
2835 replacement = split_value_list(prop->value(var));
2836 } else if(var_type == FUNCTION) {
2837 replacement = doProjectExpand(var, args, place);
2838 } else if(var_type == VAR) {
2839 replacement = values(var, place);
2841 if(!(replaced++) && start_var)
2842 current = str.left(start_var);
2843 if(!replacement.isEmpty()) {
2845 current += replacement.join(QString(Option::field_sep));
2847 current += replacement.takeFirst();
2848 if(!replacement.isEmpty()) {
2849 if(!current.isEmpty())
2850 ret.append(current);
2851 current = replacement.takeLast();
2852 if(!replacement.isEmpty())
2857 debug_msg(2, "Project Parser [var replace]: %s -> %s",
2858 str.toLatin1().constData(), var.toLatin1().constData(),
2859 replacement.join("::").toLatin1().constData());
2862 current.append("$");
2865 if(quote && unicode == quote) {
2868 } else if(unicode == SLASH) {
2869 bool escape = false;
2870 const char *symbols = "[]{}()$\\'\"";
2871 for(const char *s = symbols; *s; ++s) {
2872 if(str_data[i+1].unicode() == (ushort)*s) {
2876 current = str.left(start_var);
2877 current.append(str.at(i));
2881 if(!escape && !backslashWarned) {
2882 backslashWarned = true;
2883 warn_msg(WarnDeprecated, "%s:%d: Unescaped backslashes are deprecated.",
2884 parser.file.toLatin1().constData(), parser.line_no);
2886 if(escape || !replaced)
2888 } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
2891 if(!(replaced++) && i)
2892 current = str.left(i);
2893 } else if(!quote && (unicode == SPACE || unicode == TAB)) {
2895 if(!current.isEmpty()) {
2896 ret.append(current);
2900 if(replaced && unicode)
2901 current.append(QChar(unicode));
2904 ret = QStringList(str);
2905 else if(!current.isEmpty())
2906 ret.append(current);
2907 //qDebug() << "REPLACE" << str << ret;
2909 warn_msg(WarnDeprecated, "%s:%d: Unmatched quotes are deprecated.",
2910 parser.file.toLatin1().constData(), parser.line_no);
2914 QStringList &QMakeProject::values(const QString &_var, QHash<QString, QStringList> &place)
2916 QString var = varMap(_var);
2917 if(var == QLatin1String("LITERAL_WHITESPACE")) { //a real space in a token)
2918 var = ".BUILTIN." + var;
2919 place[var] = QStringList(QLatin1String("\t"));
2920 } else if(var == QLatin1String("LITERAL_DOLLAR")) { //a real $
2921 var = ".BUILTIN." + var;
2922 place[var] = QStringList(QLatin1String("$"));
2923 } else if(var == QLatin1String("LITERAL_HASH")) { //a real #
2924 var = ".BUILTIN." + var;
2925 place[var] = QStringList("#");
2926 } else if(var == QLatin1String("OUT_PWD")) { //the out going dir
2927 var = ".BUILTIN." + var;
2928 place[var] = QStringList(Option::output_dir);
2929 } else if(var == QLatin1String("PWD") || //current working dir (of _FILE_)
2930 var == QLatin1String("IN_PWD")) {
2931 var = ".BUILTIN." + var;
2932 place[var] = QStringList(qmake_getpwd());
2933 } else if(var == QLatin1String("DIR_SEPARATOR")) {
2935 var = ".BUILTIN." + var;
2936 place[var] = QStringList(Option::dir_sep);
2937 } else if(var == QLatin1String("DIRLIST_SEPARATOR")) {
2938 var = ".BUILTIN." + var;
2939 place[var] = QStringList(Option::dirlist_sep);
2940 } else if(var == QLatin1String("_LINE_")) { //parser line number
2941 var = ".BUILTIN." + var;
2942 place[var] = QStringList(QString::number(parser.line_no));
2943 } else if(var == QLatin1String("_FILE_")) { //parser file
2944 var = ".BUILTIN." + var;
2945 place[var] = QStringList(parser.file);
2946 } else if(var == QLatin1String("_DATE_")) { //current date/time
2947 var = ".BUILTIN." + var;
2948 place[var] = QStringList(QDateTime::currentDateTime().toString());
2949 } else if(var == QLatin1String("_PRO_FILE_")) {
2950 var = ".BUILTIN." + var;
2951 place[var] = QStringList(pfile);
2952 } else if(var == QLatin1String("_PRO_FILE_PWD_")) {
2953 var = ".BUILTIN." + var;
2954 place[var] = QStringList(pfile.isEmpty() ? qmake_getpwd() : QFileInfo(pfile).absolutePath());
2955 } else if(var == QLatin1String("_QMAKE_CACHE_")) {
2956 var = ".BUILTIN." + var;
2957 if(Option::mkfile::do_cache)
2958 place[var] = QStringList(Option::mkfile::cachefile);
2959 } else if(var == QLatin1String("TEMPLATE")) {
2960 if(!Option::user_template.isEmpty()) {
2961 var = ".BUILTIN.USER." + var;
2962 place[var] = QStringList(Option::user_template);
2964 QString orig_template, real_template;
2965 if(!place[var].isEmpty())
2966 orig_template = place[var].first();
2967 real_template = orig_template.isEmpty() ? "app" : orig_template;
2968 if(!Option::user_template_prefix.isEmpty() && !orig_template.startsWith(Option::user_template_prefix))
2969 real_template.prepend(Option::user_template_prefix);
2970 if(real_template != orig_template) {
2971 var = ".BUILTIN." + var;
2972 place[var] = QStringList(real_template);
2975 } else if(var.startsWith(QLatin1String("QMAKE_HOST."))) {
2976 QString ret, type = var.mid(11);
2977 #if defined(Q_OS_WIN32)
2980 } else if(type == "name") {
2981 DWORD name_length = 1024;
2983 if (GetComputerName(name, &name_length))
2984 ret = QString::fromWCharArray(name);
2985 } else if(type == "version" || type == "version_string") {
2986 QSysInfo::WinVersion ver = QSysInfo::WindowsVersion;
2987 if(type == "version")
2988 ret = QString::number(ver);
2989 else if(ver == QSysInfo::WV_Me)
2991 else if(ver == QSysInfo::WV_95)
2993 else if(ver == QSysInfo::WV_98)
2995 else if(ver == QSysInfo::WV_NT)
2997 else if(ver == QSysInfo::WV_2000)
2999 else if(ver == QSysInfo::WV_2000)
3001 else if(ver == QSysInfo::WV_XP)
3003 else if(ver == QSysInfo::WV_VISTA)
3007 } else if(type == "arch") {
3009 GetSystemInfo(&info);
3010 switch(info.wProcessorArchitecture) {
3011 #ifdef PROCESSOR_ARCHITECTURE_AMD64
3012 case PROCESSOR_ARCHITECTURE_AMD64:
3016 case PROCESSOR_ARCHITECTURE_INTEL:
3019 case PROCESSOR_ARCHITECTURE_IA64:
3020 #ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
3021 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
3030 #elif defined(Q_OS_UNIX)
3031 struct utsname name;
3035 else if(type == "name")
3036 ret = name.nodename;
3037 else if(type == "version")
3039 else if(type == "version_string")
3041 else if(type == "arch")
3045 var = ".BUILTIN.HOST." + type;
3046 place[var] = QStringList(ret);
3047 } else if (var == QLatin1String("QMAKE_DIR_SEP")) {
3048 if (place[var].isEmpty())
3049 return values("DIR_SEPARATOR", place);
3050 } else if (var == QLatin1String("QMAKE_EXT_OBJ")) {
3051 if (place[var].isEmpty()) {
3052 var = ".BUILTIN." + var;
3053 place[var] = QStringList(Option::obj_ext);
3055 } else if (var == QLatin1String("QMAKE_QMAKE")) {
3056 if (place[var].isEmpty())
3057 place[var] = QStringList(Option::fixPathToTargetOS(
3058 !Option::qmake_abslocation.isEmpty()
3059 ? Option::qmake_abslocation
3060 : QLibraryInfo::location(QLibraryInfo::HostBinariesPath) + "/qmake",
3063 #if defined(Q_OS_WIN32) && defined(Q_CC_MSVC)
3064 else if(var.startsWith(QLatin1String("QMAKE_TARGET."))) {
3065 QString ret, type = var.mid(13);
3066 if(type == "arch") {
3067 QString paths = QString::fromLocal8Bit(qgetenv("PATH"));
3068 QString vcBin64 = QString::fromLocal8Bit(qgetenv("VCINSTALLDIR"));
3069 if (!vcBin64.endsWith('\\'))
3070 vcBin64.append('\\');
3071 vcBin64.append("bin\\amd64");
3072 QString vcBinX86_64 = QString::fromLocal8Bit(qgetenv("VCINSTALLDIR"));
3073 if (!vcBinX86_64.endsWith('\\'))
3074 vcBinX86_64.append('\\');
3075 vcBinX86_64.append("bin\\x86_amd64");
3076 if(paths.contains(vcBin64,Qt::CaseInsensitive) || paths.contains(vcBinX86_64,Qt::CaseInsensitive))
3081 place[var] = QStringList(ret);
3084 //qDebug("REPLACE [%s]->[%s]", qPrintable(var), qPrintable(place[var].join("::")));
3088 bool QMakeProject::isEmpty(const QString &v)
3090 QHash<QString, QStringList>::ConstIterator it = vars.constFind(varMap(v));
3091 return it == vars.constEnd() || it->isEmpty();