aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules/cpp/CppModule.qbs
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-01-26 15:37:20 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2017-02-17 11:10:28 +0000
commitb860cd4f40b3efba8edff2b9bb87b8b999def42e (patch)
tree213796b49768675ad1793377efaa7061f9c1caa3 /share/qbs/modules/cpp/CppModule.qbs
parentb78607350bcefdd75d4c41473312bf580801d0f6 (diff)
Cpp module: Allow a set of source files to be combined into one
We introduce file tags and properties to support the concept of "amalgamation builds" for C, C++, Objective-C and Objective-C++. [ChangeLog] Provided the means to easily combine source files for the C language family in order to support "amalgamation builds". Change-Id: Ia3d248203c29418907178b47dba84ca3a18a0857 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'share/qbs/modules/cpp/CppModule.qbs')
-rw-r--r--share/qbs/modules/cpp/CppModule.qbs84
1 files changed, 80 insertions, 4 deletions
diff --git a/share/qbs/modules/cpp/CppModule.qbs b/share/qbs/modules/cpp/CppModule.qbs
index dd36cc228..150d773e1 100644
--- a/share/qbs/modules/cpp/CppModule.qbs
+++ b/share/qbs/modules/cpp/CppModule.qbs
@@ -312,24 +312,100 @@ Module {
property bool allowUnresolvedSymbols: false
+ property bool combineCSources: false
+ property bool combineCxxSources: false
+ property bool combineObjcSources: false
+ property bool combineObjcxxSources: false
+
+ // TODO: The following four rules could use a convenience base item if rule properties
+ // were available in Artifact items and prepare scripts.
+ Rule {
+ multiplex: true
+ inputs: ["c.combine"]
+ Artifact {
+ filePath: "amalgamated_" + product.targetName + ".c"
+ fileTags: ["c"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating " + output.fileName;
+ cmd.highlight = "codegen";
+ cmd.sourceCode = function() {
+ ModUtils.mergeCFiles(inputs["c.combine"], output.filePath);
+ };
+ return [cmd];
+ }
+ }
+ Rule {
+ multiplex: true
+ inputs: ["cpp.combine"]
+ Artifact {
+ filePath: "amalgamated_" + product.targetName + ".cpp"
+ fileTags: ["cpp"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating " + output.fileName;
+ cmd.highlight = "codegen";
+ cmd.sourceCode = function() {
+ ModUtils.mergeCFiles(inputs["cpp.combine"], output.filePath);
+ };
+ return [cmd];
+ }
+ }
+ Rule {
+ multiplex: true
+ inputs: ["objc.combine"]
+ Artifact {
+ filePath: "amalgamated_" + product.targetName + ".m"
+ fileTags: ["objc"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating " + output.fileName;
+ cmd.highlight = "codegen";
+ cmd.sourceCode = function() {
+ ModUtils.mergeCFiles(inputs["objc.combine"], output.filePath);
+ };
+ return [cmd];
+ }
+ }
+ Rule {
+ multiplex: true
+ inputs: ["objcpp.combine"]
+ Artifact {
+ filePath: "amalgamated_" + product.targetName + ".mm"
+ fileTags: ["objccpp"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating " + output.fileName;
+ cmd.highlight = "codegen";
+ cmd.sourceCode = function() {
+ ModUtils.mergeCFiles(inputs["objcpp.combine"], output.filePath);
+ };
+ return [cmd];
+ }
+ }
+
FileTagger {
patterns: ["*.c"]
- fileTags: ["c"]
+ fileTags: combineCSources ? ["c.combine"] : ["c"]
}
FileTagger {
patterns: ["*.C", "*.cpp", "*.cxx", "*.c++", "*.cc"]
- fileTags: ["cpp"]
+ fileTags: combineCxxSources ? ["cpp.combine"] : ["cpp"]
}
FileTagger {
patterns: ["*.m"]
- fileTags: ["objc"]
+ fileTags: combineObjcSources ? ["objc.combine"] : ["objc"]
}
FileTagger {
patterns: ["*.mm"]
- fileTags: ["objcpp"]
+ fileTags: combineObjcxxSources ? ["objcpp.combine"] : ["objcpp"]
}
FileTagger {