aboutsummaryrefslogtreecommitdiffstats
path: root/share/share.qbs
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-09-20 18:54:40 -0700
committerJake Petroules <jake.petroules@qt.io>2017-11-01 17:01:27 +0000
commit6cb626668a0f5062afbd89a971dcc9488a6188d1 (patch)
tree4490a4102fca47560e7808707857071a9b626737 /share/share.qbs
parent2e97dd0b29d17c0f81d6f2ad2dd947ba3f0ef2b9 (diff)
Automatically generate the QML type descriptions as part of the build
This guarantees that clients (such as Qt Creator) will always have up to date information. Change-Id: I1fe7d8ae8cd6960681f41e78635576cde3f17083 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share/share.qbs')
-rw-r--r--share/share.qbs81
1 files changed, 80 insertions, 1 deletions
diff --git a/share/share.qbs b/share/share.qbs
index 7cb75b883..c9966c791 100644
--- a/share/share.qbs
+++ b/share/share.qbs
@@ -1,10 +1,12 @@
import qbs
import qbs.File
import qbs.FileInfo
+import qbs.TextFile
+import qbs.Utilities
Product {
name: "qbs resources"
- type: ["copied qbs resources"]
+ type: ["copied qbs resources", "qbs qml type descriptions", "qbs qml type bundle"]
Depends { name: "qbsbuildconfig" }
Group {
@@ -71,4 +73,81 @@ Product {
return cmd;
}
}
+
+ Rule {
+ condition: Utilities.versionCompare(product.qbs.version, "1.9.1") >= 0
+ multiplex: true
+ Artifact {
+ filePath: FileInfo.joinPaths(
+ project.buildDirectory,
+ product.qbsbuildconfig.resourcesInstallDir,
+ product.qbsbuildconfig.qmlTypeDescriptionsInstallDir, "qbs.qmltypes")
+ fileTags: ["qbs qml type descriptions"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "Generating " + output.fileName;
+ cmd.highlight = "codegen";
+ cmd.sourceCode = function() {
+ var tf;
+ try {
+ tf = new TextFile(output.filePath, TextFile.WriteOnly);
+ tf.writeLine(Utilities.qmlTypeInfo());
+ } finally {
+ if (tf)
+ tf.close();
+ }
+ };
+ return cmd;
+ }
+ }
+
+ Rule {
+ condition: Utilities.versionCompare(product.qbs.version, "1.9.1") >= 0
+ multiplex: true
+ Artifact {
+ filePath: FileInfo.joinPaths(
+ project.buildDirectory,
+ product.qbsbuildconfig.resourcesInstallDir,
+ product.qbsbuildconfig.qmlTypeDescriptionsInstallDir, "qbs-bundle.json")
+ fileTags: ["qbs qml type bundle"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "Generating " + output.fileName;
+ cmd.highlight = "codegen";
+ cmd.sourceCode = function() {
+ var tf;
+ try {
+ var imports = File.directoryEntries(FileInfo.joinPaths(product.sourceDirectory,
+ "qbs", "imports", "qbs"),
+ File.Dirs | File.NoDotAndDotDot).filter(
+ function(i) { return i !== "base"; }).concat(
+ Utilities.builtinExtensionNames()).map(
+ function(i) { return "qbs." + i; });
+ imports.sort();
+ var obj = {
+ "name": "qbs",
+ "searchPaths": ["$(QBS_IMPORT_PATH)"],
+ "installPaths": ["$(QBS_IMPORT_PATH)"],
+ "implicitImports": ["__javascriptQt5__"],
+ "supportedImports": ["qbs"].concat(imports)
+ };
+ tf = new TextFile(output.filePath, TextFile.WriteOnly);
+ tf.writeLine(JSON.stringify(obj, undefined, 4));
+ } finally {
+ if (tf)
+ tf.close();
+ }
+ };
+ return cmd;
+ }
+ }
+
+ Group {
+ name: "QML Type Info"
+ fileTagsFilter: ["qbs qml type descriptions", "qbs qml type bundle"]
+ qbs.install: true
+ qbs.installSourceBase: project.buildDirectory
+ }
}