qbs build: More steps toward creating a "development installation".

Namely:
    - Install header files.
    - Install imports and modules.
    - Create modules from products and install them.

This is most of what we need. The main thing still left to do is
dealing with paths in Export items. These have to be translated
somehow. (Currently we only copy the Depends items out of the
Export items and ignore everything else.)

Change-Id: I12d49fa31d1c1e05bc77a0e0ce3ec9c78c27192a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Christian Kandeler
2016-06-08 17:10:04 +02:00
parent 44771d245b
commit f085cb2236
23 changed files with 2263 additions and 2047 deletions

View File

@@ -0,0 +1,6 @@
import qbs
QtcPlugin {
Depends { name: "LicenseChecker"; required: false }
cpp.defines: base.concat(LicenseChecker.present ? ["LICENSECHECKER"] : [])
}

View File

@@ -0,0 +1,15 @@
import qbs
import qbs.FileInfo
Product {
property string productName: project.name
name: productName + " dev headers"
condition: qtc.make_dev_package
Depends { name: "qtc" }
Group {
files: ["**/*.h"]
qbs.install: true
qbs.installDir: qtc.ide_include_path + '/' + FileInfo.fileName(product.sourceDirectory)
qbs.installSourceBase: product.sourceDirectory
}
}

View File

@@ -2,8 +2,9 @@ import qbs 1.0
import QtcFunctions import QtcFunctions
QtcProduct { QtcProduct {
type: ["dynamiclibrary", "dynamiclibrary_symlink"] type: ["dynamiclibrary", "dynamiclibrary_symlink", "qtc.dev-module"]
installDir: qtc.ide_library_path installDir: qtc.ide_library_path
installTags: ["dynamiclibrary", "dynamiclibrary_symlink"]
Depends { Depends {
condition: qtc.testsEnabled condition: qtc.testsEnabled
name: "Qt.test" name: "Qt.test"

View File

@@ -3,8 +3,9 @@ import qbs.FileInfo
import QtcFunctions import QtcFunctions
QtcProduct { QtcProduct {
type: ["dynamiclibrary", "pluginSpec"] type: ["dynamiclibrary", "pluginSpec", "qtc.dev-module"]
installDir: qtc.ide_plugin_path installDir: qtc.ide_plugin_path
installTags: ["dynamiclibrary"]
property var pluginJsonReplacements property var pluginJsonReplacements
property var pluginRecommends: [] property var pluginRecommends: []

View File

@@ -2,12 +2,15 @@ import qbs 1.0
import QtcFunctions import QtcFunctions
Product { Product {
name: project.name
version: qtc.qtcreator_version version: qtc.qtcreator_version
property bool install: true property bool install: true
property string installDir property string installDir
property stringList installTags: type
Depends { name: "cpp" } Depends { name: "cpp" }
Depends { name: "qtc" } Depends { name: "qtc" }
Depends { name: product.name + " dev headers"; required: false }
cpp.cxxLanguageVersion: "c++11" cpp.cxxLanguageVersion: "c++11"
cpp.defines: qtc.generalDefines cpp.defines: qtc.generalDefines
@@ -24,8 +27,14 @@ Product {
Depends { name: "Qt.core" } Depends { name: "Qt.core" }
Group { Group {
fileTagsFilter: product.type fileTagsFilter: installTags
qbs.install: install qbs.install: install
qbs.installDir: installDir qbs.installDir: installDir
} }
Group {
fileTagsFilter: ["qtc.dev-module"]
qbs.install: true
qbs.installDir: qtc.ide_qbs_modules_path + '/' + product.name
}
} }

92
qbs/modules/qtc/qtc.js Normal file
View File

@@ -0,0 +1,92 @@
var File = loadExtension("qbs.File");
var FileInfo = loadExtension("qbs.FileInfo");
var TextFile = loadExtension("qbs.TextFile");
function getExportBlock(productFile)
{
var exportBlock = "";
var exportIndex = -1;
while (!productFile.atEof()) {
var line = productFile.readLine();
if (exportIndex === -1) {
exportIndex = line.indexOf("Export {");
continue;
}
if (line.indexOf('}') === exportIndex)
break;
exportBlock += line + '\n';
}
return exportBlock;
}
function getDependsItemsFromExportBlock(exportBlock)
{
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;
}
}
return dependsItems;
}
function getDependsItems(product)
{
var productFilePath = FileInfo.joinPaths(product.sourceDirectory,
FileInfo.fileName(product.sourceDirectory) + ".qbs");
var productFile = new TextFile(productFilePath, TextFile.ReadOnly);
try {
var exportBlock = getExportBlock(productFile);
return getDependsItemsFromExportBlock(exportBlock);
} finally {
productFile.close();
}
}
function writeModuleFile(product, input, output, dependsItems)
{
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("}");
} finally {
moduleFile.close();
}
}

View File

@@ -1,5 +1,6 @@
import qbs import qbs
import qbs.Environment import qbs.Environment
import "qtc.js" as HelperFunctions
Module { Module {
property string ide_version_major: '4' property string ide_version_major: '4'
@@ -46,6 +47,12 @@ Module {
property string ide_doc_path: qbs.targetOS.contains("osx") property string ide_doc_path: qbs.targetOS.contains("osx")
? ide_data_path + "/doc" ? ide_data_path + "/doc"
: "share/doc/qtcreator" : "share/doc/qtcreator"
property string ide_include_path: "include"
property string ide_qbs_resources_path: "qbs-resources"
property string ide_qbs_modules_path: ide_qbs_resources_path + "/modules"
property string ide_qbs_imports_path: ide_qbs_resources_path + "/imports"
property bool make_dev_package: false
property bool testsEnabled: Environment.getEnv("TEST") || qbs.buildVariant === "debug" property bool testsEnabled: Environment.getEnv("TEST") || qbs.buildVariant === "debug"
property stringList generalDefines: [ property stringList generalDefines: [
@@ -54,4 +61,22 @@ Module {
"QT_NO_CAST_TO_ASCII", "QT_NO_CAST_TO_ASCII",
"QT_RESTRICTED_CAST_FROM_ASCII" "QT_RESTRICTED_CAST_FROM_ASCII"
].concat(testsEnabled ? ["WITH_TESTS"] : []) ].concat(testsEnabled ? ["WITH_TESTS"] : [])
Rule {
condition: make_dev_package
inputs: ["dynamiclibrary", "staticlibrary"]
Artifact {
filePath: product.name + "-module.qbs"
fileTags: ["qtc.dev-module"]
}
prepare: {
var cmd = new JavaScriptCommand();
cmd.description = "Creating " + output.fileName;
cmd.sourceCode = function() {
var dependsItems = HelperFunctions.getDependsItems(product);
HelperFunctions.writeModuleFile(product, input, output, dependsItems);
};
return [cmd];
}
}
} }

View File

@@ -23,6 +23,18 @@ Project {
"tests/tests.qbs" "tests/tests.qbs"
] ]
Product {
name: "qbs_imports_modules"
Depends { name: "qtc" }
Group {
prefix: "qbs/"
files: ["**/*"]
qbs.install: qtc.make_dev_package
qbs.installDir: qtc.ide_qbs_resources_path
qbs.installSourceBase: "qbs"
}
}
AutotestRunner { AutotestRunner {
Depends { name: "Qt.core" } Depends { name: "Qt.core" }
Depends { name: "qtc" } Depends { name: "qtc" }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcLibrary { Project {
name: "Aggregation" name: "Aggregation"
QtcDevHeaders { }
QtcLibrary {
Depends { name: "Qt.core" } Depends { name: "Qt.core" }
cpp.defines: base.concat("AGGREGATION_LIBRARY") cpp.defines: base.concat("AGGREGATION_LIBRARY")
@@ -11,4 +14,6 @@ QtcLibrary {
"aggregate.h", "aggregate.h",
"aggregation_global.h", "aggregation_global.h",
] ]
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcLibrary { Project {
name: "ExtensionSystem" name: "ExtensionSystem"
QtcDevHeaders { }
QtcLibrary {
cpp.defines: base.concat([ cpp.defines: base.concat([
"EXTENSIONSYSTEM_LIBRARY", "EXTENSIONSYSTEM_LIBRARY",
"IDE_TEST_DIR=\".\"" "IDE_TEST_DIR=\".\""
@@ -49,4 +52,5 @@ QtcLibrary {
Export { Export {
Depends { name: "Qt.core" } Depends { name: "Qt.core" }
} }
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcLibrary { Project {
name: "QmlDebug" name: "QmlDebug"
QtcDevHeaders { }
QtcLibrary {
cpp.defines: base.concat("QMLDEBUG_LIB") cpp.defines: base.concat("QMLDEBUG_LIB")
Depends { name: "Qt"; submodules: ["gui", "network"] } Depends { name: "Qt"; submodules: ["gui", "network"] }
@@ -35,5 +38,5 @@ QtcLibrary {
"qpacketprotocol.cpp", "qpacketprotocol.cpp",
"qpacketprotocol.h", "qpacketprotocol.h",
] ]
}
} }

View File

@@ -1,9 +1,12 @@
import qbs 1.0 import qbs 1.0
import qbs.Environment import qbs.Environment
QtcLibrary { Project {
name: "QtcSsh" name: "QtcSsh"
QtcDevHeaders { }
QtcLibrary {
cpp.defines: base.concat(["QSSH_LIBRARY"]).concat(botanDefines) cpp.defines: base.concat(["QSSH_LIBRARY"]).concat(botanDefines)
cpp.includePaths: botanIncludes cpp.includePaths: botanIncludes
cpp.dynamicLibraries: botanLibs cpp.dynamicLibraries: botanLibs
@@ -127,4 +130,5 @@ QtcLibrary {
Export { Export {
Depends { name: "Qt"; submodules: ["widgets", "network"] } Depends { name: "Qt"; submodules: ["widgets", "network"] }
} }
}
} }

View File

@@ -2,9 +2,12 @@ import qbs 1.0
import QtcLibrary import QtcLibrary
QtcLibrary { Project {
name: "Timeline" name: "Timeline"
QtcDevHeaders { }
QtcLibrary {
Depends { name: "Qt"; submodules: ["qml", "quick", "gui"] } Depends { name: "Qt"; submodules: ["qml", "quick", "gui"] }
Depends { name: "Utils" } Depends { name: "Utils" }
@@ -36,4 +39,5 @@ QtcLibrary {
} }
cpp.defines: base.concat("TIMELINE_LIBRARY") cpp.defines: base.concat("TIMELINE_LIBRARY")
}
} }

View File

@@ -1,9 +1,13 @@
import qbs 1.0 import qbs 1.0
import qbs.FileInfo import qbs.FileInfo
QtcLibrary { Project {
name: "Utils" name: "Utils"
QtcDevHeaders { }
QtcLibrary {
cpp.defines: base.concat([ cpp.defines: base.concat([
"QTCREATOR_UTILS_LIB", "QTCREATOR_UTILS_LIB",
"QTC_REL_TOOLS_PATH=\"" + FileInfo.relativePath('/' + qtc.ide_bin_path, "QTC_REL_TOOLS_PATH=\"" + FileInfo.relativePath('/' + qtc.ide_bin_path,
@@ -304,5 +308,5 @@ QtcLibrary {
Export { Export {
Depends { name: "Qt"; submodules: ["concurrent", "widgets" ] } Depends { name: "Qt"; submodules: ["concurrent", "widgets" ] }
} }
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcPlugin { Project {
name: "Android" name: "Android"
QtcDevHeaders { }
QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "xml", "network"] } Depends { name: "Qt"; submodules: ["widgets", "xml", "network"] }
Depends { name: "Core" } Depends { name: "Core" }
Depends { name: "Debugger" } Depends { name: "Debugger" }
@@ -101,4 +104,5 @@ QtcPlugin {
"javaparser.cpp", "javaparser.cpp",
"javaparser.h", "javaparser.h",
] ]
}
} }

View File

@@ -1,14 +1,15 @@
import qbs 1.0 import qbs 1.0
import qbs.FileInfo import qbs.FileInfo
QtcPlugin { Project {
name: "Core" name: "Core"
QtcDevHeaders { }
QtcPlugin {
Depends { Depends {
name: "Qt" name: "Qt"
submodules: [ submodules: ["widgets", "xml", "network", "qml", "sql", "help", "printsupport"]
"widgets", "xml", "network", "qml", "sql", "help", "printsupport"
]
} }
Depends { Depends {
@@ -22,10 +23,8 @@ QtcPlugin {
Depends { name: "app_version_header" } Depends { name: "app_version_header" }
cpp.dynamicLibraries: { cpp.dynamicLibraries: {
if (qbs.targetOS.contains("windows")) return [ if (qbs.targetOS.contains("windows"))
"ole32", return ["ole32", "user32"]
"user32"
]
} }
cpp.frameworks: qbs.targetOS.contains("osx") ? ["AppKit"] : undefined cpp.frameworks: qbs.targetOS.contains("osx") ? ["AppKit"] : undefined
@@ -300,4 +299,5 @@ QtcPlugin {
Depends { name: "Aggregation" } Depends { name: "Aggregation" }
Depends { name: "Utils" } Depends { name: "Utils" }
} }
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcPlugin { Project {
name: "Debugger" name: "Debugger"
QtcDevHeaders { }
QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "network"] } Depends { name: "Qt"; submodules: ["widgets", "network"] }
Depends { name: "Aggregation" } Depends { name: "Aggregation" }
Depends { name: "CPlusPlus" } Depends { name: "CPlusPlus" }
@@ -105,11 +108,11 @@ QtcPlugin {
name: "cdb" name: "cdb"
prefix: "cdb/" prefix: "cdb/"
files: [ files: [
"stringinputstream.cpp", "stringinputstream.h",
"cdbengine.cpp", "cdbengine.h", "cdbengine.cpp", "cdbengine.h",
"cdboptionspage.cpp", "cdboptionspage.h", "cdboptionspage.cpp", "cdboptionspage.h",
"cdboptionspagewidget.ui", "cdboptionspagewidget.ui",
"cdbparsehelpers.cpp", "cdbparsehelpers.h" "cdbparsehelpers.cpp", "cdbparsehelpers.h",
"stringinputstream.cpp", "stringinputstream.h",
] ]
} }
@@ -281,4 +284,5 @@ QtcPlugin {
Depends { name: "QtcSsh" } Depends { name: "QtcSsh" }
Depends { name: "CPlusPlus" } Depends { name: "CPlusPlus" }
} }
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcPlugin { Project {
name: "ProjectExplorer" name: "ProjectExplorer"
QtcDevHeaders { }
QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "qml"] } Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "qml"] }
Depends { name: "Qt.quick" } Depends { name: "Qt.quick" }
Depends { name: "Aggregation" } Depends { name: "Aggregation" }
@@ -260,4 +263,5 @@ QtcPlugin {
Export { Export {
Depends { name: "Qt.network" } Depends { name: "Qt.network" }
} }
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcPlugin { Project {
name: "QmakeProjectManager" name: "QmakeProjectManager"
QtcDevHeaders { }
QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "network"] } Depends { name: "Qt"; submodules: ["widgets", "network"] }
Depends { name: "QmlJS" } Depends { name: "QmlJS" }
Depends { name: "Utils" } Depends { name: "Utils" }
@@ -108,4 +111,5 @@ QtcPlugin {
Depends { name: "cpp" } Depends { name: "cpp" }
cpp.includePaths: [project.sharedSourcesDir] cpp.includePaths: [project.sharedSourcesDir]
} }
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcPlugin { Project {
name: "QtSupport" name: "QtSupport"
QtcDevHeaders { }
QtcPlugin {
Depends { name: "Qt"; submodules: ["quick", "widgets", "xml"]; } Depends { name: "Qt"; submodules: ["quick", "widgets", "xml"]; }
Depends { name: "QmlJS" } Depends { name: "QmlJS" }
Depends { name: "Utils" } Depends { name: "Utils" }
@@ -130,4 +133,5 @@ QtcPlugin {
"PROEVALUATOR_SETENV" "PROEVALUATOR_SETENV"
] ]
} }
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcPlugin { Project {
name: "RemoteLinux" name: "RemoteLinux"
QtcDevHeaders { }
QtcPlugin {
Depends { name: "Qt.widgets" } Depends { name: "Qt.widgets" }
Depends { name: "QtcSsh" } Depends { name: "QtcSsh" }
Depends { name: "QmlDebug" } Depends { name: "QmlDebug" }
@@ -117,5 +120,5 @@ QtcPlugin {
Depends { name: "Core" } Depends { name: "Core" }
Depends { name: "QtcSsh" } Depends { name: "QtcSsh" }
} }
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcPlugin { Project {
name: "ResourceEditor" name: "ResourceEditor"
QtcDevHeaders { }
QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "xml"] } Depends { name: "Qt"; submodules: ["widgets", "xml"] }
Depends { name: "Aggregation" } Depends { name: "Aggregation" }
Depends { name: "ProjectExplorer" } Depends { name: "ProjectExplorer" }
@@ -34,4 +37,5 @@ QtcPlugin {
"undocommands.cpp", "undocommands_p.h", "undocommands.cpp", "undocommands_p.h",
] ]
} }
}
} }

View File

@@ -1,8 +1,11 @@
import qbs 1.0 import qbs 1.0
QtcPlugin { Project {
name: "TextEditor" name: "TextEditor"
QtcDevHeaders { }
QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "printsupport"] } Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "printsupport"] }
Depends { name: "Aggregation" } Depends { name: "Aggregation" }
Depends { name: "Utils" } Depends { name: "Utils" }
@@ -272,4 +275,5 @@ QtcPlugin {
"texteditor_test.cpp", "texteditor_test.cpp",
] ]
} }
}
} }