Ignore:
Timestamp:
Mar 8, 2010, 12:52:58 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.2 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/qmake/generators/symbian/symmake.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4141
    4242#include "symmake.h"
    43 #include "initprojectdeploy_symbian.h"
    4443
    4544#include <qstring.h>
     
    6362#define BLD_INF_TAG_TESTMMPFILES "prj_testmmpfiles"
    6463#define BLD_INF_TAG_EXTENSIONS "prj_extensions"
     64#define BLD_INF_TAG_EXPORTS "prj_exports"
    6565
    6666#define RSS_RULES "RSS_RULES"
     
    8989
    9090#define SIS_TARGET "sis"
     91#define INSTALLER_SIS_TARGET "installer_sis"
    9192#define OK_SIS_TARGET "ok_sis"
     93#define OK_INSTALLER_SIS_TARGET "ok_installer_sis"
    9294#define FAIL_SIS_NOPKG_TARGET "fail_sis_nopkg"
    9395#define FAIL_SIS_NOCACHE_TARGET "fail_sis_nocache"
    94 #define RESTORE_BUILD_TARGET "restore_build"
    9596
    9697#define PRINT_FILE_CREATE_ERROR(filename) fprintf(stderr, "Error: Could not create '%s'\n", qPrintable(filename));
     98
     99#define MANUFACTURER_NOTE_FILE "manufacturer_note.txt"
     100#define DEFAULT_MANUFACTURER_NOTE \
     101    "The package is not supported for devices from this manufacturer. Please try the selfsigned " \
     102    "version of the package instead."
    97103
    98104QString SymbianMakefileGenerator::fixPathForMmp(const QString& origPath, const QDir& parentDir)
     
    204210    // Generate pkg files if there are any actual files to deploy
    205211    bool generatePkg = false;
     212    DeploymentList depList;
     213
    206214    if (targetType == TypeExe) {
    207215        generatePkg = true;
     
    216224
    217225    if (generatePkg) {
    218         generatePkgFile(iconFile);
    219     }
    220 
    221     writeBldInfContent(t, generatePkg, iconFile);
     226        generatePkgFile(iconFile, depList);
     227    }
     228
     229    writeBldInfContent(t, generatePkg, iconFile, depList);
    222230
    223231    // Generate empty wrapper makefile here, because wrapper makefile must exist before writeMkFile,
     
    274282}
    275283
    276 void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile)
     284void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile, DeploymentList &depList)
    277285{
    278286    QString pkgFilename = QString("%1_template.%2")
     
    286294
    287295    generatedFiles << pkgFile.fileName();
     296    QTextStream t(&pkgFile);
     297
     298    QString installerSisHeader = project->values("DEPLOYMENT.installer_header").join("\n");
     299    if (installerSisHeader.isEmpty())
     300        installerSisHeader = "0xA000D7CE"; // Use default self-signable UID if not defined
     301
     302    QString wrapperStreamBuffer;
     303    QTextStream tw(&wrapperStreamBuffer);
     304
     305    QString dateStr = QDateTime::currentDateTime().toString(Qt::ISODate);
    288306
    289307    // Header info
    290     QTextStream t(&pkgFile);
    291     t << QString("; %1 generated by qmake at %2").arg(pkgFilename).arg(QDateTime::currentDateTime().toString(Qt::ISODate))  << endl;
    292     t << "; This file is generated by qmake and should not be modified by the user" << endl;
    293     t << ";" << endl << endl;
     308    QString wrapperPkgFilename = QString("%1_installer.%2")
     309                                .arg(fixedTarget)
     310                                .arg("pkg");
     311    QString headerComment = "; %1 generated by qmake at %2\n"
     312        "; This file is generated by qmake and should not be modified by the user\n"
     313        ";\n\n";
     314    t << headerComment.arg(pkgFilename).arg(dateStr);
     315    tw << headerComment.arg(wrapperPkgFilename).arg(dateStr);
    294316
    295317    // Construct QStringList from pkg_prerules since we need search it before printed to file
     
    314336    if (!containsStartWithItem('&', rawPkgPreRules)) {
    315337        // language, (*** hardcoded to english atm, should be parsed from TRANSLATIONS)
    316         t << "; Language" << endl;
    317         t << "&EN" << endl << endl;
     338        QString languageCode = "; Language\n&EN\n\n";
     339        t << languageCode;
     340        tw << languageCode;
    318341    } else {
    319342        // In case user defines langs, he must take care also about SIS header
     
    324347    // name of application, UID and version
    325348    QString applicationVersion = project->first("VERSION").isEmpty() ? "1,0,0" : project->first("VERSION").replace('.', ',');
     349    QString sisHeader = "; SIS header: name, uid, version\n#{\"%1\"},(%2),%3\n\n";
     350    QString visualTarget = escapeFilePath(fileFixify(project->first("TARGET")));
     351    visualTarget = removePathSeparators(visualTarget);
     352    QString wrapperTarget = visualTarget + " installer";
     353
     354    if (installerSisHeader.startsWith("0x", Qt::CaseInsensitive)) {
     355        tw << sisHeader.arg(wrapperTarget).arg(installerSisHeader).arg(applicationVersion);
     356    } else {
     357        tw << installerSisHeader << endl;
     358    }
    326359
    327360    if (!containsStartWithItem('#', rawPkgPreRules)) {
    328         QString visualTarget = escapeFilePath(fileFixify(project->first("TARGET")));
    329         visualTarget = removePathSeparators(visualTarget);
    330 
    331         t << "; SIS header: name, uid, version" << endl;
    332         t << QString("#{\"%1\"},(%2),%3").arg(visualTarget).arg(uid3).arg(applicationVersion) << endl << endl;
     361        t << sisHeader.arg(visualTarget).arg(uid3).arg(applicationVersion);
    333362    }
    334363
    335364    // Localized vendor name
     365    QString vendorName;
    336366    if (!containsStartWithItem('%', rawPkgPreRules)) {
    337         t << "; Localised Vendor name" << endl;
    338         t << "%{\"Vendor\"}" << endl << endl;
     367        vendorName += "; Localised Vendor name\n%{\"Vendor\"}\n\n";
    339368    }
    340369
    341370    // Unique vendor name
    342371    if (!containsStartWithItem(':', rawPkgPreRules)) {
    343         t << "; Unique Vendor name" << endl;
    344         t << ":\"Vendor\"" << endl << endl;
    345     }
     372        vendorName += "; Unique Vendor name\n:\"Vendor\"\n\n";
     373    }
     374
     375    t << vendorName;
     376    tw << vendorName;
    346377
    347378    // PKG pre-rules - these are added before actual file installations i.e. SIS package body
    348379    if (rawPkgPreRules.size()) {
    349         t << "; Manual PKG pre-rules from PRO files" << endl;
     380        QString comment = "\n; Manual PKG pre-rules from PRO files\n";
     381        t << comment;
     382        tw << comment;
     383
    350384        foreach(QString item, rawPkgPreRules) {
     385            // Only regular pkg file should have package dependencies or pkg header if that is
     386            // defined using prerules.
     387            if (!item.startsWith("(") && !item.startsWith("#")) {
     388                tw << item << endl;
     389            }
    351390            t << item << endl;
    352391        }
    353392        t << endl;
     393        tw << endl;
     394    }
     395
     396    // Begin Manufacturer block
     397    if (!project->values("DEPLOYMENT.manufacturers").isEmpty()) {
     398        QString manufacturerStr("IF ");
     399        foreach(QString manufacturer, project->values("DEPLOYMENT.manufacturers")) {
     400            manufacturerStr.append(QString("(MANUFACTURER)=(%1) OR \n   ").arg(manufacturer));
     401        }
     402        // Remove the final OR
     403        manufacturerStr.chop(8);
     404        t << manufacturerStr << endl;
    354405    }
    355406
     
    362413    QString epocReleasePath = QString("%1epoc32/release/$(PLATFORM)/$(TARGET)")
    363414                              .arg(epocRoot());
    364 
    365415
    366416    if (targetType == TypeExe) {
     
    398448
    399449    // deploy any additional DEPLOYMENT  files
    400     DeploymentList depList;
    401450    QString remoteTestPath;
    402451    remoteTestPath = QString("!:\\private\\%1").arg(privateDirUid);
     
    428477            t << endl;
    429478        }
     479    }
     480
     481    // Close Manufacturer block
     482    if (!project->values("DEPLOYMENT.manufacturers").isEmpty()) {
     483        QString manufacturerFailNoteFile;
     484        if (project->values("DEPLOYMENT.manufacturers.fail_note").isEmpty()) {
     485            manufacturerFailNoteFile = QString("%1_" MANUFACTURER_NOTE_FILE).arg(uid3);
     486            QFile ft(manufacturerFailNoteFile);
     487            if (ft.open(QIODevice::WriteOnly)) {
     488                generatedFiles << ft.fileName();
     489                QTextStream t2(&ft);
     490
     491                t2 << QString(DEFAULT_MANUFACTURER_NOTE) << endl;
     492            } else {
     493                PRINT_FILE_CREATE_ERROR(manufacturerFailNoteFile)
     494            }
     495        } else {
     496            manufacturerFailNoteFile = project->values("DEPLOYMENT.manufacturers.fail_note").join("");
     497        }
     498
     499        t << "ELSEIF NOT(0) ; MANUFACTURER" << endl
     500          << "\"" << fileInfo(manufacturerFailNoteFile).absoluteFilePath() << "\""
     501          << " - \"\", FILETEXT, TEXTEXIT" << endl
     502          << "ENDIF ; MANUFACTURER" << endl;
     503    }
     504
     505    // Write wrapper pkg
     506    if (!installerSisHeader.isEmpty()) {
     507        QFile wrapperPkgFile(wrapperPkgFilename);
     508        if (!wrapperPkgFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
     509            PRINT_FILE_CREATE_ERROR(wrapperPkgFilename);
     510            return;
     511        }
     512
     513        generatedFiles << wrapperPkgFile.fileName();
     514        QTextStream twf(&wrapperPkgFile);
     515
     516        twf << wrapperStreamBuffer << endl;
     517
     518        // Wrapped files deployment
     519        QString currentPath = qmake_getpwd();
     520        QString sisName = QString("%1.sis").arg(fixedTarget);
     521        twf << "\"" << currentPath << "/" << sisName << "\" - \"c:\\adm\\" << sisName << "\"" << endl;
     522
     523        QString bootStrapPath = QLibraryInfo::location(QLibraryInfo::PrefixPath);
     524        bootStrapPath.append("/smartinstaller.sis");
     525        QFileInfo fi(fileInfo(bootStrapPath));
     526        twf << "@\"" << fi.absoluteFilePath() << "\",(0x2002CCCD)" << endl;
    430527    }
    431528}
     
    11731270}
    11741271
    1175 void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploymentExtension, const QString &iconFile)
     1272void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploymentExtension, const QString &iconFile, DeploymentList &depList)
    11761273{
    11771274    // Read user defined bld inf rules
     
    13011398        t << item << endl;
    13021399    userBldInfRules.remove(BLD_INF_TAG_EXTENSIONS);
     1400
     1401    t << endl << BLD_INF_TAG_EXPORTS << endl << endl;
     1402
     1403    // Generate export rules
     1404
     1405    // Export any deployed plugin stubs under /epoc32/data/z to support ROM builds
     1406    for (int i = 0; i < depList.size(); ++i)  {
     1407        int index = depList.at(i).from.indexOf(PLUGIN_STUB_DIR);
     1408        if (index != -1) {
     1409            t << QString("%1 /epoc32/data/z%2")
     1410                .arg(QString(depList.at(i).from).mid(index).replace('\\','/'))
     1411                .arg(QString(depList.at(i).to).mid(2).replace('\\','/')) << endl;
     1412        }
     1413    }
     1414
     1415    userItems = userBldInfRules.value(BLD_INF_TAG_EXPORTS);
     1416    foreach(QString item, userItems)
     1417        t << item << endl;
     1418    userBldInfRules.remove(BLD_INF_TAG_EXPORTS);
    13031419
    13041420    // Add rest of the user defined content
     
    17631879void SymbianMakefileGenerator::writeSisTargets(QTextStream &t)
    17641880{
    1765     t << SIS_TARGET ": " RESTORE_BUILD_TARGET << endl;
     1881    t << "-include " MAKE_CACHE_NAME << endl;
     1882    t << endl;
     1883
     1884    t << SIS_TARGET ":" << endl;
    17661885    QString siscommand = QString("\t$(if $(wildcard %1_template.%2),$(if $(wildcard %3)," \
    17671886                                  "$(MAKE) -s -f $(MAKEFILE) %4," \
     
    17871906    t << endl;
    17881907
     1908    QString sisName = fixedTarget;
     1909    sisName += ".sis";
     1910
     1911    t << sisName << ":" << endl;
     1912    t << "\t$(MAKE) -s -f $(MAKEFILE) " SIS_TARGET << endl << endl;
     1913
     1914    t << INSTALLER_SIS_TARGET ": " << sisName << endl;
     1915    siscommand = QString("\t$(if $(wildcard %1_installer.%2)," \
     1916                                  "$(MAKE) -s -f $(MAKEFILE) %3," \
     1917                                  "$(MAKE) -s -f $(MAKEFILE) %4)")
     1918                          .arg(fixedTarget)
     1919                          .arg("pkg")
     1920                          .arg(OK_INSTALLER_SIS_TARGET)
     1921                          .arg(FAIL_SIS_NOPKG_TARGET);
     1922    t << siscommand << endl;
     1923    t << endl;
     1924
     1925    t << OK_INSTALLER_SIS_TARGET ": " << endl;
     1926
     1927    pkgcommand = QString("\tcreatepackage.bat $(QT_SIS_OPTIONS) %1_installer.%2 - " \
     1928                         "$(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE)")
     1929                  .arg(fixedTarget)
     1930                  .arg("pkg");
     1931    t << pkgcommand << endl;
     1932    t << endl;
     1933
    17891934    t << FAIL_SIS_NOPKG_TARGET ":" << endl;
    1790     t << "\t$(error PKG file does not exist, 'SIS' target is only supported for executables or projects with DEPLOYMENT statement)" << endl;
     1935    t << "\t$(error PKG file does not exist, '" SIS_TARGET "' and '" INSTALLER_SIS_TARGET "' target are only supported for executables or projects with DEPLOYMENT statement)" << endl;
    17911936    t << endl;
    17921937
    17931938    t << FAIL_SIS_NOCACHE_TARGET ":" << endl;
    17941939    t << "\t$(error Project has to be built or QT_SIS_TARGET environment variable has to be set before calling 'SIS' target)" << endl;
    1795     t << endl;
    1796 
    1797 
    1798     t << RESTORE_BUILD_TARGET ":" << endl;
    1799     t << "-include " MAKE_CACHE_NAME << endl;
    18001940    t << endl;
    18011941}
Note: See TracChangeset for help on using the changeset viewer.