summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-09-27 12:51:01 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-10-01 09:13:42 +0000
commit7822a01904d60a883cc089175d1ca5400663040c (patch)
tree7073bd2ca811bc93ecc2e27186ee46119bfe8e34
parent51d8271a301b5767f797e57e73ba425a64b3a359 (diff)
baremetal: Add missed output artifacts for SDCC compiler
Compiler produces a lot of additional ".adb", ".lst", ".asm", ".sym", ".rst", ".lk", ".mem" files. This files should be also processed in SDCC module (e.g. it allows to remove this files by 'clean' command). Change-Id: Ib07dbe63ab27e263d67025ce5cd40a967910d354 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--share/qbs/modules/cpp/sdcc.js89
-rw-r--r--share/qbs/modules/cpp/sdcc.qbs64
2 files changed, 92 insertions, 61 deletions
diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js
index c84ec0f5d..f8c0d3b12 100644
--- a/share/qbs/modules/cpp/sdcc.js
+++ b/share/qbs/modules/cpp/sdcc.js
@@ -33,6 +33,7 @@ var Environment = require("qbs.Environment");
var File = require("qbs.File");
var FileInfo = require("qbs.FileInfo");
var ModUtils = require("qbs.ModUtils");
+var PathTools = require("qbs.PathTools");
var Process = require("qbs.Process");
var TemporaryDir = require("qbs.TemporaryDir");
var TextFile = require("qbs.TextFile");
@@ -178,15 +179,87 @@ function collectLibraryDependencies(product) {
return result;
}
-function compilerFlags(project, product, input, output, explicitlyDependsOn) {
+function compilerOutputArtifacts(input) {
+ var obj = {
+ fileTags: ["obj"],
+ filePath: Utilities.getHash(input.baseDir) + "/"
+ + input.fileName + input.cpp.objectSuffix
+ };
+ var asm_adb = {
+ fileTags: ["asm_adb"],
+ filePath: Utilities.getHash(input.baseDir) + "/"
+ + input.fileName + ".adb"
+ };
+ var asm_lst = {
+ fileTags: ["asm_lst"],
+ filePath: Utilities.getHash(input.baseDir) + "/"
+ + input.fileName + ".lst"
+ };
+ var asm_src = {
+ fileTags: ["asm_src"],
+ filePath: Utilities.getHash(input.baseDir) + "/"
+ + input.fileName + ".asm"
+ };
+ var asm_sym = {
+ fileTags: ["asm_sym"],
+ filePath: Utilities.getHash(input.baseDir) + "/"
+ + input.fileName + ".sym"
+ };
+ var rst_data = {
+ fileTags: ["rst_data"],
+ filePath: Utilities.getHash(input.baseDir) + "/"
+ + input.fileName + ".rst"
+ };
+ return [obj, asm_adb, asm_lst, asm_src, asm_sym, rst_data];
+}
+
+function applicationLinkerOutputArtifacts(product) {
+ var app = {
+ fileTags: ["application"],
+ filePath: FileInfo.joinPaths(
+ product.destinationDirectory,
+ PathTools.applicationFilePath(product))
+ };
+ var lk_cmd = {
+ fileTags: ["lk_cmd"],
+ filePath: FileInfo.joinPaths(
+ product.destinationDirectory,
+ product.targetName + ".lk")
+ };
+ var mem_summary = {
+ fileTags: ["mem_summary"],
+ filePath: FileInfo.joinPaths(
+ product.destinationDirectory,
+ product.targetName + ".mem")
+ };
+ var mem_map = {
+ fileTags: ["mem_map"],
+ filePath: FileInfo.joinPaths(
+ product.destinationDirectory,
+ product.targetName + ".map")
+ };
+ return [app, lk_cmd, mem_summary, mem_map]
+}
+
+function staticLibraryLinkerOutputArtifacts(product) {
+ var staticLib = {
+ fileTags: ["staticlibrary"],
+ filePath: FileInfo.joinPaths(
+ product.destinationDirectory,
+ PathTools.staticLibraryFilePath(product))
+ };
+ return [staticLib]
+}
+
+function compilerFlags(project, product, input, outputs, explicitlyDependsOn) {
// Determine which C-language we"re compiling.
- var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags));
+ var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags));
var args = [];
args.push(input.filePath);
args.push("-c");
- args.push("-o", output.filePath);
+ args.push("-o", outputs.obj[0].filePath);
switch (input.cpp.optimization) {
case "small":
@@ -247,9 +320,9 @@ function compilerFlags(project, product, input, output, explicitlyDependsOn) {
return args;
}
-function assemblerFlags(project, product, input, output, explicitlyDependsOn) {
+function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) {
// Determine which C-language we"re compiling
- var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags));
+ var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags));
var args = [];
@@ -267,7 +340,7 @@ function assemblerFlags(project, product, input, output, explicitlyDependsOn) {
ModUtils.moduleProperty(input, "driverFlags", tag));
args.push("-ol");
- args.push(output.filePath);
+ args.push(outputs.obj[0].filePath);
args.push(input.filePath);
return args;
}
@@ -347,7 +420,7 @@ function archiverFlags(project, product, input, outputs) {
}
function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) {
- var args = compilerFlags(project, product, input, output, explicitlyDependsOn);
+ var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn);
var compilerPath = input.cpp.compilerPath;
var cmd = new Command(compilerPath, args)
cmd.description = "compiling " + input.fileName;
@@ -356,7 +429,7 @@ function prepareCompiler(project, product, inputs, outputs, input, output, expli
}
function prepareAssembler(project, product, inputs, outputs, input, output, explicitlyDependsOn) {
- var args = assemblerFlags(project, product, input, output, explicitlyDependsOn);
+ var args = assemblerFlags(project, product, input, outputs, explicitlyDependsOn);
var assemblerPath = input.cpp.assemblerPath;
var cmd = new Command(assemblerPath, args)
cmd.description = "assembling " + input.fileName;
diff --git a/share/qbs/modules/cpp/sdcc.qbs b/share/qbs/modules/cpp/sdcc.qbs
index a0d795b40..7b65ec609 100644
--- a/share/qbs/modules/cpp/sdcc.qbs
+++ b/share/qbs/modules/cpp/sdcc.qbs
@@ -32,9 +32,7 @@ import qbs 1.0
import qbs.File
import qbs.FileInfo
import qbs.ModUtils
-import qbs.PathTools
import qbs.Probes
-import qbs.Utilities
import "sdcc.js" as SDCC
CppModule {
@@ -117,13 +115,8 @@ CppModule {
Rule {
id: assembler
inputs: ["asm"]
-
- Artifact {
- fileTags: ["obj"]
- filePath: Utilities.getHash(input.baseDir) + "/"
- + input.fileName + input.cpp.objectSuffix
- }
-
+ outputFileTags: ["obj", "asm_adb", "asm_lst", "asm_src", "asm_sym", "rst_data"]
+ outputArtifacts: SDCC.compilerOutputArtifacts(input)
prepare: SDCC.prepareAssembler.apply(SDCC, arguments);
}
@@ -143,14 +136,9 @@ CppModule {
id: compiler
inputs: ["cpp", "c"]
auxiliaryInputs: ["hpp"]
-
- Artifact {
- fileTags: ["obj"]
- filePath: Utilities.getHash(input.baseDir) + "/"
- + input.fileName + input.cpp.objectSuffix
- }
-
- prepare: SDCC.prepareCompiler.apply(SDCC, arguments);
+ outputFileTags: ["obj", "asm_adb", "asm_lst", "asm_src", "asm_sym", "rst_data"]
+ outputArtifacts: SDCC.compilerOutputArtifacts(input)
+ prepare: SDCC.prepareCompiler.apply(SDCC, arguments)
}
Rule {
@@ -158,33 +146,9 @@ CppModule {
multiplex: true
inputs: ["obj", "linkerscript"]
inputsFromDependencies: ["staticlibrary"]
-
- outputFileTags: {
- var tags = ["application"];
- if (product.moduleProperty("cpp", "generateMapFile"))
- tags.push("map_file");
- return tags;
- }
- outputArtifacts: {
- var app = {
- fileTags: ["application"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- PathTools.applicationFilePath(product))
- };
- var artifacts = [app];
- if (product.cpp.generateMapFile) {
- artifacts.push({
- fileTags: ["map_file"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- product.targetName + ".map")
- });
- }
- return artifacts;
- }
-
- prepare:SDCC.prepareLinker.apply(SDCC, arguments);
+ outputFileTags: ["application", "lk_cmd", "mem_summary", "mem_map"]
+ outputArtifacts: SDCC.applicationLinkerOutputArtifacts(product)
+ prepare:SDCC.prepareLinker.apply(SDCC, arguments)
}
Rule {
@@ -192,14 +156,8 @@ CppModule {
multiplex: true
inputs: ["obj"]
inputsFromDependencies: ["staticlibrary"]
-
- Artifact {
- fileTags: ["staticlibrary"]
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- PathTools.staticLibraryFilePath(product))
- }
-
- prepare: SDCC.prepareArchiver.apply(SDCC, arguments);
+ outputFileTags: ["staticlibrary"]
+ outputArtifacts: SDCC.staticLibraryLinkerOutputArtifacts(product)
+ prepare: SDCC.prepareArchiver.apply(SDCC, arguments)
}
}