From f0092aeea998ab96f6db9b5c0761ad452a0d493a Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Sat, 11 May 2019 13:19:19 +0300 Subject: bare-metal: Implement cpp.compilerIncludePaths for SDCC toolchain Change-Id: If9143a5af10c842bbb2b6dd08d201f8d9963012f Reviewed-by: Christian Kandeler --- share/qbs/imports/qbs/Probes/SdccProbe.qbs | 4 ++++ share/qbs/modules/cpp/sdcc.js | 31 ++++++++++++++++++++++++++++++ share/qbs/modules/cpp/sdcc.qbs | 1 + 3 files changed, 36 insertions(+) (limited to 'share') 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 -- cgit v1.2.3