Skip to content

Commit

Permalink
qbs build: Introduce new module "qtc".
Browse files Browse the repository at this point in the history
The qtc module gathers properties that used to live in the top-level
project file. This is the first step towards making it possible to build
plugins against an installed Qt Creator ("out of source build").

Change-Id: Ia1514cc9c888e80be01b308e908de48980fcbdb8
Reviewed-by: Joerg Bornemann <[email protected]>
  • Loading branch information
Christian Kandeler committed Jun 8, 2016
1 parent db9437c commit a0f956f
Show file tree
Hide file tree
Showing 48 changed files with 189 additions and 152 deletions.
8 changes: 4 additions & 4 deletions qbs/imports/QtcAutotest.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ QtcProduct {
+ FileInfo.relativePath(project.ide_source_tree, sourceDirectory)

cpp.rpaths: [
project.buildDirectory + '/' + project.ide_library_path,
project.buildDirectory + '/' + project.ide_plugin_path
project.buildDirectory + '/' + qtc.ide_library_path,
project.buildDirectory + '/' + qtc.ide_plugin_path
]
cpp.minimumOsxVersion: "10.7"
cpp.defines: base.filter(function(d) { return d != "QT_RESTRICTED_CAST_FROM_ASCII"; })
Expand All @@ -28,6 +28,6 @@ QtcProduct {
// absolute paths to resources in the build directory.
// cpp.rpaths: qbs.targetOS.contains("osx")
// ? ["@loader_path/../Frameworks", "@loader_path/../PlugIns"]
// : ["$ORIGIN/../" + project.libDirName + "/qtcreator",
// "$ORIGIN/../" project.libDirName + "/qtcreator/plugins"]
// : ["$ORIGIN/../" + qtc.libDirName + "/qtcreator",
// "$ORIGIN/../" qtc.libDirName + "/qtcreator/plugins"]
}
9 changes: 5 additions & 4 deletions qbs/imports/QtcDocumentation.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Product {
builtByDefault: false
type: [isOnlineDoc ? "qdoc-output" : "qch"]
Depends { name: "Qt.core" }
Depends { name: "qtc" }

property path mainDocConfFile
property bool isOnlineDoc
Expand All @@ -14,11 +15,11 @@ Product {
fileTags: ["qdocconf-main"]
}

property string versionTag: project.qtcreator_version.replace(/\.|-/g, "")
property string versionTag: qtc.qtcreator_version.replace(/\.|-/g, "")
Qt.core.qdocEnvironment: [
"QTC_LICENSE_TYPE=" + project.licenseType,
"QTC_VERSION=" + project.qtcreator_version,
"QTC_VERSION_TAG=" + project.qtcreator_version,
"QTC_VERSION=" + qtc.qtcreator_version,
"QTC_VERSION_TAG=" + qtc.qtcreator_version,
"SRCDIR=" + sourceDirectory,
"QT_INSTALL_DOCS=" + Qt.core.docPath,
"QDOC_INDEX_DIR=" + Qt.core.docPath,
Expand All @@ -28,6 +29,6 @@ Product {
Group {
fileTagsFilter: ["qch"]
qbs.install: !qbs.targetOS.contains("osx")
qbs.installDir: project.ide_doc_path
qbs.installDir: qtc.ide_doc_path
}
}
8 changes: 4 additions & 4 deletions qbs/imports/QtcLibrary.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import QtcFunctions

QtcProduct {
type: ["dynamiclibrary", "dynamiclibrary_symlink"]
installDir: project.ide_library_path
installDir: qtc.ide_library_path
Depends {
condition: project.testsEnabled
condition: qtc.testsEnabled
name: "Qt.test"
}

targetName: QtcFunctions.qtLibraryName(qbs, name)
destinationDirectory: project.ide_library_path
destinationDirectory: qtc.ide_library_path

cpp.linkerFlags: {
var flags = base;
if (qbs.buildVariant == "debug" && qbs.toolchain.contains("msvc"))
flags.push("/INCREMENTAL:NO"); // Speed up startup time when debugging with cdb
if (qbs.targetOS.contains("osx"))
flags.push("-compatibility_version", project.qtcreator_compat_version);
flags.push("-compatibility_version", qtc.qtcreator_compat_version);
return flags;
}
cpp.installNamePrefix: "@rpath"
Expand Down
8 changes: 4 additions & 4 deletions qbs/imports/QtcPlugin.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import QtcFunctions

QtcProduct {
type: ["dynamiclibrary", "pluginSpec"]
installDir: project.ide_plugin_path
installDir: qtc.ide_plugin_path

property var pluginJsonReplacements
property var pluginRecommends: []
Expand All @@ -14,12 +14,12 @@ QtcProduct {
condition: QtcFunctions.versionIsAtLeast(Qt.core.version, minimumQtVersion)

targetName: QtcFunctions.qtLibraryName(qbs, name)
destinationDirectory: project.ide_plugin_path
destinationDirectory: qtc.ide_plugin_path

Depends { name: "ExtensionSystem" }
Depends { name: "pluginjson" }
Depends {
condition: project.testsEnabled
condition: qtc.testsEnabled
name: "Qt.test"
}

Expand All @@ -34,7 +34,7 @@ QtcProduct {
if (qbs.buildVariant == "debug" && qbs.toolchain.contains("msvc"))
flags.push("/INCREMENTAL:NO"); // Speed up startup time when debugging with cdb
if (qbs.targetOS.contains("osx"))
flags.push("-compatibility_version", project.qtcreator_compat_version);
flags.push("-compatibility_version", qtc.qtcreator_compat_version);
return flags;
}

Expand Down
6 changes: 4 additions & 2 deletions qbs/imports/QtcProduct.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import qbs 1.0
import QtcFunctions

Product {
version: project.qtcreator_version
version: qtc.qtcreator_version
property bool install: true
property string installDir

Depends { name: "cpp" }
cpp.defines: project.generalDefines
Depends { name: "qtc" }

cpp.cxxLanguageVersion: "c++11"
cpp.defines: qtc.generalDefines
cpp.linkerFlags: {
var flags = [];
if (qbs.buildVariant == "release" && (qbs.toolchain.contains("gcc") || qbs.toolchain.contains("mingw")))
Expand Down
10 changes: 5 additions & 5 deletions qbs/imports/QtcTool.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import qbs.FileInfo
QtcProduct {
type: ["application"]
consoleApplication: true
installDir: project.ide_libexec_path
installDir: qtc.ide_libexec_path

cpp.rpaths: {
var relativePathToLibs = FileInfo.relativePath('/' + project.ide_libexec_path,
'/' + project.ide_library_path);
var relativePathToPlugins = FileInfo.relativePath('/' + project.ide_libexec_path,
'/' + project.ide_plugin_path);
var relativePathToLibs = FileInfo.relativePath('/' + qtc.ide_libexec_path,
'/' + qtc.ide_library_path);
var relativePathToPlugins = FileInfo.relativePath('/' + qtc.ide_libexec_path,
'/' + qtc.ide_plugin_path);
var prefix = qbs.targetOS.contains("osx") ? "@executable_path" : "$ORIGIN";
return [
FileInfo.joinPaths(prefix, relativePathToLibs),
Expand Down
19 changes: 11 additions & 8 deletions qbs/modules/pluginjson/pluginjson.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import qbs.FileInfo

Module {
Depends { id: qtcore; name: "Qt.core" }
Depends { name: "qtc" }

additionalProductTypes: ["qt_plugin_metadata"]

Expand Down Expand Up @@ -46,20 +47,22 @@ Module {
// replace quoted quotes
all = all.replace(/\\\"/g, '"');
// replace config vars
vars['QTCREATOR_VERSION'] = project.qtcreator_version;
vars['QTCREATOR_COMPAT_VERSION'] = project.qtcreator_compat_version;
vars['IDE_VERSION_MAJOR'] = project.ide_version_major;
vars['IDE_VERSION_MINOR'] = project.ide_version_minor;
vars['IDE_VERSION_RELEASE'] = project.ide_version_release;
var qtcVersion = product.moduleProperty("qtc", "qtcreator_version");
vars['QTCREATOR_VERSION'] = qtcVersion;
vars['QTCREATOR_COMPAT_VERSION']
= product.moduleProperty("qtc", "qtcreator_compat_version");
vars['IDE_VERSION_MAJOR'] = product.moduleProperty("qtc", "ide_version_major");
vars['IDE_VERSION_MINOR'] = product.moduleProperty("qtc", "ide_version_minor");
vars['IDE_VERSION_RELEASE'] = product.moduleProperty("qtc", "ide_version_release");
var deplist = [];
for (i in plugin_depends) {
deplist.push(" { \"Name\" : \"" + plugin_depends[i] + "\", \"Version\" : \"" + project.qtcreator_version + "\" }");
deplist.push(" { \"Name\" : \"" + plugin_depends[i] + "\", \"Version\" : \"" + qtcVersion + "\" }");
}
for (i in plugin_recommends) {
deplist.push(" { \"Name\" : \"" + plugin_recommends[i] + "\", \"Version\" : \"" + project.qtcreator_version + "\", \"Type\" : \"optional\" }");
deplist.push(" { \"Name\" : \"" + plugin_recommends[i] + "\", \"Version\" : \"" + qtcVersion + "\", \"Type\" : \"optional\" }");
}
for (i in plugin_test_depends) {
deplist.push(" { \"Name\" : \"" + plugin_test_depends[i] + "\", \"Version\" : \"" + project.qtcreator_version + "\", \"Type\" : \"test\" }");
deplist.push(" { \"Name\" : \"" + plugin_test_depends[i] + "\", \"Version\" : \"" + qtcVersion + "\", \"Type\" : \"test\" }");
}
deplist = deplist.join(",\n")
vars['dependencyList'] = "\"Dependencies\" : [\n" + deplist + "\n ]";
Expand Down
24 changes: 24 additions & 0 deletions qbs/modules/qbsbuildconfig/qbsbuildconfig.qbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import qbs
import qbs.FileInfo

Module {
Depends { name: "qtc" }

property bool enableUnitTests: false
property bool enableProjectFileUpdates: true
property bool installApiHeaders: false
property string libInstallDir: qtc.ide_library_path
property stringList libRPaths: qbs.targetOS.contains("osx")
? ["@loader_path/" + FileInfo.relativePath('/' + appInstallDir, '/' + libInstallDir)]
: ["$ORIGIN/..", "$ORIGIN/../" + qtc.ide_library_path]
property string resourcesInstallDir: qtc.ide_data_path + "/qbs"
property string pluginsInstallDir: qtc.ide_plugin_path
property string appInstallDir: qtc.ide_bin_path
property string libexecInstallDir: qtc.ide_libexec_path
property string relativeLibexecPath: FileInfo.relativePath('/' + appInstallDir,
'/' + libexecInstallDir)
property string relativePluginsPath: FileInfo.relativePath('/' + appInstallDir,
'/' + pluginsInstallDir)
property string relativeSearchPath: FileInfo.relativePath('/' + appInstallDir,
'/' + resourcesInstallDir)
}
57 changes: 57 additions & 0 deletions qbs/modules/qtc/qtc.qbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import qbs
import qbs.Environment

Module {
property string ide_version_major: '4'
property string ide_version_minor: '0'
property string ide_version_release: '82'
property string qtcreator_version: ide_version_major + '.' + ide_version_minor + '.'
+ ide_version_release

property string ide_compat_version_major: '4'
property string ide_compat_version_minor: '0'
property string ide_compat_version_release: '82'
property string qtcreator_compat_version: ide_compat_version_major + '.'
+ ide_compat_version_minor + '.' + ide_compat_version_release

property string libDirName: "lib"
property string ide_app_path: qbs.targetOS.contains("osx") ? "" : "bin"
property string ide_app_target: qbs.targetOS.contains("osx") ? "Qt Creator" : "qtcreator"
property string ide_library_path: {
if (qbs.targetOS.contains("osx"))
return ide_app_target + ".app/Contents/Frameworks"
else if (qbs.targetOS.contains("windows"))
return ide_app_path
else
return libDirName + "/qtcreator"
}
property string ide_plugin_path: {
if (qbs.targetOS.contains("osx"))
return ide_app_target + ".app/Contents/PlugIns"
else if (qbs.targetOS.contains("windows"))
return libDirName + "/qtcreator/plugins"
else
return ide_library_path + "/plugins"
}
property string ide_data_path: qbs.targetOS.contains("osx")
? ide_app_target + ".app/Contents/Resources"
: "share/qtcreator"
property string ide_libexec_path: qbs.targetOS.contains("osx")
? ide_data_path : qbs.targetOS.contains("windows")
? ide_app_path
: "libexec/qtcreator"
property string ide_bin_path: qbs.targetOS.contains("osx")
? ide_app_target + ".app/Contents/MacOS"
: ide_app_path
property string ide_doc_path: qbs.targetOS.contains("osx")
? ide_data_path + "/doc"
: "share/doc/qtcreator"

property bool testsEnabled: Environment.getEnv("TEST") || qbs.buildVariant === "debug"
property stringList generalDefines: [
"QT_CREATOR",
'IDE_LIBRARY_BASENAME="' + libDirName + '"',
"QT_NO_CAST_TO_ASCII",
"QT_RESTRICTED_CAST_FROM_ASCII"
].concat(testsEnabled ? ["WITH_TESTS"] : [])
}
55 changes: 5 additions & 50 deletions qtcreator.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,12 @@ Project {
minimumQbsVersion: "1.5.0"
property bool withAutotests: qbs.buildVariant === "debug"
property string licenseType: "opensource"
property string ide_version_major: '4'
property string ide_version_minor: '0'
property string ide_version_release: '82'
property string qtcreator_version: ide_version_major + '.' + ide_version_minor + '.' + ide_version_release
property string ide_compat_version_major: '4'
property string ide_compat_version_minor: '0'
property string ide_compat_version_release: '82'
property string qtcreator_compat_version: ide_compat_version_major + '.' + ide_compat_version_minor + '.' + ide_compat_version_release
property path ide_source_tree: path
property string ide_app_path: qbs.targetOS.contains("osx") ? "" : "bin"
property string ide_app_target: qbs.targetOS.contains("osx") ? "Qt Creator" : "qtcreator"
property pathList additionalPlugins: []
property pathList additionalLibs: []
property pathList additionalTools: []
property pathList additionalAutotests: []
property string sharedSourcesDir: path + "/src/shared"
property string libDirName: "lib"
property string ide_library_path: {
if (qbs.targetOS.contains("osx"))
return ide_app_target + ".app/Contents/Frameworks"
else if (qbs.targetOS.contains("windows"))
return ide_app_path
else
return libDirName + "/qtcreator"
}
property string ide_plugin_path: {
if (qbs.targetOS.contains("osx"))
return ide_app_target + ".app/Contents/PlugIns"
else if (qbs.targetOS.contains("windows"))
return libDirName + "/qtcreator/plugins"
else
return ide_library_path + "/plugins"
}
property string ide_data_path: qbs.targetOS.contains("osx")
? ide_app_target + ".app/Contents/Resources"
: "share/qtcreator"
property string ide_libexec_path: qbs.targetOS.contains("osx")
? ide_data_path : qbs.targetOS.contains("windows")
? ide_app_path
: "libexec/qtcreator"
property string ide_doc_path: qbs.targetOS.contains("osx")
? ide_data_path + "/doc"
: "share/doc/qtcreator"
property string ide_bin_path: qbs.targetOS.contains("osx")
? ide_app_target + ".app/Contents/MacOS"
: ide_app_path
property bool testsEnabled: Environment.getEnv("TEST") || qbs.buildVariant === "debug"
property stringList generalDefines: [
"QT_CREATOR",
'IDE_LIBRARY_BASENAME="' + libDirName + '"',
"QT_NO_CAST_TO_ASCII",
"QT_RESTRICTED_CAST_FROM_ASCII"
].concat(testsEnabled ? ["WITH_TESTS"] : [])
qbsSearchPaths: "qbs"

references: [
Expand All @@ -72,6 +25,7 @@ Project {

AutotestRunner {
Depends { name: "Qt.core" }
Depends { name: "qtc" }
environment: {
var env = base;
if (!qbs.hostOS.contains("windows") || !qbs.targetOS.contains("windows"))
Expand All @@ -85,9 +39,10 @@ Project {
}
var fullQtcInstallDir
= FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix, qbs.InstallDir);
var fullLibInstallDir = FileInfo.joinPaths(fullQtcInstallDir, project.ide_library_path);
var fullPluginInstallDir
= FileInfo.joinPaths(fullQtcInstallDir, project.ide_plugin_path);
var fullLibInstallDir = FileInfo.joinPaths(fullQtcInstallDir,
product.moduleProperty("ide", "ide_library_path"));
var fullPluginInstallDir = FileInfo.joinPaths(fullQtcInstallDir,
product.moduleProperty("qtc", "ide_plugin_path"));
path = Qt.core.binPath + ";" + fullLibInstallDir + ";" + fullPluginInstallDir
+ ";" + path;
var arrayElem = "PATH=" + path;
Expand Down
3 changes: 2 additions & 1 deletion share/qtcreator/translations/translations.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Product {
name: "Translations"
type: "qm"
Depends { name: "Qt.core" }
Depends { name: "qtc" }

Group {
files: ["*.ts"]
Expand All @@ -17,6 +18,6 @@ Product {
Group {
fileTagsFilter: product.type
qbs.install: true
qbs.installDir: project.ide_data_path + "/translations"
qbs.installDir: qtc.ide_data_path + "/translations"
}
}
7 changes: 4 additions & 3 deletions share/share.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import qbs 1.0

Product {
name: "SharedContent"
Depends { name: "qtc" }

Group {
name: "Unconditional"
qbs.install: true
qbs.installDir: project.ide_data_path
qbs.installDir: qtc.ide_data_path
qbs.installSourceBase: "qtcreator"
prefix: "qtcreator/"
files: [
Expand All @@ -31,7 +32,7 @@ Product {
Group {
name: "3rdparty"
qbs.install: true
qbs.installDir: project.ide_data_path
qbs.installDir: qtc.ide_data_path
qbs.installSourceBase: project.ide_source_tree + "/src/share/3rdparty"
prefix: project.ide_source_tree + "/src/share/3rdparty/"
files: [
Expand All @@ -42,7 +43,7 @@ Product {
Group {
name: "Conditional"
qbs.install: true
qbs.installDir: project.ide_data_path + "/externaltools"
qbs.installDir: qtc.ide_data_path + "/externaltools"
prefix: project.ide_source_tree + "/src/share/qtcreator/externaltools/"
files: {
var list = [
Expand Down
Loading

0 comments on commit a0f956f

Please sign in to comment.