diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2020-09-22 18:33:59 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2020-09-23 19:00:07 +0000 |
commit | 12d227409e1143b55bc1e49bfaef402fb641cd56 (patch) | |
tree | c8127cfa9317ba37f23d16b7c30e0dd11e7ffdde | |
parent | 36b345c8cdd6a3c471a871ef184936b56674e696 (diff) |
baremetal: Implement cpp.generateCompilerListingFiles for ARMCLANG
The ARMCLANG compiler does not support generating of
the listing files. Instead, it is recommended to use
the disassembler:
* https://www.keil.com/support/docs/4152.htm
Take a note that the disassembler does not work with
the evaluation license!
Change-Id: If8b45e40523015d27e4439cf00028815211338ed
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
4 files changed, 38 insertions, 38 deletions
diff --git a/share/qbs/modules/cpp/keil.js b/share/qbs/modules/cpp/keil.js index 78b783e32..07d844018 100644 --- a/share/qbs/modules/cpp/keil.js +++ b/share/qbs/modules/cpp/keil.js @@ -133,6 +133,11 @@ function archiverName(qbs) { + architecture + "'"; } +function disassemblerName(qbs) { + var architecture = qbs.architecture; + return isArmArchitecture(architecture) ? "fromelf" : undefined; +} + function staticLibrarySuffix(qbs) { var architecture = qbs.architecture; if (isMcsArchitecture(architecture) || isC166Architecture(architecture) @@ -638,9 +643,7 @@ function compilerOutputArtifacts(input, useListing) { artifacts.push({ fileTags: ["lst"], filePath: Utilities.getHash(input.baseDir) + "/" - + ((isMcsArchitecture(input.cpp.architecture) - || isC166Architecture(input.cpp.architecture)) - ? input.fileName : input.baseName) + + (isArmCCCompiler(input.cpp.compilerPath) ? input.baseName : input.fileName) + ".lst" }); } @@ -1011,6 +1014,13 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { return args; } +function disassemblerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = ["--disassemble", "--interleave=source"]; + args.push(outputs.obj[0].filePath); + args.push("--output=" + outputs.lst[0].filePath); + return args; +} + function linkerFlags(project, product, inputs, outputs) { var args = []; @@ -1133,6 +1143,7 @@ function archiverFlags(project, product, inputs, outputs) { } function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn); var compilerPath = input.cpp.compilerPath; var architecture = input.cpp.architecture; @@ -1146,7 +1157,21 @@ function prepareCompiler(project, product, inputs, outputs, input, output, expli cmd.maxExitCode = 1; cmd.stdoutFilterFunction = filterC166Output; } - return [cmd]; + 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; + cmds.push(cmd); + } + return cmds; } function prepareAssembler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { diff --git a/share/qbs/modules/cpp/keil.qbs b/share/qbs/modules/cpp/keil.qbs index 7a994d7ea..eba52adff 100644 --- a/share/qbs/modules/cpp/keil.qbs +++ b/share/qbs/modules/cpp/keil.qbs @@ -83,6 +83,9 @@ CppModule { property string archiverName: KEIL.archiverName(qbs) + compilerExtension property string archiverPath: FileInfo.joinPaths(toolchainInstallPath, archiverName) + property string disassemblerName: KEIL.disassemblerName(qbs) + compilerExtension + property string disassemblerPath: FileInfo.joinPaths(toolchainInstallPath, disassemblerName) + runtimeLibrary: "static" staticLibrarySuffix: KEIL.staticLibrarySuffix(qbs) diff --git a/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs index 46faf9440..1bc4ba208 100644 --- a/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs +++ b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs @@ -2,24 +2,10 @@ import "../BareMetalApplication.qbs" as BareMetalApplication BareMetalApplication { condition: { - if (qbs.toolchainType === "sdcc") - return true; - if (qbs.toolchainType === "msvc") - return true; - if (qbs.toolchainType === "clang-cl") - return true; - if (qbs.toolchainType === "iar") - return true; - if (qbs.toolchainType === "keil") { - if (qbs.architecture === "mcs51" - || qbs.architecture === "mcs251" - || qbs.architecture === "c166") { - return true; - } - if (cpp.compilerName.startsWith("armcc")) { + if (!qbs.toolchain.contains("gcc")) { + if (cpp.compilerName.startsWith("armcc")) console.info("using short listing file names"); - return true; - } + return true; } console.info("unsupported toolset: %%" + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); diff --git a/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs index 2596b441d..a6731d224 100644 --- a/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs +++ b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs @@ -2,24 +2,10 @@ import "../BareMetalApplication.qbs" as BareMetalApplication BareMetalApplication { condition: { - if (qbs.toolchainType === "sdcc") - return true; - if (qbs.toolchainType === "msvc") - return true; - if (qbs.toolchainType === "clang-cl") - return true; - if (qbs.toolchainType === "iar") - return true; - if (qbs.toolchainType === "keil") { - if (qbs.architecture === "mcs51" - || qbs.architecture === "mcs251" - || qbs.architecture === "c166") { - return true; - } - if (cpp.compilerName.startsWith("armcc")) { + if (!qbs.toolchain.contains("gcc")) { + if (cpp.compilerName.startsWith("armcc")) console.info("using short listing file names"); - return true; - } + return true; } console.info("unsupported toolset: %%" + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); |