aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules/cpp/iar.js
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2020-05-06 13:34:03 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2020-05-11 09:19:58 +0000
commitebd0788b1c749d6a573581f572f2d7b574deade5 (patch)
tree9222e7fa9c121c8de7beeff7d98ad95241c2de62 /share/qbs/modules/cpp/iar.js
parent0bbc9cddde0a5fdb54412d12397fd96d560b83d0 (diff)
baremetal: Simplify output artifact extensions handling for IAR toolchain
Some architectures in IAR have 'magic' code names, e.g. "avr" equals with '90', "avr32" equals with '82' and so forth. Besides, an output artifacts for executable/object/library objects contains that 'magic' codes in own file extensions. So, it is makes sense to create the separate function which return that 'magic' codes and to use this function inside of executable/object/library extensions generation to simplify a code and to minimize the copy/paste operations. Change-Id: Id2223bc577847c616f58bc4eb736d3192a3285a7 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share/qbs/modules/cpp/iar.js')
-rw-r--r--share/qbs/modules/cpp/iar.js105
1 files changed, 40 insertions, 65 deletions
diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js
index 2daaf6fe7..4c4cc3c51 100644
--- a/share/qbs/modules/cpp/iar.js
+++ b/share/qbs/modules/cpp/iar.js
@@ -49,6 +49,26 @@ function supportILinker(architecture) {
|| architecture === "rx" || architecture === "stm8";
}
+// It is a 'magic' IAR-specific target architecture code.
+function architectureCode(architecture) {
+ switch (architecture) {
+ case "78k":
+ return "26";
+ case "avr":
+ return "90";
+ case "avr32":
+ return "82";
+ case "mcs51":
+ return "51";
+ case "msp430":
+ return "43";
+ case "v850":
+ return "85";
+ case "arm": case "rh850": case "rl78": case "rx": case "stm8":
+ return "";
+ }
+}
+
function compilerName(qbs) {
var architecture = qbs.architecture;
if (architecture.startsWith("arm"))
@@ -132,87 +152,42 @@ function archiverName(qbs) {
function staticLibrarySuffix(qbs) {
var architecture = qbs.architecture;
- if (architecture.startsWith("arm")
- || architecture === "stm8" || architecture === "rl78"
- || architecture === "rx" || architecture === "rh850") {
- return ".a";
- } else if (architecture === "mcs51") {
- return ".r51";
- } else if (architecture === "avr") {
- return ".r90";
- } else if (architecture === "msp430") {
- return ".r43";
- } else if (architecture === "v850") {
- return ".r85";
- } else if (architecture === "78k") {
- return ".r26";
- } else if (architecture === "avr32") {
- return ".r82";
+ var code = architectureCode(architecture);
+ if (code === undefined) {
+ throw "Unable to deduce static library suffix for unsupported architecture: '"
+ + architecture + "'";
}
- throw "Unable to deduce static library suffix for unsupported architecture: '"
- + architecture + "'";
+ return (code !== "") ? (".r" + code) : ".a";
}
function executableSuffix(qbs) {
var architecture = qbs.architecture;
- var isDebug = qbs.debugInformation;
- if (architecture.startsWith("arm")
- || architecture === "stm8" || architecture === "rl78"
- || architecture === "rx" || architecture === "rh850") {
- return ".out";
- } else if (architecture === "mcs51") {
- return isDebug ? ".d51" : ".a51";
- } else if (architecture === "avr") {
- return isDebug ? ".d90" : ".a90";
- } else if (architecture === "msp430") {
- return isDebug ? ".d43" : ".a43";
- } else if (architecture === "v850") {
- return isDebug ? ".d85" : ".a85";
- } else if (architecture === "78k") {
- return isDebug ? ".d26" : ".a26";
- } else if (architecture === "avr32") {
- return isDebug ? ".d82" : ".a82";
+ var code = architectureCode(architecture);
+ if (code === undefined) {
+ throw "Unable to deduce executable suffix for unsupported architecture: '"
+ + architecture + "'";
}
- throw "Unable to deduce executable suffix for unsupported architecture: '"
- + architecture + "'";
+ return (code !== "") ? ((qbs.debugInformation) ? (".d" + code) : (".a" + code)) : ".out";
}
function objectSuffix(qbs) {
var architecture = qbs.architecture;
- if (architecture.startsWith("arm")
- || architecture === "stm8" || architecture === "rl78"
- || architecture === "rx" || architecture === "rh850") {
- return ".o";
- } else if (architecture === "mcs51") {
- return ".r51";
- } else if (architecture === "avr") {
- return ".r90";
- } else if (architecture === "msp430") {
- return ".r43";
- } else if (architecture === "v850") {
- return ".r85";
- } else if (architecture === "78k") {
- return ".r26";
- } else if (architecture === "avr32") {
- return ".r82";
+ var code = architectureCode(architecture);
+ if (code === undefined) {
+ throw "Unable to deduce object file suffix for unsupported architecture: '"
+ + architecture + "'";
}
- throw "Unable to deduce object file suffix for unsupported architecture: '"
- + architecture + "'";
+ return (code !== "") ? (".r" + code) : ".o";
}
function imageFormat(qbs) {
var architecture = qbs.architecture;
- if (architecture.startsWith("arm")
- || architecture === "stm8" || architecture === "rl78"
- || architecture === "rx" || architecture === "rh850") {
- return "elf";
- } else if (architecture=== "mcs51" || architecture === "avr"
- || architecture === "msp430" || architecture === "v850"
- || architecture === "78k" || architecture === "avr32") {
- return "ubrof";
+ var code = architectureCode(architecture);
+ if (code === undefined) {
+ throw "Unable to deduce image format for unsupported architecture: '"
+ + architecture + "'";
}
- throw "Unable to deduce image format for unsupported architecture: '"
- + architecture + "'";
+ return (code !== "") ? "ubrof" : "elf";
}
function guessArmArchitecture(core) {