aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules/cpp/gcc.js
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-05-22 16:12:50 -0700
committerJake Petroules <jake.petroules@qt.io>2017-05-30 09:00:44 +0000
commit6f09ae52a21ec34b0d20e1c367ef2aa7807a0bdd (patch)
tree3b0386154cf61c50af18ca4448c5a811e022cf2c /share/qbs/modules/cpp/gcc.js
parentc35ff7aa67fc8af6ccb98bc2eb8f59e8e9ad3bcf (diff)
Introduce dependency parameter cpp.symbolLinkMode
Maps to -lazy_library, -reexport_library, -upward_library, or -weak_library on Apple platforms. [ChangeLog][Parameters] When pulling in library products, the new Depends parameter cpp.symbolLinkMode can now be specified to control how the library is linked into the target binary on Apple platforms: specifically, whether the library is linked as weak, lazy, reexported, and/or upward (see the ld64 man page for more information). Task-number: QBS-200 Task-number: QBS-874 Change-Id: Ia68cfdf6d99f300c5a28f5638980711022d32d2f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share/qbs/modules/cpp/gcc.js')
-rw-r--r--share/qbs/modules/cpp/gcc.js26
1 files changed, 22 insertions, 4 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js
index f7cb4f30f..bb6c9d363 100644
--- a/share/qbs/modules/cpp/gcc.js
+++ b/share/qbs/modules/cpp/gcc.js
@@ -86,11 +86,14 @@ function collectLibraryDependencies(product) {
function addPublicFilePath(filePath, dep) {
var existing = objectByFilePath[filePath];
var wholeArchive = dep.parameters.cpp && dep.parameters.cpp.linkWholeArchive;
+ var symbolLinkMode = dep.parameters.cpp && dep.parameters.cpp.symbolLinkMode;
if (existing) {
existing.direct = true;
existing.wholeArchive = wholeArchive;
+ existing.symbolLinkMode = symbolLinkMode;
} else {
- addObject({ direct: true, filePath: filePath, wholeArchive: wholeArchive },
+ addObject({ direct: true, filePath: filePath,
+ wholeArchive: wholeArchive, symbolLinkMode: symbolLinkMode },
Array.prototype.unshift);
}
}
@@ -164,7 +167,8 @@ function collectLibraryDependencies(product) {
function (obj) {
if (obj.direct) {
result.libraries.push({ filePath: obj.filePath,
- wholeArchive: obj.wholeArchive });
+ wholeArchive: obj.wholeArchive,
+ symbolLinkMode: obj.symbolLinkMode });
} else {
var dirPath = FileInfo.path(obj.filePath);
if (!seenRPathLinkDirs.hasOwnProperty(dirPath)) {
@@ -393,10 +397,24 @@ function linkerFlags(project, product, inputs, output) {
escapeLinkerFlags(product, inputs, ["--no-whole-archive"]));
wholeArchiveActive = false;
}
- if (FileInfo.isAbsolutePath(lib) || lib.startsWith('@'))
+
+ var symbolLinkMode = dep.symbolLinkMode;
+ if (isDarwin && symbolLinkMode) {
+ if (!["lazy", "reexport", "upward", "weak"].contains(symbolLinkMode))
+ throw new Error("unknown value '" + symbolLinkMode + "' for cpp.symbolLinkMode");
+
+ var flags;
+ if (FileInfo.isAbsolutePath(lib) || lib.startsWith('@'))
+ flags = ["-" + symbolLinkMode + "_library", lib];
+ else
+ flags = ["-" + symbolLinkMode + "-l" + lib];
+
+ Array.prototype.push.apply(args, escapeLinkerFlags(product, inputs, flags));
+ } else if (FileInfo.isAbsolutePath(lib) || lib.startsWith('@')) {
args.push(lib);
- else
+ } else {
args.push('-l' + lib);
+ }
}
if (wholeArchiveActive) {
Array.prototype.push.apply(args,