Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/qmake/project.cpp

    r405 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the qmake application of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4444#include "option.h"
    4545#include "cachekeys.h"
     46
     47
    4648
    4749#include <qdatetime.h>
     
    5860#include <sys/utsname.h>
    5961#elif defined(Q_OS_WIN32)
    60 #include <Windows.h>
     62#include <indows.h>
    6163#elif defined(Q_OS_OS2)
    6264#include <qt_os2.h>
     
    7981                  E_SPRINTF, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION,
    8082                  E_FIND, E_SYSTEM, E_UNIQUE, E_QUOTE, E_ESCAPE_EXPAND,
    81                   E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_REPLACE };
     83                  E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_REPLACE,
     84                  E_SIZE };
    8285QMap<QString, ExpandFunc> qmake_expandFunctions()
    8386{
     
    110113        qmake_expand_functions->insert("prompt", E_PROMPT);
    111114        qmake_expand_functions->insert("replace", E_REPLACE);
     115
    112116    }
    113117    return *qmake_expand_functions;
     
    155159    return *qmake_test_functions;
    156160}
    157 
    158 QT_END_NAMESPACE
    159 
    160 #ifdef QTSCRIPT_SUPPORT
    161 #include "qscriptvalue.h"
    162 #include "qscriptengine.h"
    163 #include "qscriptvalueiterator.h"
    164 
    165 QT_BEGIN_NAMESPACE
    166 
    167 static QScriptValue qscript_projectWrapper(QScriptEngine *eng, QMakeProject *project,
    168                                     const QMap<QString, QStringList> &place);
    169 
    170 static bool qscript_createQMakeProjectMap(QMap<QString, QStringList> &vars, QScriptValue js)
    171 {
    172     QScriptValueIterator it(js);
    173     while(it.hasNext()) {
    174         it.next();
    175         vars[it.name()] = qscriptvalue_cast<QStringList>(it.value());
    176     }
    177     return true;
    178 }
    179 
    180 static QScriptValue qscript_call_testfunction(QScriptContext *context, QScriptEngine *engine)
    181 {
    182     QMakeProject *self = qscriptvalue_cast<QMakeProject*>(context->callee().property("qmakeProject"));
    183     QString func = context->callee().property("functionName").toString();
    184     QStringList args;
    185     for(int i = 0; i < context->argumentCount(); ++i)
    186         args += context->argument(i).toString();
    187     QMap<QString, QStringList> place = self->variables();
    188     qscript_createQMakeProjectMap(place, engine->globalObject().property("qmake"));
    189     QScriptValue ret(engine, self->doProjectTest(func, args, place));
    190     engine->globalObject().setProperty("qmake", qscript_projectWrapper(engine, self, place));
    191     return ret;
    192 }
    193 
    194 static QScriptValue qscript_call_expandfunction(QScriptContext *context, QScriptEngine *engine)
    195 {
    196     QMakeProject *self = qscriptvalue_cast<QMakeProject*>(context->callee().property("qmakeProject"));
    197     QString func = context->callee().property("functionName").toString();
    198     QStringList args;
    199     for(int i = 0; i < context->argumentCount(); ++i)
    200         args += context->argument(i).toString();
    201     QMap<QString, QStringList> place = self->variables();
    202     qscript_createQMakeProjectMap(place, engine->globalObject().property("qmake"));
    203     QScriptValue ret = qScriptValueFromValue(engine, self->doProjectExpand(func, args, place));
    204     engine->globalObject().setProperty("qmake", qscript_projectWrapper(engine, self, place));
    205     return ret;
    206 }
    207 
    208 static QScriptValue qscript_projectWrapper(QScriptEngine *eng, QMakeProject *project,
    209                                            const QMap<QString, QStringList> &place)
    210 {
    211     QScriptValue ret = eng->newObject();
    212     {
    213         QStringList testFuncs = qmake_testFunctions().keys() + project->userTestFunctions();
    214         for(int i = 0; i < testFuncs.size(); ++i) {
    215             QString funcName = testFuncs.at(i);
    216             QScriptValue fun = eng->newFunction(qscript_call_testfunction);
    217             fun.setProperty("qmakeProject", eng->newVariant(qVariantFromValue(project)));
    218             fun.setProperty("functionName", QScriptValue(eng, funcName));
    219             eng->globalObject().setProperty(funcName, fun);
    220         }
    221     }
    222     {
    223         QStringList testFuncs = qmake_expandFunctions().keys() + project->userExpandFunctions();
    224         for(int i = 0; i < testFuncs.size(); ++i) {
    225             QString funcName = testFuncs.at(i);
    226             QScriptValue fun = eng->newFunction(qscript_call_expandfunction);
    227             fun.setProperty("qmakeProject", eng->newVariant(qVariantFromValue(project)));
    228             fun.setProperty("functionName", QScriptValue(eng, funcName));
    229             eng->globalObject().setProperty(funcName, fun);
    230         }
    231     }
    232     for(QMap<QString, QStringList>::ConstIterator it = place.begin(); it != place.end(); ++it)
    233         ret.setProperty(it.key(), qScriptValueFromValue(eng, it.value()));
    234     return ret;
    235 }
    236 
    237 QT_END_NAMESPACE
    238 
    239 #endif
    240 
    241 QT_BEGIN_NAMESPACE
    242161
    243162struct parser_info {
     
    591510}
    592511
     512
     513
     514
     515
     516
     517
     518
     519
     520
     521
     522
     523
     524
     525
     526
     527
     528
     529
     530
     531
     532
     533
     534
     535
     536
     537
     538
     539
     540
     541
     542
     543
     544
     545
     546
     547
     548
     549
     550
     551
     552
     553
     554
     555
     556
     557
     558
     559
     560
     561
     562
     563
     564
     565
     566
     567
     568
     569
     570
     571
     572
     573
     574
    593575/*
    594576   1) environment variable QMAKEFEATURES (as separated by colons)
     
    617599            break;
    618600        case Option::TARG_UNIX_MODE:
    619             concat << base_concat + QDir::separator() + "unix";
    620             break;
     601            {
     602                if (isForSymbian())
     603                    concat << base_concat + QDir::separator() + "symbian";
     604                else
     605                    concat << base_concat + QDir::separator() + "unix";
     606                break;
     607            }
    621608        case Option::TARG_WIN_MODE:
    622             concat << base_concat + QDir::separator() + "win32";
    623             break;
     609            {
     610                if (isForSymbian())
     611                    concat << base_concat + QDir::separator() + "symbian";
     612                else
     613                    concat << base_concat + QDir::separator() + "win32";
     614                break;
     615            }
    624616        case Option::TARG_OS2_MODE:
    625617            concat << base_concat + QDir::separator() + "os2";
     
    628620            concat << base_concat + QDir::separator() + "mac";
    629621            concat << base_concat + QDir::separator() + "mac9";
    630             break;
    631         case Option::TARG_QNX6_MODE: //also a unix
    632             concat << base_concat + QDir::separator() + "qnx6";
    633             concat << base_concat + QDir::separator() + "unix";
    634622            break;
    635623        }
     
    14811469                return false;
    14821470            }
     1471
     1472
     1473
    14831474            if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty()) {
    14841475                debug_msg(1, "QMAKECACHE file: reading %s", Option::mkfile::cachefile.toLatin1().constData());
     
    15271518    if(cmd & ReadProFile) { // parse project file
    15281519        debug_msg(1, "Project file: reading %s", pfile.toLatin1().constData());
    1529         if(pfile != "-" && !QFile::exists(pfile) && !pfile.endsWith(".pro"))
    1530             pfile += ".pro";
     1520        if(pfile != "-" && !QFile::exists(pfile) && !pfile.endsWith())
     1521            pfile += ;
    15311522        if(!read(pfile, vars))
    15321523            return false;
     
    16151606        return false;
    16161607
     1608
     1609
     1610
     1611
     1612
     1613
     1614
     1615
     1616
     1617
     1618
     1619
    16171620    //mkspecs
    1618     if((Option::target_mode == Option::TARG_MACX_MODE || Option::target_mode == Option::TARG_QNX6_MODE ||
     1621    if((Option::target_mode == Option::TARG_MACX_MODE ||
    16191622        Option::target_mode == Option::TARG_UNIX_MODE) && x == "unix")
    1620         return true;
     1623        return ;
    16211624    else if(Option::target_mode == Option::TARG_MACX_MODE && x == "macx")
    1622         return true;
    1623     else if(Option::target_mode == Option::TARG_QNX6_MODE && x == "qnx6")
    1624         return true;
     1625        return !isForSymbian();
    16251626    else if(Option::target_mode == Option::TARG_MAC9_MODE && x == "mac9")
    1626         return true;
     1627        return ;
    16271628    else if((Option::target_mode == Option::TARG_MAC9_MODE || Option::target_mode == Option::TARG_MACX_MODE) &&
    16281629            x == "mac")
    1629         return true;
     1630        return ;
    16301631    else if(Option::target_mode == Option::TARG_WIN_MODE && x == "win32")
    1631         return true;
     1632        return ;
    16321633    else if(Option::target_mode == Option::TARG_OS2_MODE && x == "os2")
    16331634        return true;
    16341635    QRegExp re(x, Qt::CaseSensitive, QRegExp::Wildcard);
    1635     static QString spec;
    1636     if(spec.isEmpty())
    1637         spec = QFileInfo(Option::mkfile::qmakespec).fileName();
    16381636    if((regex && re.exactMatch(spec)) || (!regex && spec == x))
    16391637        return true;
     
    17231721            static QStringList *feature_roots = 0;
    17241722            if(!feature_roots) {
     1723
    17251724                feature_roots = new QStringList(qmake_feature_paths(prop));
    17261725                qmakeAddCacheClear(qmakeDeleteCacheClear_QStringList, (void**)&feature_roots);
     
    18081807    parser_info pi = parser;
    18091808    if(format == JSFormat) {
    1810 #ifdef QTSCRIPT_SUPPORT
    1811         eng.globalObject().setProperty("qmake", qscript_projectWrapper(&eng, this, place));
    1812         QFile f(file);
    1813         if (f.open(QFile::ReadOnly)) {
    1814             QString code = f.readAll();
    1815             QScriptValue r = eng.evaluate(code);
    1816             if(eng.hasUncaughtException()) {
    1817                 const int lineNo = eng.uncaughtExceptionLineNumber();
    1818                 fprintf(stderr, "%s:%d: %s\n", file.toLatin1().constData(), lineNo,
    1819                         r.toString().toLatin1().constData());
    1820             } else {
    1821                 parsed = true;
    1822                 QScriptValue variables = eng.globalObject().property("qmake");
    1823                 if (variables.isValid() && variables.isObject())
    1824                     qscript_createQMakeProjectMap(place, variables);
    1825             }
    1826         }
    1827 #else
    18281809        warn_msg(WarnParser, "%s:%d: QtScript support disabled for %s.",
    18291810                 pi.file.toLatin1().constData(), pi.line_no, orig_file.toLatin1().constData());
    1830 #endif
    18311811    } else {
    18321812        QStack<ScopeBlock> sc = scope_blocks;
     
    21652145            QMakeProjectEnv env(place);
    21662146            char buff[256];
    2167             FILE *proc = QT_POPEN(args[0].toLatin1(), "r");
    21682147            bool singleLine = true;
    21692148            if(args.count() > 1)
    21702149                singleLine = (args[1].toLower() == "true");
    21712150            QString output;
     2151
    21722152            while(proc && !feof(proc)) {
    21732153                int read_in = int(fread(buff, 1, 255, proc));
     
    23182298        }
    23192299        break; }
     2300
     2301
     2302
     2303
     2304
     2305
     2306
     2307
     2308
     2309
    23202310    default: {
    2321 #ifdef QTSCRIPT_SUPPORT
    2322         {
    2323             QScriptValue jsFunc = eng.globalObject().property(func);
    2324             if(jsFunc.isFunction()) {
    2325                 QScriptValueList jsArgs;
    2326                 for(int i = 0; i < args.size(); ++i)
    2327                     jsArgs += QScriptValue(&eng, args.at(i));
    2328                 QScriptValue jsRet = jsFunc.call(eng.globalObject(), jsArgs);
    2329                 ret = qscriptvalue_cast<QStringList>(jsRet);
    2330                 break;
    2331             }
    2332         }
    2333 #endif
    23342311        fprintf(stderr, "%s:%d: Unknown replace function: %s\n",
    23352312                parser.file.toLatin1().constData(), parser.line_no,
     
    24132390            int lhs_int = lhs.toInt(&ok);
    24142391            if(ok) {
    2415                 if(func == "greaterThan")
     2392                if(func)
    24162393                    return lhs_int > rhs_int;
    24172394                return lhs_int < rhs_int;
     
    27082685        QString parseInto;
    27092686        const bool include_statement = (func_t == T_INCLUDE);
    2710         bool ignore_error = include_statement;
    2711         if(args.count() == 2) {
     2687        bool ignore_error = ;
     2688        if(args.count() = 2) {
    27122689            if(func_t == T_INCLUDE) {
    27132690                parseInto = args[1];
     2691
     2692
     2693
     2694
     2695
    27142696            } else {
    27152697                QString sarg = args[1];
     
    27532735            warn_msg(WarnParser, "%s:%d: Duplicate of loaded feature %s",
    27542736                     parser.file.toLatin1().constData(), parser.line_no, file.toLatin1().constData());
    2755         } else if(stat == IncludeNoExist && include_statement) {
    2756             warn_msg(WarnParser, "%s:%d: Unable to find file for inclusion %s",
     2737        } else if(stat == IncludeNoExist && ) {
     2738            warn_msg(Warn, "%s:%d: Unable to find file for inclusion %s",
    27572739                     parser.file.toLatin1().constData(), parser.line_no, file.toLatin1().constData());
    27582740            return false;
     
    27972779        return true; }
    27982780    default:
    2799 #ifdef QTSCRIPT_SUPPORT
    2800         {
    2801             QScriptValue jsFunc = eng.globalObject().property(func);
    2802             if(jsFunc.isFunction()) {
    2803                 QScriptValueList jsArgs;
    2804                 for(int i = 0; i < args.size(); ++i)
    2805                     jsArgs += QScriptValue(&eng, args.at(i));
    2806                 QScriptValue jsRet = jsFunc.call(eng.globalObject(), jsArgs);
    2807                 if(eng.hasUncaughtException())
    2808                     return false;
    2809                 return qscriptvalue_cast<bool>(jsRet);
    2810             }
    2811         }
    2812 #endif
    28132781        fprintf(stderr, "%s:%d: Unknown test function: %s\n", parser.file.toLatin1().constData(), parser.line_no,
    28142782                func.toLatin1().constData());
     
    31263094        } else if(type == "name") {
    31273095            DWORD name_length = 1024;
    3128             TCHAR name[1024];
    3129             if(GetComputerName(name, &name_length))
    3130                 ret = QString::fromUtf16((ushort*)name, name_length);
     3096            name[1024];
     3097            if(GetComputerName(name, &name_length))
     3098                ret = QString::from);
    31313099        } else if(type == "version" || type == "version_string") {
    31323100            QSysInfo::WinVersion ver = QSysInfo::WindowsVersion;
     
    32253193        if (place[var].isEmpty())
    32263194            return values("DIR_SEPARATOR", place);
     3195
     3196
     3197
    32273198    }
    32283199    //qDebug("REPLACE [%s]->[%s]", qPrintable(var), qPrintable(place[var].join("::")));
Note: See TracChangeset for help on using the changeset viewer.