Enable QtCreator Ios plugin
[qtsdk:qtsdk.git] / packaging-tools / configurations / pkg_tools / qt.tools.qtcreator / meta / installscript.qs
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 var component_root_path = "/";
43 var native_path_separator = "/";
44
45 // constructor
46 function Component()
47 {
48     component.loaded.connect(this, Component.prototype.loaded);
49     installer.installationFinished.connect(this, Component.prototype.installationFinishedPageIsShown);
50     installer.finishButtonClicked.connect(this, Component.prototype.installationFinished);
51     installer.valueChanged.connect(this, Component.prototype.reactOnTargetDirChange);
52
53     if (installer.value("os") == "win")
54     {
55         // Creator needs vcredist 32bit on windows
56         component.addDependency("qt.tools.vcredist");
57     }
58
59     if (installer.value("os") == "x11")
60     {
61         // set installation directory
62         installer.setValue("EmbeddedInstallationRootDir", "/usr/local/Trolltech");
63         installer.setValue("EmbeddedToolchainDir", "/usr/local/angstrom/arm");
64     }
65
66     // set the default values to SDKToolBinary and QtCreatorInstallerSettingsFile
67     Component.prototype.reactOnTargetDirChange("TargetDir", installer.value("TargetDir"));
68 }
69
70 Component.prototype.loaded = function()
71 {
72     try {
73         if (installer.value("os") == "win" && installer.isInstaller())
74             installer.addWizardPageItem(component, "AssociateCommonFiletypesForm", QInstaller.TargetDirectory);
75     } catch(e) {
76         print(e);
77     }
78 }
79
80 Component.prototype.beginInstallation = function()
81 {
82     if (installer.value("os") === "win") {
83         var path = component_root_path + native_path_separator + "bin" + native_path_separator;
84         component.setStopProcessForUpdateRequest(path + "qtcreator.exe", true);
85         component.setStopProcessForUpdateRequest(path + "linguist.exe", true);
86         component.setStopProcessForUpdateRequest(path + "qmlviewer.exe", true);
87     }
88 }
89
90 Component.prototype.reactOnTargetDirChange = function(key, value)
91 {
92     if (key == "TargetDir") {
93         component.qtCreatorBinaryPath = value;
94         if (installer.value("os") == "win") {
95             installer.setValue("QtCreatorInstallerSettingsFile", value + "/%TARGET_INSTALL_DIR%/share/qtcreator/QtProject/QtCreator.ini");
96             installer.setValue("SDKToolBinary", value + "\\%TARGET_INSTALL_DIR%\\bin\\sdktool.exe");
97             component.qtCreatorBinaryPath = value + "\\%TARGET_INSTALL_DIR%\\bin\\qtcreator.exe";
98             component.qtCreatorBinaryPath = component.qtCreatorBinaryPath.replace(/\//g, "\\");
99         } else if (installer.value("os") == "mac") {
100             installer.setValue("QtCreatorInstallerSettingsFile", value + "/%TARGET_INSTALL_DIR%/Qt Creator.app/Contents/Resources/QtProject/QtCreator.ini");
101             installer.setValue("SDKToolBinary", value + "/%TARGET_INSTALL_DIR%/Qt Creator.app/Contents/Resources/sdktool");
102             component.qtCreatorBinaryPath = value + "/%TARGET_INSTALL_DIR%/Qt Creator.app/Contents/MacOS/Qt Creator";
103             // fix duplicate forward slashes in path
104             component.qtCreatorBinaryPath = component.qtCreatorBinaryPath.replace(/\/+/g, "/");
105         } else {
106             installer.setValue("QtCreatorInstallerSettingsFile", value + "/%TARGET_INSTALL_DIR%/share/qtcreator/QtProject/QtCreator.ini");
107             installer.setValue("SDKToolBinary", value + "/%TARGET_INSTALL_DIR%/bin/sdktool");
108             component.qtCreatorBinaryPath = value + "/%TARGET_INSTALL_DIR%/bin/qtcreator";
109             // fix duplicate forward slashes in path
110             component.qtCreatorBinaryPath = component.qtCreatorBinaryPath.replace(/\/+/g, "/");
111         }
112     }
113 }
114
115 function buildNativeComponentRootPath()
116 {
117     var target_install_dir = "%TARGET_INSTALL_DIR%";
118     if (installer.value("os") == "win") {
119         native_path_separator = "\\";
120         target_install_dir = target_install_dir.replace(/\//g, "\\");
121     }
122     else {
123         native_path_separator = "/";
124     }
125
126     component_root_path = installer.value("TargetDir") + target_install_dir;
127 }
128
129 registerCommonWindowsFileTypeExtensions = function()
130 {
131     var headerExtensions = new Array("h", "hh", "hxx", "h++", "hpp");
132
133     for (var i = 0; i < headerExtensions.length; ++i) {
134         component.addOperation( "RegisterFileType",
135                                 headerExtensions[i],
136                                 component.qtCreatorBinaryPath + " -client \"%1\"",
137                                 "C++ Header file",
138                                 "text/plain",
139                                 component.qtCreatorBinaryPath + ",3",
140                                 "ProgId=QtProject.QtCreator." + headerExtensions[i]);
141     }
142
143     var cppExtensions = new Array("cc", "cxx", "c++", "cp", "cpp");
144
145     for (var i = 0; i < cppExtensions.length; ++i) {
146         component.addOperation( "RegisterFileType",
147                                 cppExtensions[i],
148                                 component.qtCreatorBinaryPath + " -client \"%1\"",
149                                 "C++ Source file",
150                                 "text/plain",
151                                 component.qtCreatorBinaryPath + ",2",
152                                 "ProgId=QtProject.QtCreator." + cppExtensions[i]);
153     }
154
155     component.addOperation( "RegisterFileType",
156                             "c",
157                             component.qtCreatorBinaryPath + " -client \"%1\"",
158                             "C Source file",
159                             "text/plain",
160                             component.qtCreatorBinaryPath + ",1",
161                             "ProgId=QtProject.QtCreator.c");
162 }
163
164 registerWindowsFileTypeExtensions = function()
165 {
166     component.addOperation( "RegisterFileType",
167                             "ui",
168                             component.qtCreatorBinaryPath + " -client \"%1\"",
169                             "Qt UI file",
170                             "text/plain",
171                             component.qtCreatorBinaryPath + ",4",
172                             "ProgId=QtProject.QtCreator.ui");
173     component.addOperation( "RegisterFileType",
174                             "pro",
175                             component.qtCreatorBinaryPath + " -client \"%1\"",
176                             "Qt Project file",
177                             "text/plain",
178                             component.qtCreatorBinaryPath + ",5",
179                             "ProgId=QtProject.QtCreator.pro");
180     component.addOperation( "RegisterFileType",
181                             "pri",
182                             component.qtCreatorBinaryPath + " -client \"%1\"",
183                             "Qt Project Include file",
184                             "text/plain",
185                             component.qtCreatorBinaryPath + ",6",
186                             "ProgId=QtProject.QtCreator.pri");
187     component.addOperation( "RegisterFileType",
188                             "qbs",
189                             component.qtCreatorBinaryPath + " -client \"%1\"",
190                             "Qbs Project file",
191                             "text/plain",
192                             component.qtCreatorBinaryPath + ",5",
193                             "ProgId=QtProject.QtCreator.qbs");
194     component.addOperation( "RegisterFileType",
195                             "qs",
196                             component.qtCreatorBinaryPath + " -client \"%1\"",
197                             "Qt Script file",
198                             "text/plain",
199                             component.qtCreatorBinaryPath + ",0",
200                             "ProgId=QtProject.QtCreator.qs");
201     component.addOperation( "RegisterFileType",
202                             "qml",
203                             component.qtCreatorBinaryPath + " -client \"%1\"",
204                             "Qt Quick Markup language file",
205                             "text/plain",
206                             component.qtCreatorBinaryPath + ",7",
207                             "ProgId=QtProject.QtCreator.qml");
208 }
209
210 Component.prototype.createOperations = function()
211 {
212     // Call the base createOperations and afterwards set some registry settings
213     component.createOperations();
214     buildNativeComponentRootPath();
215     var path = component_root_path + native_path_separator;
216     var maintenanceToolPath;
217
218     if ( installer.value("os") == "win" )
219     {
220         component.addOperation( "CreateShortcut",
221                                 component.qtCreatorBinaryPath,
222                                 "@StartMenuDir@\\Qt Creator.lnk",
223                                 "workingDirectory=" + path + "bin");
224
225         registerWindowsFileTypeExtensions();
226
227         if (component.userInterface("AssociateCommonFiletypesForm").AssociateCommonFiletypesCheckBox.checked) {
228             registerCommonWindowsFileTypeExtensions();
229         }
230
231         maintenanceToolPath = installer.value("TargetDir")
232                 + "/MaintenanceTool.app/Contents/MacOS/MaintenanceTool";
233     }
234     if ( installer.value("os") == "x11" )
235     {
236         component.addOperation( "InstallIcons", path + "share" + native_path_separator + "icons" );
237         component.addOperation( "CreateDesktopEntry",
238                                 "DigiaQtOpenSource-qtcreator.desktop",
239                                 "Type=Application\nExec=" + component.qtCreatorBinaryPath + "\nName=Qt Creator (Opensource)\nGenericName=The IDE of choice for Qt development.\nIcon=QtProject-qtcreator\nTerminal=false\nCategories=Development;IDE;Qt;\nMimeType=text/x-c++src;text/x-c++hdr;text/x-xsrc;application/x-designer;application/vnd.qt.qmakeprofile;application/vnd.qt.xml.resource;text/x-qml;text/x-qt.qml;text/x-qt.qbs;");
240         maintenanceToolPath = installer.value("TargetDir") + "/MaintenanceTool";
241     }
242     if (installer.value("os") == "mac")
243     {
244         maintenanceToolPath = installer.value("TargetDir") + "/MaintenanceTool.exe";
245     }
246
247     var settingsFile = installer.value("QtCreatorInstallerSettingsFile");
248     if (!installer.isOfflineOnly()) {
249         // Configure & enable UpdateInfo plugin
250         component.addOperation("Settings", "path="+settingsFile, "method=set",
251                                "key=Updater/Application",
252                                "value="+maintenanceToolPath);
253         component.addOperation("Settings", "path="+settingsFile, "method=set",
254                                "key=Updater/RunUiArgument",
255                                "value=--updater");
256         component.addOperation("Settings", "path="+settingsFile, "method=set",
257                                "key=Updater/CheckOnlyArgument",
258                                "value=--checkupdates");
259         component.addOperation("Settings", "path="+settingsFile,
260                                "method=add_array_value",
261                                "key=Plugins/ForceEnabled", "value=UpdateInfo");
262     }
263
264     if (installer.value("os") == "mac")
265     {
266         component.addOperation("Settings", "path="+settingsFile, "method=add_array_value",
267                                "key=Plugins/ForceEnabled", "value=Ios");
268     }
269 }
270
271 Component.prototype.installationFinishedPageIsShown = function()
272 {
273     try {
274         if (component.installed && installer.isInstaller() && installer.status == QInstaller.Success) {
275             installer.addWizardPageItem( component, "LaunchQtCreatorCheckBoxForm", QInstaller.InstallationFinished );
276         }
277     } catch(e) {
278         print(e);
279     }
280 }
281
282 Component.prototype.installationFinished = function()
283 {
284     try {
285         if (component.installed && installer.isInstaller() && installer.status == QInstaller.Success) {
286             var isLaunchQtCreatorCheckBoxChecked = component.userInterface("LaunchQtCreatorCheckBoxForm").launchQtCreatorCheckBox.checked;
287             if (isLaunchQtCreatorCheckBoxChecked)
288                 installer.executeDetached(component.qtCreatorBinaryPath, new Array(), "@homeDir@");
289         }
290     } catch(e) {
291         print(e);
292     }
293 }
294