From 83c37b5232f01efb15a326a2cca42b3a267823bb Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 23 Feb 2010 15:49:29 +0200 Subject: Basic deployment support for ROM in Symbian Deploy everything currently deployed under /epoc32/winscw/c to also under /epoc32/data/z to make is easier to deploy applications to ROM. Also changes path separators in deployment generation to be Linux friendly. Reviewed-by: Janne Anttila --- .../symbian/initprojectdeploy_symbian.cpp | 109 ++++++++++++++------- .../generators/symbian/initprojectdeploy_symbian.h | 2 + qmake/generators/symbian/symmake.cpp | 20 ---- qmake/generators/symbian/symmake_abld.cpp | 51 +++++++--- qmake/generators/symbian/symmake_abld.h | 2 +- qmake/generators/symbian/symmake_sbsv2.cpp | 43 +++++--- qmake/generators/symbian/symmake_sbsv2.h | 1 + 7 files changed, 144 insertions(+), 84 deletions(-) diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.cpp b/qmake/generators/symbian/initprojectdeploy_symbian.cpp index 2a22305..81c9408 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp +++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp @@ -49,12 +49,18 @@ // Included from tools/shared #include -#define SYSBIN_DIR "\\sys\\bin" +#define SYSBIN_DIR "/sys/bin" #define SUFFIX_DLL "dll" #define SUFFIX_EXE "exe" #define SUFFIX_QTPLUGIN "qtplugin" +static QString fixPathToEpocOS(const QString &src) +{ + QString ret = Option::fixPathToTargetOS(src); + return ret.replace('/', '\\'); +} + static bool isPlugin(const QFileInfo& info, const QString& devicePath) { // Libraries are plugins if deployment path is something else than @@ -85,12 +91,12 @@ static void createPluginStub(const QFileInfo& info, QStringList& generatedDirs, QStringList& generatedFiles) { - QDir().mkpath(QLatin1String(PLUGIN_STUB_DIR "\\")); + QDir().mkpath(QLatin1String(PLUGIN_STUB_DIR)); if (!generatedDirs.contains(PLUGIN_STUB_DIR)) generatedDirs << PLUGIN_STUB_DIR; // Plugin stubs must have different name from the actual plugins, because // the toolchain for creating ROM images cannot handle non-binary .dll files properly. - QFile stubFile(QLatin1String(PLUGIN_STUB_DIR "\\") + info.completeBaseName() + "." SUFFIX_QTPLUGIN); + QFile stubFile(QLatin1String(PLUGIN_STUB_DIR "/") + info.completeBaseName() + "." SUFFIX_QTPLUGIN); if (stubFile.open(QIODevice::WriteOnly)) { if (!generatedFiles.contains(stubFile.fileName())) generatedFiles << stubFile.fileName(); @@ -104,7 +110,7 @@ static void createPluginStub(const QFileInfo& info, } QFileInfo stubInfo(stubFile); deploymentList.append(CopyItem(Option::fixPathToLocalOS(stubInfo.absoluteFilePath()), - Option::fixPathToLocalOS(devicePath + "\\" + stubInfo.fileName()))); + fixPathToEpocOS(devicePath + "/" + stubInfo.fileName()))); } QString generate_uid(const QString& target) @@ -168,21 +174,29 @@ void initProjectDeploySymbian(QMakeProject* project, foreach(QString item, project->values("DEPLOYMENT")) { QString devicePath = project->first(item + ".path"); + QString devicePathWithoutDrive = devicePath; + + bool devicePathHasDriveLetter = false; + if (devicePath.size() > 1) { + devicePathHasDriveLetter = devicePath.at(1) == QLatin1Char(':'); + } + + // Sometimes devicePath can contain disk but APP_RESOURCE_DIR does not, + // so remove the drive letter for comparison purposes. + if (devicePathHasDriveLetter) + { + devicePathWithoutDrive.remove(0,2); + } if (!deployBinaries - && !devicePath.isEmpty() - && (0 == devicePath.compare(project->values("APP_RESOURCE_DIR").join(""), Qt::CaseInsensitive) - || 0 == devicePath.compare(project->values("REG_RESOURCE_IMPORT_DIR").join(""), Qt::CaseInsensitive))) { + && !devicePathWithoutDrive.isEmpty() + && (0 == devicePathWithoutDrive.compare(project->values("APP_RESOURCE_DIR").join(""), Qt::CaseInsensitive) + || 0 == devicePathWithoutDrive.compare(project->values("REG_RESOURCE_IMPORT_DIR").join(""), Qt::CaseInsensitive))) { // Do not deploy resources in emulator builds, as that seems to cause conflicts // If there is ever a real need to deploy pre-built resources for emulator, // BLD_INF_RULES.prj_exports can be used as a workaround. continue; } - bool devicePathHasDriveLetter = false; - if (devicePath.size() > 1) { - devicePathHasDriveLetter = devicePath.at(1) == QLatin1Char(':'); - } - if (devicePath.isEmpty() || devicePath == QLatin1String(".")) { devicePath = targetPath; } @@ -190,24 +204,35 @@ void initProjectDeploySymbian(QMakeProject* project, else if (!(devicePath.at(0) == QLatin1Char('/') || devicePath.at(0) == QLatin1Char('\\') || devicePathHasDriveLetter)) { - // create output path - devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('\\') + devicePath)); + // Create output path + devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('/') + devicePath)); } else { - if (0 == platform.compare(QLatin1String("winscw"), Qt::CaseInsensitive)) { + if (!platform.compare(QLatin1String(EMULATOR_DEPLOYMENT_PLATFORM))) { if (devicePathHasDriveLetter) { - devicePath = epocRoot() + "epoc32\\winscw\\" + devicePath.remove(1, 1); + devicePath = epocRoot() + "epoc32/winscw/" + devicePath.remove(1, 1); } else { - devicePath = epocRoot() + "epoc32\\winscw\\c" + devicePath; + devicePath = epocRoot() + "epoc32/winscw/c" + devicePath; } } else { - // Drive letter needed if targetpath contains one and it is not already in - if (targetPathHasDriveLetter && !devicePathHasDriveLetter) { - devicePath = deploymentDrive + devicePath; + if (!devicePathHasDriveLetter) { + if (!platform.compare(QLatin1String(ROM_DEPLOYMENT_PLATFORM))) { + //For plugin deployment under ARM no needed drive letter + devicePath = epocRoot() + "epoc32/data/z" + devicePath; + } else if (targetPathHasDriveLetter) { + // Drive letter needed if targetpath contains one and it is not already in + devicePath = deploymentDrive + devicePath; + } + } else { + //it is necessary to delete drive letter for ARM deployment + if (!platform.compare(QLatin1String(ROM_DEPLOYMENT_PLATFORM))) { + devicePath.remove(0,2); + devicePath = epocRoot() + "epoc32/data/z" + devicePath; + } } } } - devicePath.replace(QLatin1String("/"), QLatin1String("\\")); + devicePath.replace(QLatin1String("\\"), QLatin1String("/")); if (!deployBinaries && 0 == devicePath.right(8).compare(QLatin1String(SYSBIN_DIR), Qt::CaseInsensitive)) { @@ -231,7 +256,7 @@ void initProjectDeploySymbian(QMakeProject* project, dirSearch = true; } else { if (info.exists() || source.indexOf('*') != -1) { - nameFilter = source.split('\\').last(); + nameFilter = source.split(QDir::separator()).last(); searchPath = info.absolutePath(); } else { // Entry was not found. That is ok if it is a binary, since those do not necessarily yet exist. @@ -239,13 +264,19 @@ void initProjectDeploySymbian(QMakeProject* project, if (isBinary(info)) { if (deployBinaries) { // Executables and libraries are deployed to \sys\bin - QFileInfo releasePath(epocRoot() + "epoc32\\release\\" + platform + "\\" + build + "\\"); + QFileInfo targetPath(epocRoot() + "epoc32/release/" + platform + "/" + build + "/"); if(devicePathHasDriveLetter) { - deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "\\" + info.fileName(), false, true), - Option::fixPathToLocalOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "\\") + info.fileName()))); + deploymentList.append(CopyItem( + Option::fixPathToLocalOS(targetPath.absolutePath() + "/" + info.fileName(), + false, true), + fixPathToEpocOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/") + + info.fileName()))); } else { - deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "\\" + info.fileName(), false, true), - Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "\\") + info.fileName()))); + deploymentList.append(CopyItem( + Option::fixPathToLocalOS(targetPath.absolutePath() + "/" + info.fileName(), + false, true), + fixPathToEpocOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/") + + info.fileName()))); } } if (isPlugin(info, devicePath)) { @@ -256,7 +287,7 @@ void initProjectDeploySymbian(QMakeProject* project, // Generate deployment even if file doesn't exist, as this may be the case // when generating .pkg files. deploymentList.append(CopyItem(Option::fixPathToLocalOS(info.absoluteFilePath()), - Option::fixPathToLocalOS(devicePath + "\\" + info.fileName()))); + fixPathToEpocOS(devicePath + "/" + info.fileName()))); continue; } } @@ -278,14 +309,26 @@ void initProjectDeploySymbian(QMakeProject* project, // This deploys pre-built plugins. Other pre-built binaries will deploy normally, // as they have SYSBIN_DIR target path. if (deployBinaries) { - deploymentList.append(CopyItem(Option::fixPathToLocalOS(absoluteItemPath + "\\" + iterator.fileName()), - Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "\\") + iterator.fileName()))); + if (devicePathHasDriveLetter) { + deploymentList.append(CopyItem( + Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()), + fixPathToEpocOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/") + + iterator.fileName()))); + } else { + deploymentList.append(CopyItem( + Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()), + fixPathToEpocOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/") + + iterator.fileName()))); + } } - createPluginStub(info, devicePath + "\\" + absoluteItemPath.right(diffSize), deploymentList, generatedDirs, generatedFiles); + createPluginStub(info, devicePath + "/" + absoluteItemPath.right(diffSize), + deploymentList, generatedDirs, generatedFiles); continue; } else { - deploymentList.append(CopyItem(Option::fixPathToLocalOS(absoluteItemPath + "\\" + iterator.fileName()), - Option::fixPathToLocalOS(devicePath + "\\" + absoluteItemPath.right(diffSize) + "\\" + iterator.fileName()))); + deploymentList.append(CopyItem( + Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()), + fixPathToEpocOS(devicePath + "/" + absoluteItemPath.right(diffSize) + + "/" + iterator.fileName()))); } } } diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.h b/qmake/generators/symbian/initprojectdeploy_symbian.h index b409225..c621915 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.h +++ b/qmake/generators/symbian/initprojectdeploy_symbian.h @@ -51,6 +51,8 @@ #include #define PLUGIN_STUB_DIR "qmakepluginstubs" +#define ROM_DEPLOYMENT_PLATFORM "rom" +#define EMULATOR_DEPLOYMENT_PLATFORM "emulator" struct CopyItem { diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index 217c1c3..93ea5ca 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -63,7 +63,6 @@ #define BLD_INF_TAG_MMPFILES "prj_mmpfiles" #define BLD_INF_TAG_TESTMMPFILES "prj_testmmpfiles" #define BLD_INF_TAG_EXTENSIONS "prj_extensions" -#define BLD_INF_TAG_EXPORTS "prj_exports" #define RSS_RULES "RSS_RULES" #define RSS_RULES_BASE "RSS_RULES." @@ -1395,25 +1394,6 @@ void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploy t << item << endl; userBldInfRules.remove(BLD_INF_TAG_EXTENSIONS); - t << endl << BLD_INF_TAG_EXPORTS << endl << endl; - - // Generate export rules - - // Export any deployed plugin stubs under /epoc32/data/z to support ROM builds - for (int i = 0; i < depList.size(); ++i) { - int index = depList.at(i).from.indexOf(PLUGIN_STUB_DIR); - if (index != -1) { - t << QString("%1 /epoc32/data/z%2") - .arg(QString(depList.at(i).from).mid(index).replace('\\','/')) - .arg(QString(depList.at(i).to).mid(2).replace('\\','/')) << endl; - } - } - - userItems = userBldInfRules.value(BLD_INF_TAG_EXPORTS); - foreach(QString item, userItems) - t << item << endl; - userBldInfRules.remove(BLD_INF_TAG_EXPORTS); - // Add rest of the user defined content for (QMap::iterator it = userBldInfRules.begin(); it != userBldInfRules.end(); ++it) { diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index 6c62412..6ac5463 100644 --- a/qmake/generators/symbian/symmake_abld.cpp +++ b/qmake/generators/symbian/symmake_abld.cpp @@ -59,6 +59,8 @@ #define FINALIZE_TARGET "finalize" #define GENERATED_SOURCES_TARGET "generated_sources" #define ALL_SOURCE_DEPS_TARGET "all_source_deps" +#define DEPLOYMENT_TARGET "deployment" +#define DEPLOYMENT_CLEAN_TARGET "deployment_clean" #define WINSCW_DEPLOYMENT_TARGET "winscw_deployment" #define WINSCW_DEPLOYMENT_CLEAN_TARGET "winscw_deployment_clean" #define STORE_BUILD_TARGET "store_build" @@ -112,25 +114,29 @@ void SymbianAbldMakefileGenerator::writeMkFile(const QString& wrapperFileName, b QStringList wrapperTargets; if (deploymentOnly) { buildDeps.append(STORE_BUILD_TARGET); - cleanDeps.append(DO_NOTHING_TARGET); - cleanDepsWinscw.append(WINSCW_DEPLOYMENT_CLEAN_TARGET); - finalDeps.append(DO_NOTHING_TARGET); - finalDepsWinscw.append(WINSCW_DEPLOYMENT_TARGET); + cleanDeps.append(DEPLOYMENT_CLEAN_TARGET); + cleanDepsWinscw.append(WINSCW_DEPLOYMENT_CLEAN_TARGET " " DEPLOYMENT_CLEAN_TARGET); + finalDeps.append(DEPLOYMENT_TARGET); + finalDepsWinscw.append(WINSCW_DEPLOYMENT_TARGET " " DEPLOYMENT_TARGET); wrapperTargets << WINSCW_DEPLOYMENT_TARGET << WINSCW_DEPLOYMENT_CLEAN_TARGET + << DEPLOYMENT_TARGET + << DEPLOYMENT_CLEAN_TARGET << STORE_BUILD_TARGET; } else { buildDeps.append(CREATE_TEMPS_TARGET " " PRE_TARGETDEPS_TARGET " " STORE_BUILD_TARGET); - cleanDeps.append(EXTENSION_CLEAN); - cleanDepsWinscw.append(EXTENSION_CLEAN " " WINSCW_DEPLOYMENT_CLEAN_TARGET); - finalDeps.append(FINALIZE_TARGET); - finalDepsWinscw.append(FINALIZE_TARGET " " WINSCW_DEPLOYMENT_TARGET); + cleanDeps.append(EXTENSION_CLEAN " " DEPLOYMENT_CLEAN_TARGET); + cleanDepsWinscw.append(EXTENSION_CLEAN " " WINSCW_DEPLOYMENT_CLEAN_TARGET " " DEPLOYMENT_CLEAN_TARGET); + finalDeps.append(FINALIZE_TARGET " " DEPLOYMENT_TARGET); + finalDepsWinscw.append(FINALIZE_TARGET " " WINSCW_DEPLOYMENT_TARGET " " DEPLOYMENT_TARGET); wrapperTargets << PRE_TARGETDEPS_TARGET << CREATE_TEMPS_TARGET << EXTENSION_CLEAN << FINALIZE_TARGET << WINSCW_DEPLOYMENT_CLEAN_TARGET << WINSCW_DEPLOYMENT_TARGET + << DEPLOYMENT_CLEAN_TARGET + << DEPLOYMENT_TARGET << STORE_BUILD_TARGET; } @@ -362,7 +368,9 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool qDeleteAll(subtargets); } - writeDeploymentTargets(t); + // Deploymend targets for both emulator and rom deployment + writeDeploymentTargets(t, false); + writeDeploymentTargets(t, true); writeSisTargets(t); @@ -407,13 +415,21 @@ void SymbianAbldMakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t, Q_UNUSED(iconTargetFile); } -bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t) +bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t, bool isRom) { - t << WINSCW_DEPLOYMENT_TARGET ":" << endl; + if (isRom) + t << DEPLOYMENT_TARGET ":" << endl; + else + t << WINSCW_DEPLOYMENT_TARGET ":" << endl; - QString remoteTestPath = epocRoot() + QLatin1String("epoc32\\winscw\\c\\private\\") + privateDirUid; // default 4 OpenC; 4 all Symbian too + QString remoteTestPath = epocRoot() + + QLatin1String(isRom ? "epoc32\\data\\z\\private\\" : "epoc32\\winscw\\c\\private\\") + + privateDirUid; DeploymentList depList; - initProjectDeploySymbian(project, depList, remoteTestPath, false, QLatin1String("winscw"), QLatin1String("udeb"), generatedDirs, generatedFiles); + + initProjectDeploySymbian(project, depList, remoteTestPath, false, + QLatin1String(isRom ? ROM_DEPLOYMENT_PLATFORM : EMULATOR_DEPLOYMENT_PLATFORM), + QString(), generatedDirs, generatedFiles); if (depList.size()) t << "\t-echo Deploying changed files..." << endl; @@ -422,12 +438,17 @@ bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t) // Xcopy prompts for selecting file or directory if target doesn't exist, // and doesn't provide switch to force file selection. It does provide dir forcing, though, // so strip the last part of the destination. - t << "\t-$(XCOPY) \"" << depList.at(i).from << "\" \"" << depList.at(i).to.left(depList.at(i).to.lastIndexOf("\\") + 1) << "\"" << endl; + t << "\t-$(XCOPY) \"" << depList.at(i).from << "\" \"" + << depList.at(i).to.left(depList.at(i).to.lastIndexOf("\\") + 1) << "\"" << endl; } t << endl; - t << WINSCW_DEPLOYMENT_CLEAN_TARGET ":" << endl; + if (isRom) + t << DEPLOYMENT_CLEAN_TARGET ":" << endl; + else + t << WINSCW_DEPLOYMENT_CLEAN_TARGET ":" << endl; + QStringList cleanList; for (int i = 0; i < depList.size(); ++i) { cleanList.append(depList.at(i).to); diff --git a/qmake/generators/symbian/symmake_abld.h b/qmake/generators/symbian/symmake_abld.h index 25b06bb..c033284 100644 --- a/qmake/generators/symbian/symmake_abld.h +++ b/qmake/generators/symbian/symmake_abld.h @@ -58,7 +58,7 @@ protected: virtual void appendAbldTempDirs(QStringList& sysincspaths, QString includepath); void writeStoreBuildTarget(QTextStream &t); - bool writeDeploymentTargets(QTextStream &t); + bool writeDeploymentTargets(QTextStream &t, bool isRom); public: diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index 8accfce..5571183 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -90,6 +90,23 @@ void SymbianSbsv2MakefileGenerator::exportFlm() } } +void SymbianSbsv2MakefileGenerator::writeSbsDeploymentList(const DeploymentList& depList, QTextStream& t) +{ + for (int i = 0; i < depList.size(); ++i) { + t << "START EXTENSION qt/qmake_emulator_deployment" << endl; + QString fromItem = depList.at(i).from; + QString toItem = depList.at(i).to; + fromItem.replace("\\", "/"); + toItem.replace("\\", "/"); +#if defined(Q_OS_WIN) + toItem.prepend(QDir::current().absolutePath().left(2)); // add drive +#endif + t << "OPTION DEPLOY_SOURCE " << fromItem << endl; + t << "OPTION DEPLOY_TARGET " << toItem << endl; + t << "END" << endl; + } +} + void SymbianSbsv2MakefileGenerator::writeMkFile(const QString& wrapperFileName, bool deploymentOnly) { // Can't use extension makefile with sbsv2 @@ -365,27 +382,23 @@ void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t t << endl; - // Write winscw deployment rules + // Write deployment rules QString remoteTestPath = epocRoot() + QLatin1String("epoc32/winscw/c/private/") + privateDirUid; DeploymentList depList; - initProjectDeploySymbian(project, depList, remoteTestPath, false, QLatin1String("winscw"), QLatin1String("udeb"), generatedDirs, generatedFiles); + //write emulator deployment t << "#if defined(WINSCW)" << endl; - for (int i = 0; i < depList.size(); ++i) { - t << "START EXTENSION qt/qmake_emulator_deployment" << endl; - QString fromItem = depList.at(i).from; - QString toItem = depList.at(i).to; - fromItem.replace("\\", "/"); - toItem.replace("\\", "/"); -#if defined(Q_OS_WIN) - toItem.prepend(QDir::current().absolutePath().left(2)); // add drive -#endif - t << "OPTION DEPLOY_SOURCE " << fromItem << endl; - t << "OPTION DEPLOY_TARGET " << toItem << endl; - t << "END" << endl; - } + initProjectDeploySymbian(project, depList, remoteTestPath, false, + QLatin1String(EMULATOR_DEPLOYMENT_PLATFORM), QString(), generatedDirs, generatedFiles); + writeSbsDeploymentList(depList, t); t << "#endif" << endl; + //write ROM deployment + remoteTestPath = epocRoot() + QLatin1String("epoc32/data/z/private/") + privateDirUid; + depList.clear(); + initProjectDeploySymbian(project, depList, remoteTestPath, false, + QLatin1String(ROM_DEPLOYMENT_PLATFORM), QString(), generatedDirs, generatedFiles); + writeSbsDeploymentList(depList, t); t << endl; // Write post link rules diff --git a/qmake/generators/symbian/symmake_sbsv2.h b/qmake/generators/symbian/symmake_sbsv2.h index 5c31249..b8ccdbe 100644 --- a/qmake/generators/symbian/symmake_sbsv2.h +++ b/qmake/generators/symbian/symmake_sbsv2.h @@ -64,6 +64,7 @@ public: private: void exportFlm(); + void writeSbsDeploymentList(const DeploymentList& depList, QTextStream& t); QString extraTargetsCache; QString extraCompilersCache; -- cgit v0.12