From 54ed620f35f19600195e9057cfcf5bc01573f396 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 21 Jun 2013 13:12:30 +0200 Subject: [PATCH] Refactor qbs project files. - Use sub-projects. - Move the main application and the application header products into dedicated files. As a result, qtcreator.qbs becomes much simpler to understand, consisting now of just a bunch of global properties and a few sub-project references. Change-Id: Ic7300d489d3982394be5ad1d12a79a2914320298 Reviewed-by: Joerg Bornemann --- qbs/pluginspec/pluginspec.qbs | 2 +- qtcreator.qbs | 196 +-------------------------------- src/app/app.qbs | 70 ++++++++++++ src/app/app_version_header.qbs | 53 +++++++++ src/libs/libs.qbs | 21 ++++ src/plugins/QtcPlugin.qbs | 1 + src/plugins/plugins.qbs | 61 ++++++++++ src/src.qbs | 12 ++ src/tools/tools.qbs | 11 ++ 9 files changed, 231 insertions(+), 196 deletions(-) create mode 100644 src/app/app.qbs create mode 100644 src/app/app_version_header.qbs create mode 100644 src/libs/libs.qbs create mode 100644 src/plugins/plugins.qbs create mode 100644 src/src.qbs create mode 100644 src/tools/tools.qbs diff --git a/qbs/pluginspec/pluginspec.qbs b/qbs/pluginspec/pluginspec.qbs index e3d256376d6..d2035389e1e 100644 --- a/qbs/pluginspec/pluginspec.qbs +++ b/qbs/pluginspec/pluginspec.qbs @@ -87,7 +87,7 @@ Module { } prepare: { - var xslFile = project.path + "/src/pluginjsonmetadata.xsl"; + var xslFile = project.path + "/../pluginjsonmetadata.xsl"; // project is "Plugins" var xmlPatternsPath = product.moduleProperty("Qt/core", "binPath") + "/xmlpatterns"; var args = [ "-no-format", diff --git a/qtcreator.qbs b/qtcreator.qbs index 6e0ff79f3ea..bcf6b5ac36f 100644 --- a/qtcreator.qbs +++ b/qtcreator.qbs @@ -1,9 +1,6 @@ import qbs.base 1.0 -import qbs.fileinfo as FileInfo -import "qbs/defaults.js" as Defaults Project { - property string ide_version_major: '2' property string ide_version_minor: '7' property string ide_version_release: '83' @@ -41,200 +38,9 @@ Project { moduleSearchPaths: "qbs" references: [ + "src/src.qbs", "lib/qtcreator/qtcomponents/qtcomponents.qbs", "share/share.qbs", "share/qtcreator/translations/translations.qbs", - "src/libs/aggregation/aggregation.qbs", - "src/libs/cplusplus/cplusplus.qbs", - "src/libs/extensionsystem/extensionsystem.qbs", - "src/libs/glsl/glsl.qbs", - "src/libs/languageutils/languageutils.qbs", - "src/libs/qmleditorwidgets/qmleditorwidgets.qbs", - "src/libs/qmljs/qmljs.qbs", - "src/libs/qmldebug/qmldebug.qbs", - "src/libs/qtcomponents/styleitem/styleitem.qbs", - "src/libs/ssh/ssh.qbs", - "src/libs/utils/process_stub.qbs", - "src/libs/utils/process_ctrlc_stub.qbs", - "src/libs/utils/utils.qbs", - "src/libs/zeroconf/zeroconf.qbs", - "src/plugins/analyzerbase/analyzerbase.qbs", - "src/plugins/android/android.qbs", - "src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs", - "src/plugins/bazaar/bazaar.qbs", - "src/plugins/bineditor/bineditor.qbs", - "src/plugins/bookmarks/bookmarks.qbs", - "src/plugins/classview/classview.qbs", - "src/plugins/clearcase/clearcase.qbs", - "src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs", - "src/plugins/coreplugin/coreplugin.qbs", - "src/plugins/coreplugin/images/logo/logo.qbs", - "src/plugins/cpaster/cpaster.qbs", - "src/plugins/cppeditor/cppeditor.qbs", - "src/plugins/cpptools/cpptools.qbs", - "src/plugins/cvs/cvs.qbs", - "src/plugins/debugger/debugger.qbs", - "src/plugins/debugger/ptracepreload.qbs", - "src/plugins/designer/designer.qbs", - "src/plugins/diffeditor/diffeditor.qbs", - "src/plugins/fakevim/fakevim.qbs", - "src/plugins/find/find.qbs", - "src/plugins/genericprojectmanager/genericprojectmanager.qbs", - "src/plugins/git/git.qbs", - "src/plugins/glsleditor/glsleditor.qbs", - "src/plugins/helloworld/helloworld.qbs", - "src/plugins/help/help.qbs", - "src/plugins/imageviewer/imageviewer.qbs", - "src/plugins/locator/locator.qbs", - "src/plugins/macros/macros.qbs", - "src/plugins/madde/madde.qbs", - "src/plugins/mercurial/mercurial.qbs", - "src/plugins/perforce/perforce.qbs", - "src/plugins/projectexplorer/projectexplorer.qbs", - "src/plugins/qbsprojectmanager/qbsprojectmanager.qbs", - "src/plugins/pythoneditor/pythoneditor.qbs", -// "src/plugins/qmldesigner/qmldesigner.qbs", - "src/plugins/qmljseditor/qmljseditor.qbs", - "src/plugins/qmljstools/qmljstools.qbs", - "src/plugins/qmlprofiler/qmlprofiler.qbs", - "src/plugins/qmlprojectmanager/qmlprojectmanager.qbs", - "src/plugins/qnx/qnx.qbs", - "src/plugins/qt4projectmanager/qt4projectmanager.qbs", - "src/plugins/qtsupport/qtsupport.qbs", - "src/plugins/remotelinux/remotelinux.qbs", - "src/plugins/resourceeditor/resourceeditor.qbs", - "src/plugins/subversion/subversion.qbs", - "src/plugins/tasklist/tasklist.qbs", - "src/plugins/texteditor/texteditor.qbs", - "src/plugins/todo/todo.qbs", - "src/plugins/updateinfo/updateinfo.qbs", - "src/plugins/valgrind/valgrind.qbs", - "src/plugins/vcsbase/vcsbase.qbs", - "src/plugins/welcome/welcome.qbs", - "src/tools/qtcdebugger/qtcdebugger.qbs", - "src/tools/qtcreatorcrashhandler/qtcreatorcrashhandler.qbs", - "src/tools/qtpromaker/qtpromaker.qbs", - "src/plugins/cpaster/frontend/frontend.qbs", - "src/tools/sdktool/sdktool.qbs" ] - - Product { - name: "app_version_header" - type: "hpp" - files: "src/app/app_version.h.in" - property string ide_version_major: project.ide_version_major - property string ide_version_minor: project.ide_version_minor - property string ide_version_release: project.ide_version_release - property string qtcreator_version: project.qtcreator_version - - Transformer { - inputs: ["src/app/app_version.h.in"] - Artifact { - fileName: "app/app_version.h" - fileTags: "hpp" - } - prepare: { - var cmd = new JavaScriptCommand(); - cmd.description = "generating app_version.h"; - cmd.highlight = "codegen"; - cmd.qtcreator_version = product.qtcreator_version; - cmd.ide_version_major = product.ide_version_major; - cmd.ide_version_minor = product.ide_version_minor; - cmd.ide_version_release = product.ide_version_release; - cmd.onWindows = (product.moduleProperty("qbs", "targetOS") === "windows"); - cmd.sourceCode = function() { - var file = new TextFile(input.fileName); - var content = file.readAll(); - // replace quoted quotes - content = content.replace(/\\\"/g, '"'); - // replace Windows line endings - if (onWindows) - content = content.replace(/\r\n/g, "\n"); - // replace the magic qmake incantations - content = content.replace(/(\n#define IDE_VERSION) .+\n/, "$1 " + qtcreator_version + "\n"); - content = content.replace(/(\n#define IDE_VERSION_MAJOR) .+\n/, "$1 " + ide_version_major + "\n") - content = content.replace(/(\n#define IDE_VERSION_MINOR) .+\n/, "$1 " + ide_version_minor + "\n") - content = content.replace(/(\n#define IDE_VERSION_RELEASE) .+\n/, "$1 " + ide_version_release + "\n") - file = new TextFile(output.fileName, TextFile.WriteOnly); - file.truncate(); - file.write(content); - file.close(); - } - return cmd; - } - } - - Export { - Depends { name: "cpp" } - cpp.includePaths: product.buildDirectory - } - } - - Application { - name: project.ide_app_target - consoleApplication: qbs.debugInformation - - cpp.rpaths: qbs.targetOS.contains("mac") ? ["@executable_path/.."] - : ["$ORIGIN/../lib/qtcreator"] - cpp.defines: Defaults.defines(qbs) - cpp.linkerFlags: { - if (qbs.buildVariant == "release" && (qbs.toolchain == "gcc" || qbs.toolchain == "mingw")) - return ["-Wl,-s"] - } - cpp.includePaths: [ - "src", - "src/libs", - "src/shared/qtsingleapplication", - "src/shared/qtlockedfile", - buildDirectory - ] - - Depends { name: "app_version_header" } - Depends { name: "cpp" } - Depends { name: "Qt"; submodules: ["widgets", "network"] } - Depends { name: "Utils" } - Depends { name: "ExtensionSystem" } - - files: [ - "src/app/main.cpp", - "src/app/qtcreator.rc", - "src/shared/qtsingleapplication/qtsingleapplication.h", - "src/shared/qtsingleapplication/qtsingleapplication.cpp", - "src/shared/qtsingleapplication/qtlocalpeer.h", - "src/shared/qtsingleapplication/qtlocalpeer.cpp", - "src/shared/qtlockedfile/qtlockedfile.cpp", - "src/tools/qtcreatorcrashhandler/crashhandlersetup.cpp", - "src/tools/qtcreatorcrashhandler/crashhandlersetup.h" - ] - - Group { - name: "qtcreator.sh" - condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("mac") - files: "bin/qtcreator.sh" - qbs.install: true - qbs.installDir: "bin" - } - - Group { - name: "QtLockedFile_unix" - condition: qbs.targetOS.contains("unix") - files: [ - "src/shared/qtlockedfile/qtlockedfile_unix.cpp" - ] - } - - Group { - name: "QtLockedFile_win" - condition: qbs.targetOS.contains("windows") - files: [ - "src/shared/qtlockedfile/qtlockedfile_win.cpp" - ] - } - - Group { - fileTagsFilter: product.type - qbs.install: true - qbs.installDir: project.ide_app_path - } - } } diff --git a/src/app/app.qbs b/src/app/app.qbs new file mode 100644 index 00000000000..c92d864d9f2 --- /dev/null +++ b/src/app/app.qbs @@ -0,0 +1,70 @@ +import qbs +import "../../qbs/defaults.js" as Defaults + +Application { + name: project.ide_app_target + consoleApplication: qbs.debugInformation + + cpp.rpaths: qbs.targetOS.contains("mac") ? ["@executable_path/.."] + : ["$ORIGIN/../lib/qtcreator"] + cpp.defines: Defaults.defines(qbs) + cpp.linkerFlags: { + if (qbs.buildVariant == "release" && (qbs.toolchain == "gcc" || qbs.toolchain == "mingw")) + return ["-Wl,-s"] + } + cpp.includePaths: [ + "..", + "../libs", + "../shared/qtsingleapplication", + "../shared/qtlockedfile", + buildDirectory + ] + + Depends { name: "app_version_header" } + Depends { name: "cpp" } + Depends { name: "Qt"; submodules: ["widgets", "network"] } + Depends { name: "Utils" } + Depends { name: "ExtensionSystem" } + + files: [ + "main.cpp", + "qtcreator.rc", + "../shared/qtsingleapplication/qtsingleapplication.h", + "../shared/qtsingleapplication/qtsingleapplication.cpp", + "../shared/qtsingleapplication/qtlocalpeer.h", + "../shared/qtsingleapplication/qtlocalpeer.cpp", + "../shared/qtlockedfile/qtlockedfile.cpp", + "../tools/qtcreatorcrashhandler/crashhandlersetup.cpp", + "../tools/qtcreatorcrashhandler/crashhandlersetup.h" + ] + + Group { + name: "qtcreator.sh" + condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("mac") + files: "../../bin/qtcreator.sh" + qbs.install: true + qbs.installDir: "bin" + } + + Group { + name: "QtLockedFile_unix" + condition: qbs.targetOS.contains("unix") + files: [ + "../shared/qtlockedfile/qtlockedfile_unix.cpp" + ] + } + + Group { + name: "QtLockedFile_win" + condition: qbs.targetOS.contains("windows") + files: [ + "../shared/qtlockedfile/qtlockedfile_win.cpp" + ] + } + + Group { + fileTagsFilter: product.type + qbs.install: true + qbs.installDir: project.ide_app_path + } +} diff --git a/src/app/app_version_header.qbs b/src/app/app_version_header.qbs new file mode 100644 index 00000000000..3b3ebf0e0a4 --- /dev/null +++ b/src/app/app_version_header.qbs @@ -0,0 +1,53 @@ +import qbs + +Product { + name: "app_version_header" + type: "hpp" + files: "app_version.h.in" + property string ide_version_major: project.ide_version_major + property string ide_version_minor: project.ide_version_minor + property string ide_version_release: project.ide_version_release + property string qtcreator_version: project.qtcreator_version + + Transformer { + inputs: ["app_version.h.in"] + Artifact { + fileName: "app/app_version.h" + fileTags: "hpp" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating app_version.h"; + cmd.highlight = "codegen"; + cmd.qtcreator_version = product.qtcreator_version; + cmd.ide_version_major = product.ide_version_major; + cmd.ide_version_minor = product.ide_version_minor; + cmd.ide_version_release = product.ide_version_release; + cmd.onWindows = (product.moduleProperty("qbs", "targetOS") === "windows"); + cmd.sourceCode = function() { + var file = new TextFile(input.fileName); + var content = file.readAll(); + // replace quoted quotes + content = content.replace(/\\\"/g, '"'); + // replace Windows line endings + if (onWindows) + content = content.replace(/\r\n/g, "\n"); + // replace the magic qmake incantations + content = content.replace(/(\n#define IDE_VERSION) .+\n/, "$1 " + qtcreator_version + "\n"); + content = content.replace(/(\n#define IDE_VERSION_MAJOR) .+\n/, "$1 " + ide_version_major + "\n") + content = content.replace(/(\n#define IDE_VERSION_MINOR) .+\n/, "$1 " + ide_version_minor + "\n") + content = content.replace(/(\n#define IDE_VERSION_RELEASE) .+\n/, "$1 " + ide_version_release + "\n") + file = new TextFile(output.fileName, TextFile.WriteOnly); + file.truncate(); + file.write(content); + file.close(); + } + return cmd; + } + } + + Export { + Depends { name: "cpp" } + cpp.includePaths: product.buildDirectory + } +} diff --git a/src/libs/libs.qbs b/src/libs/libs.qbs new file mode 100644 index 00000000000..d7ca88dd113 --- /dev/null +++ b/src/libs/libs.qbs @@ -0,0 +1,21 @@ +import qbs + +Project { + name: "Libs" + references: [ + "aggregation/aggregation.qbs", + "cplusplus/cplusplus.qbs", + "extensionsystem/extensionsystem.qbs", + "glsl/glsl.qbs", + "languageutils/languageutils.qbs", + "qmleditorwidgets/qmleditorwidgets.qbs", + "qmljs/qmljs.qbs", + "qmldebug/qmldebug.qbs", + "qtcomponents/styleitem/styleitem.qbs", + "ssh/ssh.qbs", + "utils/process_stub.qbs", + "utils/process_ctrlc_stub.qbs", + "utils/utils.qbs", + "zeroconf/zeroconf.qbs", + ] +} diff --git a/src/plugins/QtcPlugin.qbs b/src/plugins/QtcPlugin.qbs index d3476a68b3f..21530f63141 100644 --- a/src/plugins/QtcPlugin.qbs +++ b/src/plugins/QtcPlugin.qbs @@ -19,6 +19,7 @@ Product { } return name; } + moduleSearchPaths: "../../../qbs" // TODO: Should get inherited from project, but doesn't. Depends { name: "ExtensionSystem" } Depends { name: "pluginspec" } diff --git a/src/plugins/plugins.qbs b/src/plugins/plugins.qbs new file mode 100644 index 00000000000..0f0d0441226 --- /dev/null +++ b/src/plugins/plugins.qbs @@ -0,0 +1,61 @@ +import qbs + +Project { + name: "Plugins" + references: [ + "analyzerbase/analyzerbase.qbs", + "android/android.qbs", + "autotoolsprojectmanager/autotoolsprojectmanager.qbs", + "bazaar/bazaar.qbs", + "bineditor/bineditor.qbs", + "bookmarks/bookmarks.qbs", + "classview/classview.qbs", + "clearcase/clearcase.qbs", + "cmakeprojectmanager/cmakeprojectmanager.qbs", + "coreplugin/coreplugin.qbs", + "coreplugin/images/logo/logo.qbs", + "cpaster/cpaster.qbs", + "cpaster/frontend/frontend.qbs", + "cppeditor/cppeditor.qbs", + "cpptools/cpptools.qbs", + "cvs/cvs.qbs", + "debugger/debugger.qbs", + "debugger/ptracepreload.qbs", + "designer/designer.qbs", + "diffeditor/diffeditor.qbs", + "fakevim/fakevim.qbs", + "find/find.qbs", + "genericprojectmanager/genericprojectmanager.qbs", + "git/git.qbs", + "glsleditor/glsleditor.qbs", + "helloworld/helloworld.qbs", + "help/help.qbs", + "imageviewer/imageviewer.qbs", + "locator/locator.qbs", + "macros/macros.qbs", + "madde/madde.qbs", + "mercurial/mercurial.qbs", + "perforce/perforce.qbs", + "projectexplorer/projectexplorer.qbs", + "qbsprojectmanager/qbsprojectmanager.qbs", + "pythoneditor/pythoneditor.qbs", +// "qmldesigner/qmldesigner.qbs", + "qmljseditor/qmljseditor.qbs", + "qmljstools/qmljstools.qbs", + "qmlprofiler/qmlprofiler.qbs", + "qmlprojectmanager/qmlprojectmanager.qbs", + "qnx/qnx.qbs", + "qt4projectmanager/qt4projectmanager.qbs", + "qtsupport/qtsupport.qbs", + "remotelinux/remotelinux.qbs", + "resourceeditor/resourceeditor.qbs", + "subversion/subversion.qbs", + "tasklist/tasklist.qbs", + "texteditor/texteditor.qbs", + "todo/todo.qbs", + "updateinfo/updateinfo.qbs", + "valgrind/valgrind.qbs", + "vcsbase/vcsbase.qbs", + "welcome/welcome.qbs" + ] +} diff --git a/src/src.qbs b/src/src.qbs new file mode 100644 index 00000000000..2f74200f77a --- /dev/null +++ b/src/src.qbs @@ -0,0 +1,12 @@ +import qbs + +Project { + name: "Sources" + references: [ + "app/app.qbs", + "app/app_version_header.qbs", + "libs/libs.qbs", + "plugins/plugins.qbs", + "tools/tools.qbs" + ] +} diff --git a/src/tools/tools.qbs b/src/tools/tools.qbs new file mode 100644 index 00000000000..3b187c9d55d --- /dev/null +++ b/src/tools/tools.qbs @@ -0,0 +1,11 @@ +import qbs + +Project { + name: "Tools" + references: [ + "qtcdebugger/qtcdebugger.qbs", + "qtcreatorcrashhandler/qtcreatorcrashhandler.qbs", + "qtpromaker/qtpromaker.qbs", + "sdktool/sdktool.qbs" + ] +}