aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2015-07-23 14:39:19 -0700
committerJake Petroules <jake.petroules@petroules.com>2015-09-02 15:42:16 +0000
commit7069834085fdcaad1587c8f3fd1918cc4b168cdd (patch)
treed91d3c59e9c780c4232043e88b6aba367610f21b
parent09f2e967ceb2c1cb4c21822e9fce6ef3a0e819c8 (diff)
Let Qbs build its own Windows ZIP distribution.
Change-Id: Id633922727fd715750547f4c27cac6f604abe28a Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r--dist/dist.qbs131
-rw-r--r--qbs.qbs1
-rw-r--r--share/qbs/imports/qbs/ModUtils/utils.js16
3 files changed, 148 insertions, 0 deletions
diff --git a/dist/dist.qbs b/dist/dist.qbs
new file mode 100644
index 000000000..a43f5820e
--- /dev/null
+++ b/dist/dist.qbs
@@ -0,0 +1,131 @@
+import qbs
+import qbs.FileInfo
+import qbs.ModUtils
+import qbs.Process
+import qbs.TextFile
+import QbsFunctions
+
+Product {
+ Depends { name: "qbs-config" }
+ Depends { name: "qbs-config-ui" }
+ Depends { name: "qbs-qmltypes" }
+ Depends { name: "qbs-setup-android" }
+ Depends { name: "qbs-setup-qt" }
+ Depends { name: "qbs-setup-toolchains" }
+ Depends { name: "qbs_app" }
+ Depends { name: "qbscore" }
+ Depends { name: "qbsqtprofilesetup" }
+ Depends { name: "qbs_cpp_scanner" }
+ Depends { name: "qbs_qt_scanner" }
+ Depends { name: "documentation" }
+ Depends { name: "qbs resources" }
+
+ Depends { name: "archiver" }
+ Depends { name: "Qt.core" }
+
+ condition: qbs.targetOS.contains("windows")
+ builtByDefault: false
+ type: ["archiver.archive"]
+ targetName: "qbs-windows-" + qbs.architecture + "-" + QbsFunctions.qbsVersion()
+ destinationDirectory: project.buildDirectory
+
+ archiver.type: "zip"
+ archiver.workingDirectory: qbs.installRoot
+
+ Rule {
+ multiplex: true
+ inputsFromDependencies: ["installable"]
+
+ Artifact {
+ filePath: "windeployqt.json"
+ fileTags: ["dependencies.json"]
+ }
+
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "windeployqt";
+ cmd.outputFilePath = output.filePath;
+ cmd.installRoot = product.moduleProperty("qbs", "installRoot");
+ cmd.binaryFilePaths = inputs.installable.filter(function (artifact) {
+ return artifact.fileTags.contains("application")
+ || artifact.fileTags.contains("dynamiclibrary");
+ }).map(ModUtils.artifactInstalledFilePath);
+ cmd.sourceCode = function () {
+ var out;
+ var process;
+ try {
+ process = new Process();
+ process.exec(FileInfo.joinPaths(product.moduleProperty("Qt.core", "binPath"),
+ "windeployqt"), ["--json"]
+ .concat(binaryFilePaths), true);
+ out = process.readStdOut();
+ } finally {
+ if (process)
+ process.close();
+ }
+
+ var tf;
+ try {
+ tf = new TextFile(outputFilePath, TextFile.WriteOnly);
+ tf.write(out);
+ } finally {
+ if (tf)
+ tf.close();
+ }
+ };
+ return [cmd];
+ }
+ }
+
+ Rule {
+ multiplex: true
+ inputs: ["dependencies.json"]
+ inputsFromDependencies: ["installable"]
+
+ Artifact {
+ filePath: "list.txt"
+ fileTags: ["archiver.input-list"]
+ }
+
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.silent = true;
+ cmd.inputFilePaths = inputs.installable.map(ModUtils.artifactInstalledFilePath);
+ cmd.outputFilePath = output.filePath;
+ cmd.installRoot = product.moduleProperty("qbs", "installRoot");
+ cmd.sourceCode = function() {
+ var tf;
+ for (var i = 0; i < inputs["dependencies.json"].length; ++i) {
+ try {
+ tf = new TextFile(inputs["dependencies.json"][i].filePath,
+ TextFile.ReadOnly);
+ inputFilePaths = inputFilePaths.concat(
+ JSON.parse(tf.readAll())["files"].map(function (obj) {
+ return FileInfo.joinPaths(
+ FileInfo.fromWindowsSeparators(obj.target),
+ FileInfo.fileName(
+ FileInfo.fromWindowsSeparators(
+ obj.source)));
+ }));
+ } finally {
+ if (tf)
+ tf.close();
+ }
+ }
+
+ inputFilePaths.sort();
+
+ try {
+ tf = new TextFile(outputFilePath, TextFile.ReadWrite);
+ for (var i = 0; i < inputFilePaths.length; ++i)
+ tf.writeLine(FileInfo.relativePath(installRoot, inputFilePaths[i]));
+ } finally {
+ if (tf)
+ tf.close();
+ }
+ };
+
+ return [cmd];
+ }
+ }
+}
diff --git a/qbs.qbs b/qbs.qbs
index eac936a01..94d1d324f 100644
--- a/qbs.qbs
+++ b/qbs.qbs
@@ -27,6 +27,7 @@ Project {
property string pluginsInstallDir: libDirName
references: [
+ "dist/dist.qbs",
"doc/doc.qbs",
"share/share.qbs",
"src/src.qbs",
diff --git a/share/qbs/imports/qbs/ModUtils/utils.js b/share/qbs/imports/qbs/ModUtils/utils.js
index 6498ade9b..61a43cc88 100644
--- a/share/qbs/imports/qbs/ModUtils/utils.js
+++ b/share/qbs/imports/qbs/ModUtils/utils.js
@@ -33,6 +33,22 @@ var FileInfo = loadExtension("qbs.FileInfo");
var Process = loadExtension("qbs.Process");
var TemporaryDir = loadExtension("qbs.TemporaryDir");
+function artifactInstalledFilePath(artifact, product) {
+ var relativeInstallDir = artifact.moduleProperty("qbs", "installDir");
+ var installPrefix = artifact.moduleProperty("qbs", "installPrefix");
+ var installSourceBase = artifact.moduleProperty("qbs", "installSourceBase");
+ var targetDir = FileInfo.joinPaths(artifact.moduleProperty("qbs", "installRoot"),
+ installPrefix, relativeInstallDir);
+ if (installSourceBase) {
+ if (!FileInfo.isAbsolutePath(installSourceBase))
+ throw "installSourceBase is not an absolute path";
+ if (!artifact.filePath.startsWith(installSourceBase))
+ throw "artifact file path doesn't start with the value of qbs.installSourceBase";
+ return FileInfo.joinPaths(targetDir, artifact.filePath.substr(installSourceBase.length + 1));
+ }
+ return FileInfo.joinPaths(targetDir, artifact.fileName);
+}
+
/**
* Given a list of file tags, returns the file tag (one of [c, cpp, objc, objcpp])
* corresponding to the C-family language the file should be compiled as.