qmake/generators/symbian/symmake.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 5 d3bac044e0f0
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the qmake application of the Qt Toolkit.
     7 ** This file is part of the qmake application of the Qt Toolkit.
     8 **
     8 **
    38 ** $QT_END_LICENSE$
    38 ** $QT_END_LICENSE$
    39 **
    39 **
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 
    41 
    42 #include "symmake.h"
    42 #include "symmake.h"
    43 #include "initprojectdeploy_symbian.h"
       
    44 
    43 
    45 #include <qstring.h>
    44 #include <qstring.h>
    46 #include <qhash.h>
    45 #include <qhash.h>
    47 #include <qstringlist.h>
    46 #include <qstringlist.h>
    48 #include <qdir.h>
    47 #include <qdir.h>
    49 #include <qdatetime.h>
    48 #include <qdatetime.h>
    50 #include <stdlib.h>
    49 #include <stdlib.h>
    51 #include <qdebug.h>
    50 #include <qdebug.h>
    52 #include <qxmlstream.h>
    51 #include <qxmlstream.h>
    53 #include <qsettings>
    52 #include <QSettings>
    54 
    53 
    55 #define RESOURCE_DIRECTORY_MMP "/resource/apps"
    54 #define RESOURCE_DIRECTORY_MMP "/resource/apps"
    56 #define RESOURCE_DIRECTORY_RESOURCE "\\\\resource\\\\apps\\\\"
    55 #define RESOURCE_DIRECTORY_RESOURCE "\\\\resource\\\\apps\\\\"
    57 #define REGISTRATION_RESOURCE_DIRECTORY_HW "/private/10003a3f/import/apps"
    56 #define REGISTRATION_RESOURCE_DIRECTORY_HW "/private/10003a3f/import/apps"
    58 #define PLUGIN_COMMON_DEF_FILE_FOR_MMP "./plugin_common.def"
    57 #define PLUGIN_COMMON_DEF_FILE_FOR_MMP "./plugin_common.def"
    62 #define BLD_INF_RULES_BASE "BLD_INF_RULES."
    61 #define BLD_INF_RULES_BASE "BLD_INF_RULES."
    63 #define BLD_INF_TAG_PLATFORMS "prj_platforms"
    62 #define BLD_INF_TAG_PLATFORMS "prj_platforms"
    64 #define BLD_INF_TAG_MMPFILES "prj_mmpfiles"
    63 #define BLD_INF_TAG_MMPFILES "prj_mmpfiles"
    65 #define BLD_INF_TAG_TESTMMPFILES "prj_testmmpfiles"
    64 #define BLD_INF_TAG_TESTMMPFILES "prj_testmmpfiles"
    66 #define BLD_INF_TAG_EXTENSIONS "prj_extensions"
    65 #define BLD_INF_TAG_EXTENSIONS "prj_extensions"
       
    66 #define BLD_INF_TAG_EXPORTS "prj_exports"
    67 
    67 
    68 #define RSS_RULES "RSS_RULES"
    68 #define RSS_RULES "RSS_RULES"
    69 #define RSS_RULES_BASE "RSS_RULES."
    69 #define RSS_RULES_BASE "RSS_RULES."
    70 #define RSS_TAG_NBROFICONS "number_of_icons"
    70 #define RSS_TAG_NBROFICONS "number_of_icons"
    71 #define RSS_TAG_ICONFILE "icon_file"
    71 #define RSS_TAG_ICONFILE "icon_file"
    91 
    91 
    92 #define SIS_TARGET "sis"
    92 #define SIS_TARGET "sis"
    93 #define OK_SIS_TARGET "ok_sis"
    93 #define OK_SIS_TARGET "ok_sis"
    94 #define FAIL_SIS_NOPKG_TARGET "fail_sis_nopkg"
    94 #define FAIL_SIS_NOPKG_TARGET "fail_sis_nopkg"
    95 #define FAIL_SIS_NOCACHE_TARGET "fail_sis_nocache"
    95 #define FAIL_SIS_NOCACHE_TARGET "fail_sis_nocache"
    96 #define RESTORE_BUILD_TARGET "restore_build"
       
    97 
    96 
    98 #define PRINT_FILE_CREATE_ERROR(filename) fprintf(stderr, "Error: Could not create '%s'\n", qPrintable(filename));
    97 #define PRINT_FILE_CREATE_ERROR(filename) fprintf(stderr, "Error: Could not create '%s'\n", qPrintable(filename));
    99 
    98 
   100 QString SymbianMakefileGenerator::fixPathForMmp(const QString& origPath, const QDir& parentDir)
    99 QString SymbianMakefileGenerator::fixPathForMmp(const QString& origPath, const QDir& parentDir)
   101 {
   100 {
   223     // Get the application translations and convert to symbian OS lang code, i.e. decical number
   222     // Get the application translations and convert to symbian OS lang code, i.e. decical number
   224     QStringList symbianLangCodes = symbianLangCodesFromTsFiles();
   223     QStringList symbianLangCodes = symbianLangCodesFromTsFiles();
   225 
   224 
   226     // Generate pkg files if there are any actual files to deploy
   225     // Generate pkg files if there are any actual files to deploy
   227     bool generatePkg = false;
   226     bool generatePkg = false;
       
   227     DeploymentList depList;
       
   228 
   228     if (targetType == TypeExe) {
   229     if (targetType == TypeExe) {
   229         generatePkg = true;
   230         generatePkg = true;
   230     } else {
   231     } else {
   231         foreach(QString item, project->values("DEPLOYMENT")) {
   232         foreach(QString item, project->values("DEPLOYMENT")) {
   232             if (!project->values(item + ".sources").isEmpty()) {
   233             if (!project->values(item + ".sources").isEmpty()) {
   235             }
   236             }
   236         }
   237         }
   237     }
   238     }
   238 
   239 
   239     if (generatePkg) {
   240     if (generatePkg) {
   240         generatePkgFile(iconFile);
   241         generatePkgFile(iconFile, depList);
   241     }
   242     }
   242 
   243 
   243     writeBldInfContent(t, generatePkg, iconFile);
   244     writeBldInfContent(t, generatePkg, iconFile, depList);
   244 
   245 
   245     // Generate empty wrapper makefile here, because wrapper makefile must exist before writeMkFile,
   246     // Generate empty wrapper makefile here, because wrapper makefile must exist before writeMkFile,
   246     // but all required data is not yet available.
   247     // but all required data is not yet available.
   247     bool isPrimaryMakefile = true;
   248     bool isPrimaryMakefile = true;
   248     QString wrapperFileName("Makefile");
   249     QString wrapperFileName("Makefile");
   299     writeWrapperMakefile(wrapperMakefile, isPrimaryMakefile);
   300     writeWrapperMakefile(wrapperMakefile, isPrimaryMakefile);
   300 
   301 
   301     return true;
   302     return true;
   302 }
   303 }
   303 
   304 
   304 void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile)
   305 void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile, DeploymentList &depList)
   305 {
   306 {
   306     QString pkgFilename = QString("%1_template.%2")
   307     QString pkgFilename = QString("%1_template.%2")
   307                           .arg(fixedTarget)
   308                           .arg(fixedTarget)
   308                           .arg("pkg");
   309                           .arg("pkg");
   309     QFile pkgFile(pkgFilename);
   310     QFile pkgFile(pkgFilename);
   425             }
   426             }
   426         }
   427         }
   427     }
   428     }
   428 
   429 
   429     // deploy any additional DEPLOYMENT  files
   430     // deploy any additional DEPLOYMENT  files
   430     DeploymentList depList;
       
   431     QString remoteTestPath;
   431     QString remoteTestPath;
   432     remoteTestPath = QString("!:\\private\\%1").arg(privateDirUid);
   432     remoteTestPath = QString("!:\\private\\%1").arg(privateDirUid);
   433 
   433 
   434     initProjectDeploySymbian(project, depList, remoteTestPath, true, "$(PLATFORM)", "$(TARGET)", generatedDirs, generatedFiles);
   434     initProjectDeploySymbian(project, depList, remoteTestPath, true, "$(PLATFORM)", "$(TARGET)", generatedDirs, generatedFiles);
   435     if (depList.size())
   435     if (depList.size())
  1216             }
  1216             }
  1217         }
  1217         }
  1218     }
  1218     }
  1219 }
  1219 }
  1220 
  1220 
  1221 void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploymentExtension, const QString &iconFile)
  1221 void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploymentExtension, const QString &iconFile, DeploymentList &depList)
  1222 {
  1222 {
  1223     // Read user defined bld inf rules
  1223     // Read user defined bld inf rules
  1224 
  1224 
  1225     QMap<QString, QStringList> userBldInfRules;
  1225     QMap<QString, QStringList> userBldInfRules;
  1226     for (QMap<QString, QStringList>::iterator it = project->variables().begin(); it != project->variables().end(); ++it) {
  1226     for (QMap<QString, QStringList>::iterator it = project->variables().begin(); it != project->variables().end(); ++it) {
  2039     str.replace(QString(" "), QString("_"));
  2039     str.replace(QString(" "), QString("_"));
  2040 }
  2040 }
  2041 
  2041 
  2042 void SymbianMakefileGenerator::writeSisTargets(QTextStream &t)
  2042 void SymbianMakefileGenerator::writeSisTargets(QTextStream &t)
  2043 {
  2043 {
  2044     t << SIS_TARGET ": " RESTORE_BUILD_TARGET << endl;
  2044     t << "-include " MAKE_CACHE_NAME << endl;
       
  2045     t << endl;
       
  2046 
       
  2047     t << SIS_TARGET ":" << endl;
  2045     QString siscommand = QString("\t$(if $(wildcard %1_template.%2),$(if $(wildcard %3)," \
  2048     QString siscommand = QString("\t$(if $(wildcard %1_template.%2),$(if $(wildcard %3)," \
  2046                                   "$(MAKE) -s -f $(MAKEFILE) %4,$(MAKE) -s -f $(MAKEFILE) %5)," \
  2049                                   "$(MAKE) -s -f $(MAKEFILE) %4," \
       
  2050                                   "$(if $(QT_SIS_TARGET),$(MAKE) -s -f $(MAKEFILE) %4," \
       
  2051                                   "$(MAKE) -s -f $(MAKEFILE) %5))," \
  2047                                   "$(MAKE) -s -f $(MAKEFILE) %6)")
  2052                                   "$(MAKE) -s -f $(MAKEFILE) %6)")
  2048                           .arg(fixedTarget)
  2053                           .arg(fixedTarget)
  2049                           .arg("pkg")
  2054                           .arg("pkg")
  2050                           .arg(MAKE_CACHE_NAME)
  2055                           .arg(MAKE_CACHE_NAME)
  2051                           .arg(OK_SIS_TARGET)
  2056                           .arg(OK_SIS_TARGET)
  2066     t << FAIL_SIS_NOPKG_TARGET ":" << endl;
  2071     t << FAIL_SIS_NOPKG_TARGET ":" << endl;
  2067     t << "\t$(error PKG file does not exist, 'SIS' target is only supported for executables or projects with DEPLOYMENT statement)" << endl;
  2072     t << "\t$(error PKG file does not exist, 'SIS' target is only supported for executables or projects with DEPLOYMENT statement)" << endl;
  2068     t << endl;
  2073     t << endl;
  2069 
  2074 
  2070     t << FAIL_SIS_NOCACHE_TARGET ":" << endl;
  2075     t << FAIL_SIS_NOCACHE_TARGET ":" << endl;
  2071     t << "\t$(error Project has to be build before calling 'SIS' target)" << endl;
  2076     t << "\t$(error Project has to be built or QT_SIS_TARGET environment variable has to be set before calling 'SIS' target)" << endl;
  2072     t << endl;
       
  2073 
       
  2074 
       
  2075     t << RESTORE_BUILD_TARGET ":" << endl;
       
  2076     t << "-include " MAKE_CACHE_NAME << endl;
       
  2077     t << endl;
  2077     t << endl;
  2078 }
  2078 }
  2079 
  2079 
  2080 void SymbianMakefileGenerator::generateDistcleanTargets(QTextStream& t)
  2080 void SymbianMakefileGenerator::generateDistcleanTargets(QTextStream& t)
  2081 {
  2081 {
  2129     t << endl;
  2129     t << endl;
  2130 
  2130 
  2131     t << "distclean: clean dodistclean" << endl;
  2131     t << "distclean: clean dodistclean" << endl;
  2132     t << endl;
  2132     t << endl;
  2133 }
  2133 }
       
  2134 
       
  2135 void SymbianMakefileGenerator::generateExecutionTargets(QTextStream& t, const QStringList& platforms)
       
  2136 {
       
  2137     // create execution targets
       
  2138     if (targetType == TypeExe) {
       
  2139         if (platforms.contains("winscw")) {
       
  2140             t << "run:" << endl;
       
  2141             t << "\t-call " << epocRoot() << "epoc32/release/winscw/udeb/" << fixedTarget << ".exe " << "$(QT_RUN_OPTIONS)" << endl;
       
  2142         }
       
  2143         t << "runonphone: sis" << endl;
       
  2144         t << "\trunonphone $(QT_RUN_ON_PHONE_OPTIONS) --sis " << fixedTarget << "_$(QT_SIS_TARGET).sis " << fixedTarget << ".exe " << "$(QT_RUN_OPTIONS)" << endl;
       
  2145         t << endl;
       
  2146     }
       
  2147 }