summaryrefslogtreecommitdiff
path: root/qbs/modules
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2016-06-10 17:51:22 +0200
committerChristian Kandeler <christian.kandeler@theqtcompany.com>2016-06-15 12:35:55 +0000
commite1e203598dd876337e7c91e1d4da87f7dab7acf0 (patch)
treebb56bb035a00d0943ccbf28920bda7ac5597c77f /qbs/modules
parent96a3d49b07fa0119d11ed4f76d9f1fd5e86686ef (diff)
downloadqt-creator-e1e203598dd876337e7c91e1d4da87f7dab7acf0.tar.gz
qbs build: Final steps to support building plugins "out of source".
- Use the entire Export block when creating a module, not just the Depends items. Adapt references to the product source directory and the "share" directory so that they point to the respective locations in the install tree. - Install dev headers for some more plugins. - Bug fixes & polishing. Create a "dev installation" like this: $ qbs qtc.make_dev_package:true qbs.installRoot:<install root> Then build your plugin against it like this: $ qbs qtc.make_dev_package:true qbs.installRoot:<install root> project.qbsSearchPaths:<install root>/qbs-resources (Using qbs from 1.5 branch; 1.5.1 requires a trivial wrapper project.) That's all. Successfully tested with all commercial plugins on Linux. Change-Id: Ie39c4717dafcd431c533421a15f2f898783d8521 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'qbs/modules')
-rw-r--r--qbs/modules/qtc/qtc.js86
-rw-r--r--qbs/modules/qtc/qtc.qbs10
2 files changed, 46 insertions, 50 deletions
diff --git a/qbs/modules/qtc/qtc.js b/qbs/modules/qtc/qtc.js
index ebaa063a7e..6220f6dc9d 100644
--- a/qbs/modules/qtc/qtc.js
+++ b/qbs/modules/qtc/qtc.js
@@ -14,77 +14,67 @@ function getExportBlock(productFile)
}
if (line.indexOf('}') === exportIndex)
break;
- exportBlock += line + '\n';
+ exportBlock += " " + line.trim() + '\n';
}
return exportBlock;
}
-function getDependsItemsFromExportBlock(exportBlock)
+function insertOrAddToProperty(product, content, propertyName, value)
{
- var lines = exportBlock.split('\n');
- var dependsItems = ["Depends { name: 'cpp' }"];
- var dependsIndex = -1;
- var currentDependsItem;
- for (var i = 0; i < lines.length; ++i) {
- var line = lines[i];
- if (dependsIndex !== -1) {
- currentDependsItem += line;
- if (line.indexOf('}') === dependsIndex) {
- dependsItems.push(currentDependsItem);
- dependsIndex = -1;
- }
- continue;
- }
- dependsIndex = line.indexOf("Depends {");
- if (dependsIndex === -1)
- continue;
- if (line.contains('}')) {
- if (!dependsItems.contains("cpp"))
- dependsItems.push(line);
- dependsIndex = -1;
- } else {
- currentDependsItem = line;
- }
+ var valueAsList = '[' + value + ']';
+ var propertyNameIndex = content.indexOf(propertyName + ':');
+ if (propertyNameIndex !== -1) {
+ var endListIndex = content.indexOf(']', propertyNameIndex);
+ if (endListIndex === -1)
+ throw "Failed to parse Export item of product '" + product.name + "'";
+ var contentStart = content.slice(0, endListIndex + 1);
+ var contentEnd = content.slice(endListIndex + 1);
+ return contentStart + ".concat(" + valueAsList + ')' + contentEnd;
}
- return dependsItems;
+ return content + '\n' + propertyName + ": " + valueAsList;
}
-function getDependsItems(product)
+function transformedExportBlock(product, input, output)
{
- var productFilePath = FileInfo.joinPaths(product.sourceDirectory,
- FileInfo.fileName(product.sourceDirectory) + ".qbs");
+ var productFilePath = FileInfo.joinPaths(product.sourceDirectory, product.fileName);
var productFile = new TextFile(productFilePath, TextFile.ReadOnly);
try {
var exportBlock = getExportBlock(productFile);
- return getDependsItemsFromExportBlock(exportBlock);
+ exportBlock = " Depends { name: 'cpp' }\n" + exportBlock;
+ var modulePath = FileInfo.joinPaths("/",
+ product.moduleProperty("qtc", "ide_qbs_modules_path"), product.name);
+ var includePath = FileInfo.joinPaths("/",
+ product.moduleProperty("qtc", "ide_include_path"));
+ var relPathToIncludes = FileInfo.relativePath(modulePath, includePath);
+ var absPathToIncludes = "path + '/" + relPathToIncludes + "'";
+ exportBlock = exportBlock.replace(/product.sourceDirectory/g, absPathToIncludes + " + '/"
+ + FileInfo.fileName(product.sourceDirectory) + "'");
+ var dataPath = FileInfo.joinPaths("/", product.moduleProperty("qtc", "ide_data_path"));
+ var relPathToData = FileInfo.relativePath(modulePath, dataPath);
+ exportBlock = exportBlock.replace(/qtc.export_data_base/g, "path + '/"
+ + relPathToData + "'");
+ exportBlock = insertOrAddToProperty(product, exportBlock, "cpp.includePaths",
+ absPathToIncludes);
+ var libInstallPath = FileInfo.joinPaths("/", input.moduleProperty("qbs", "installDir"));
+ var relPathToLibrary = FileInfo.relativePath(modulePath, libInstallPath);
+ var fullPathToLibrary = "path + '/" + relPathToLibrary + "/" + input.fileName + "'";
+ var libType = input.fileTags.contains("dynamiclibrary") ? "dynamic" : "static";
+ exportBlock = insertOrAddToProperty(product, exportBlock, "cpp." + libType + "Libraries",
+ fullPathToLibrary);
+ return exportBlock;
} finally {
productFile.close();
}
}
-function writeModuleFile(product, input, output, dependsItems)
+function writeModuleFile(output, content)
{
var moduleFile = new TextFile(output.filePath, TextFile.WriteOnly);
try {
moduleFile.writeLine("import qbs");
moduleFile.writeLine("");
moduleFile.writeLine("Module {")
- for (var i = 0; i < dependsItems.length; ++i) {
- moduleFile.writeLine(" " + dependsItems[i].trim());
- moduleFile.writeLine("");
- }
- var includePath = FileInfo.joinPaths("/",
- product.moduleProperty("qtc", "ide_include_path"));
- var modulePath = FileInfo.joinPaths("/",
- product.moduleProperty("qtc", "ide_qbs_modules_path"), product.name);
- var relPathToIncludes = FileInfo.relativePath(modulePath, includePath);
- moduleFile.writeLine(" cpp.includePaths: [path + '/" + relPathToIncludes + "']");
- var libInstallPath = FileInfo.joinPaths("/", input.moduleProperty("qbs", "installPrefix"),
- input.moduleProperty("qbs", "installDir"));
- var relPathToLibrary = FileInfo.relativePath(modulePath, libInstallPath);
- var libType = input.fileTags.contains("dynamiclibrary") ? "dynamic" : "static";
- moduleFile.writeLine(" cpp." + libType + "Libraries: [path + '/"
- + relPathToLibrary + "/" + input.fileName + "']");
+ moduleFile.writeLine(content);
moduleFile.writeLine("}");
} finally {
moduleFile.close();
diff --git a/qbs/modules/qtc/qtc.qbs b/qbs/modules/qtc/qtc.qbs
index 1e1b8f90f2..42f61b981b 100644
--- a/qbs/modules/qtc/qtc.qbs
+++ b/qbs/modules/qtc/qtc.qbs
@@ -54,6 +54,9 @@ Module {
property bool make_dev_package: false
+ // Will be replaced when creating modules from products
+ property string export_data_base: project.ide_source_tree + "/share/qtcreator"
+
property bool testsEnabled: Environment.getEnv("TEST") || qbs.buildVariant === "debug"
property stringList generalDefines: [
"QT_CREATOR",
@@ -65,6 +68,7 @@ Module {
Rule {
condition: make_dev_package
inputs: [product.type.contains("dynamiclibrary") ? "dynamiclibrary" : "staticlibrary"]
+ explicitlyDependsOn: ["qbs"]
Artifact {
filePath: product.name + "-module.qbs"
fileTags: ["qtc.dev-module"]
@@ -73,8 +77,10 @@ Module {
var cmd = new JavaScriptCommand();
cmd.description = "Creating " + output.fileName;
cmd.sourceCode = function() {
- var dependsItems = HelperFunctions.getDependsItems(product);
- HelperFunctions.writeModuleFile(product, input, output, dependsItems);
+ var transformedExportBlock = HelperFunctions.transformedExportBlock(product, input,
+ output);
+ HelperFunctions.writeModuleFile(output, transformedExportBlock);
+
};
return [cmd];
}