summaryrefslogtreecommitdiff
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
parent2e97dd0b29d17c0f81d6f2ad2dd947ba3f0ef2b9 (diff)
downloadqbs-6cb626668a0f5062afbd89a971dcc9488a6188d1.tar.gz
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>
-rw-r--r--qbs-resources/modules/qbsbuildconfig/qbsbuildconfig.qbs1
-rw-r--r--qbs.pro5
-rw-r--r--share/share.qbs81
-rw-r--r--static-res.pro59
4 files changed, 144 insertions, 2 deletions
diff --git a/qbs-resources/modules/qbsbuildconfig/qbsbuildconfig.qbs b/qbs-resources/modules/qbsbuildconfig/qbsbuildconfig.qbs
index 6e510a786..74613021d 100644
--- a/qbs-resources/modules/qbsbuildconfig/qbsbuildconfig.qbs
+++ b/qbs-resources/modules/qbsbuildconfig/qbsbuildconfig.qbs
@@ -28,4 +28,5 @@ Module {
}
property string resourcesInstallDir: ""
property string pluginsInstallDir: libDirName
+ property string qmlTypeDescriptionsInstallDir: "share/qbs/qml-type-descriptions"
}
diff --git a/qbs.pro b/qbs.pro
index 9a50c545a..c3fa48fac 100644
--- a/qbs.pro
+++ b/qbs.pro
@@ -37,7 +37,9 @@ src_app.depends = setupqtprofilelib
src_libexec.subdir = src/libexec
src_plugins.subdir = src/plugins
CONFIG(shared, static|shared): src_plugins.depends = corelib
-tests.depends = corelib src_plugins
+tests.depends = static_res
+static_res.file = static-res.pro
+static_res.depends = src_app src_libexec src_plugins static.pro
SUBDIRS += \
corelib\
setupqtprofilelib\
@@ -45,6 +47,7 @@ SUBDIRS += \
src_libexec\
src_plugins\
static.pro\
+ static_res\
tests
OTHER_FILES += \
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
+ }
}
diff --git a/static-res.pro b/static-res.pro
new file mode 100644
index 000000000..6ceae11cb
--- /dev/null
+++ b/static-res.pro
@@ -0,0 +1,59 @@
+TEMPLATE = aux
+
+!isEmpty(QBS_APPS_DESTDIR): qbsbindir = $${QBS_APPS_DESTDIR}
+else: qbsbindir = ../../../bin
+qbsbindir = $$clean_path(src/app/qbs/$$qbsbindir)
+
+builddirname = qbsres
+typedescdir = share/qbs/qml-type-descriptions
+typedescdir_src = $$builddirname/default/install-root/$$typedescdir
+!isEmpty(QBS_RESOURCES_BUILD_DIR): \
+ typedescdir_dst = $$QBS_RESOURCES_BUILD_DIR/$$typedescdir
+else: \
+ typedescdir_dst = $$typedescdir
+
+qbsres.target = $$builddirname/default/default.bg
+qbsres.commands = \
+ $$shell_quote($$shell_path($$qbsbindir/qbs)) \
+ setup-qt \
+ --settings-dir $$shell_quote($$builddirname/settings) \
+ $(QMAKE) qt $$escape_expand(\\n\\t) \
+ $$shell_quote($$shell_path($$qbsbindir/qbs)) \
+ build \
+ --settings-dir $$shell_quote($$builddirname/settings) \
+ -f $$shell_quote($$PWD/qbs.qbs) \
+ -d $$shell_quote($$builddirname) \
+ -p $$shell_quote("qbs resources") \
+ profile:qt
+
+qbsqmltypes.target = $$typedescdir_dst/qbs.qmltypes
+qbsqmltypes.commands = \
+ $$sprintf($$QMAKE_MKDIR_CMD, \
+ $$shell_quote($$shell_path($$typedescdir_dst))) $$escape_expand(\\n\\t) \
+ $$QMAKE_COPY \
+ $$shell_quote($$shell_path($$typedescdir_src/qbs.qmltypes)) \
+ $$shell_quote($$shell_path($$typedescdir_dst/qbs.qmltypes))
+qbsqmltypes.depends += qbsres
+
+qbsbundle.target = $$typedescdir_dst/qbs-bundle.json
+qbsbundle.commands = \
+ $$sprintf($$QMAKE_MKDIR_CMD, \
+ $$shell_quote($$shell_path($$typedescdir_dst))) $$escape_expand(\\n\\t) \
+ $$QMAKE_COPY \
+ $$shell_quote($$shell_path($$typedescdir_src/qbs-bundle.json)) \
+ $$shell_quote($$shell_path($$typedescdir_dst/qbs-bundle.json))
+qbsbundle.depends += qbsres
+
+QMAKE_EXTRA_TARGETS += qbsres qbsqmltypes qbsbundle
+
+PRE_TARGETDEPS += $$qbsqmltypes.target $$qbsbundle.target
+
+include(src/install_prefix.pri)
+
+qbstypedescfiles.files = $$qbsqmltypes.target $$qbsbundle.target
+!isEmpty(QBS_RESOURCES_INSTALL_DIR): \
+ installPrefix = $${QBS_RESOURCES_INSTALL_DIR}
+else: \
+ installPrefix = $${QBS_INSTALL_PREFIX}
+qbstypedescfiles.path = $${installPrefix}/$$typedescdir
+INSTALLS += qbstypedescfiles