aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-05-10 14:12:26 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-05-10 13:56:53 +0000
commit3598640bbdcd9e6447c3c54c0fc1b5b789f3eaa7 (patch)
tree825c28166b0f43235a8bd3dcf68a1a4a88b4a3e7
parentdcc8a1b552ad19c77c9bb33df3bcac9d5b43571b (diff)
bare-metal: Implement cpp.compilerIncludePaths for IAR toolchain
Change-Id: I3b8a3607e1e5c252731dea783acd9c1a0867a127 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--share/qbs/imports/qbs/Probes/IarProbe.qbs7
-rw-r--r--share/qbs/modules/cpp/iar.js47
-rw-r--r--share/qbs/modules/cpp/iar.qbs1
3 files changed, 55 insertions, 0 deletions
diff --git a/share/qbs/imports/qbs/Probes/IarProbe.qbs b/share/qbs/imports/qbs/Probes/IarProbe.qbs
index 04d338268..6e7fb7d64 100644
--- a/share/qbs/imports/qbs/Probes/IarProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/IarProbe.qbs
@@ -44,6 +44,7 @@ PathProbe {
property int versionMajor;
property int versionMinor;
property int versionPatch;
+ property stringList includePaths;
property var compilerDefinesByLanguage;
configure: {
@@ -64,11 +65,17 @@ PathProbe {
compilerFilePath, tag);
}
+ // FIXME: Do we need dump the default paths for both C
+ // and C++ languages?
+ var defaultPaths = IAR.dumpDefaultPaths(
+ compilerFilePath, languages[0]);
+
var macros = compilerDefinesByLanguage["c"]
|| compilerDefinesByLanguage["cpp"];
architecture = IAR.guessArchitecture(macros);
endianness = IAR.guessEndianness(macros);
+ includePaths = defaultPaths.includePaths;
var version = parseInt(macros["__VER__"], 10);
diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js
index cf4577c6a..646826e8a 100644
--- a/share/qbs/modules/cpp/iar.js
+++ b/share/qbs/modules/cpp/iar.js
@@ -77,6 +77,53 @@ function dumpMacros(compilerFilePath, tag) {
return map;
}
+function dumpDefaultPaths(compilerFilePath, tag) {
+ var tempDir = new TemporaryDir();
+ var inFilePath = FileInfo.fromNativeSeparators(tempDir.path() + "/empty-source.c");
+ var inFile = new TextFile(inFilePath, TextFile.WriteOnly);
+
+ var args = [ inFilePath, "--preinclude", "." ];
+ if (tag === "cpp")
+ args.push("--ec++");
+
+ var p = new Process();
+ // This process should return an error, don't throw
+ // an error in this case.
+ p.exec(compilerFilePath, args, false);
+ var output = p.readStdErr();
+
+ var includePaths = [];
+ var pass = 0;
+ for (var pos = 0; pos < output.length; ++pos) {
+ var searchIndex = output.indexOf("searched:", pos);
+ if (searchIndex === -1)
+ break;
+ var startQuoteIndex = output.indexOf('"', searchIndex + 1);
+ if (startQuoteIndex === -1)
+ break;
+ var endQuoteIndex = output.indexOf('"', startQuoteIndex + 1);
+ if (endQuoteIndex === -1)
+ break;
+ pos = endQuoteIndex + 1;
+
+ // Ignore the first path as it is not a compiler include path.
+ ++pass;
+ if (pass === 1)
+ continue;
+
+ var parts = output.substring(startQuoteIndex + 1, endQuoteIndex).split("\n");
+ var includePath = "";
+ for (var i in parts)
+ includePath += parts[i].trim();
+
+ includePaths.push(includePath);
+ }
+
+ return {
+ "includePaths": includePaths
+ };
+}
+
function collectLibraryDependencies(product) {
var seen = {};
var result = [];
diff --git a/share/qbs/modules/cpp/iar.qbs b/share/qbs/modules/cpp/iar.qbs
index 05a76c6b5..6d15781a5 100644
--- a/share/qbs/modules/cpp/iar.qbs
+++ b/share/qbs/modules/cpp/iar.qbs
@@ -61,6 +61,7 @@ CppModule {
endianness: iarProbe.endianness
compilerDefinesByLanguage: iarProbe.compilerDefinesByLanguage
+ compilerIncludePaths: iarProbe.includePaths
property string toolchainInstallPath: compilerPathProbe.found
? compilerPathProbe.path : undefined