diff options
author | Ola Røer Thorsen <ola@silentwings.no> | 2019-01-03 14:44:15 +0100 |
---|---|---|
committer | Ola Røer Thorsen <ola@silentwings.no> | 2019-01-18 09:39:15 +0000 |
commit | 0be365894406cbca8ed54253419ea2ad6f961bdf (patch) | |
tree | 45a6286600bc61fc56769835d0ee2bb4a93790f0 /share/qbs/modules/cpp/GenericGCC.qbs | |
parent | 9e55ddfa97619f7983ea66213ce6764ee0aed2d9 (diff) |
Add recursive dependency scanning of GNU ld linkerscripts
Linkerscripts may contain INCLUDE and SEARCH_DIR commands that allows
it to include other linkerscripts in a similary way as headers are
included in C++. This commit adds a scanner that adds these additional
dependencies.
[ChangeLog] Added recursive dependency scanning of GNU ld
linkerscripts that contain INCLUDE and SEARCH_DIR commands.
Change-Id: I7549e27aad4fe7ade2a6a26eba14f66880261077
Reviewed-by: Ola Røer Thorsen <ola@silentwings.no>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share/qbs/modules/cpp/GenericGCC.qbs')
-rw-r--r-- | share/qbs/modules/cpp/GenericGCC.qbs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs index 60288e76a..b4e755a3e 100644 --- a/share/qbs/modules/cpp/GenericGCC.qbs +++ b/share/qbs/modules/cpp/GenericGCC.qbs @@ -34,6 +34,7 @@ import qbs.ModUtils import qbs.PathTools import qbs.Probes import qbs.Process +import qbs.TextFile import qbs.Utilities import qbs.UnixUtils import qbs.WindowsUtils @@ -696,4 +697,43 @@ CppModule { patterns: "*.sx" fileTags: ["asm_cpp"] } + + Scanner { + inputs: ["linkerscript"] + recursive: true + scan: { + console.debug("scanning linkerscript " + filePath + " for dependencies"); + var retval = []; + var linkerScript = new TextFile(filePath, TextFile.ReadOnly); + var regexp = /[\s]*INCLUDE[\s]+(\S+).*/ // "INCLUDE filename" + var match; + while (!linkerScript.atEof()) { + match = regexp.exec(linkerScript.readLine()); + if (match) { + var dependencyFileName = match[1]; + retval.push(dependencyFileName); + console.debug("linkerscript " + filePath + " depends on " + dependencyFileName); + } + } + linkerScript.close(); + return retval; + } + searchPaths: { + var retval = []; + for (var i = 0; i < (product.cpp.libraryPaths || []).length; i++) + retval.push(product.cpp.libraryPaths[i]); + var regexp = /[\s]*SEARCH_DIR\((\S+)\).*/ // "SEARCH_DIR(path)" + var match; + var linkerScript = new TextFile(input.filePath, TextFile.ReadOnly); + while (!linkerScript.atEof()) { + match = regexp.exec(linkerScript.readLine()); + if(match) { + var additionalPath = match[1]; + retval.push(additionalPath); + } + } + linkerScript.close(); + return retval; + } + } } |