summaryrefslogtreecommitdiffstats
path: root/qmake/generators/symbian/symmake_abld.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/generators/symbian/symmake_abld.cpp')
-rw-r--r--qmake/generators/symbian/symmake_abld.cpp436
1 files changed, 436 insertions, 0 deletions
diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp
new file mode 100644
index 0000000..d1942c6
--- /dev/null
+++ b/qmake/generators/symbian/symmake_abld.cpp
@@ -0,0 +1,436 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#include "symmake_abld.h"
+#include "initprojectdeploy_symbian.h"
+
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qdir.h>
+#include <qdatetime.h>
+#include <qdebug.h>
+
+#define DO_NOTHING_TARGET "do_nothing"
+#define CREATE_TEMPS_TARGET "create_temps"
+#define EXTENSION_CLEAN "extension_clean"
+#define PRE_TARGETDEPS_TARGET "pre_targetdeps"
+#define COMPILER_CLEAN_TARGET "compiler_clean"
+#define FINALIZE_TARGET "finalize"
+#define GENERATED_SOURCES_TARGET "generated_sources"
+#define ALL_SOURCE_DEPS_TARGET "all_source_deps"
+#define WINSCW_DEPLOYMENT_TARGET "winscw_deployment"
+#define WINSCW_DEPLOYMENT_CLEAN_TARGET "winscw_deployment_clean"
+
+SymbianAbldMakefileGenerator::SymbianAbldMakefileGenerator() : SymbianMakefileGenerator() { }
+SymbianAbldMakefileGenerator::~SymbianAbldMakefileGenerator() { }
+
+bool SymbianAbldMakefileGenerator::writeMkFile(const QString& wrapperFileName, bool deploymentOnly)
+{
+
+ QString gnuMakefileName = QLatin1String("Makefile_") + uid3;
+ removeSpecialCharacters(gnuMakefileName);
+ gnuMakefileName.append(".mk");
+
+ QFile ft(gnuMakefileName);
+ if(ft.open(QIODevice::WriteOnly)) {
+ generatedFiles << ft.fileName();
+ QTextStream t(&ft);
+
+ t << "# ==============================================================================" << endl;
+ t << "# Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: ";
+ t << QDateTime::currentDateTime().toString() << endl;
+ t << "# This file is generated by qmake and should not be modified by the" << endl;
+ t << "# user." << endl;
+ t << "# Name : " << gnuMakefileName << endl;
+ t << "# Part of : " << project->values("TARGET").join(" ") << endl;
+ t << "# Description : This file is used to call necessary targets on wrapper makefile" << endl;
+ t << "# during normal Symbian build process." << endl;
+ t << "# Version : " << endl;
+ t << "#" << endl;
+ t << "# ==============================================================================" << "\n" << endl;
+
+ t << endl << endl;
+
+ t << "MAKE = make" << endl;
+ t << endl;
+
+ t << DO_NOTHING_TARGET " :" << endl;
+ t << "\t" << "@rem " DO_NOTHING_TARGET << endl << endl;
+
+ QString buildDeps;
+ QString cleanDeps;
+ QString finalDeps;
+ QString cleanDepsWinscw;
+ QString finalDepsWinscw;
+ QStringList wrapperTargets;
+ if (deploymentOnly) {
+ buildDeps.append(DO_NOTHING_TARGET);
+ cleanDeps.append(DO_NOTHING_TARGET);
+ cleanDepsWinscw.append( WINSCW_DEPLOYMENT_CLEAN_TARGET);
+ finalDeps.append(DO_NOTHING_TARGET);
+ finalDepsWinscw.append(WINSCW_DEPLOYMENT_TARGET);
+ wrapperTargets << WINSCW_DEPLOYMENT_TARGET << WINSCW_DEPLOYMENT_CLEAN_TARGET;
+ } else {
+ buildDeps.append(CREATE_TEMPS_TARGET " " PRE_TARGETDEPS_TARGET);
+ cleanDeps.append(EXTENSION_CLEAN);
+ cleanDepsWinscw.append(EXTENSION_CLEAN " " WINSCW_DEPLOYMENT_CLEAN_TARGET);
+ finalDeps.append(FINALIZE_TARGET);
+ finalDepsWinscw.append(FINALIZE_TARGET " " WINSCW_DEPLOYMENT_TARGET);
+ wrapperTargets << PRE_TARGETDEPS_TARGET
+ << CREATE_TEMPS_TARGET
+ << EXTENSION_CLEAN
+ << FINALIZE_TARGET
+ << WINSCW_DEPLOYMENT_CLEAN_TARGET
+ << WINSCW_DEPLOYMENT_TARGET;
+ }
+
+ t << "MAKMAKE: " << buildDeps << endl << endl;
+ t << "LIB: " << buildDeps << endl << endl;
+ t << "BLD: " << buildDeps << endl << endl;
+ t << "ifeq \"$(PLATFORM)\" \"WINSCW\"" << endl;
+ t << "CLEAN: " << cleanDepsWinscw << endl;
+ t << "else" << endl;
+ t << "CLEAN: " << cleanDeps << endl;
+ t << "endif" << endl << endl;
+ t << "CLEANLIB: " DO_NOTHING_TARGET << endl << endl;
+ t << "RESOURCE: " DO_NOTHING_TARGET << endl << endl;
+ t << "FREEZE: " DO_NOTHING_TARGET << endl << endl;
+ t << "SAVESPACE: " DO_NOTHING_TARGET << endl << endl;
+ t << "RELEASABLES: " DO_NOTHING_TARGET << endl << endl;
+ t << "ifeq \"$(PLATFORM)\" \"WINSCW\"" << endl;
+ t << "FINAL: " << finalDepsWinscw << endl;
+ t << "else" << endl;
+ t << "FINAL: " << finalDeps << endl;
+ t << "endif" << endl << endl;
+
+ QString makefile(Option::fixPathToTargetOS(fileInfo(wrapperFileName).canonicalFilePath()));
+ foreach(QString target, wrapperTargets) {
+ t << target << " : " << makefile << endl;
+ t << "\t-$(MAKE) -f \"" << makefile << "\" " << target << endl << endl;
+ }
+
+ t << endl;
+ } // if(ft.open(QIODevice::WriteOnly))
+
+ return true;
+}
+
+void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool isPrimaryMakefile)
+{
+ QStringList allPlatforms;
+ foreach(QString platform, project->values("SYMBIAN_PLATFORMS")) {
+ allPlatforms << platform.toLower();
+ }
+
+ QStringList debugPlatforms = allPlatforms;
+ QStringList releasePlatforms = allPlatforms;
+ releasePlatforms.removeAll("winscw"); // No release for emulator
+
+ bool isSubdirs = getTargetExtension() == "subdirs";
+
+ QString testClause;
+ if (project->values("CONFIG").contains("symbian_test", Qt::CaseInsensitive))
+ testClause = QLatin1String(" test");
+ else
+ testClause = QLatin1String("");
+
+ QTextStream t(&wrapperFile);
+
+ t << "# ==============================================================================" << endl;
+ t << "# Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: ";
+ t << QDateTime::currentDateTime().toString() << endl;
+ t << "# This file is generated by qmake and should not be modified by the" << endl;
+ t << "# user." << endl;
+ t << "# Name : " << wrapperFile.fileName() << endl;
+ t << "# Description : Wrapper Makefile for calling Symbian build tools" << endl;
+ t << "#" << endl;
+ t << "# ==============================================================================" << "\n" << endl;
+ t << endl;
+ t << "QMAKE = " << Option::fixPathToTargetOS(var("QMAKE_QMAKE")) << endl;
+ t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
+ t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
+ t << "XCOPY = xcopy /d /f /h /r /k /y /i" << endl;
+ t << "ABLD = ABLD.BAT" << endl;
+ t << "DEBUG_PLATFORMS = " << debugPlatforms.join(" ") << endl;
+ t << "RELEASE_PLATFORMS = " << releasePlatforms.join(" ") << endl;
+ t << "MAKE = make" << endl;
+ t << endl;
+ t << "ifeq (WINS,$(findstring WINS, $(PLATFORM)))" << endl;
+ t << "ZDIR=$(EPOCROOT)epoc32\\release\\$(PLATFORM)\\$(CFG)\\Z" << endl;
+ t << "else" << endl;
+ t << "ZDIR=$(EPOCROOT)epoc32\\data\\z" << endl;
+ t << "endif" << endl;
+ t << endl;
+ t << "DEFINES" << '\t' << " = "
+ << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
+ << varGlue("QMAKE_COMPILER_DEFINES", "-D", "-D", " ")
+ << varGlue("DEFINES","-D"," -D","") << endl;
+
+ t << "INCPATH" << '\t' << " = ";
+
+ for(QMap<QString, QStringList>::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) {
+ QStringList values = it.value();
+ for (int i = 0; i < values.size(); ++i) {
+ t << " -I\"" << values.at(i) << "\"";
+ }
+ }
+ t << endl;
+ t << "first: default" << endl;
+ if (debugPlatforms.contains("winscw"))
+ t << "default: debug-winscw";
+ else if (debugPlatforms.contains("armv5"))
+ t << "default: debug-armv5";
+ else if (debugPlatforms.size())
+ t << "default: debug-" << debugPlatforms.first();
+ else
+ t << "default: all";
+
+ t << endl;
+ if (!isPrimaryMakefile) {
+ t << "all:" << endl;
+ } else {
+ t << "all: debug release" << endl;
+ t << endl;
+ t << "qmake:" << endl;
+ t << "\t$(QMAKE) -spec symbian-abld -o \"" << fileInfo(Option::output.fileName()).fileName()
+ << "\" \"" << project->projectFile() << "\"" << endl;
+ t << endl;
+ t << BLD_INF_FILENAME ":" << endl;
+ t << "\t$(QMAKE)" << endl;
+ t << endl;
+ t << "$(ABLD): " BLD_INF_FILENAME << endl;
+ t << "\tbldmake bldfiles" << endl;
+ t << endl;
+
+ t << "debug: $(ABLD)" << endl;
+ foreach(QString item, debugPlatforms) {
+ t << "\t$(ABLD)" << testClause << " build " << item << " udeb" << endl;
+ }
+ t << endl;
+ t << "release: $(ABLD)" << endl;
+ foreach(QString item, releasePlatforms) {
+ t << "\t$(ABLD)" << testClause << " build " << item << " urel" << endl;
+ }
+ t << endl;
+
+ // For more specific builds, targets are in this form: build-platform, e.g. release-armv5
+ foreach(QString item, debugPlatforms) {
+ t << "debug-" << item << ": $(ABLD)" << endl;
+ t << "\t$(ABLD)" << testClause << " build " << item << " udeb" << endl;
+ }
+
+ foreach(QString item, releasePlatforms) {
+ t << "release-" << item << ": $(ABLD)" << endl;
+ t << "\t$(ABLD)" << testClause << " build " << item << " urel" << endl;
+ }
+
+ t << endl;
+ t << "export: $(ABLD)" << endl;
+ t << "\t$(ABLD)" << testClause << " export" << endl;
+ t << endl;
+
+ t << "cleanexport: $(ABLD)" << endl;
+ t << "\t$(ABLD)" << testClause << " cleanexport" << endl;
+ t << endl;
+
+ }
+
+ writeExtraTargets(t);
+
+ // pre_targetdeps target depends on:
+ // - all targets specified in PRE_TARGETDEPS
+ // - the GENERATED_SOURCES sources (so that they get generated)
+ // - all dependencies of sources targeted for compilation
+ // (mainly to ensure that any included UNUSED_SOURCES that need to be generated get generated)
+ //
+ // Unfortunately, Symbian build chain doesn't support linking generated objects to target,
+ // so supporting generating sources is the best we can do. This is enough for mocs.
+
+ if (!isSubdirs) {
+ writeExtraCompilerTargets(t);
+
+ t << CREATE_TEMPS_TARGET ":" << endl;
+ // generate command lines like this ...
+ // -@ if NOT EXIST ".\somedir" mkdir ".\somedir"
+ for(QMap<QString, QStringList>::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) {
+ QStringList values = it.value();
+ for (int i = 0; i < values.size(); ++i) {
+ t << "\t-@ if NOT EXIST \"" << QDir::toNativeSeparators(values.at(i)) << "\\tmp\" mkdir \""
+ << QDir::toNativeSeparators(values.at(i)) << "\\tmp\"" << endl;
+ }
+ }
+ t << endl;
+
+ // Note: EXTENSION_CLEAN will get called many times when doing reallyclean
+ // This is why the "2> NUL" gets appended to generated clean targets in makefile.cpp.
+ t << EXTENSION_CLEAN ": " COMPILER_CLEAN_TARGET << endl;
+ for(QMap<QString, QStringList>::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) {
+ QStringList dirsToClean = it.value();
+ generateCleanCommands(t, dirsToClean, var("QMAKE_DEL_DIR"), " /S /Q ", "", "/tmp");
+ }
+ t << endl;
+
+ t << PRE_TARGETDEPS_TARGET ":"
+ << MAKEFILE_DEPENDENCY_SEPARATOR GENERATED_SOURCES_TARGET
+ << MAKEFILE_DEPENDENCY_SEPARATOR ALL_SOURCE_DEPS_TARGET;
+ if (project->values("PRE_TARGETDEPS").size())
+ t << MAKEFILE_DEPENDENCY_SEPARATOR << project->values("PRE_TARGETDEPS").join(MAKEFILE_DEPENDENCY_SEPARATOR);
+ t << endl << endl;
+ t << GENERATED_SOURCES_TARGET ":";
+ if (project->values("GENERATED_SOURCES").size())
+ t << MAKEFILE_DEPENDENCY_SEPARATOR << project->values("GENERATED_SOURCES").join(MAKEFILE_DEPENDENCY_SEPARATOR);
+ t << endl << endl;
+ t << ALL_SOURCE_DEPS_TARGET ":";
+
+ QStringList allDeps;
+ for(QMap<QString, QStringList>::iterator it = sources.begin(); it != sources.end(); ++it) {
+ QString currentSourcePath = it.key();
+ QStringList values = it.value();
+ for (int i = 0; i < values.size(); ++i) {
+ // we need additional check
+ QString sourceFile = currentSourcePath + "/" + values.at(i);
+ QStringList deps = findDependencies(QDir::toNativeSeparators(sourceFile));
+ appendIfnotExist(allDeps, deps);
+ }
+ }
+
+ foreach(QString item, allDeps) {
+ t << MAKEFILE_DEPENDENCY_SEPARATOR << item;
+ }
+ t << endl << endl;
+
+ // Post link operations
+ t << FINALIZE_TARGET ":" << endl;
+ if(!project->isEmpty("QMAKE_POST_LINK")) {
+ t << '\t' << var("QMAKE_POST_LINK");
+ t << endl;
+ }
+ t << endl;
+ }
+
+ writeDeploymentTargets(t);
+
+ t << "dodistclean:" << endl;
+ foreach(QString item, project->values("SUBDIRS")) {
+ bool fromFile = false;
+ QString fixedItem;
+ if(!project->isEmpty(item + ".file")) {
+ fixedItem = project->first(item + ".file");
+ fromFile = true;
+ } else if(!project->isEmpty(item + ".subdir")) {
+ fixedItem = project->first(item + ".subdir");
+ fromFile = false;
+ } else {
+ fromFile = item.endsWith(Option::pro_ext);
+ fixedItem = item;
+ }
+ QFileInfo fi(fileInfo(fixedItem));
+ if (!fromFile) {
+ t << "\t-$(MAKE) -f \"" << Option::fixPathToTargetOS(fi.canonicalFilePath()) << "\\Makefile\" dodistclean" << endl;
+ } else {
+ QString itemName = fi.fileName();
+ int extIndex = itemName.lastIndexOf(Option::pro_ext);
+ if (extIndex)
+ fixedItem = fi.canonicalPath() + "/" + QString("Makefile.") + itemName.mid(0,extIndex);
+ t << "\t-$(MAKE) -f \"" << Option::fixPathToTargetOS(fixedItem) << "\" dodistclean" << endl;
+ }
+
+ }
+
+ generatedFiles << Option::fixPathToTargetOS(fileInfo(Option::output.fileName()).canonicalFilePath()); // bld.inf
+ generatedFiles << project->values("QMAKE_INTERNAL_PRL_FILE"); // Add generated prl files for cleanup
+ generatedFiles << project->values("QMAKE_DISTCLEAN"); // Add any additional files marked for distclean
+ QStringList fixedFiles;
+ QStringList fixedDirs;
+ foreach(QString item, generatedFiles) {
+ QString fixedItem = Option::fixPathToTargetOS(fileInfo(item).canonicalFilePath());
+ if (!fixedFiles.contains(fixedItem)) {
+ fixedFiles << fixedItem;
+ }
+ }
+ foreach(QString item, generatedDirs) {
+ QString fixedItem = Option::fixPathToTargetOS(fileInfo(item).canonicalFilePath());
+ if (!fixedDirs.contains(fixedItem)) {
+ fixedDirs << fixedItem;
+ }
+ }
+ generateCleanCommands(t, fixedFiles, "$(DEL_FILE)", "", "", "");
+ generateCleanCommands(t, fixedDirs, "$(DEL_DIR)", "", "", "");
+ t << endl;
+
+ t << "distclean: clean dodistclean" << endl;
+ t << endl;
+ t << "clean: $(ABLD)" << endl;
+ t << "\t-$(ABLD)" << testClause << " reallyclean" << endl;
+ t << "\t-bldmake clean" << endl;
+ t << endl;
+
+ // create execution target
+ if (debugPlatforms.contains("winscw") && getTargetExtension() == "exe") {
+ t << "run:" << endl;
+ t << "\t-call " << epocRoot() << "epoc32\\release\\winscw\\udeb\\" << removePathSeparators(escapeFilePath(fileFixify(project->first("TARGET"))).append(".exe")) << endl << endl;
+ }
+}
+
+bool SymbianAbldMakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t)
+{
+ // We don't use extensions for anything in abld
+ Q_UNUSED(t);
+ return true;
+}
+
+bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t)
+{
+ t << WINSCW_DEPLOYMENT_TARGET ":" << endl;
+
+ QString remoteTestPath = epocRoot() + QLatin1String("epoc32\\winscw\\c\\private\\") + privateDirUid; // default 4 OpenC; 4 all Symbian too
+ DeploymentList depList;
+ initProjectDeploySymbian( project, depList, remoteTestPath, false, QLatin1String("winscw"), QLatin1String("udeb"), generatedDirs, generatedFiles );
+
+ if (depList.size())
+ t << "\t-echo Deploying changed files..." << endl;
+
+ for (int i=0; i<depList.size(); ++i) {
+ // 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 << endl;
+
+ t << WINSCW_DEPLOYMENT_CLEAN_TARGET ":" << endl;
+ QStringList cleanList;
+ for (int i=0; i<depList.size(); ++i) {
+ cleanList.append(depList.at(i).to);
+ }
+ generateCleanCommands(t, cleanList, "$(DEL_FILE)", "", "", "");
+
+ // Note: If deployment creates any directories, they will not get deleted after cleanup.
+ // To do this in robust fashion could be quite complex.
+
+ t << endl;
+
+ return true;
+}
+
+void SymbianAbldMakefileGenerator::writeBldInfMkFilePart(QTextStream& t, bool addDeploymentExtension)
+{
+ // Normally emulator deployment gets done via regular makefile, but since subdirs
+ // do not get that, special deployment only makefile is generated for them if needed.
+ if(getTargetExtension() != "subdirs" || addDeploymentExtension) {
+ QString gnuMakefileName = QLatin1String("Makefile_") + uid3;
+ removeSpecialCharacters(gnuMakefileName);
+ gnuMakefileName.append(".mk");
+ t << "gnumakefile " << gnuMakefileName << endl;
+ }
+}
+