diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2021-04-07 20:11:29 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2021-04-08 12:18:26 +0000 |
commit | 4b5680cc16f5a190b98b7c0ed42bc43f8e9438b7 (patch) | |
tree | fa02844b43cd0a49203adf7a98660426e3a66bb1 /share/qbs/modules/cpp/keil.js | |
parent | d8cd1d151528da700ef0789c77e2f3dfdd5e17bb (diff) | |
download | qbs-4b5680cc16f5a190b98b7c0ed42bc43f8e9438b7.tar.gz |
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>
Diffstat (limited to 'share/qbs/modules/cpp/keil.js')
-rw-r--r-- | share/qbs/modules/cpp/keil.js | 56 |
1 files changed, 41 insertions, 15 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; } |