aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-05-11 13:19:19 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-05-14 13:58:29 +0000
commitf0092aeea998ab96f6db9b5c0761ad452a0d493a (patch)
tree405e1f889a181f6779d6dcb0b2610f963202280e
parentfc4d6354ad99aa402b6ca2e6cb1baebd566cee32 (diff)
bare-metal: Implement cpp.compilerIncludePaths for SDCC toolchain
Change-Id: If9143a5af10c842bbb2b6dd08d201f8d9963012f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--share/qbs/imports/qbs/Probes/SdccProbe.qbs4
-rw-r--r--share/qbs/modules/cpp/sdcc.js31
-rw-r--r--share/qbs/modules/cpp/sdcc.qbs1
3 files changed, 36 insertions, 0 deletions
diff --git a/share/qbs/imports/qbs/Probes/SdccProbe.qbs b/share/qbs/imports/qbs/Probes/SdccProbe.qbs
index 10f6461cb..864dc45bc 100644
--- a/share/qbs/imports/qbs/Probes/SdccProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/SdccProbe.qbs
@@ -42,6 +42,7 @@ PathProbe {
property int versionMajor;
property int versionMinor;
property int versionPatch;
+ property stringList includePaths;
configure: {
if (!File.exists(compilerFilePath)) {
@@ -54,6 +55,9 @@ PathProbe {
architecture = SDCC.guessArchitecture(macros);
endianness = SDCC.guessEndianness(macros);
+ var defaultPaths = SDCC.dumpDefaultPaths(compilerFilePath, architecture);
+ includePaths = defaultPaths.includePaths;
+
versionMajor = parseInt(macros["__SDCC_VERSION_MAJOR"], 10);
versionMinor = parseInt(macros["__SDCC_VERSION_MINOR"], 10);
versionPatch = parseInt(macros["__SDCC_VERSION_PATCH"], 10);
diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js
index e047fc977..2f148d2c2 100644
--- a/share/qbs/modules/cpp/sdcc.js
+++ b/share/qbs/modules/cpp/sdcc.js
@@ -75,6 +75,37 @@ function dumpMacros(compilerFilePath, architecture) {
return map;
}
+function dumpDefaultPaths(compilerFilePath, architecture) {
+ var args = [ "--print-search-dirs" ];
+
+ var targetFlag = targetArchitectureFlag(architecture);
+ if (targetFlag)
+ args.push(targetFlag);
+
+ var p = new Process();
+ p.exec(compilerFilePath, args, true);
+ var includePaths = [];
+ var addIncludePaths = false;
+ var lines = p.readStdOut().trim().split(/\r?\n/g);
+ for (var i in lines) {
+ var line = lines[i];
+ if (line.startsWith("includedir:")) {
+ addIncludePaths = true;
+ } else if (line.startsWith("programs:")
+ || line.startsWith("datadir:")
+ || line.startsWith("libdir:")
+ || line.startsWith("libpath:")) {
+ addIncludePaths = false;
+ } else if (addIncludePaths) {
+ includePaths.push(line);
+ }
+ }
+
+ return {
+ "includePaths": includePaths
+ }
+}
+
function effectiveLinkerPath(product) {
if (product.cpp.linkerMode === "automatic")
return product.cpp.compilerPath;
diff --git a/share/qbs/modules/cpp/sdcc.qbs b/share/qbs/modules/cpp/sdcc.qbs
index 0944cccd3..901539bfc 100644
--- a/share/qbs/modules/cpp/sdcc.qbs
+++ b/share/qbs/modules/cpp/sdcc.qbs
@@ -61,6 +61,7 @@ CppModule {
endianness: sdccProbe.endianness
compilerDefinesByLanguage: []
+ compilerIncludePaths: sdccProbe.includePaths
property string toolchainInstallPath: compilerPathProbe.found
? compilerPathProbe.path : undefined