diff options
author | Richard Weickelt <[email protected]> | 2025-04-14 22:45:46 +0200 |
---|---|---|
committer | Richard Weickelt <[email protected]> | 2025-05-06 08:24:32 +0000 |
commit | 10cd7751abac29dcdf5486d402ab8f2328e3bb3d (patch) | |
tree | edfc11dcbed3702801ec649ffff816113f72780b | |
parent | 43cf1fe9171381a82234f51f427f7b9f6e6e098c (diff) |
Add archiverFlags property to cpp module
All toolchain offer tools to generate static libraries. This is usually
not done by a linker, but by the so-called archiver. We should not mix
up the terms linking and archiving. And since we already have flags for
all tools and we have properties like archiverName, archiverPath, it
feels only natural to also add an archiverFlags property.
Task-number: QBS-1832
Change-Id: Ide0609616be50a20eb59c9af04afc61b36fc45f2
Reviewed-by: Christian Kandeler <[email protected]>
-rw-r--r-- | doc/reference/modules/cpp-module.qdoc | 22 | ||||
-rw-r--r-- | share/qbs/modules/cpp/CppModule.qbs | 2 | ||||
-rw-r--r-- | share/qbs/modules/cpp/cosmic.js | 1 | ||||
-rw-r--r-- | share/qbs/modules/cpp/dmc.js | 1 | ||||
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 4 | ||||
-rw-r--r-- | share/qbs/modules/cpp/iar.js | 1 | ||||
-rw-r--r-- | share/qbs/modules/cpp/keil.js | 1 | ||||
-rw-r--r-- | share/qbs/modules/cpp/msvc.js | 1 | ||||
-rw-r--r-- | share/qbs/modules/cpp/sdcc.js | 1 |
9 files changed, 25 insertions, 9 deletions
diff --git a/doc/reference/modules/cpp-module.qdoc b/doc/reference/modules/cpp-module.qdoc index f8b23269b..76b15ce7b 100644 --- a/doc/reference/modules/cpp-module.qdoc +++ b/doc/reference/modules/cpp-module.qdoc @@ -1342,25 +1342,31 @@ /*! \qmlproperty string cpp::archiverName - \unixproperty - - The name of the archiver binary. This property is set in the build profile. + The name of the archiver binary. This property is usually predetermined by the toolchain and + may be overridden. For instance, when enabling link-time optimization in a gcc-based toolchain, + \c{"gcc-ar"} has to be used instead of \c{"ar"}. - \defaultvalue \c{"ar"} + \defaultvalue Depends on the selected toolchain. */ /*! \qmlproperty string cpp::archiverPath - \unixproperty - - The full path of the archiver binary. This property is set in the build - profile. + The full path of the archiver binary. \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. */ /*! + \qmlproperty string cpp::archiverFlags + + Additional flags that are appended to the archiver command. + + \defaultvalue An empty list + \since Qbs 3.0.0 +*/ + +/*! \qmlproperty string cpp::exportedSymbolsCheckMode \since Qbs 1.4.1 diff --git a/share/qbs/modules/cpp/CppModule.qbs b/share/qbs/modules/cpp/CppModule.qbs index 5f4015356..a18bc8b4f 100644 --- a/share/qbs/modules/cpp/CppModule.qbs +++ b/share/qbs/modules/cpp/CppModule.qbs @@ -242,6 +242,8 @@ Module { + "linker." } + property stringList archiverFlags + property stringList assemblerFlags PropertyOptions { name: "assemblerFlags" diff --git a/share/qbs/modules/cpp/cosmic.js b/share/qbs/modules/cpp/cosmic.js index 4979f33f7..7a51f1237 100644 --- a/share/qbs/modules/cpp/cosmic.js +++ b/share/qbs/modules/cpp/cosmic.js @@ -320,6 +320,7 @@ function linkerFlags(project, product, inputs, outputs) { function archiverFlags(project, product, inputs, outputs) { var args = ["-cl"]; + Array.prototype.push.apply(args, product.cpp.archiverFlags); // Output. args.push(outputs.staticlibrary[0].filePath); diff --git a/share/qbs/modules/cpp/dmc.js b/share/qbs/modules/cpp/dmc.js index ea7cd7bb5..47d3fb474 100644 --- a/share/qbs/modules/cpp/dmc.js +++ b/share/qbs/modules/cpp/dmc.js @@ -379,6 +379,7 @@ function linkerFlags(project, product, inputs, outputs) { function archiverFlags(project, product, inputs, outputs) { var args = ["-c"]; + Array.prototype.push.apply(args, product.cpp.archiverFlags); // Output. args.push(FileInfo.toWindowsSeparators(outputs.staticlibrary[0].filePath)); // Input objects. diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index 8d398d91d..09f7ee69f 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -1702,7 +1702,9 @@ function staticLibLinkerOutputArtifacts(product) function staticLibLinkerCommands(project, product, inputs, outputs, input, output, explicitlyDependsOn) { - var args = ['rcs', output.filePath]; + var args = ['rcs']; + Array.prototype.push.apply(args, product.cpp.archiverFlags); + args.push(output.filePath); for (var i in inputs.obj) args.push(inputs.obj[i].filePath); for (var i in inputs.res) diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js index ed58ac262..bbf1f242b 100644 --- a/share/qbs/modules/cpp/iar.js +++ b/share/qbs/modules/cpp/iar.js @@ -721,6 +721,7 @@ function archiverFlags(project, product, inputs, outputs) { if (supportIArchiver(architecture)) args.push("--create"); args.push("-o", outputs.staticlibrary[0].filePath); + Array.prototype.push.apply(args, product.cpp.archiverFlags); return args; } diff --git a/share/qbs/modules/cpp/keil.js b/share/qbs/modules/cpp/keil.js index 8f3297aa2..bf95eec0a 100644 --- a/share/qbs/modules/cpp/keil.js +++ b/share/qbs/modules/cpp/keil.js @@ -873,6 +873,7 @@ function archiverFlags(project, product, inputs, outputs) { if (product.cpp.debugInformation) args.push("--debug_symbols"); } + Array.prototype.push.apply(args, product.cpp.archiverFlags); return args; } diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js index c1381f7b4..192d7b1cb 100644 --- a/share/qbs/modules/cpp/msvc.js +++ b/share/qbs/modules/cpp/msvc.js @@ -736,6 +736,7 @@ function libtoolCommands(project, product, inputs, outputs, input, output, expli var lib = outputs["staticlibrary"][0]; var nativeOutputFileName = FileInfo.toWindowsSeparators(lib.filePath) args.push('/OUT:' + nativeOutputFileName) + Array.prototype.push.apply(args, product.cpp.archiverFlags); for (var i in inputs.obj) { var fileName = FileInfo.toWindowsSeparators(inputs.obj[i].filePath) args.push(fileName) diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js index 49da8a715..0327da6f0 100644 --- a/share/qbs/modules/cpp/sdcc.js +++ b/share/qbs/modules/cpp/sdcc.js @@ -381,6 +381,7 @@ function linkerFlags(project, product, inputs, outputs) { function archiverFlags(project, product, inputs, outputs) { var args = ["-rc"]; + Array.prototype.push.apply(args, product.cpp.archiverFlags); args.push(outputs.staticlibrary[0].filePath); args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); return args; |