aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2021-05-06 15:27:32 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2021-05-14 11:20:45 +0000
commit79b9b022ceac0b66cdc4e3a4400926b76be3f41d (patch)
tree0f154038d4333cbf047563ae594194c983d73251 /share
parent05d16754fe403af343e256c032d83970420b058b (diff)
baremetal: Share generation of generic lists of tags and artifacts
It makes sense to put in separate functions the repeating code for generating a list of tags and artifacts for compilation and linking. The generic code has been moved into the ModUtils module, which simplifies maintenance and minimizes copy-paste errors. Change-Id: I28b8e5467cf6a6764cbe7b1b7b68797b1d6ec1f4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qbs/imports/qbs/ModUtils/utils.js125
-rw-r--r--share/qbs/modules/cpp/iar.js122
-rw-r--r--share/qbs/modules/cpp/iar.qbs16
-rw-r--r--share/qbs/modules/cpp/keil.js124
-rw-r--r--share/qbs/modules/cpp/keil.qbs16
-rw-r--r--share/qbs/modules/cpp/sdcc.js149
-rw-r--r--share/qbs/modules/cpp/sdcc.qbs22
7 files changed, 179 insertions, 395 deletions
diff --git a/share/qbs/imports/qbs/ModUtils/utils.js b/share/qbs/imports/qbs/ModUtils/utils.js
index 0433fa46e..6e5a68178 100644
--- a/share/qbs/imports/qbs/ModUtils/utils.js
+++ b/share/qbs/imports/qbs/ModUtils/utils.js
@@ -31,6 +31,7 @@
var Environment = require("qbs.Environment");
var File = require("qbs.File");
var FileInfo = require("qbs.FileInfo");
+var PathTools = require("qbs.PathTools");
var Process = require("qbs.Process");
var TemporaryDir = require("qbs.TemporaryDir");
var TextFile = require("qbs.TextFile");
@@ -649,3 +650,127 @@ function extractMacros(output) {
});
return m;
}
+
+function compilerOutputTags(needsListingFiles) {
+ var tags = ["obj"];
+ if (needsListingFiles)
+ tags.push("lst");
+ return tags;
+}
+
+function applicationLinkerOutputTags(needsLinkerMapFile) {
+ var tags = ["application"];
+ if (needsLinkerMapFile)
+ tags.push("mem_map");
+ return tags;
+}
+
+function staticLibraryLinkerOutputTags() {
+ return ["staticlibrary"];
+}
+
+function compilerOutputArtifacts(input, isCompilerArtifacts) {
+ var artifacts = [];
+ artifacts.push({
+ fileTags: ["obj"],
+ filePath: Utilities.getHash(input.baseDir) + "/"
+ + input.fileName + input.cpp.objectSuffix
+ });
+ if (isCompilerArtifacts && input.cpp.generateCompilerListingFiles) {
+ artifacts.push({
+ fileTags: ["lst"],
+ filePath: Utilities.getHash(input.baseDir) + "/"
+ + 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;
+}
+
+function applicationLinkerOutputArtifacts(product) {
+ var artifacts = [{
+ fileTags: ["application"],
+ filePath: FileInfo.joinPaths(
+ product.destinationDirectory,
+ PathTools.applicationFilePath(product))
+ }];
+ if (product.cpp.generateLinkerMapFile) {
+ artifacts.push({
+ fileTags: ["mem_map"],
+ filePath: FileInfo.joinPaths(
+ product.destinationDirectory,
+ product.targetName + product.cpp.linkerMapSuffix)
+ });
+ }
+ return artifacts;
+}
+
+function staticLibraryLinkerOutputArtifacts(product) {
+ var staticLib = {
+ fileTags: ["staticlibrary"],
+ filePath: FileInfo.joinPaths(
+ product.destinationDirectory,
+ PathTools.staticLibraryFilePath(product))
+ };
+ return [staticLib]
+}
+
+function collectLibraryDependencies(product) {
+ var seen = {};
+ var result = [];
+
+ function addFilePath(filePath) {
+ result.push({ filePath: filePath });
+ }
+
+ function addArtifactFilePaths(dep, artifacts) {
+ if (!artifacts)
+ return;
+ var artifactFilePaths = artifacts.map(function(a) { return a.filePath; });
+ artifactFilePaths.forEach(addFilePath);
+ }
+
+ function addExternalStaticLibs(obj) {
+ if (!obj.cpp)
+ return;
+ function ensureArray(a) {
+ return (a instanceof Array) ? a : [];
+ }
+ function sanitizedModuleListProperty(obj, moduleName, propertyName) {
+ return ensureArray(ModUtils.sanitizedModuleProperty(obj, moduleName, propertyName));
+ }
+ var externalLibs = [].concat(
+ sanitizedModuleListProperty(obj, "cpp", "staticLibraries"));
+ var staticLibrarySuffix = obj.moduleProperty("cpp", "staticLibrarySuffix");
+ externalLibs.forEach(function(staticLibraryName) {
+ if (!staticLibraryName.endsWith(staticLibrarySuffix))
+ staticLibraryName += staticLibrarySuffix;
+ addFilePath(staticLibraryName);
+ });
+ }
+
+ function traverse(dep) {
+ if (seen.hasOwnProperty(dep.name))
+ return;
+ seen[dep.name] = true;
+
+ if (dep.parameters.cpp && dep.parameters.cpp.link === false)
+ return;
+
+ var staticLibraryArtifacts = dep.artifacts["staticlibrary"];
+ if (staticLibraryArtifacts) {
+ dep.dependencies.forEach(traverse);
+ addArtifactFilePaths(dep, staticLibraryArtifacts);
+ addExternalStaticLibs(dep);
+ }
+ }
+
+ product.dependencies.forEach(traverse);
+ addExternalStaticLibs(product);
+ return result;
+}
diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js
index 47158a209..ad971ed6c 100644
--- a/share/qbs/modules/cpp/iar.js
+++ b/share/qbs/modules/cpp/iar.js
@@ -557,126 +557,6 @@ function dumpDefaultPaths(compilerFilePath, tag) {
};
}
-function collectLibraryDependencies(product) {
- var seen = {};
- var result = [];
-
- function addFilePath(filePath) {
- result.push({ filePath: filePath });
- }
-
- function addArtifactFilePaths(dep, artifacts) {
- if (!artifacts)
- return;
- var artifactFilePaths = artifacts.map(function(a) { return a.filePath; });
- artifactFilePaths.forEach(addFilePath);
- }
-
- function addExternalStaticLibs(obj) {
- if (!obj.cpp)
- return;
- function ensureArray(a) {
- return (a instanceof Array) ? a : [];
- }
- function sanitizedModuleListProperty(obj, moduleName, propertyName) {
- return ensureArray(ModUtils.sanitizedModuleProperty(obj, moduleName, propertyName));
- }
- var externalLibs = [].concat(
- sanitizedModuleListProperty(obj, "cpp", "staticLibraries"));
- var staticLibrarySuffix = obj.moduleProperty("cpp", "staticLibrarySuffix");
- externalLibs.forEach(function(staticLibraryName) {
- if (!staticLibraryName.endsWith(staticLibrarySuffix))
- staticLibraryName += staticLibrarySuffix;
- addFilePath(staticLibraryName);
- });
- }
-
- function traverse(dep) {
- if (seen.hasOwnProperty(dep.name))
- return;
- seen[dep.name] = true;
-
- if (dep.parameters.cpp && dep.parameters.cpp.link === false)
- return;
-
- var staticLibraryArtifacts = dep.artifacts["staticlibrary"];
- if (staticLibraryArtifacts) {
- dep.dependencies.forEach(traverse);
- addArtifactFilePaths(dep, staticLibraryArtifacts);
- addExternalStaticLibs(dep);
- }
- }
-
- product.dependencies.forEach(traverse);
- addExternalStaticLibs(product);
- return result;
-}
-
-function compilerOutputTags(needsListingFiles) {
- var tags = ["obj"];
- if (needsListingFiles)
- tags.push("lst");
- return tags;
-}
-
-function applicationLinkerOutputTags(needsLinkerMapFile) {
- var tags = ["application"];
- if (needsLinkerMapFile)
- tags.push("mem_map");
- return tags;
-}
-
-function compilerOutputArtifacts(input, isCompilerArtifacts) {
- var artifacts = [];
- artifacts.push({
- fileTags: ["obj"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + input.fileName + input.cpp.objectSuffix
- });
- if (isCompilerArtifacts && input.cpp.generateCompilerListingFiles) {
- artifacts.push({
- fileTags: ["lst"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + 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;
-}
-
-function applicationLinkerOutputArtifacts(product) {
- var artifacts = [{
- fileTags: ["application"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- PathTools.applicationFilePath(product))
- }];
- if (product.cpp.generateLinkerMapFile) {
- artifacts.push({
- fileTags: ["mem_map"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- product.targetName + product.cpp.linkerMapSuffix)
- });
- }
- return artifacts;
-}
-
-function staticLibraryLinkerOutputArtifacts(product) {
- var staticLib = {
- fileTags: ["staticlibrary"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- PathTools.staticLibraryFilePath(product))
- };
- return [staticLib]
-}
-
function compilerFlags(project, product, input, outputs, explicitlyDependsOn) {
var args = [];
@@ -894,7 +774,7 @@ function linkerFlags(project, product, inputs, outputs) {
allLibraryPaths = allLibraryPaths.uniqueConcat(distributionLibraryPaths);
// Library dependencies.
- var libraryDependencies = collectLibraryDependencies(product);
+ var libraryDependencies = ModUtils.collectLibraryDependencies(product);
if (libraryDependencies)
args = args.concat(libraryDependencies.map(function(dep) { return dep.filePath }));
diff --git a/share/qbs/modules/cpp/iar.qbs b/share/qbs/modules/cpp/iar.qbs
index eee750840..e2241cc55 100644
--- a/share/qbs/modules/cpp/iar.qbs
+++ b/share/qbs/modules/cpp/iar.qbs
@@ -98,8 +98,8 @@ CppModule {
Rule {
id: assembler
inputs: ["asm"]
- outputFileTags: IAR.compilerOutputTags(generateAssemblerListingFiles)
- outputArtifacts: IAR.compilerOutputArtifacts(input, false)
+ outputFileTags: ModUtils.compilerOutputTags(generateAssemblerListingFiles)
+ outputArtifacts: ModUtils.compilerOutputArtifacts(input, false)
prepare: IAR.prepareAssembler.apply(IAR, arguments)
}
@@ -112,8 +112,8 @@ CppModule {
id: compiler
inputs: ["cpp", "c"]
auxiliaryInputs: ["hpp"]
- outputFileTags: IAR.compilerOutputTags(generateCompilerListingFiles)
- outputArtifacts: IAR.compilerOutputArtifacts(input, true)
+ outputFileTags: ModUtils.compilerOutputTags(generateCompilerListingFiles)
+ outputArtifacts: ModUtils.compilerOutputArtifacts(input, true)
prepare: IAR.prepareCompiler.apply(IAR, arguments)
}
@@ -122,8 +122,8 @@ CppModule {
multiplex: true
inputs: ["obj", "linkerscript"]
inputsFromDependencies: ["staticlibrary"]
- outputFileTags: IAR.applicationLinkerOutputTags(generateLinkerMapFile)
- outputArtifacts: IAR.applicationLinkerOutputArtifacts(product)
+ outputFileTags: ModUtils.applicationLinkerOutputTags(generateLinkerMapFile)
+ outputArtifacts: ModUtils.applicationLinkerOutputArtifacts(product)
prepare: IAR.prepareLinker.apply(IAR, arguments)
}
@@ -132,8 +132,8 @@ CppModule {
multiplex: true
inputs: ["obj"]
inputsFromDependencies: ["staticlibrary"]
- outputFileTags: ["staticlibrary"]
- outputArtifacts: IAR.staticLibraryLinkerOutputArtifacts(product)
+ outputFileTags: ModUtils.staticLibraryLinkerOutputTags()
+ outputArtifacts: ModUtils.staticLibraryLinkerOutputArtifacts(product)
prepare: IAR.prepareArchiver.apply(IAR, arguments)
}
}
diff --git a/share/qbs/modules/cpp/keil.js b/share/qbs/modules/cpp/keil.js
index a36fe592c..e1876e0b2 100644
--- a/share/qbs/modules/cpp/keil.js
+++ b/share/qbs/modules/cpp/keil.js
@@ -507,61 +507,6 @@ function dumpDefaultPaths(compilerFilePath, nullDevice) {
return { "includePaths": includePaths };
}
-function collectLibraryDependencies(product) {
- var seen = {};
- var result = [];
-
- function addFilePath(filePath) {
- result.push({ filePath: filePath });
- }
-
- function addArtifactFilePaths(dep, artifacts) {
- if (!artifacts)
- return;
- var artifactFilePaths = artifacts.map(function(a) { return a.filePath; });
- artifactFilePaths.forEach(addFilePath);
- }
-
- function addExternalStaticLibs(obj) {
- if (!obj.cpp)
- return;
- function ensureArray(a) {
- return (a instanceof Array) ? a : [];
- }
- function sanitizedModuleListProperty(obj, moduleName, propertyName) {
- return ensureArray(ModUtils.sanitizedModuleProperty(obj, moduleName, propertyName));
- }
- var externalLibs = [].concat(
- sanitizedModuleListProperty(obj, "cpp", "staticLibraries"));
- var staticLibrarySuffix = obj.moduleProperty("cpp", "staticLibrarySuffix");
- externalLibs.forEach(function(staticLibraryName) {
- if (!staticLibraryName.endsWith(staticLibrarySuffix))
- staticLibraryName += staticLibrarySuffix;
- addFilePath(staticLibraryName);
- });
- }
-
- function traverse(dep) {
- if (seen.hasOwnProperty(dep.name))
- return;
- seen[dep.name] = true;
-
- if (dep.parameters.cpp && dep.parameters.cpp.link === false)
- return;
-
- var staticLibraryArtifacts = dep.artifacts["staticlibrary"];
- if (staticLibraryArtifacts) {
- dep.dependencies.forEach(traverse);
- addArtifactFilePaths(dep, staticLibraryArtifacts);
- addExternalStaticLibs(dep);
- }
- }
-
- product.dependencies.forEach(traverse);
- addExternalStaticLibs(product);
- return result;
-}
-
function filterMcsOutput(output) {
var filteredLines = [];
output.split(/\r\n|\r|\n/).forEach(function(line) {
@@ -582,71 +527,6 @@ function filterC166Output(output) {
return filteredLines.join('\n');
};
-function compilerOutputTags(needsListingFiles) {
- var tags = ["obj"];
- if (needsListingFiles)
- tags.push("lst");
- return tags;
-}
-
-function applicationLinkerOutputTags(needsLinkerMapFile) {
- var tags = ["application"];
- if (needsLinkerMapFile)
- tags.push("mem_map");
- return tags;
-}
-
-function compilerOutputArtifacts(input, isCompilerArtifacts) {
- var artifacts = [];
- artifacts.push({
- fileTags: ["obj"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + input.fileName + input.cpp.objectSuffix
- });
- if (isCompilerArtifacts && input.cpp.generateCompilerListingFiles) {
- artifacts.push({
- fileTags: ["lst"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + 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;
-}
-
-function applicationLinkerOutputArtifacts(product) {
- var artifacts = [{
- fileTags: ["application"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- PathTools.applicationFilePath(product))
- }];
- if (product.cpp.generateLinkerMapFile) {
- artifacts.push({
- fileTags: ["mem_map"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- product.targetName + product.cpp.linkerMapSuffix)
- });
- }
- return artifacts;
-}
-
-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(outputs.obj[0].fileTags));
@@ -1006,7 +886,7 @@ function linkerFlags(project, product, inputs, outputs) {
inputs.obj.map(function(obj) { allObjectPaths.push(obj.filePath) });
// Library dependencies.
- var libraryObjects = collectLibraryDependencies(product);
+ var libraryObjects = ModUtils.collectLibraryDependencies(product);
allObjectPaths = allObjectPaths.concat(libraryObjects.map(function(lib) {
// Semi-intelligent handling the library paths.
// We need to add the full path prefix to the library file if this
@@ -1047,7 +927,7 @@ function linkerFlags(project, product, inputs, outputs) {
args.push("--userlibpath=" + libraryPaths.join(","));
// Library dependencies.
- var libraryDependencies = collectLibraryDependencies(product);
+ var libraryDependencies = ModUtils.collectLibraryDependencies(product);
args = args.concat(libraryDependencies.map(function(dep) { return dep.filePath; }));
// Debug information flag.
diff --git a/share/qbs/modules/cpp/keil.qbs b/share/qbs/modules/cpp/keil.qbs
index 1d84f43d8..94c575b20 100644
--- a/share/qbs/modules/cpp/keil.qbs
+++ b/share/qbs/modules/cpp/keil.qbs
@@ -102,8 +102,8 @@ CppModule {
Rule {
id: assembler
inputs: ["asm"]
- outputFileTags: KEIL.compilerOutputTags(generateAssemblerListingFiles)
- outputArtifacts: KEIL.compilerOutputArtifacts(input, false)
+ outputFileTags: ModUtils.compilerOutputTags(generateAssemblerListingFiles)
+ outputArtifacts: ModUtils.compilerOutputArtifacts(input, false)
prepare: KEIL.prepareAssembler.apply(KEIL, arguments)
}
@@ -116,8 +116,8 @@ CppModule {
id: compiler
inputs: ["cpp", "c"]
auxiliaryInputs: ["hpp"]
- outputFileTags: KEIL.compilerOutputTags(generateCompilerListingFiles)
- outputArtifacts: KEIL.compilerOutputArtifacts(input, true)
+ outputFileTags: ModUtils.compilerOutputTags(generateCompilerListingFiles)
+ outputArtifacts: ModUtils.compilerOutputArtifacts(input, true)
prepare: KEIL.prepareCompiler.apply(KEIL, arguments)
}
@@ -126,8 +126,8 @@ CppModule {
multiplex: true
inputs: ["obj", "linkerscript"]
inputsFromDependencies: ["staticlibrary"]
- outputFileTags: KEIL.applicationLinkerOutputTags(generateLinkerMapFile)
- outputArtifacts: KEIL.applicationLinkerOutputArtifacts(product)
+ outputFileTags: ModUtils.applicationLinkerOutputTags(generateLinkerMapFile)
+ outputArtifacts: ModUtils.applicationLinkerOutputArtifacts(product)
prepare: KEIL.prepareLinker.apply(KEIL, arguments)
}
@@ -136,8 +136,8 @@ CppModule {
multiplex: true
inputs: ["obj"]
inputsFromDependencies: ["staticlibrary"]
- outputFileTags: ["staticlibrary"]
- outputArtifacts: KEIL.staticLibraryLinkerOutputArtifacts(product)
+ outputFileTags: ModUtils.staticLibraryLinkerOutputTags()
+ outputArtifacts: ModUtils.staticLibraryLinkerOutputArtifacts(product)
prepare: KEIL.prepareArchiver.apply(KEIL, arguments)
}
}
diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js
index 022ab54b7..93566a0df 100644
--- a/share/qbs/modules/cpp/sdcc.js
+++ b/share/qbs/modules/cpp/sdcc.js
@@ -184,93 +184,25 @@ function escapePreprocessorFlags(preprocessorFlags) {
return ["-Wp " + preprocessorFlags.join(",")];
}
-function collectLibraryDependencies(product) {
- var seen = {};
- var result = [];
-
- function addFilePath(filePath) {
- result.push({ filePath: filePath });
- }
-
- function addArtifactFilePaths(dep, artifacts) {
- if (!artifacts)
- return;
- var artifactFilePaths = artifacts.map(function(a) { return a.filePath; });
- artifactFilePaths.forEach(addFilePath);
- }
-
- function addExternalStaticLibs(obj) {
- if (!obj.cpp)
- return;
- function ensureArray(a) {
- return (a instanceof Array) ? a : [];
- }
- function sanitizedModuleListProperty(obj, moduleName, propertyName) {
- return ensureArray(ModUtils.sanitizedModuleProperty(obj, moduleName, propertyName));
- }
- var externalLibs = [].concat(
- sanitizedModuleListProperty(obj, "cpp", "staticLibraries"));
- var staticLibrarySuffix = obj.moduleProperty("cpp", "staticLibrarySuffix");
- externalLibs.forEach(function(staticLibraryName) {
- if (!staticLibraryName.endsWith(staticLibrarySuffix))
- staticLibraryName += staticLibrarySuffix;
- addFilePath(staticLibraryName);
- });
- }
-
- function traverse(dep) {
- if (seen.hasOwnProperty(dep.name))
- return;
- seen[dep.name] = true;
-
- if (dep.parameters.cpp && dep.parameters.cpp.link === false)
- return;
-
- var staticLibraryArtifacts = dep.artifacts["staticlibrary"];
- if (staticLibraryArtifacts) {
- dep.dependencies.forEach(traverse);
- addArtifactFilePaths(dep, staticLibraryArtifacts);
- addExternalStaticLibs(dep);
- }
- }
-
- product.dependencies.forEach(traverse);
- addExternalStaticLibs(product);
- return result;
+// 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).
+function extraCompilerOutputTags() {
+ return ["asm_adb", "asm_src", "asm_sym", "rst_data"];
}
-function compilerOutputTags(needsListingFiles) {
- // 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 tags = ["obj", "asm_adb", "asm_src", "asm_sym", "rst_data"]
- if (needsListingFiles)
- tags.push("lst");
- return tags;
+// We need to use the lk_cmd, and mem_summary artifacts without
+// of any conditions. Because SDCC always generates
+// it (and seems, this behavior can not be disabled for SDCC).
+function extraApplicationLinkerOutputTags() {
+ return ["lk_cmd", "mem_summary"];
}
-function applicationLinkerOutputTags(needsLinkerMapFile) {
- // We need to use the lk_cmd, and mem_summary artifacts without
- // of any conditions. Because SDCC always generates
- // it (and seems, this behavior can not be disabled for SDCC).
-
- var tags = ["application", "lk_cmd", "mem_summary"];
- if (needsLinkerMapFile)
- tags.push("mem_map");
- return tags;
-}
-
-function compilerOutputArtifacts(input, isCompilerArtifacts) {
- // 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 artifacts = [{
- fileTags: ["obj"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + input.fileName + input.cpp.objectSuffix
- }, {
+// 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).
+function extraCompilerOutputArtifacts(input) {
+ return [{
fileTags: ["asm_adb"],
filePath: Utilities.getHash(input.baseDir) + "/"
+ input.fileName + ".adb"
@@ -287,33 +219,13 @@ function compilerOutputArtifacts(input, isCompilerArtifacts) {
filePath: Utilities.getHash(input.baseDir) + "/"
+ input.fileName + ".rst"
}];
- if (isCompilerArtifacts && input.cpp.generateCompilerListingFiles) {
- artifacts.push({
- fileTags: ["lst"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + 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;
}
-function applicationLinkerOutputArtifacts(product) {
- // We need to use the lk_cmd, and mem_summary artifacts without
- // of any conditions. Because SDCC always generates
- // it (and seems, this behavior can not be disabled for SDCC).
-
- var artifacts = [{
- fileTags: ["application"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- PathTools.applicationFilePath(product))
- }, {
+// We need to use the lk_cmd, and mem_summary artifacts without
+// of any conditions. Because SDCC always generates
+// it (and seems, this behavior can not be disabled for SDCC).
+function extraApplicationLinkerOutputArtifacts(product) {
+ return [{
fileTags: ["lk_cmd"],
filePath: FileInfo.joinPaths(
product.destinationDirectory,
@@ -324,25 +236,6 @@ function applicationLinkerOutputArtifacts(product) {
product.destinationDirectory,
product.targetName + ".mem")
}];
- if (product.cpp.generateLinkerMapFile) {
- artifacts.push({
- fileTags: ["mem_map"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- product.targetName + product.cpp.linkerMapSuffix)
- });
- }
- return artifacts;
-}
-
-function staticLibraryLinkerOutputArtifacts(product) {
- var staticLib = {
- fileTags: ["staticlibrary"],
- filePath: FileInfo.joinPaths(
- product.destinationDirectory,
- PathTools.staticLibraryFilePath(product))
- };
- return [staticLib]
}
function compilerFlags(project, product, input, outputs, explicitlyDependsOn) {
@@ -503,7 +396,7 @@ function linkerFlags(project, product, inputs, outputs) {
if (distributionLibraryPaths)
allLibraryPaths = allLibraryPaths.uniqueConcat(distributionLibraryPaths);
- var libraryDependencies = collectLibraryDependencies(product);
+ var libraryDependencies = ModUtils.collectLibraryDependencies(product);
var escapableLinkerFlags = [];
diff --git a/share/qbs/modules/cpp/sdcc.qbs b/share/qbs/modules/cpp/sdcc.qbs
index 4e68c8c24..1f0df82bf 100644
--- a/share/qbs/modules/cpp/sdcc.qbs
+++ b/share/qbs/modules/cpp/sdcc.qbs
@@ -99,8 +99,10 @@ CppModule {
Rule {
id: assembler
inputs: ["asm"]
- outputFileTags: SDCC.compilerOutputTags(generateAssemblerListingFiles)
- outputArtifacts: SDCC.compilerOutputArtifacts(input, false)
+ outputFileTags: SDCC.extraCompilerOutputTags().concat(
+ ModUtils.compilerOutputTags(generateAssemblerListingFiles))
+ outputArtifacts: SDCC.extraCompilerOutputArtifacts(input).concat(
+ ModUtils.compilerOutputArtifacts(input, false))
prepare: SDCC.prepareAssembler.apply(SDCC, arguments)
}
@@ -113,8 +115,10 @@ CppModule {
id: compiler
inputs: ["cpp", "c"]
auxiliaryInputs: ["hpp"]
- outputFileTags: SDCC.compilerOutputTags(generateCompilerListingFiles)
- outputArtifacts: SDCC.compilerOutputArtifacts(input, true)
+ outputFileTags: SDCC.extraCompilerOutputTags().concat(
+ ModUtils.compilerOutputTags(generateCompilerListingFiles))
+ outputArtifacts: SDCC.extraCompilerOutputArtifacts(input).concat(
+ ModUtils.compilerOutputArtifacts(input, true))
prepare: SDCC.prepareCompiler.apply(SDCC, arguments)
}
@@ -123,8 +127,10 @@ CppModule {
multiplex: true
inputs: ["obj", "linkerscript"]
inputsFromDependencies: ["staticlibrary"]
- outputFileTags: SDCC.applicationLinkerOutputTags(generateLinkerMapFile)
- outputArtifacts: SDCC.applicationLinkerOutputArtifacts(product)
+ outputFileTags: SDCC.extraApplicationLinkerOutputTags().concat(
+ ModUtils.applicationLinkerOutputTags(generateLinkerMapFile))
+ outputArtifacts: SDCC.extraApplicationLinkerOutputArtifacts(product).concat(
+ ModUtils.applicationLinkerOutputArtifacts(product))
prepare: SDCC.prepareLinker.apply(SDCC, arguments)
}
@@ -133,8 +139,8 @@ CppModule {
multiplex: true
inputs: ["obj"]
inputsFromDependencies: ["staticlibrary"]
- outputFileTags: ["staticlibrary"]
- outputArtifacts: SDCC.staticLibraryLinkerOutputArtifacts(product)
+ outputFileTags: ModUtils.staticLibraryLinkerOutputTags()
+ outputArtifacts: ModUtils.staticLibraryLinkerOutputArtifacts(product)
prepare: SDCC.prepareArchiver.apply(SDCC, arguments)
}
}