Skip to content

Commit

Permalink
qbs build: Improve some base items
Browse files Browse the repository at this point in the history
Clean-up, simplification and modernization.
Also fix the bugs uncovered by this.

Change-Id: Ia3a77557f10faf9a901540a55fd6c07a2e986bf5
Reviewed-by: Christian Stenger <[email protected]>
  • Loading branch information
ckandeler committed Sep 18, 2023
1 parent 2842eee commit bdded29
Show file tree
Hide file tree
Showing 97 changed files with 232 additions and 278 deletions.
25 changes: 11 additions & 14 deletions qbs/imports/QtcAutotest.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@ import qbs
import qbs.FileInfo

QtcProduct {
// This needs to be absolute, because it is passed to one of the source files.
destinationDirectory: project.buildDirectory + '/'
+ FileInfo.relativePath(project.ide_source_tree, sourceDirectory)

targetName: "tst_" + name.split(' ').join("")
type: ["application", "autotest"]

installTags: []

Depends { name: "autotest" }
Depends { name: "Qt.testlib" }
Depends { name: "copyable_resource" }
targetName: "tst_" + name.split(' ').join("")

// This needs to be absolute, because it is passed to one of the source files.
destinationDirectory: project.buildDirectory + '/'
+ FileInfo.relativePath(project.ide_source_tree, sourceDirectory)

cpp.rpaths: [
project.buildDirectory + '/' + qtc.ide_library_path,
project.buildDirectory + '/' + qtc.ide_plugin_path
]
cpp.defines: {
var defines = base.filter(function(d) { return d !== "QT_RESTRICTED_CAST_FROM_ASCII"; });
var absLibExecPath = FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix,
Expand All @@ -25,11 +23,10 @@ QtcProduct {
defines.push('TEST_RELATIVE_LIBEXEC_PATH="' + relLibExecPath + '"');
return defines;
}

Group {
fileTagsFilter: product.type
qbs.install: false
}
cpp.rpaths: [
project.buildDirectory + '/' + qtc.ide_library_path,
project.buildDirectory + '/' + qtc.ide_plugin_path
]

// The following would be conceptually right, but does not work currently as some autotests
// (e.g. extensionsystem) do not work when installed, because they want hardcoded
Expand Down
2 changes: 0 additions & 2 deletions qbs/imports/QtcCommercialPlugin.qbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import qbs

QtcPlugin {
Depends { name: "LicenseChecker"; required: false }
cpp.defines: base.concat(LicenseChecker.present ? ["LICENSECHECKER"] : [])
Expand Down
28 changes: 14 additions & 14 deletions qbs/imports/QtcDocumentation.qbs
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import qbs
import qbs.FileInfo

Product {
builtByDefault: false
type: [isOnlineDoc ? "qdoc-output" : "qch"]

Depends { name: "Qt.core" }
Depends { name: "qtc" }

property path mainDocConfFile
property bool isOnlineDoc

Group {
name: "main qdocconf file"
prefix: product.sourceDirectory + '/'
files: [mainDocConfFile]
fileTags: ["qdocconf-main"]
}

property path mainDocConfFile
property string versionTag: qtc.qtcreator_version.replace(/\.|-/g, "")

Qt.core.qdocEnvironment: [
"IDE_DISPLAY_NAME=" + qtc.ide_display_name,
"IDE_ID=" + qtc.ide_id,
"IDE_CASED_ID=" + qtc.ide_cased_id,
"IDE_ID=" + qtc.ide_id,
"QTCREATOR_COPYRIGHT_YEAR=" + qtc.qtcreator_copyright_year,
"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,
"VERSION_TAG=" + versionTag
"SRCDIR=" + sourceDirectory,
"VERSION_TAG=" + versionTag,
]

Group {
fileTagsFilter: ["qch"]
name: "main qdocconf file"
prefix: product.sourceDirectory + '/'
files: mainDocConfFile
fileTags: "qdocconf-main"
}

Group {
fileTagsFilter: "qch"
qbs.install: !qbs.targetOS.contains("macos")
qbs.installDir: qtc.ide_doc_path
}
Expand Down
21 changes: 6 additions & 15 deletions qbs/imports/QtcLibrary.qbs
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import qbs 1.0
import qbs.FileInfo
import QtcFunctions

QtcProduct {
type: ["dynamiclibrary", "dynamiclibrary_symlink"]
destinationDirectory: FileInfo.joinPaths(project.buildDirectory, qtc.ide_library_path)
targetName: QtcFunctions.qtLibraryName(qbs, name)

installDir: qtc.ide_library_path
installTags: ["dynamiclibrary", "dynamiclibrary_symlink", "debuginfo_dll"]
installTags: type.concat("debuginfo_dll")
useNonGuiPchFile: true
Depends {
condition: qtc.testsEnabled
name: "Qt.testlib"
}

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

cpp.linkerFlags: {
var flags = base;
Expand All @@ -23,17 +18,13 @@ QtcProduct {
flags.push("-compatibility_version", qtc.qtcreator_compat_version);
return flags;
}
cpp.sonamePrefix: qbs.targetOS.contains("macos")
? "@rpath"
: undefined
cpp.sonamePrefix: qbs.targetOS.contains("macos") ? "@rpath" : undefined
cpp.rpaths: qbs.targetOS.contains("macos")
? ["@loader_path/../Frameworks"]
: ["$ORIGIN", "$ORIGIN/.."]
property string libIncludeBase: ".." // #include <lib/header.h>
cpp.includePaths: [libIncludeBase]

Export {
Depends { name: "cpp" }
cpp.includePaths: [exportingProduct.libIncludeBase]
cpp.includePaths: project.ide_source_tree + "/src/libs"
}
}
21 changes: 10 additions & 11 deletions qbs/imports/QtcManualtest.qbs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import qbs
import qbs.FileInfo

QtcProduct {
type: ["application"]
destinationDirectory: project.buildDirectory + '/'
+ FileInfo.relativePath(project.ide_source_tree, sourceDirectory)
targetName: "tst_" + name.split(' ').join("")
type: "application"

install: false

Depends { name: "Qt.testlib" }
Depends { name: "copyable_resource" }
targetName: "tst_" + name.split(' ').join("")

cpp.rpaths: [
project.buildDirectory + '/' + qtc.ide_library_path,
project.buildDirectory + '/' + qtc.ide_plugin_path
]
cpp.defines: {
var defines = base.filter(function(d) { return d !== "QT_RESTRICTED_CAST_FROM_ASCII"; });
return defines;
}

destinationDirectory: project.buildDirectory + '/'
+ FileInfo.relativePath(project.ide_source_tree, sourceDirectory)
install: false
cpp.rpaths: [
project.buildDirectory + '/' + qtc.ide_library_path,
project.buildDirectory + '/' + qtc.ide_plugin_path
]
}
49 changes: 20 additions & 29 deletions qbs/imports/QtcPlugin.qbs
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
import qbs 1.0
import qbs.FileInfo
import QtcFunctions

QtcProduct {
destinationDirectory: FileInfo.joinPaths(project.buildDirectory, qtc.ide_plugin_path)
name: project.name
targetName: QtcFunctions.qtLibraryName(qbs, name)
type: ["dynamiclibrary", "pluginSpec"]

installDir: qtc.ide_plugin_path
installTags: ["dynamiclibrary", "debuginfo_dll"]
useGuiPchFile: true

property var pluginRecommends: []
property var pluginTestDepends: []

targetName: QtcFunctions.qtLibraryName(qbs, name)
destinationDirectory: FileInfo.joinPaths(project.buildDirectory, qtc.ide_plugin_path)
property stringList pluginRecommends: []
property stringList pluginTestDepends: []

Depends { name: "Qt.testlib"; condition: qtc.testsEnabled }
Depends { name: "ExtensionSystem" }
Depends { name: "pluginjson" }
pluginjson.useVcsData: false
Depends {
condition: qtc.testsEnabled
name: "Qt.testlib"
}

Properties {
condition: qbs.targetOS.contains("unix")
cpp.internalVersion: ""
}
cpp.defines: base.concat([name.toUpperCase() + "_LIBRARY"])
cpp.sonamePrefix: qbs.targetOS.contains("macos")
? "@rpath"
: undefined
cpp.rpaths: qbs.targetOS.contains("macos")
? ["@loader_path/../Frameworks", "@loader_path/../PlugIns"]
: ["$ORIGIN", "$ORIGIN/.."]
Properties { cpp.internalVersion: ""; condition: qbs.targetOS.contains("unix") }
cpp.linkerFlags: {
var flags = base;
if (qbs.buildVariant == "debug" && qbs.toolchain.contains("msvc"))
Expand All @@ -41,20 +28,24 @@ QtcProduct {
flags.push("-compatibility_version", qtc.qtcreator_compat_version);
return flags;
}

property string pluginIncludeBase: ".." // #include <plugin/header.h>
cpp.includePaths: [pluginIncludeBase]
cpp.rpaths: qbs.targetOS.contains("macos")
? ["@loader_path/../Frameworks", "@loader_path/../PlugIns"]
: ["$ORIGIN", "$ORIGIN/.."]
cpp.sonamePrefix: qbs.targetOS.contains("macos")
? "@rpath"
: undefined
pluginjson.useVcsData: false

Group {
name: "PluginMetaData"
prefix: product.sourceDirectory + '/'
files: [ product.name + ".json.in" ]
fileTags: ["pluginJsonIn"]
prefix: sourceDirectory + '/'
files: product.name + ".json.in"
fileTags: "pluginJsonIn"
}

Export {
Depends { name: "ExtensionSystem" }
Depends { name: "cpp" }
cpp.includePaths: [exportingProduct.pluginIncludeBase]
Depends { name: "ExtensionSystem" }
cpp.includePaths: ".."
}
}
34 changes: 9 additions & 25 deletions qbs/imports/QtcProduct.qbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import qbs 1.0
import qbs.FileInfo
import qbs.Utilities
import QtcFunctions

Product {
name: project.name
version: qtc.qtcreator_version

property bool install: true
property string installDir
property string installSourceBase: destinationDirectory
property stringList installTags: type
property string fileName: FileInfo.fileName(sourceDirectory) + ".qbs"
property bool useNonGuiPchFile: false
property bool useGuiPchFile: false
property bool useQt: true
Expand All @@ -20,26 +17,14 @@ Product {
property bool sanitizable: true

Depends { name: "cpp" }
Depends { name: "qtc" }
Depends {
name: product.name + " dev headers";
required: false
Properties {
condition: Utilities.versionCompare(qbs.version, "1.13") >= 0
enableFallback: false
}
}
Depends {
name: "Qt"
condition: useQt
submodules: ["core", "core5compat"]
versionAtLeast: "6.2.0"
}

// TODO: Should fall back to what came from Qt.core for Qt < 5.7, but we cannot express that
// atm. Conditionally pulling in a module that sets the property is also not possible,
// because conflicting scalar values would be reported (QBS-1225 would fix that).
cpp.minimumMacosVersion: project.minimumMacosVersion
Depends { name: "qtc" }

cpp.cxxFlags: {
var flags = [];
Expand All @@ -62,7 +47,8 @@ Product {
}
return flags;
}

cpp.cxxLanguageVersion: "c++17"
cpp.defines: qtc.generalDefines
Properties {
condition: sanitizable && qbs.toolchain.contains("gcc")
cpp.driverFlags: {
Expand All @@ -76,9 +62,7 @@ Product {
return flags;
}
}

cpp.cxxLanguageVersion: "c++17"
cpp.defines: qtc.generalDefines
cpp.minimumMacosVersion: "10.15"
cpp.minimumWindowsVersion: "6.1"
cpp.useCxxPrecompiledHeader: useQt && (useNonGuiPchFile || useGuiPchFile)
cpp.visibility: "minimal"
Expand All @@ -94,15 +78,15 @@ Product {
name: "standard pch file (non-gui)"
condition: useNonGuiPchFile
prefix: pathToSharedSources + '/'
files: ["qtcreator_pch.h"]
fileTags: ["cpp_pch_src"]
files: "qtcreator_pch.h"
fileTags: "cpp_pch_src"
}

Group {
name: "standard pch file (gui)"
condition: useGuiPchFile
prefix: pathToSharedSources + '/'
files: ["qtcreator_gui_pch.h"]
fileTags: ["cpp_pch_src"]
files: "qtcreator_gui_pch.h"
fileTags: "cpp_pch_src"
}
}
1 change: 0 additions & 1 deletion qbs/imports/QtcTestApp.qbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import qbs
import qbs.FileInfo

CppApplication {
Expand Down
2 changes: 0 additions & 2 deletions qbs/imports/QtcTestFiles.qbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import qbs 1.0

Group {
name: "Unit tests"
condition: qtc.testsEnabled
Expand Down
6 changes: 3 additions & 3 deletions qbs/imports/QtcTool.qbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import qbs
import qbs.FileInfo

QtcProduct {
type: ["application"]
consoleApplication: true
type: "application"

installDir: qtc.ide_libexec_path
installTags: base.concat(["debuginfo_app"])
installTags: type.concat("debuginfo_app")
useNonGuiPchFile: true

cpp.rpaths: {
Expand Down
1 change: 0 additions & 1 deletion qtcreator.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import qbs.FileInfo
Project {
name: "Qt Creator"
minimumQbsVersion: "1.19.0"
property string minimumMacosVersion: "10.15"
property bool withAutotests: qbs.buildVariant === "debug"
property path ide_source_tree: path
property pathList additionalPlugins: []
Expand Down
Loading

0 comments on commit bdded29

Please sign in to comment.