qtcreator.qbs 9.77 KB
Newer Older
Joerg Bornemann's avatar
Joerg Bornemann committed
1
import qbs.base 1.0
2
import qbs.fileinfo as FileInfo
3
import "qbs/defaults.js" as Defaults
Joerg Bornemann's avatar
Joerg Bornemann committed
4 5

Project {
6

Joerg Bornemann's avatar
Joerg Bornemann committed
7
    property string ide_version_major: '2'
Kai Koehne's avatar
Kai Koehne committed
8
    property string ide_version_minor: '7'
Eike Ziller's avatar
Eike Ziller committed
9
    property string ide_version_release: '83'
Joerg Bornemann's avatar
Joerg Bornemann committed
10
    property string qtcreator_version: ide_version_major + '.' + ide_version_minor + '.' + ide_version_release
Joerg Bornemann's avatar
Joerg Bornemann committed
11 12
    property string ide_app_path: qbs.targetOS.contains("mac") ? "" : "bin"
    property string ide_app_target: qbs.targetOS.contains("mac") ? "Qt Creator" : "qtcreator"
13
    property string ide_library_path: {
Joerg Bornemann's avatar
Joerg Bornemann committed
14
        if (qbs.targetOS.contains("mac"))
15
            return ide_app_target + ".app/Contents/PlugIns"
Joerg Bornemann's avatar
Joerg Bornemann committed
16
        else if (qbs.targetOS.contains("windows"))
17 18 19 20 21
            return ide_app_path
        else
            return "lib/qtcreator"
    }
    property string ide_plugin_path: {
Joerg Bornemann's avatar
Joerg Bornemann committed
22
        if (qbs.targetOS.contains("mac"))
23
            return ide_library_path
Joerg Bornemann's avatar
Joerg Bornemann committed
24
        else if (qbs.targetOS.contains("windows"))
25 26 27 28
            return "lib/qtcreator/plugins"
        else
            return ide_library_path + "/plugins"
    }
Joerg Bornemann's avatar
Joerg Bornemann committed
29 30 31 32 33 34 35 36 37 38 39 40
    property string ide_data_path: qbs.targetOS.contains("mac")
            ? ide_app_target + ".app/Contents/Resources"
            : "share/qtcreator"
    property string ide_libexec_path: qbs.targetOS.contains("mac")
            ? ide_data_path
            : ide_app_path
    property string ide_doc_path: qbs.targetOS.contains("mac")
            ? ide_data_path + "/doc"
            : "share/doc/qtcreator"
    property string ide_bin_path: qbs.targetOS.contains("mac")
            ? ide_app_target + ".app/Contents/MacOS"
            : ide_app_path
Joerg Bornemann's avatar
Joerg Bornemann committed
41 42 43 44 45
    moduleSearchPaths: "qbs"

    references: [
        "lib/qtcreator/qtcomponents/qtcomponents.qbs",
        "share/share.qbs",
46
        "share/qtcreator/translations/translations.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
47 48 49 50 51 52 53
        "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",
54
        "src/libs/qmldebug/qmldebug.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
55
        "src/libs/qtcomponents/styleitem/styleitem.qbs",
56
        "src/libs/ssh/ssh.qbs",
Orgad Shaneh's avatar
Orgad Shaneh committed
57 58
        "src/libs/utils/process_stub.qbs",
        "src/libs/utils/process_ctrlc_stub.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
59
        "src/libs/utils/utils.qbs",
60
        "src/libs/zeroconf/zeroconf.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
61
        "src/plugins/analyzerbase/analyzerbase.qbs",
Daniel Teske's avatar
Daniel Teske committed
62
        "src/plugins/android/android.qbs",
63
        "src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
64 65 66 67
        "src/plugins/bazaar/bazaar.qbs",
        "src/plugins/bineditor/bineditor.qbs",
        "src/plugins/bookmarks/bookmarks.qbs",
        "src/plugins/classview/classview.qbs",
Orgad Shaneh's avatar
Orgad Shaneh committed
68
        "src/plugins/clearcase/clearcase.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
69 70
        "src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs",
        "src/plugins/coreplugin/coreplugin.qbs",
Yuchen Deng's avatar
Yuchen Deng committed
71
        "src/plugins/coreplugin/images/logo/logo.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
72 73 74 75 76
        "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",
Orgad Shaneh's avatar
Orgad Shaneh committed
77
        "src/plugins/debugger/ptracepreload.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
78
        "src/plugins/designer/designer.qbs",
79
        "src/plugins/diffeditor/diffeditor.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93
        "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",
Tobias Hunger's avatar
Tobias Hunger committed
94
        "src/plugins/qbsprojectmanager/qbsprojectmanager.qbs",
Sergey Shambir's avatar
Sergey Shambir committed
95
        "src/plugins/pythoneditor/pythoneditor.qbs",
96
//        "src/plugins/qmldesigner/qmldesigner.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
97 98 99 100
        "src/plugins/qmljseditor/qmljseditor.qbs",
        "src/plugins/qmljstools/qmljstools.qbs",
        "src/plugins/qmlprofiler/qmlprofiler.qbs",
        "src/plugins/qmlprojectmanager/qmlprojectmanager.qbs",
Orgad Shaneh's avatar
Orgad Shaneh committed
101
        "src/plugins/qnx/qnx.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
102 103 104 105 106 107 108
        "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",
Orgad Shaneh's avatar
Orgad Shaneh committed
109
        "src/plugins/todo/todo.qbs",
Orgad Shaneh's avatar
Orgad Shaneh committed
110
        "src/plugins/updateinfo/updateinfo.qbs",
Joerg Bornemann's avatar
Joerg Bornemann committed
111 112 113
        "src/plugins/valgrind/valgrind.qbs",
        "src/plugins/vcsbase/vcsbase.qbs",
        "src/plugins/welcome/welcome.qbs",
Orgad Shaneh's avatar
Orgad Shaneh committed
114
        "src/tools/qtcdebugger/qtcdebugger.qbs",
115
        "src/tools/qtcreatorcrashhandler/qtcreatorcrashhandler.qbs",
116
        "src/tools/qtpromaker/qtpromaker.qbs",
117
        "src/plugins/cpaster/frontend/frontend.qbs",
Tobias Hunger's avatar
Tobias Hunger committed
118
        "src/tools/sdktool/sdktool.qbs"
Joerg Bornemann's avatar
Joerg Bornemann committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
    ]

    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;
144
                cmd.onWindows = (product.moduleProperty("qbs", "targetOS") === "windows");
Joerg Bornemann's avatar
Joerg Bornemann committed
145 146 147 148
                cmd.sourceCode = function() {
                    var file = new TextFile(input.fileName);
                    var content = file.readAll();
                    // replace quoted quotes
Yuchen Deng's avatar
Yuchen Deng committed
149
                    content = content.replace(/\\\"/g, '"');
Joerg Bornemann's avatar
Joerg Bornemann committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
                    // 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;
            }
        }
166

167
        Export {
168 169 170
            Depends { name: "cpp" }
            cpp.includePaths: product.buildDirectory
        }
Joerg Bornemann's avatar
Joerg Bornemann committed
171 172
    }

