aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-05-11 00:20:58 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-05-14 13:58:21 +0000
commitfc4d6354ad99aa402b6ca2e6cb1baebd566cee32 (patch)
tree750b026fd7862b55c4dbbfff8dbed8526bf7366a /share/qbs/modules
parentca4987ae21f3cb30fde699448abc213b37b90214 (diff)
bare-metal: Use preferred architecture to dump macros
.. for SDCC toolchain. The SDCC compiler binary support multiple architectures (aka 8051, z80, and others). So, it is necessary to set a target architecture option before getting the macros. We will take a preferred target architecture from the qbs.architecture property. If this property initially is undefined, then will be returned macros for default compiler architecture (usually it is mcs51). Change-Id: I379ffe90895b62e2786c3ffba2da47b1864da75d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share/qbs/modules')
-rw-r--r--share/qbs/modules/cpp/sdcc.js17
-rw-r--r--share/qbs/modules/cpp/sdcc.qbs1
2 files changed, 14 insertions, 4 deletions
diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js
index d5138d949..e047fc977 100644
--- a/share/qbs/modules/cpp/sdcc.js
+++ b/share/qbs/modules/cpp/sdcc.js
@@ -39,6 +39,11 @@ var TextFile = require("qbs.TextFile");
var Utilities = require("qbs.Utilities");
var WindowsUtils = require("qbs.WindowsUtils");
+function targetArchitectureFlag(architecture) {
+ if (architecture === "mcs51")
+ return "-mmcs51";
+}
+
function guessArchitecture(macros)
{
if (macros["__SDCC_mcs51"] === "1")
@@ -51,13 +56,17 @@ function guessEndianness(macros)
return "little";
}
-function dumpMacros(compilerFilePath, qbs) {
+function dumpMacros(compilerFilePath, architecture) {
var tempDir = new TemporaryDir();
var fakeIn = new TextFile(tempDir.path() + "/empty-source.c", TextFile.WriteOnly);
+ var args = [ fakeIn.filePath(), "-dM", "-E" ];
+
+ var targetFlag = targetArchitectureFlag(architecture);
+ if (targetFlag)
+ args.push(targetFlag);
+
var p = new Process();
- p.exec(compilerFilePath,
- [ fakeIn.filePath(), "-dM", "-E" ],
- true);
+ p.exec(compilerFilePath, args, true);
var map = {};
p.readStdOut().trim().split(/\r?\n/g).map(function (line) {
var parts = line.split(" ", 3);
diff --git a/share/qbs/modules/cpp/sdcc.qbs b/share/qbs/modules/cpp/sdcc.qbs
index e18f77985..0944cccd3 100644
--- a/share/qbs/modules/cpp/sdcc.qbs
+++ b/share/qbs/modules/cpp/sdcc.qbs
@@ -50,6 +50,7 @@ CppModule {
id: sdccProbe
condition: !_skipAllChecks
compilerFilePath: compilerPath
+ preferredArchitecture: qbs.architecture
}
qbs.architecture: sdccProbe.found ? sdccProbe.architecture : original