source: branches/4.5.1/tools/installer/nsis/modules/environment.nsh

Last change on this file was 2, checked in by Dmitry A. Kuminov, 17 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 6.4 KB
Line 
1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2;;
3;; Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4;; Contact: Qt Software Information (qt-info@nokia.com)
5;;
6;; This file is part of the tools applications of the Qt Toolkit.
7;;
8;; $QT_BEGIN_LICENSE:LGPL$
9;; Commercial Usage
10;; Licensees holding valid Qt Commercial licenses may use this file in
11;; accordance with the Qt Commercial License Agreement provided with the
12;; Software or, alternatively, in accordance with the terms contained in
13;; a written agreement between you and Nokia.
14;;
15;; GNU Lesser General Public License Usage
16;; Alternatively, this file may be used under the terms of the GNU Lesser
17;; General Public License version 2.1 as published by the Free Software
18;; Foundation and appearing in the file LICENSE.LGPL included in the
19;; packaging of this file. Please review the following information to
20;; ensure the GNU Lesser General Public License version 2.1 requirements
21;; will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22;;
23;; In addition, as a special exception, Nokia gives you certain
24;; additional rights. These rights are described in the Nokia Qt LGPL
25;; Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26;; package.
27;;
28;; GNU General Public License Usage
29;; Alternatively, this file may be used under the terms of the GNU
30;; General Public License version 3.0 as published by the Free Software
31;; Foundation and appearing in the file LICENSE.GPL included in the
32;; packaging of this file. Please review the following information to
33;; ensure the GNU General Public License version 3.0 requirements will be
34;; met: http://www.gnu.org/copyleft/gpl.html.
35;;
36;; If you are unsure which license is appropriate for your use, please
37;; contact the sales department at qt-sales@nokia.com.
38;; $QT_END_LICENSE$
39;;
40;; This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
41;; WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
42;;
43;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
44!ifdef MODULE_ENVIRONMENT
45!macro ENVIRONMENT_INITIALIZE
46 !include "includes\writeEnvStr.nsh"
47 !include "includes\writePathStr.nsh"
48
49 !ifndef MODULE_ENVIRONMENT_QTDIR
50 !ifdef MODULE_MINGW
51 !define MODULE_ENVIRONMENT_QTDIR $MINGW_INSTDIR
52 !endif
53
54 !ifdef MODULE_MSVC
55 !define MODULE_ENVIRONMENT_QTDIR $MSVC_INSTDIR
56 !endif
57 !endif
58
59 !define MODULE_ENVIRONMENT_PAGE "envpage.ini"
60 var MODULE_ENVIRONMENT_SET
61 var MODULE_ENVIRONMENT_OLD
62 LangString ModuleEnvironmentTitle ${LANG_ENGLISH} "Configure Environment"
63 LangString ModuleEnvironmentDescription ${LANG_ENGLISH} "Configure Qt environment variables"
64
65 Page custom ModuleEnvironmentPageEnter ModuleEnvironmentPageExit
66!macroend
67!macro ENVIRONMENT_SECTIONS
68 Section -ModuleEnvironmentRegister
69 push "${MODULE_ENVIRONMENT_QTDIR}"
70 call RegisterQtEnvVariables
71 SectionEnd
72
73 Function ModuleEnvironmentPageEnter
74 push $0
75 Call IsNT
76 pop $0
77 strcmp "$0" "1" +2
78 abort
79 pop $0
80
81 !insertmacro MUI_HEADER_TEXT "$(ModuleEnvironmentTitle)" "$(ModuleEnvironmentDescription)"
82
83 strcmp $MODULE_ENVIRONMENT_SET "1" 0 envCheckNo
84 !insertmacro MUI_INSTALLOPTIONS_WRITE "${MODULE_ENVIRONMENT_PAGE}" "Field 2" "State" "1"
85 goto showEnvPage
86 envCheckNo:
87 !insertmacro MUI_INSTALLOPTIONS_WRITE "${MODULE_ENVIRONMENT_PAGE}" "Field 2" "State" "0"
88
89 showEnvPage:
90 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "${MODULE_ENVIRONMENT_PAGE}"
91 FunctionEnd
92
93 Function ModuleEnvironmentPageExit
94 !insertmacro MUI_INSTALLOPTIONS_READ $MODULE_ENVIRONMENT_SET "${MODULE_ENVIRONMENT_PAGE}" "Field 2" "State"
95 FunctionEnd
96
97 Function RegisterQtEnvVariables
98 exch $2 ; the installation path = QTDIR
99 push $0 ; I think WriteEnvStr mixes up $0 and $1
100 push $1
101
102 WriteRegDWORD SHCTX "$PRODUCT_UNIQUE_KEY" "QtEnvSet" $MODULE_ENVIRONMENT_SET
103
104 strcmp $MODULE_ENVIRONMENT_SET "1" 0 noenv
105
106 StrCmp $MODULE_ENVIRONMENT_OLD "0" +4
107 DetailPrint "Removing $MODULE_ENVIRONMENT_OLD\bin from PATH"
108 push "$MODULE_ENVIRONMENT_OLD\bin"
109 Call RemoveFromPath ; remove old qtdir
110
111 DetailPrint "Setting QTDIR to $2"
112 push "QTDIR"
113 push $2
114 Call WriteEnvStr ; set the QTDIR
115
116 DetailPrint "Adding $2\bin to PATH"
117 push "$2\bin"
118 Call AddToPath ; set the PATH
119
120
121 push "QMAKESPEC"
122 push ${INSTALL_COMPILER}
123 Call GetMkSpec
124 pop $0
125 DetailPrint "Setting QMAKESPEC to $0"
126 push $0
127 Call WriteEnvStr ; set the QMAKESPEC
128
129 noenv:
130 pop $1
131 pop $0
132 pop $2
133 FunctionEnd
134
135 Function un.RegisterQtEnvVariables
136 exch $0 ; QTDIR
137 push $1
138
139 ClearErrors
140 ReadRegDWORD $MODULE_ENVIRONMENT_SET SHCTX "$PRODUCT_UNIQUE_KEY" "QtEnvSet"
141 intcmp $MODULE_ENVIRONMENT_SET 0 noenv
142
143 DetailPrint "Removing $0\bin from the PATH"
144 push "$0\bin"
145 Call un.RemoveFromPath ; removes qt from the path
146
147 ;Check if QTDIR is equal to installdir
148 ExpandEnvStrings $1 "%QTDIR%"
149
150 StrCmp "$0" "$1" removeenv
151 StrCmp "$0\" "$1" removeenv
152 StrCmp "$0" "$1\" removeenv
153 Goto noenv
154
155 removeenv:
156 DetailPrint "Removing QTDIR"
157 push "QTDIR"
158 Call un.DeleteEnvStr ; removes QTDIR
159
160 DetailPrint "Removing QMAKESPEC"
161 push "QMAKESPEC"
162 Call un.DeleteEnvStr ; removes QMAKESPEC
163
164 noenv:
165 pop $1
166 pop $0
167 FunctionEnd
168!macroend
169!macro ENVIRONMENT_DESCRIPTION
170!macroend
171!macro ENVIRONMENT_STARTUP
172 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "${MODULE_ENVIRONMENT_PAGE}"
173 push $0
174 ExpandEnvStrings $0 "%QTDIR%"
175
176 StrCmp $0 "%QTDIR%" +4
177 strcpy $MODULE_ENVIRONMENT_SET "0" ;QTDIR exists
178 strcpy $MODULE_ENVIRONMENT_OLD $0
179 Goto +3
180 strcpy $MODULE_ENVIRONMENT_SET "1" ;no QTDIR
181 strcpy $MODULE_ENVIRONMENT_OLD "0"
182
183 Call IsNT
184 pop $0
185 strcmp "$0" "1" +2
186 strcpy $MODULE_ENVIRONMENT_SET "0"
187 pop $0
188!macroend
189!macro ENVIRONMENT_FINISH
190!macroend
191!macro ENVIRONMENT_UNSTARTUP
192!macroend
193!macro ENVIRONMENT_UNINSTALL
194 Section -un.ModuleEnvironmentRegister
195 push "${MODULE_ENVIRONMENT_QTDIR}"
196 call un.RegisterQtEnvVariables
197 SectionEnd
198!macroend
199!macro ENVIRONMENT_UNFINISH
200!macroend
201!else ;MODULE_ENVIRONMENT
202!macro ENVIRONMENT_INITIALIZE
203!macroend
204!macro ENVIRONMENT_SECTIONS
205!macroend
206!macro ENVIRONMENT_DESCRIPTION
207!macroend
208!macro ENVIRONMENT_STARTUP
209!macroend
210!macro ENVIRONMENT_FINISH
211!macroend
212!macro ENVIRONMENT_UNSTARTUP
213!macroend
214!macro ENVIRONMENT_UNINSTALL
215!macroend
216!macro ENVIRONMENT_UNFINISH
217!macroend
218!endif ;MODULE_ENVIRONMENT
219
Note: See TracBrowser for help on using the repository browser.