464 } |
464 } |
465 |
465 |
466 if(!project->isEmpty("QMAKE_SUBSTITUTES")) { |
466 if(!project->isEmpty("QMAKE_SUBSTITUTES")) { |
467 const QStringList &subs = v["QMAKE_SUBSTITUTES"]; |
467 const QStringList &subs = v["QMAKE_SUBSTITUTES"]; |
468 for(int i = 0; i < subs.size(); ++i) { |
468 for(int i = 0; i < subs.size(); ++i) { |
469 if(!subs.at(i).endsWith(".in")) { |
469 QString inn = subs.at(i) + ".input", outn = subs.at(i) + ".output"; |
470 warn_msg(WarnLogic, "Substitute '%s' does not end with '.in'", |
470 if (v.contains(inn) || v.contains(outn)) { |
471 subs.at(i).toLatin1().constData()); |
471 if (!v.contains(inn) || !v.contains(outn)) { |
472 continue; |
472 warn_msg(WarnLogic, "Substitute '%s' has only one of .input and .output", |
473 } |
473 subs.at(i).toLatin1().constData()); |
474 QFile in(fileFixify(subs.at(i))), out(fileInfo(subs.at(i)).fileName()); |
474 continue; |
475 if(out.fileName().endsWith(".in")) |
475 } |
476 out.setFileName(out.fileName().left(out.fileName().length()-3)); |
476 const QStringList &tinn = v[inn], &toutn = v[outn]; |
|
477 if (tinn.length() != 1) { |
|
478 warn_msg(WarnLogic, "Substitute '%s.input' does not have exactly one value", |
|
479 subs.at(i).toLatin1().constData()); |
|
480 continue; |
|
481 } |
|
482 if (toutn.length() != 1) { |
|
483 warn_msg(WarnLogic, "Substitute '%s.output' does not have exactly one value", |
|
484 subs.at(i).toLatin1().constData()); |
|
485 continue; |
|
486 } |
|
487 inn = tinn.first(); |
|
488 outn = toutn.first(); |
|
489 } else { |
|
490 inn = subs.at(i); |
|
491 if(!inn.endsWith(".in")) { |
|
492 warn_msg(WarnLogic, "Substitute '%s' does not end with '.in'", |
|
493 inn.toLatin1().constData()); |
|
494 continue; |
|
495 } |
|
496 outn = inn.left(inn.length()-3); |
|
497 } |
|
498 QFile in(fileFixify(inn)); |
|
499 QFile out(fileFixify(outn, qmake_getpwd(), Option::output_dir)); |
477 if(in.open(QFile::ReadOnly)) { |
500 if(in.open(QFile::ReadOnly)) { |
478 QString contents; |
501 QString contents; |
479 QStack<int> state; |
502 QStack<int> state; |
480 enum { IN_CONDITION, MET_CONDITION, PENDING_CONDITION }; |
503 enum { IN_CONDITION, MET_CONDITION, PENDING_CONDITION }; |
481 for(int count = 1; !in.atEnd(); ++count) { |
504 for(int count = 1; !in.atEnd(); ++count) { |
526 } |
549 } |
527 } |
550 } |
528 if(out.exists() && out.open(QFile::ReadOnly)) { |
551 if(out.exists() && out.open(QFile::ReadOnly)) { |
529 QString old = QString::fromUtf8(out.readAll()); |
552 QString old = QString::fromUtf8(out.readAll()); |
530 if(contents == old) { |
553 if(contents == old) { |
531 v["QMAKE_INTERNAL_INCLUDED_FILES"].append(subs.at(i)); |
554 v["QMAKE_INTERNAL_INCLUDED_FILES"].append(in.fileName()); |
532 continue; |
555 continue; |
533 } |
556 } |
534 out.close(); |
557 out.close(); |
535 if(!out.remove()) { |
558 if(!out.remove()) { |
536 warn_msg(WarnLogic, "Cannot clear substitute '%s'", |
559 warn_msg(WarnLogic, "Cannot clear substitute '%s'", |
537 out.fileName().toLatin1().constData()); |
560 out.fileName().toLatin1().constData()); |
538 continue; |
561 continue; |
539 } |
562 } |
540 } |
563 } |
|
564 mkdir(QFileInfo(out).absolutePath()); |
541 if(out.open(QFile::WriteOnly)) { |
565 if(out.open(QFile::WriteOnly)) { |
542 v["QMAKE_INTERNAL_INCLUDED_FILES"].append(subs.at(i)); |
566 v["QMAKE_INTERNAL_INCLUDED_FILES"].append(in.fileName()); |
543 out.write(contents.toUtf8()); |
567 out.write(contents.toUtf8()); |
544 } else { |
568 } else { |
545 warn_msg(WarnLogic, "Cannot open substitute for output '%s'", |
569 warn_msg(WarnLogic, "Cannot open substitute for output '%s'", |
546 out.fileName().toLatin1().constData()); |
570 out.fileName().toLatin1().constData()); |
547 } |
571 } |