From 44ef034472337abdb894f76f593da6648f9782d5 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Mon, 5 Apr 2021 12:14:34 +0300 Subject: Share cpp::{assembler|compiler}ListingSuffix properties It makes sense to add the cpp.assemblerListingSuffix and the cpp.compilerListingSuffix properties to the base CppModule due the following reasons: 1. It is possible that the user wants to change the extension for the generated listing files, which makes working with Qbs more flexible. 2. It will be easier to write an autotests that check the generation of the listing files for a bare metal platforms, where listing files can have various extensions such as ".lst", ".ls", and so forth. Change-Id: I9989288bff0659dd3e8b7a443d0354bb78475270 Reviewed-by: Ivan Komissarov --- doc/reference/modules/cpp-module.qdoc | 16 ++++++++++++++++ share/qbs/modules/cpp/CppModule.qbs | 2 ++ share/qbs/modules/cpp/iar.js | 12 +++++++++--- share/qbs/modules/cpp/iar.qbs | 6 ++---- share/qbs/modules/cpp/keil.js | 13 ++++++++++--- share/qbs/modules/cpp/keil.qbs | 6 ++---- share/qbs/modules/cpp/sdcc.js | 15 +++++++++++---- share/qbs/modules/cpp/sdcc.qbs | 5 ++--- share/qbs/modules/cpp/windows-msvc-base.qbs | 3 ++- 9 files changed, 56 insertions(+), 22 deletions(-) diff --git a/doc/reference/modules/cpp-module.qdoc b/doc/reference/modules/cpp-module.qdoc index 1b09320f0..56f41af5d 100644 --- a/doc/reference/modules/cpp-module.qdoc +++ b/doc/reference/modules/cpp-module.qdoc @@ -633,6 +633,22 @@ \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical value is \c ".map" */ +/*! + \qmlproperty string cpp::compilerListingSuffix + + A string to append to the generated compiler listing files. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical value is \c ".lst" +*/ + +/*! + \qmlproperty string cpp::assemblerListingSuffix + + A string to append to the generated assembler listing files. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical value is \c ".lst" +*/ + /*! \qmlproperty pathList cpp::prefixHeaders \since Qbs 1.0.1 diff --git a/share/qbs/modules/cpp/CppModule.qbs b/share/qbs/modules/cpp/CppModule.qbs index 761e8be85..39077bec8 100644 --- a/share/qbs/modules/cpp/CppModule.qbs +++ b/share/qbs/modules/cpp/CppModule.qbs @@ -188,6 +188,8 @@ Module { property string dynamicLibraryImportSuffix: ".lib" property string objectSuffix: ".o" property string linkerMapSuffix: ".map" + property string compilerListingSuffix: ".lst" + property string assemblerListingSuffix: ".lst" property bool createSymlinks: true property stringList dynamicLibraries // list of names, will be linked with -lname property stringList staticLibraries // list of static library files diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js index a1f1a9a88..416de7ee2 100644 --- a/share/qbs/modules/cpp/iar.js +++ b/share/qbs/modules/cpp/iar.js @@ -612,18 +612,24 @@ function collectLibraryDependencies(product) { return result; } -function compilerOutputArtifacts(input, useListing) { +function compilerOutputArtifacts(input, isCompilerArtifacts) { var artifacts = []; artifacts.push({ fileTags: ["obj"], filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + input.cpp.objectSuffix }); - if (useListing) { + if (isCompilerArtifacts && input.cpp.generateCompilerListingFiles) { artifacts.push({ fileTags: ["lst"], filePath: Utilities.getHash(input.baseDir) + "/" - + input.fileName + ".lst" + + input.fileName + input.cpp.compilerListingSuffix + }); + } else if (!isCompilerArtifacts && input.cpp.generateAssemblerListingFiles) { + artifacts.push({ + fileTags: ["lst"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + input.cpp.assemblerListingSuffix }); } return artifacts; diff --git a/share/qbs/modules/cpp/iar.qbs b/share/qbs/modules/cpp/iar.qbs index 6c00f8f36..9709695c1 100644 --- a/share/qbs/modules/cpp/iar.qbs +++ b/share/qbs/modules/cpp/iar.qbs @@ -99,8 +99,7 @@ CppModule { id: assembler inputs: ["asm"] outputFileTags: ["obj", "lst"] - outputArtifacts: IAR.compilerOutputArtifacts( - input, input.cpp.generateAssemblerListingFiles) + outputArtifacts: IAR.compilerOutputArtifacts(input, false) prepare: IAR.prepareAssembler.apply(IAR, arguments) } @@ -114,8 +113,7 @@ CppModule { inputs: ["cpp", "c"] auxiliaryInputs: ["hpp"] outputFileTags: ["obj", "lst"] - outputArtifacts: IAR.compilerOutputArtifacts( - input, input.cpp.generateCompilerListingFiles) + outputArtifacts: IAR.compilerOutputArtifacts(input, true) prepare: IAR.prepareCompiler.apply(IAR, arguments) } diff --git a/share/qbs/modules/cpp/keil.js b/share/qbs/modules/cpp/keil.js index 372b08e4b..2b35007b3 100644 --- a/share/qbs/modules/cpp/keil.js +++ b/share/qbs/modules/cpp/keil.js @@ -582,19 +582,26 @@ function filterC166Output(output) { return filteredLines.join('\n'); }; -function compilerOutputArtifacts(input, useListing) { +function compilerOutputArtifacts(input, isCompilerArtifacts) { var artifacts = []; artifacts.push({ fileTags: ["obj"], filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + input.cpp.objectSuffix }); - if (useListing) { + if (isCompilerArtifacts && input.cpp.generateCompilerListingFiles) { artifacts.push({ fileTags: ["lst"], filePath: Utilities.getHash(input.baseDir) + "/" + (isArmCCCompiler(input.cpp.compilerPath) ? input.baseName : input.fileName) - + ".lst" + + 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 }); } return artifacts; diff --git a/share/qbs/modules/cpp/keil.qbs b/share/qbs/modules/cpp/keil.qbs index f1f3b50e8..ea99b589c 100644 --- a/share/qbs/modules/cpp/keil.qbs +++ b/share/qbs/modules/cpp/keil.qbs @@ -103,8 +103,7 @@ CppModule { id: assembler inputs: ["asm"] outputFileTags: ["obj", "lst"] - outputArtifacts: KEIL.compilerOutputArtifacts( - input, input.cpp.generateAssemblerListingFiles) + outputArtifacts: KEIL.compilerOutputArtifacts(input, false) prepare: KEIL.prepareAssembler.apply(KEIL, arguments) } @@ -118,8 +117,7 @@ CppModule { inputs: ["cpp", "c"] auxiliaryInputs: ["hpp"] outputFileTags: ["obj", "lst"] - outputArtifacts: KEIL.compilerOutputArtifacts( - input, input.cpp.generateCompilerListingFiles) + outputArtifacts: KEIL.compilerOutputArtifacts(input, true) prepare: KEIL.prepareCompiler.apply(KEIL, arguments) } diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js index 4010e38db..ca085a421 100644 --- a/share/qbs/modules/cpp/sdcc.js +++ b/share/qbs/modules/cpp/sdcc.js @@ -239,7 +239,7 @@ function collectLibraryDependencies(product) { return result; } -function compilerOutputArtifacts(input, useListing) { +function compilerOutputArtifacts(input, isCompilerArtifacts) { var obj = { fileTags: ["obj"], filePath: Utilities.getHash(input.baseDir) + "/" @@ -270,11 +270,17 @@ function compilerOutputArtifacts(input, useListing) { + input.fileName + ".rst" }; var artifacts = [obj, asm_adb, asm_src, asm_sym, rst_data]; - if (useListing) { + if (isCompilerArtifacts && input.cpp.generateCompilerListingFiles) { artifacts.push({ fileTags: ["lst"], filePath: Utilities.getHash(input.baseDir) + "/" - + input.fileName + ".lst" + + input.fileName + input.cpp.compilerListingSuffix + }); + } else if (!isCompilerArtifacts && input.cpp.generateAssemblerListingFiles) { + artifacts.push({ + fileTags: ["lst"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + input.cpp.assemblerListingSuffix }); } return artifacts; @@ -628,6 +634,7 @@ function prepareLinker(project, product, inputs, outputs, input, output) { cmd = new JavaScriptCommand(); cmd.objectPaths = inputs.obj.map(function(a) { return a.filePath; }); cmd.objectSuffix = product.cpp.objectSuffix; + cmd.listingSuffix = product.cpp.compilerListingSuffix cmd.silent = true; cmd.sourceCode = function() { objectPaths.forEach(function(objectPath) { @@ -635,7 +642,7 @@ function prepareLinker(project, product, inputs, outputs, input, output) { return; // Skip the assembler objects. var listingPath = FileInfo.joinPaths( FileInfo.path(objectPath), - FileInfo.completeBaseName(objectPath) + ".lst"); + FileInfo.completeBaseName(objectPath) + listingSuffix); File.remove(listingPath); }); }; diff --git a/share/qbs/modules/cpp/sdcc.qbs b/share/qbs/modules/cpp/sdcc.qbs index 8b631d4e5..c5a0893d4 100644 --- a/share/qbs/modules/cpp/sdcc.qbs +++ b/share/qbs/modules/cpp/sdcc.qbs @@ -100,7 +100,7 @@ CppModule { id: assembler inputs: ["asm"] outputFileTags: ["obj", "asm_adb", "lst", "asm_src", "asm_sym", "rst_data"] - outputArtifacts: SDCC.compilerOutputArtifacts(input, true) + outputArtifacts: SDCC.compilerOutputArtifacts(input, false) prepare: SDCC.prepareAssembler.apply(SDCC, arguments) } @@ -114,8 +114,7 @@ CppModule { inputs: ["cpp", "c"] auxiliaryInputs: ["hpp"] outputFileTags: ["obj", "asm_adb", "lst", "asm_src", "asm_sym", "rst_data"] - outputArtifacts: SDCC.compilerOutputArtifacts( - input, input.cpp.generateCompilerListingFiles) + outputArtifacts: SDCC.compilerOutputArtifacts(input, true) prepare: SDCC.prepareCompiler.apply(SDCC, arguments) } diff --git a/share/qbs/modules/cpp/windows-msvc-base.qbs b/share/qbs/modules/cpp/windows-msvc-base.qbs index b25fdf159..f5fde9556 100644 --- a/share/qbs/modules/cpp/windows-msvc-base.qbs +++ b/share/qbs/modules/cpp/windows-msvc-base.qbs @@ -162,7 +162,8 @@ CppModule { if (input.cpp.generateCompilerListingFiles) { artifacts.push({ fileTags: ["lst"], - filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + ".lst" + filePath: Utilities.getHash(input.baseDir) + + "/" + input.fileName + input.cpp.compilerListingSuffix }); } return artifacts; -- cgit v1.2.3