aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/qbs/modules/cpp/sdcc.js21
-rw-r--r--tests/auto/blackbox/testdata-baremetal/linker-map/linker-map.qbs6
-rw-r--r--tests/auto/blackbox/tst_blackboxbaremetal.cpp54
3 files changed, 49 insertions, 32 deletions
diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js
index a47063401..4010e38db 100644
--- a/share/qbs/modules/cpp/sdcc.js
+++ b/share/qbs/modules/cpp/sdcc.js
@@ -641,6 +641,12 @@ function prepareLinker(project, product, inputs, outputs, input, output) {
};
cmds.push(cmd);
}
+
+ function buildLinkerMapFilePath(target, suffix) {
+ return FileInfo.joinPaths(FileInfo.path(target.filePath),
+ FileInfo.completeBaseName(target.fileName) + suffix);
+ }
+
// It is a workaround which removes the generated linker map file
// if it is disabled by cpp.generateLinkerMapFile property.
// Reason is that the SDCC compiler always generates this file,
@@ -649,13 +655,22 @@ function prepareLinker(project, product, inputs, outputs, input, output) {
// linking completes.
if (!product.cpp.generateLinkerMapFile) {
cmd = new JavaScriptCommand();
- cmd.mapFilePath = FileInfo.joinPaths(
- FileInfo.path(target.filePath),
- FileInfo.completeBaseName(target.fileName) + product.cpp.linkerMapSuffix);
+ cmd.mapFilePath = buildLinkerMapFilePath(target, product.cpp.linkerMapSuffix);
cmd.silent = true;
cmd.sourceCode = function() { File.remove(mapFilePath); };
cmds.push(cmd);
}
+ // It is a workaround to rename the extension of the output linker
+ // map file to the specified one, since the linker generates only
+ // files with the '.map' extension.
+ if (product.cpp.generateLinkerMapFile && (product.cpp.linkerMapSuffix !== ".map")) {
+ cmd = new JavaScriptCommand();
+ cmd.newMapFilePath = buildLinkerMapFilePath(target, product.cpp.linkerMapSuffix);
+ cmd.oldMapFilePath = buildLinkerMapFilePath(target, ".map");
+ cmd.silent = true;
+ cmd.sourceCode = function() { File.move(oldMapFilePath, newMapFilePath); };
+ cmds.push(cmd);
+ }
return cmds;
}
diff --git a/tests/auto/blackbox/testdata-baremetal/linker-map/linker-map.qbs b/tests/auto/blackbox/testdata-baremetal/linker-map/linker-map.qbs
index 676221e11..fe93ac144 100644
--- a/tests/auto/blackbox/testdata-baremetal/linker-map/linker-map.qbs
+++ b/tests/auto/blackbox/testdata-baremetal/linker-map/linker-map.qbs
@@ -1,10 +1,8 @@
import "../BareMetalApplication.qbs" as BareMetalApplication
BareMetalApplication {
- condition: {
- console.info("current toolset: %%"
- + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%");
- return true;
+ property bool dummy: {
+ console.info("linker map suffix: %%" + cpp.linkerMapSuffix + "%%");
}
files: ["main.c"]
}
diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
index a5feedd48..1e300e246 100644
--- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp
+++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
@@ -59,6 +59,16 @@ static bool extractCompilerIncludePaths(const QByteArray &output, QStringList &c
return true;
}
+static bool extractQuitedValue(const QByteArray &output, QString &pattern)
+{
+ const QRegularExpression re("%%(.+)%%");
+ const QRegularExpressionMatch match = re.match(output);
+ if (!match.hasMatch())
+ return false;
+ pattern = match.captured(1);
+ return true;
+}
+
static QByteArray unsupportedToolsetMessage(const QByteArray &output)
{
QByteArray toolchain;
@@ -68,17 +78,6 @@ static QByteArray unsupportedToolsetMessage(const QByteArray &output)
+ "' for architecture '" + architecture + "'";
}
-static QString linkerMapFileExtension(const QByteArray &toolchain, const QByteArray &architecture)
-{
- if (toolchain == "keil") {
- if (architecture == "mcs51")
- return QStringLiteral(".m51");
- if (architecture == "c166")
- return QStringLiteral(".m66");
- }
- return QStringLiteral(".map");
-}
-
TestBlackboxBareMetal::TestBlackboxBareMetal()
: TestBlackboxBase (SRCDIR "/testdata-baremetal", "blackbox-baremetal")
{
@@ -215,33 +214,38 @@ void TestBlackboxBareMetal::compilerListingFiles()
void TestBlackboxBareMetal::linkerMapFile_data()
{
QTest::addColumn<bool>("generateMap");
- QTest::newRow("do-not-generate-linker-map") << false;
- QTest::newRow("generate-linker-map") << true;
+ QTest::addColumn<QString>("customMapSuffix");
+ QTest::newRow("do-not-generate-linker-map") << false << "";
+ QTest::newRow("generate-default-linker-map") << true << "";
+ QTest::newRow("generate-custom-linker-map") << true << ".mmm";
}
void TestBlackboxBareMetal::linkerMapFile()
{
QFETCH(bool, generateMap);
+ QFETCH(QString, customMapSuffix);
QDir::setCurrent(testDataDir + "/linker-map");
rmDirR(relativeBuildDir());
- const QStringList args = {QStringLiteral("modules.cpp.generateLinkerMapFile:%1")
- .arg(generateMap ? "true" : "false")};
+ QStringList args = {QStringLiteral("modules.cpp.generateLinkerMapFile:%1")
+ .arg(generateMap ? "true" : "false")};
+ if (!customMapSuffix.isEmpty())
+ args << QStringLiteral("modules.cpp.linkerMapSuffix:%1").arg(customMapSuffix);
+
QCOMPARE(runQbs(QbsRunParameters("resolve", args)), 0);
- if (m_qbsStdout.contains("unsupported toolset:"))
- QSKIP(unsupportedToolsetMessage(m_qbsStdout));
- if (!m_qbsStdout.contains("current toolset:"))
- QFAIL("No current toolset pattern exists");
+ if (!m_qbsStdout.contains("linker map suffix:"))
+ QFAIL("No current linker map suffix pattern exists");
- QByteArray toolchain;
- QByteArray architecture;
- if (!extractToolset(m_qbsStdout, toolchain, architecture))
- QFAIL("Unable to extract current toolset");
+ QString linkerMapSuffix;
+ if (!extractQuitedValue(m_qbsStdout, linkerMapSuffix))
+ QFAIL("Unable to extract current linker map suffix");
+
+ if (!customMapSuffix.isEmpty())
+ QCOMPARE(linkerMapSuffix, customMapSuffix);
QCOMPARE(runQbs(QbsRunParameters(args)), 0);
const QString productBuildDir = relativeProductBuildDir("linker-map");
- const auto extension = linkerMapFileExtension(toolchain, architecture);
- const QString linkerMap = productBuildDir + "/linker-map" + extension;
+ const QString linkerMap = productBuildDir + "/linker-map" + linkerMapSuffix;
QCOMPARE(regularFileExists(linkerMap), generateMap);
}