aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2021-04-07 20:11:29 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2021-04-08 12:18:26 +0000
commit4b5680cc16f5a190b98b7c0ed42bc43f8e9438b7 (patch)
treefa02844b43cd0a49203adf7a98660426e3a66bb1
parentd8cd1d151528da700ef0789c77e2f3dfdd5e17bb (diff)
baremetal: Fix generation compiler listing using ARMCC compiler
The ARMCC compiler has no options for specifying the name of the output listing file; it only has an options for specifying an output directory. In addition, the generated listing files are in truncated format, e.g. instead of the 'module.{c|cpp}.lst' file will be generated the 'module.lst' file. This behavior complicates the writing of unit tests, and also complicates the implementation if the user wants to change the cpp.compilerListingSuffix property. A workaround is to post-process the compiler listing files after they are generated. In this case, we only need to rename the generated compiler listing file to the desired one. Change-Id: I89c81896711b90b146a94c35d2ec75e296824752 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
-rw-r--r--share/qbs/modules/cpp/keil.js56
-rw-r--r--tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs2
-rw-r--r--tests/auto/blackbox/tst_blackboxbaremetal.cpp8
3 files changed, 43 insertions, 23 deletions
diff --git a/share/qbs/modules/cpp/keil.js b/share/qbs/modules/cpp/keil.js
index 2b35007b3..27e4e12d7 100644
--- a/share/qbs/modules/cpp/keil.js
+++ b/share/qbs/modules/cpp/keil.js
@@ -593,15 +593,13 @@ function compilerOutputArtifacts(input, isCompilerArtifacts) {
artifacts.push({
fileTags: ["lst"],
filePath: Utilities.getHash(input.baseDir) + "/"
- + (isArmCCCompiler(input.cpp.compilerPath) ? input.baseName : input.fileName)
- + input.cpp.compilerListingSuffix
+ + input.fileName + input.cpp.compilerListingSuffix
});
} else if (!isCompilerArtifacts && input.cpp.generateAssemblerListingFiles) {
artifacts.push({
fileTags: ["lst"],
filePath: Utilities.getHash(input.baseDir) + "/"
- + (isArmCCCompiler(input.cpp.compilerPath) ? input.baseName : input.fileName)
- + input.cpp.assemblerListingSuffix
+ + input.fileName + input.cpp.assemblerListingSuffix
});
}
return artifacts;
@@ -1102,6 +1100,38 @@ function archiverFlags(project, product, inputs, outputs) {
return args;
}
+// The ARMCLANG compiler does not support generation
+// for the listing files:
+// * https://www.keil.com/support/docs/4152.htm
+// So, we generate the listing files from the object files
+// using the disassembler.
+function generateClangCompilerListing(project, product, inputs, outputs, input, output) {
+ if (isArmClangCompiler(input.cpp.compilerPath) && input.cpp.generateCompilerListingFiles) {
+ var args = disassemblerFlags(project, product, input, outputs, explicitlyDependsOn);
+ var disassemblerPath = input.cpp.disassemblerPath;
+ var cmd = new Command(disassemblerPath, args);
+ cmd.silent = true;
+ return cmd;
+ }
+}
+
+// The ARMCC compiler generates the listing files only in a short form,
+// e.g. to 'module.lst' instead of 'module.{c|cpp}.lst', that complicates
+// the auto-tests. Therefore we need to rename generated listing files
+// with correct unified names.
+function generateArmccCompilerListing(project, product, inputs, outputs, input, output) {
+ if (isArmCCCompiler(input.cpp.compilerPath) && input.cpp.generateCompilerListingFiles) {
+ var listingPath = FileInfo.path(outputs.lst[0].filePath);
+ var cmd = new JavaScriptCommand();
+ cmd.oldListing = FileInfo.joinPaths(listingPath, input.baseName + ".lst");
+ cmd.newListing = FileInfo.joinPaths(
+ listingPath, input.fileName + input.cpp.compilerListingSuffix);
+ cmd.silent = true;
+ cmd.sourceCode = function() { File.move(oldListing, newListing); };
+ return cmd;
+ }
+}
+
function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) {
var cmds = [];
var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn);
@@ -1119,18 +1149,14 @@ function prepareCompiler(project, product, inputs, outputs, input, output, expli
}
cmds.push(cmd);
- // The ARMCLANG compiler does not support generation
- // for the listing files:
- // * https://www.keil.com/support/docs/4152.htm
- // So, we generate the listing files from the object files
- // using the disassembler.
- if (isArmClangCompiler(compilerPath) && input.cpp.generateCompilerListingFiles) {
- args = disassemblerFlags(project, product, input, outputs, explicitlyDependsOn);
- var disassemblerPath = input.cpp.disassemblerPath;
- cmd = new Command(disassemblerPath, args);
- cmd.silent = true;
+ cmd = generateClangCompilerListing(project, product, inputs, outputs, input, output);
+ if (cmd)
cmds.push(cmd);
- }
+
+ cmd = generateArmccCompilerListing(project, product, inputs, outputs, input, output);
+ if (cmd)
+ cmds.push(cmd);
+
return cmds;
}
diff --git a/tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs b/tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs
index 0adfbe37b..bcf983c88 100644
--- a/tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs
+++ b/tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs
@@ -3,8 +3,6 @@ import "../BareMetalApplication.qbs" as BareMetalApplication
BareMetalApplication {
condition: {
if (!qbs.toolchain.contains("gcc")) {
- if (cpp.compilerName.startsWith("armcc"))
- console.info("using short listing file names");
console.info("compiler listing suffix: %%" + cpp.compilerListingSuffix + "%%");
return true;
}
diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
index b027a4e70..467c95122 100644
--- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp
+++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
@@ -210,18 +210,14 @@ void TestBlackboxBareMetal::compilerListingFiles()
if (!extractQuitedValue(m_qbsStdout, compilerListingSuffix))
QFAIL("Unable to extract current compiler listing suffix");
- const bool isShortListingNames = m_qbsStdout.contains("using short listing file names");
-
QCOMPARE(runQbs(QbsRunParameters(args)), 0);
const QString productBuildDir = relativeProductBuildDir("compiler-listing");
const QString hash = inputDirHash(".");
const QString mainListing = productBuildDir + "/" + hash
- + (isShortListingNames ? "/main" : "/main.c")
- + compilerListingSuffix;
+ + "/main.c" + compilerListingSuffix;
QCOMPARE(regularFileExists(mainListing), generateListing);
const QString funListing = productBuildDir + "/" + hash
- + (isShortListingNames ? "/fun" : "/fun.c")
- + compilerListingSuffix;
+ + "/fun.c" + compilerListingSuffix;
QCOMPARE(regularFileExists(funListing), generateListing);
}