173
    Application {
174
        name: project.ide_app_target
175
        consoleApplication: qbs.debugInformation
Joerg Bornemann's avatar
Joerg Bornemann committed
176

Joerg Bornemann's avatar
Joerg Bornemann committed
177
        cpp.rpaths: qbs.targetOS.contains("mac") ? ["@executable_path/.."]
178
                                          : ["$ORIGIN/../lib/qtcreator"]
179
        cpp.defines: Defaults.defines(qbs)
180 181 182 183
        cpp.linkerFlags: {
            if (qbs.buildVariant == "release" && (qbs.toolchain == "gcc" || qbs.toolchain == "mingw"))
                return ["-Wl,-s"]
        }
Joerg Bornemann's avatar
Joerg Bornemann committed
184 185 186 187 188 189 190 191 192 193
        cpp.includePaths: [
            "src",
            "src/libs",
            "src/shared/qtsingleapplication",
            "src/shared/qtlockedfile",
            buildDirectory
        ]

        Depends { name: "app_version_header" }
        Depends { name: "cpp" }
194
        Depends { name: "Qt"; submodules: ["widgets", "network"] }
195 196
        Depends { name: "Utils" }
        Depends { name: "ExtensionSystem" }
Joerg Bornemann's avatar
Joerg Bornemann committed
197 198 199

        files: [
            "src/app/main.cpp",
200
            "src/app/qtcreator.rc",
Joerg Bornemann's avatar
Joerg Bornemann committed
201 202 203 204
            "src/shared/qtsingleapplication/qtsingleapplication.h",
            "src/shared/qtsingleapplication/qtsingleapplication.cpp",
            "src/shared/qtsingleapplication/qtlocalpeer.h",
            "src/shared/qtsingleapplication/qtlocalpeer.cpp",
205 206 207
            "src/shared/qtlockedfile/qtlockedfile.cpp",
            "src/tools/qtcreatorcrashhandler/crashhandlersetup.cpp",
            "src/tools/qtcreatorcrashhandler/crashhandlersetup.h"
Joerg Bornemann's avatar
Joerg Bornemann committed
208 209 210
        ]

        Group {
211
            name: "qtcreator.sh"
Joerg Bornemann's avatar
Joerg Bornemann committed
212
            condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("mac")
Joerg Bornemann's avatar
Joerg Bornemann committed
213
            files: "bin/qtcreator.sh"
214
            qbs.install: true
215
            qbs.installDir: "bin"
Joerg Bornemann's avatar
Joerg Bornemann committed
216 217 218
        }

        Group {
219
            name: "QtLockedFile_unix"
Joerg Bornemann's avatar
Joerg Bornemann committed
220
            condition: qbs.targetOS.contains("unix")
221 222 223
            files: [
                "src/shared/qtlockedfile/qtlockedfile_unix.cpp"
            ]
Joerg Bornemann's avatar
Joerg Bornemann committed
224 225 226
        }

        Group {
227
            name: "QtLockedFile_win"
Joerg Bornemann's avatar
Joerg Bornemann committed
228
            condition: qbs.targetOS.contains("windows")
229 230 231
            files: [
                "src/shared/qtlockedfile/qtlockedfile_win.cpp"
            ]
Joerg Bornemann's avatar
Joerg Bornemann committed
232
        }
233 234 235 236

        Group {
            fileTagsFilter: product.type
            qbs.install: true
237
            qbs.installDir: project.ide_app_path
238
        }
Joerg Bornemann's avatar
Joerg Bornemann committed
239 240
    }
}