qmake/project.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
   669     // scope_blocks starts with one non-ignoring entity
   669     // scope_blocks starts with one non-ignoring entity
   670     scope_blocks.clear();
   670     scope_blocks.clear();
   671     scope_blocks.push(ScopeBlock());
   671     scope_blocks.push(ScopeBlock());
   672     iterator = 0;
   672     iterator = 0;
   673     function = 0;
   673     function = 0;
       
   674     backslashWarned = false;
   674 }
   675 }
   675 
   676 
   676 bool
   677 bool
   677 QMakeProject::parse(const QString &t, QMap<QString, QStringList> &place, int numLines)
   678 QMakeProject::parse(const QString &t, QMap<QString, QStringList> &place, int numLines)
   678 {
   679 {
  1044     op.replace(QRegExp("\\s"), "");
  1045     op.replace(QRegExp("\\s"), "");
  1045 
  1046 
  1046     SKIP_WS(d, d_off, s.length());
  1047     SKIP_WS(d, d_off, s.length());
  1047     QString vals = s.mid(d_off); // vals now contains the space separated list of values
  1048     QString vals = s.mid(d_off); // vals now contains the space separated list of values
  1048     int rbraces = vals.count('}'), lbraces = vals.count('{');
  1049     int rbraces = vals.count('}'), lbraces = vals.count('{');
  1049     if(scope_blocks.count() > 1 && rbraces - lbraces == 1) {
  1050     if(scope_blocks.count() > 1 && rbraces - lbraces == 1 && vals.endsWith('}')) {
  1050         debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.toLatin1().constData(),
  1051         debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.toLatin1().constData(),
  1051                   parser.line_no, scope_blocks.count());
  1052                   parser.line_no, scope_blocks.count());
  1052         ScopeBlock sb = scope_blocks.pop();
  1053         ScopeBlock sb = scope_blocks.pop();
  1053         if(sb.iterate)
  1054         if(sb.iterate)
  1054             sb.iterate->exec(this, place);
  1055             sb.iterate->exec(this, place);
  1071         }
  1072         }
  1072         fprintf(stdout, "%s %s %s\n", var.toLatin1().constData(), op.toLatin1().constData(), vals.toLatin1().constData());
  1073         fprintf(stdout, "%s %s %s\n", var.toLatin1().constData(), op.toLatin1().constData(), vals.toLatin1().constData());
  1073     }
  1074     }
  1074 
  1075 
  1075     if(vals.contains('=') && numLines > 1)
  1076     if(vals.contains('=') && numLines > 1)
  1076         warn_msg(WarnParser, "Detected possible line continuation: {%s} %s:%d",
  1077         warn_msg(WarnParser, "Possible accidental line continuation: {%s} at %s:%d",
  1077                  var.toLatin1().constData(), parser.file.toLatin1().constData(), parser.line_no);
  1078                  var.toLatin1().constData(), parser.file.toLatin1().constData(), parser.line_no);
  1078 
  1079 
  1079     QStringList &varlist = place[var]; // varlist is the list in the symbol table
  1080     QStringList &varlist = place[var]; // varlist is the list in the symbol table
  1080 
  1081 
  1081     if(Option::debug_level >= 1) {
  1082     if(Option::debug_level >= 1) {
  1403             pfile += Option::pro_ext;
  1404             pfile += Option::pro_ext;
  1404         if(!read(pfile, vars))
  1405         if(!read(pfile, vars))
  1405             return false;
  1406             return false;
  1406     }
  1407     }
  1407 
  1408 
  1408     if(cmd & ReadPostFiles) { // parse post files
       
  1409         const QStringList l = vars["QMAKE_POST_INCLUDE_FILES"];
       
  1410         for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
       
  1411             if(read((*it), vars)) {
       
  1412                 if(vars["QMAKE_INTERNAL_INCLUDED_FILES"].indexOf((*it)) == -1)
       
  1413                     vars["QMAKE_INTERNAL_INCLUDED_FILES"].append((*it));
       
  1414             }
       
  1415         }
       
  1416     }
       
  1417 
       
  1418     if(cmd & ReadCmdLine) {
  1409     if(cmd & ReadCmdLine) {
  1419         parser.file = "(internal)";
  1410         parser.file = "(internal)";
  1420         parser.from_file = false;
  1411         parser.from_file = false;
  1421         parser.line_no = 1; //really arg count now.. duh
  1412         parser.line_no = 1; //really arg count now.. duh
  1422         reset();
  1413         reset();
  1717     if(di != -1) {
  1708     if(di != -1) {
  1718         if(!qmake_setpwd(file.left(file.lastIndexOf(QDir::separator())))) {
  1709         if(!qmake_setpwd(file.left(file.lastIndexOf(QDir::separator())))) {
  1719             fprintf(stderr, "Cannot find directory: %s\n", file.left(di).toLatin1().constData());
  1710             fprintf(stderr, "Cannot find directory: %s\n", file.left(di).toLatin1().constData());
  1720             return IncludeFailure;
  1711             return IncludeFailure;
  1721         }
  1712         }
  1722         file = file.right(file.length() - di - 1);
       
  1723     }
  1713     }
  1724     bool parsed = false;
  1714     bool parsed = false;
  1725     parser_info pi = parser;
  1715     parser_info pi = parser;
  1726     if(format == JSFormat) {
  1716     if(format == JSFormat) {
  1727         warn_msg(WarnParser, "%s:%d: QtScript support disabled for %s.",
  1717         warn_msg(WarnParser, "%s:%d: QtScript support disabled for %s.",
  1737             if(flags & IncludeFlagNewParser) {
  1727             if(flags & IncludeFlagNewParser) {
  1738 #if 1
  1728 #if 1
  1739                 if(proj.doProjectInclude("default_pre", IncludeFlagFeature, proj.variables()) == IncludeNoExist)
  1729                 if(proj.doProjectInclude("default_pre", IncludeFlagFeature, proj.variables()) == IncludeNoExist)
  1740                     proj.doProjectInclude("default", IncludeFlagFeature, proj.variables());
  1730                     proj.doProjectInclude("default", IncludeFlagFeature, proj.variables());
  1741 #endif
  1731 #endif
  1742                 parsed = proj.read(file, proj.variables());
  1732                 parsed = proj.read(file, proj.variables()); // parse just that file (fromfile, infile)
  1743             } else {
  1733             } else {
  1744                 parsed = proj.read(file);
  1734                 parsed = proj.read(file); // parse all aux files (load/include into)
  1745             }
  1735             }
  1746             place = proj.variables();
  1736             place = proj.variables();
  1747         } else {
  1737         } else {
  1748             parsed = read(file, place);
  1738             parsed = read(file, place);
  1749         }
  1739         }
  2188         break; }
  2178         break; }
  2189     case E_PROMPT: {
  2179     case E_PROMPT: {
  2190         if(args.count() != 1) {
  2180         if(args.count() != 1) {
  2191             fprintf(stderr, "%s:%d prompt(question) requires one argument.\n",
  2181             fprintf(stderr, "%s:%d prompt(question) requires one argument.\n",
  2192                     parser.file.toLatin1().constData(), parser.line_no);
  2182                     parser.file.toLatin1().constData(), parser.line_no);
  2193         } else if(projectFile() == "-") {
  2183         } else if(pfile == "-") {
  2194             fprintf(stderr, "%s:%d prompt(question) cannot be used when '-o -' is used.\n",
  2184             fprintf(stderr, "%s:%d prompt(question) cannot be used when '-o -' is used.\n",
  2195                     parser.file.toLatin1().constData(), parser.line_no);
  2185                     parser.file.toLatin1().constData(), parser.line_no);
  2196         } else {
  2186         } else {
  2197             QString msg = fixEnvVariables(args.first());
  2187             QString msg = fixEnvVariables(args.first());
  2198             if(!msg.endsWith("?"))
  2188             if(!msg.endsWith("?"))
  2930                     if(!(replaced++))
  2920                     if(!(replaced++))
  2931                         current = str.left(start_var);
  2921                         current = str.left(start_var);
  2932                     current.append(str.at(i));
  2922                     current.append(str.at(i));
  2933                     break;
  2923                     break;
  2934                 }
  2924                 }
       
  2925             }
       
  2926             if(!escape && !backslashWarned) {
       
  2927                 backslashWarned = true;
       
  2928                 warn_msg(WarnDeprecated, "%s:%d: Unescaped backslashes are deprecated.",
       
  2929                          parser.file.toLatin1().constData(), parser.line_no);
  2935             }
  2930             }
  2936             if(escape || !replaced)
  2931             if(escape || !replaced)
  2937                 unicode =0;
  2932                 unicode =0;
  2938         } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
  2933         } else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
  2939             quote = unicode;
  2934             quote = unicode;
  3097         if (place[var].isEmpty()) {
  3092         if (place[var].isEmpty()) {
  3098             var = ".BUILTIN." + var;
  3093             var = ".BUILTIN." + var;
  3099             place[var] = QStringList(Option::obj_ext);
  3094             place[var] = QStringList(Option::obj_ext);
  3100         }
  3095         }
  3101     } else if (var == QLatin1String("QMAKE_QMAKE")) {
  3096     } else if (var == QLatin1String("QMAKE_QMAKE")) {
  3102         if (place[var].isEmpty()) {
  3097         if (place[var].isEmpty())
  3103             if (!Option::qmake_abslocation.isNull())
  3098             place[var] = QStringList(Option::fixPathToTargetOS(
  3104                 place[var] = QStringList(Option::qmake_abslocation);
  3099                 !Option::qmake_abslocation.isEmpty()
  3105             else
  3100                     ? Option::qmake_abslocation
  3106                 place[var] = QStringList(Option::fixPathToTargetOS(
  3101                     : QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmake",
  3107                         QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmake", false));
  3102                 false));
  3108         }
       
  3109     } else if (var == QLatin1String("EPOCROOT")) {
  3103     } else if (var == QLatin1String("EPOCROOT")) {
  3110         if (place[var].isEmpty())
  3104         if (place[var].isEmpty())
  3111             place[var] = QStringList(epocRoot());
  3105             place[var] = QStringList(epocRoot());
  3112     }
  3106     }
  3113 #if defined(Q_OS_WIN32) && defined(Q_CC_MSVC)
  3107 #if defined(Q_OS_WIN32) && defined(Q_CC_MSVC)