summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2020-08-12 13:12:39 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2020-08-13 06:50:08 +0000
commit755e979d94eaa9fd521def369ebda5d271b335ca (patch)
treea519ff5319dcd85a79e894bf79764bbc4fa29c6c
parenta499c21c032b3b1e839cea1511a39fe4736213c0 (diff)
downloadqbs-755e979d94eaa9fd521def369ebda5d271b335ca.tar.gz
baremetal: Pass 'compiler-listing-files' test for SDCC toolchain
A problem was in that the SDCC compiler does not have an option to disable generation for listing files. Besides, it use listing files for a linking. So, we need to use a workaround to remove the generated listing files after linking in case if the cpp.generateCompilerListingFiles property is false. Change-Id: I5913e62d307d296bd8891654d20787cf3a54833c Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
-rw-r--r--share/qbs/modules/cpp/sdcc.js46
-rw-r--r--share/qbs/modules/cpp/sdcc.qbs5
-rw-r--r--tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs2
-rw-r--r--tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs2
4 files changed, 44 insertions, 11 deletions
diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js
index 4cd1ee465..2c745e653 100644
--- a/share/qbs/modules/cpp/sdcc.js
+++ b/share/qbs/modules/cpp/sdcc.js
@@ -238,14 +238,14 @@ function collectLibraryDependencies(product) {
return result;
}
-function compilerOutputArtifacts(input) {
+function compilerOutputArtifacts(input, useListing) {
var obj = {
fileTags: ["obj"],
filePath: Utilities.getHash(input.baseDir) + "/"
+ input.fileName + input.cpp.objectSuffix
};
- // We need to use the asm_adb, lst, asm_src, asm_sym and rst_data
+ // We need to use the asm_adb, asm_src, asm_sym and rst_data
// artifacts without of any conditions. Because SDCC always generates
// it (and seems, this behavior can not be disabled for SDCC).
var asm_adb = {
@@ -253,11 +253,6 @@ function compilerOutputArtifacts(input) {
filePath: Utilities.getHash(input.baseDir) + "/"
+ input.fileName + ".adb"
};
- var lst = {
- fileTags: ["lst"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + input.fileName + ".lst"
- };
var asm_src = {
fileTags: ["asm_src"],
filePath: Utilities.getHash(input.baseDir) + "/"
@@ -273,7 +268,15 @@ function compilerOutputArtifacts(input) {
filePath: Utilities.getHash(input.baseDir) + "/"
+ input.fileName + ".rst"
};
- return [obj, asm_adb, lst, asm_src, asm_sym, rst_data];
+ var artifacts = [obj, asm_adb, asm_src, asm_sym, rst_data];
+ if (useListing) {
+ artifacts.push({
+ fileTags: ["lst"],
+ filePath: Utilities.getHash(input.baseDir) + "/"
+ + input.fileName + ".lst"
+ });
+ }
+ return artifacts;
}
function applicationLinkerOutputArtifacts(product) {
@@ -584,13 +587,38 @@ function prepareAssembler(project, product, inputs, outputs, input, output, expl
}
function prepareLinker(project, product, inputs, outputs, input, output) {
+ var cmds = [];
var primaryOutput = outputs.application[0];
var args = linkerFlags(project, product, inputs, outputs);
var linkerPath = effectiveLinkerPath(product);
var cmd = new Command(linkerPath, args);
cmd.description = "linking " + primaryOutput.fileName;
cmd.highlight = "linker";
- return [cmd];
+ cmds.push(cmd);
+
+ // It is a workaround which removes the generated listing files
+ // if it is disabled by cpp.generateCompilerListingFiles property.
+ // Reason is that the SDCC compiler does not have an option to
+ // disable generation for a listing files. Besides, the SDCC
+ // compiler use this files and for the linking. So, we can to
+ // remove a listing files only after the linking completes.
+ if (!product.cpp.generateCompilerListingFiles) {
+ cmd = new JavaScriptCommand();
+ cmd.objectPaths = inputs.obj.map(function(a) { return a.filePath; });
+ cmd.objectSuffix = product.cpp.objectSuffix;
+ cmd.sourceCode = function() {
+ objectPaths.forEach(function(objectPath) {
+ if (!objectPath.endsWith(".c" + objectSuffix))
+ continue; // Skip the assembler objects.
+ var listingPath = FileInfo.joinPaths(
+ FileInfo.path(objectPath),
+ FileInfo.completeBaseName(objectPath) + ".lst");
+ File.remove(listingPath);
+ });
+ };
+ cmds.push(cmd);
+ }
+ return cmds;
}
function prepareArchiver(project, product, inputs, outputs, input, output) {
diff --git a/share/qbs/modules/cpp/sdcc.qbs b/share/qbs/modules/cpp/sdcc.qbs
index 793882543..3c5be7cdd 100644
--- a/share/qbs/modules/cpp/sdcc.qbs
+++ b/share/qbs/modules/cpp/sdcc.qbs
@@ -101,7 +101,7 @@ CppModule {
id: assembler
inputs: ["asm"]
outputFileTags: ["obj", "asm_adb", "lst", "asm_src", "asm_sym", "rst_data"]
- outputArtifacts: SDCC.compilerOutputArtifacts(input)
+ outputArtifacts: SDCC.compilerOutputArtifacts(input, true)
prepare: SDCC.prepareAssembler.apply(SDCC, arguments)
}
@@ -115,7 +115,8 @@ CppModule {
inputs: ["cpp", "c"]
auxiliaryInputs: ["hpp"]
outputFileTags: ["obj", "asm_adb", "lst", "asm_src", "asm_sym", "rst_data"]
- outputArtifacts: SDCC.compilerOutputArtifacts(input)
+ outputArtifacts: SDCC.compilerOutputArtifacts(
+ input, input.cpp.generateCompilerListingFiles)
prepare: SDCC.prepareCompiler.apply(SDCC, arguments)
}
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 dc35ac2b8..8ae4fc065 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,6 +2,8 @@ import "../BareMetalApplication.qbs" as BareMetalApplication
BareMetalApplication {
condition: {
+ if (qbs.toolchainType === "sdcc")
+ return true;
if (qbs.toolchainType === "msvc")
return true;
if (qbs.toolchainType === "clang-cl")
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 ceb7d310e..741a21953 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,6 +2,8 @@ import "../BareMetalApplication.qbs" as BareMetalApplication
BareMetalApplication {
condition: {
+ if (qbs.toolchainType === "sdcc")
+ return true;
if (qbs.toolchainType === "msvc")
return true;
if (qbs.toolchainType === "clang-cl")