aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2021-01-29 16:06:44 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2021-02-02 08:15:11 +0000
commit0d0acf7d4dfaedce6d849d2db4613ca8a4e9952b (patch)
tree8b2a496cf87aeb2898acff9504c7acc91c7c94b8 /tests
parent9c547478870237086578ebec430698f28e7c14e9 (diff)
baremetal: Improve detection of IAR compiler includes
The IAR compiler has an undocumented command line option `--IDE3`, which allows you to print a list of compiler include paths as: `$$TOOL_BEGIN $$VERSION "3" $$INC_BEGIN $$FILEPATH "<path\\to\\directory>" $$TOOL_END` Besides, the same approach is used in the IAR extension for the VSCode IDE. So we can use this approach to implement it the Qbs module as well. In addition, this commit contains an autotest to check the `cpp.compilerIncludePaths` property. Change-Id: I434dd630913e5afd6cba5b4e31e1021ee0c5fe31 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/blackbox/testdata-baremetal/compiler-include-paths/compiler-include-paths.qbs9
-rw-r--r--tests/auto/blackbox/testdata-baremetal/compiler-include-paths/main.c4
-rw-r--r--tests/auto/blackbox/tst_blackboxbaremetal.cpp28
-rw-r--r--tests/auto/blackbox/tst_blackboxbaremetal.h1
4 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata-baremetal/compiler-include-paths/compiler-include-paths.qbs b/tests/auto/blackbox/testdata-baremetal/compiler-include-paths/compiler-include-paths.qbs
new file mode 100644
index 000000000..5c73302ad
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/compiler-include-paths/compiler-include-paths.qbs
@@ -0,0 +1,9 @@
+import "../BareMetalApplication.qbs" as BareMetalApplication
+
+BareMetalApplication {
+ files: ["main.c"]
+ property bool dummy: {
+ console.info("compilerIncludePaths: %%" + cpp.compilerIncludePaths + "%%");
+ return true;
+ }
+}
diff --git a/tests/auto/blackbox/testdata-baremetal/compiler-include-paths/main.c b/tests/auto/blackbox/testdata-baremetal/compiler-include-paths/main.c
new file mode 100644
index 000000000..58fe69254
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/compiler-include-paths/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
index 41f50a0ed..6d7590209 100644
--- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp
+++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
@@ -32,6 +32,7 @@
#include "../shared.h"
+#include <QtCore/qdir.h>
#include <QtCore/qregularexpression.h>
static bool extractToolset(const QByteArray &output,
@@ -47,6 +48,17 @@ static bool extractToolset(const QByteArray &output,
return true;
}
+static bool extractCompilerIncludePaths(const QByteArray &output, QStringList &compilerIncludePaths)
+{
+ const QRegularExpression re("%%([^%%]+)%%");
+ QRegularExpressionMatchIterator it = re.globalMatch(output);
+ if (!it.hasNext())
+ return false;
+ const QRegularExpressionMatch match = it.next();
+ compilerIncludePaths = match.captured(1).split(",");
+ return true;
+}
+
static QByteArray unsupportedToolsetMessage(const QByteArray &output)
{
QByteArray toolchain;
@@ -142,6 +154,22 @@ void TestBlackboxBareMetal::distributionIncludePaths()
QCOMPARE(runQbs(), 0);
}
+void TestBlackboxBareMetal::compilerIncludePaths()
+{
+ QDir::setCurrent(testDataDir + "/compiler-include-paths");
+ QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0);
+ if (!m_qbsStdout.contains("compilerIncludePaths:"))
+ QFAIL("No compiler include paths exists");
+
+ QStringList includePaths;
+ QVERIFY(extractCompilerIncludePaths(m_qbsStdout, includePaths));
+ QVERIFY(includePaths.count() > 0);
+ for (const auto &includePath : includePaths) {
+ const QDir dir(includePath);
+ QVERIFY(dir.exists());
+ }
+}
+
void TestBlackboxBareMetal::preincludeHeaders()
{
QDir::setCurrent(testDataDir + "/preinclude-headers");
diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.h b/tests/auto/blackbox/tst_blackboxbaremetal.h
index 3695cb1c3..581d1d580 100644
--- a/tests/auto/blackbox/tst_blackboxbaremetal.h
+++ b/tests/auto/blackbox/tst_blackboxbaremetal.h
@@ -52,6 +52,7 @@ private slots:
void userIncludePaths();
void systemIncludePaths();
void distributionIncludePaths();
+ void compilerIncludePaths();
void preincludeHeaders();