From 5c978d026d378f7deaa14a87cf103ed43f14c413 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 3 Sep 2010 11:33:38 +0300 Subject: Fix Symbian handling of projects with special characters in TARGET Plenty of filenames got generated with spaces which didn't work as that was not taken into account. Harmonized TARGET fixing across prf files and qmake Symbian generator code. Task-number: QTBUG-13363 Reviewed-by: Thomas Zander --- mkspecs/common/symbian/symbian.conf | 18 ++++++++ mkspecs/features/sis_targets.prf | 24 +++++----- mkspecs/features/symbian/application_icon.prf | 15 +----- mkspecs/features/symbian/run_on_phone.prf | 10 ++-- mkspecs/features/symbian/symbian_building.prf | 66 +++++++++++++-------------- qmake/generators/symbian/symbiancommon.cpp | 19 +++----- 6 files changed, 77 insertions(+), 75 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 61cc7d9..beef193 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -175,3 +175,21 @@ pkg_platform_dependencies = \ DEPLOYMENT += default_deployment +defineReplace(symbianRemoveSpecialCharacters) { + # Produce identical string to what SymbianCommonGenerator::removeSpecialCharacters and + # SymbianCommonGenerator::removeEpocSpecialCharacters produce + + fixedStr = $$1 + + fixedStr = $$replace(fixedStr, /,_) + fixedStr = $$replace(fixedStr, \\\\,_) + fixedStr = $$replace(fixedStr, " ",_) + symbian-abld|symbian-sbsv2 { + fixedStr = $$replace(fixedStr, -,_) + fixedStr = $$replace(fixedStr, \\.,_) + fixedStr = $$replace(fixedStr, :,_) + } + + return ($$fixedStr) +} + diff --git a/mkspecs/features/sis_targets.prf b/mkspecs/features/sis_targets.prf index e069ee1..800a04c 100644 --- a/mkspecs/features/sis_targets.prf +++ b/mkspecs/features/sis_targets.prf @@ -10,6 +10,9 @@ else:!equals(DEPLOYMENT, default_deployment) { } equals(GENERATE_SIS_TARGETS, true) { + + baseTarget = $$symbianRemoveSpecialCharacters($$basename(TARGET)) + symbian-abld|symbian-sbsv2 { symbian-sbsv2 { CONVERT_GCCE_PARAM = -g @@ -19,7 +22,7 @@ equals(GENERATE_SIS_TARGETS, true) { make_cache_name = .make.cache sis_target.target = sis - sis_target.commands = $(if $(wildcard $$basename(TARGET)_template.pkg), \ + sis_target.commands = $(if $(wildcard $${baseTarget}_template.pkg), \ $(if $(wildcard $$make_cache_name), \ $(MAKE) -f $(MAKEFILE) ok_sis MAKEFILES=$$make_cache_name \ , \ @@ -34,11 +37,11 @@ equals(GENERATE_SIS_TARGETS, true) { ) ok_sis_target.target = ok_sis - ok_sis_target.commands = createpackage.bat $$CONVERT_GCCE_PARAM $(QT_SIS_OPTIONS) $$basename(TARGET)_template.pkg \ + ok_sis_target.commands = createpackage.bat $$CONVERT_GCCE_PARAM $(QT_SIS_OPTIONS) $${baseTarget}_template.pkg \ $(QT_SIS_TARGET) $(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE) unsigned_sis_target.target = unsigned_sis - unsigned_sis_target.commands = $(if $(wildcard $$basename(TARGET)_template.pkg), \ + unsigned_sis_target.commands = $(if $(wildcard $${baseTarget}_template.pkg), \ $(if $(wildcard $$make_cache_name), \ $(MAKE) -f $(MAKEFILE) ok_unsigned_sis MAKEFILES=$$make_cache_name \ , \ @@ -53,21 +56,21 @@ equals(GENERATE_SIS_TARGETS, true) { ) ok_unsigned_sis_target.target = ok_unsigned_sis - ok_unsigned_sis_target.commands = createpackage.bat $$CONVERT_GCCE_PARAM $(QT_SIS_OPTIONS) -o $$basename(TARGET)_template.pkg $(QT_SIS_TARGET) + ok_unsigned_sis_target.commands = createpackage.bat $$CONVERT_GCCE_PARAM $(QT_SIS_OPTIONS) -o $${baseTarget}_template.pkg $(QT_SIS_TARGET) - target_sis_target.target = $$basename(TARGET).sis + target_sis_target.target = $${baseTarget}.sis target_sis_target.commands = $(MAKE) -f $(MAKEFILE) sis installer_sis_target.target = installer_sis - installer_sis_target.commands = $(if $(wildcard $$basename(TARGET)_installer.pkg), \ + installer_sis_target.commands = $(if $(wildcard $${baseTarget}_installer.pkg), \ $(MAKE) -f $(MAKEFILE) ok_installer_sis \ , \ $(MAKE) -f $(MAKEFILE) fail_sis_nopkg \ ) - installer_sis_target.depends = $$basename(TARGET).sis + installer_sis_target.depends = $${baseTarget}.sis ok_installer_sis_target.target = ok_installer_sis - ok_installer_sis_target.commands = createpackage.bat $(QT_SIS_OPTIONS) $$basename(TARGET)_installer.pkg - \ + ok_installer_sis_target.commands = createpackage.bat $(QT_SIS_OPTIONS) $${baseTarget}_installer.pkg - \ $(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE) fail_sis_nopkg_target.target = fail_sis_nopkg @@ -77,7 +80,7 @@ equals(GENERATE_SIS_TARGETS, true) { fail_sis_nocache_target.commands = "$(error Project has to be built or QT_SIS_TARGET environment variable has to be set before calling 'SIS' target)" stub_sis_target.target = stub_sis - stub_sis_target.commands = $(if $(wildcard $$basename(TARGET)_template.pkg), \ + stub_sis_target.commands = $(if $(wildcard $${baseTarget}_template.pkg), \ $(if $(wildcard $$make_cache_name), \ $(MAKE) -f $(MAKEFILE) ok_stub_sis MAKEFILES=$$make_cache_name \ , \ @@ -92,7 +95,7 @@ equals(GENERATE_SIS_TARGETS, true) { ) ok_stub_sis_target.target = ok_stub_sis - ok_stub_sis_target.commands = createpackage.bat -s $(QT_SIS_OPTIONS) $$basename(TARGET)_stub.pkg \ + ok_stub_sis_target.commands = createpackage.bat -s $(QT_SIS_OPTIONS) $${baseTarget}_stub.pkg \ $(QT_SIS_TARGET) $(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE) QMAKE_EXTRA_TARGETS += sis_target \ @@ -134,7 +137,6 @@ equals(GENERATE_SIS_TARGETS, true) { sis_destdir = $$DESTDIR isEmpty(sis_destdir):sis_destdir = . - baseTarget = $$basename(TARGET) !equals(TARGET, "$$baseTarget"):sis_destdir = $$sis_destdir/$$dirname(TARGET) sis_target.target = sis diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index c5654d9..9a9395a 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -14,20 +14,7 @@ contains( CONFIG, no_icon ) { warning("Only first icon specified in ICON variable is used: $$ICON") } - # Try to produce indentical string to fixedTarget in SymbianMakefileGenerator, replaced chars taken - # from SymbianCommonGenerator::removeSpecialCharacters. - # - # Note: it is not a major problem even baseTarget is not 100% identical to fixedTarget since qmake - # only uses filename from RSS_RULES.icon_file when referring to icon file name. - baseTarget = $$basename(TARGET) - baseTarget = $$replace(baseTarget, /,_) - baseTarget = $$replace(baseTarget, \\\\,_) - baseTarget = $$replace(baseTarget, " ",_) - symbian-abld|symbian-sbsv2 { - baseTarget = $$replace(baseTarget, -,_) - baseTarget = $$replace(baseTarget, \\.,_) - baseTarget = $$replace(baseTarget, :,_) - } + baseTarget = $$symbianRemoveSpecialCharacters($$basename(TARGET)) # Note: symbian-sbsv2 builds can't utilize extra compiler for mifconv, so ICON handling is done in code !symbian-sbsv2 { diff --git a/mkspecs/features/symbian/run_on_phone.prf b/mkspecs/features/symbian/run_on_phone.prf index f77369c..d845277 100644 --- a/mkspecs/features/symbian/run_on_phone.prf +++ b/mkspecs/features/symbian/run_on_phone.prf @@ -11,19 +11,21 @@ else:!equals(DEPLOYMENT, default_deployment) { } equals(GENERATE_RUN_TARGETS, true) { + baseTarget = $$symbianRemoveSpecialCharacters($$basename(TARGET)) + sis_file = $${baseTarget}.sis symbian-abld|symbian-sbsv2 { sis_destdir = - sis_file = $$basename(TARGET).sis } else { sis_destdir = $$DESTDIR - sis_file = $${TARGET}.sis + isEmpty(sis_destdir):sis_destdir = . + !equals(TARGET, "$$baseTarget"):sis_destdir = $$sis_destdir/$$dirname(TARGET) !isEmpty(sis_destdir):!contains(sis_destdir, "[/\\\\]$"):sis_destdir = $${sis_destdir}/ contains(QMAKE_HOST.os, "Windows"):sis_destdir = $$replace(sis_destdir, "/", "\\") } contains(SYMBIAN_PLATFORMS, "WINSCW"):contains(TEMPLATE, "app") { run_target.target = run - run_target.commands = call "$${EPOCROOT}epoc32/release/winscw/udeb/$$basename(TARGET).exe" $(QT_RUN_OPTIONS) + run_target.commands = call "$${EPOCROOT}epoc32/release/winscw/udeb/$${baseTarget}.exe" $(QT_RUN_OPTIONS) QMAKE_EXTRA_TARGETS += run_target } @@ -31,7 +33,7 @@ equals(GENERATE_RUN_TARGETS, true) { runonphone_target.target = runonphone runonphone_target.depends = sis runonphone_target.commands = runonphone $(QT_RUN_ON_PHONE_OPTIONS) --sis "$${sis_destdir}$${sis_file}" - contains(TEMPLATE, "app"):runonphone_target.commands += "$$basename(TARGET).exe" $(QT_RUN_OPTIONS) + contains(TEMPLATE, "app"):runonphone_target.commands += "$${baseTarget}.exe" $(QT_RUN_OPTIONS) QMAKE_EXTRA_TARGETS += runonphone_target } diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf index 414b081..0b621a3 100644 --- a/mkspecs/features/symbian/symbian_building.prf +++ b/mkspecs/features/symbian/symbian_building.prf @@ -35,7 +35,7 @@ symbianDestdir=$$DESTDIR isEmpty(symbianDestdir) { symbianDestdir = . } -baseTarget = $$basename(TARGET) +baseTarget = $$symbianRemoveSpecialCharacters($$basename(TARGET)) !equals(TARGET, "$$baseTarget"):symbianDestdir = $$symbianDestdir/$$dirname(TARGET) contains(QMAKE_CFLAGS, "--thumb")|contains(QMAKE_CXXFLAGS, "--thumb")|contains(QMAKE_CFLAGS, "-mthumb")|contains(QMAKE_CXXFLAGS, "-mthumb") { @@ -253,49 +253,45 @@ symbianresources.CONFIG = no_link target_predeps QMAKE_EXTRA_COMPILERS += symbianresources contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") { - baseResourceTarget = $$basename(TARGET) - # If you change this, also see application_icon.prf - baseResourceTarget = $$replace(baseResourceTarget, " ",_) - # Make our own extra target in order to get dependencies for generated # files right. This also avoids the warning about files not found. - symbianGenResource.target = $${symbian_resources_RCC_DIR}/$${baseResourceTarget}.rsg + symbianGenResource.target = $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg symbianGenResource.commands = cpp -nostdinc -undef \ $$symbian_resources_INCLUDES \ $$symbian_resources_DEFINES \ - $${baseResourceTarget}.rss \ - -o $${symbian_resources_RCC_DIR}/$${baseResourceTarget}.rpp \ + $${baseTarget}.rss \ + -o $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ && rcomp -u -m045,046,047 \ - -s$${symbian_resources_RCC_DIR}/$${baseResourceTarget}.rpp \ - -o$${symbianDestdir}/$${baseResourceTarget}.rsc \ - -h$${symbian_resources_RCC_DIR}/$${baseResourceTarget}.rsg \ - -i$${baseResourceTarget}.rss - silent:symbianGenResource.commands = @echo rcomp $${baseResourceTarget}.rss && $$symbianGenResource.commands - symbianGenResource.depends = $${baseResourceTarget}.rss - PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseResourceTarget}.rsg - QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseResourceTarget}.rsg - QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseResourceTarget}.rpp - QMAKE_DISTCLEAN += $${baseResourceTarget}.rss - QMAKE_DISTCLEAN += $${symbianDestdir}/$${baseResourceTarget}.rsc - - symbianGenRegResource.target = $${symbian_resources_RCC_DIR}/$${baseResourceTarget}_reg.rsg + -s$${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ + -o$${symbianDestdir}/$${baseTarget}.rsc \ + -h$${symbian_resources_RCC_DIR}/$${baseTarget}.rsg \ + -i$${baseTarget}.rss + silent:symbianGenResource.commands = @echo rcomp $${baseTarget}.rss && $$symbianGenResource.commands + symbianGenResource.depends = $${baseTarget}.rss + PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg + QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg + QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp + QMAKE_DISTCLEAN += $${baseTarget}.rss + QMAKE_DISTCLEAN += $${symbianDestdir}/$${baseTarget}.rsc + + symbianGenRegResource.target = $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg symbianGenRegResource.commands = cpp -nostdinc -undef \ $$symbian_resources_INCLUDES \ $$symbian_resources_DEFINES \ - $${baseResourceTarget}_reg.rss \ - -o $${symbian_resources_RCC_DIR}/$${baseResourceTarget}_reg.rpp \ + $${baseTarget}_reg.rss \ + -o $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ && rcomp -u -m045,046,047 \ - -s$${symbian_resources_RCC_DIR}/$${baseResourceTarget}_reg.rpp \ - -o$${symbianDestdir}/$${baseResourceTarget}_reg.rsc \ - -h$${symbian_resources_RCC_DIR}/$${baseResourceTarget}_reg.rsg \ - -i$${baseResourceTarget}_reg.rss - silent:symbianGenRegResource.commands = @echo rcomp $${baseResourceTarget}_reg.rss && $$symbianGenRegResource.commands - symbianGenRegResource.depends = $${baseResourceTarget}_reg.rss $${symbian_resources_RCC_DIR}/$${baseResourceTarget}.rsg - PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseResourceTarget}_reg.rsg - QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseResourceTarget}_reg.rsg - QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseResourceTarget}_reg.rpp - QMAKE_DISTCLEAN += $${baseResourceTarget}_reg.rss - QMAKE_DISTCLEAN += $${symbianDestdir}/$${baseResourceTarget}_reg.rsc + -s$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ + -o$${symbianDestdir}/$${baseTarget}_reg.rsc \ + -h$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg \ + -i$${baseTarget}_reg.rss + silent:symbianGenRegResource.commands = @echo rcomp $${baseTarget}_reg.rss && $$symbianGenRegResource.commands + symbianGenRegResource.depends = $${baseTarget}_reg.rss $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg + PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg + QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg + QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp + QMAKE_DISTCLEAN += $${baseTarget}_reg.rss + QMAKE_DISTCLEAN += $${symbianDestdir}/$${baseTarget}_reg.rsc # Trick to get qmake to create the RCC_DIR for us. symbianRccDirCreation.input = SOURCES @@ -312,3 +308,5 @@ contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") { # Generated pkg files QMAKE_DISTCLEAN += $${baseTarget}_template.pkg +QMAKE_DISTCLEAN += $${baseTarget}_installer.pkg +QMAKE_DISTCLEAN += $${baseTarget}_stub.pkg diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index 155dbc9..a60ae07 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -129,7 +129,7 @@ bool SymbianCommonGenerator::containsStartWithItem(const QChar &c, const QString void SymbianCommonGenerator::removeSpecialCharacters(QString& str) { - // When modifying this method check also application_icon.prf + // When modifying this method check also symbianRemoveSpecialCharacters in symbian.conf str.replace(QString("/"), QString("_")); str.replace(QString("\\"), QString("_")); str.replace(QString(" "), QString("_")); @@ -137,7 +137,7 @@ void SymbianCommonGenerator::removeSpecialCharacters(QString& str) void SymbianCommonGenerator::removeEpocSpecialCharacters(QString& str) { - // When modifying this method check also application_icon.prf + // When modifying this method check also symbianRemoveSpecialCharacters in symbian.conf str.replace(QString("-"), QString("_")); str.replace(QString(":"), QString("_")); str.replace(QString("."), QString("_")); @@ -154,13 +154,8 @@ QString romPath(const QString& path) void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocBuild) { QMakeProject *project = generator->project; - QString pkgTarget = project->first("QMAKE_ORIG_TARGET"); - if (pkgTarget.isEmpty()) - pkgTarget = project->first("TARGET"); - pkgTarget = generator->unescapeFilePath(pkgTarget); - pkgTarget = removePathSeparators(pkgTarget); QString pkgFilename = Option::output_dir + QLatin1Char('/') + - QString("%1_template.pkg").arg(pkgTarget); + QString("%1_template.pkg").arg(fixedTarget); QFile pkgFile(pkgFilename); if (!pkgFile.open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -169,7 +164,7 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB } QString stubPkgFileName = Option::output_dir + QLatin1Char('/') + - QString("%1_stub.pkg").arg(pkgTarget); + QString("%1_stub.pkg").arg(fixedTarget); QFile stubPkgFile(stubPkgFileName); if (!stubPkgFile.open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -193,7 +188,7 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB // Header info QString wrapperPkgFilename = Option::output_dir + QLatin1Char('/') + QString("%1_installer.%2") - .arg(pkgTarget).arg("pkg"); + .arg(fixedTarget).arg("pkg"); QString headerComment = "; %1 generated by qmake at %2\n" "; This file is generated by qmake and should not be modified by the user\n" @@ -535,7 +530,7 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB // Wrapped files deployment QString currentPath = qmake_getpwd(); - QString sisName = QString("%1.sis").arg(pkgTarget); + QString sisName = QString("%1.sis").arg(fixedTarget); twf << "\"" << currentPath << "/" << sisName << "\" - \"c:\\private\\2002CCCE\\import\\" << sisName << "\"" << endl; QString bootStrapPath = QLibraryInfo::location(QLibraryInfo::PrefixPath); @@ -552,7 +547,7 @@ QString SymbianCommonGenerator::removePathSeparators(QString &file) if (QDir::separator().unicode() != '/') ret.replace(QDir::separator(), QLatin1Char('/')); - if (ret.indexOf(QLatin1Char('/')) > 0) + if (ret.indexOf(QLatin1Char('/')) >= 0) ret.remove(0, ret.lastIndexOf(QLatin1Char('/')) + 1); return ret; -- cgit v0.12