summaryrefslogtreecommitdiffstats
path: root/util/scripts/win-binary/nsis/modules/qtjambieclipse.nsh
blob: d8cae70227f0c910846c376902cdcb560318e07a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
!ifdef MODULE_QTJAMBIECLIPSE

;------------------------------------------------------------------------------------------------
!macro QTJAMBIECLIPSE_INITIALIZE

!define ECLIPSE_LOCATION_KEY "EclipseLocation"
var ECLIPSE_LOCATION

!ifndef MODULE_QTJAMBIECLIPSE_INSTALLER
  !define MODULE_QTJAMBIECLIPSE_INSTALLER "${PRODUCT_NAME} v${PRODUCT_VERSION}"
!endif
!ifndef MODULE_QTJAMBIECLIPSE_ROOT
  !define MODULE_QTJAMBIECLIPSE_ROOT "${INSTALL_ROOT}\qtjambieclipse"
!endif
!ifndef MODULE_QTJAMBIECLIPSE_VERSION
  !define MODULE_QTJAMBIECLIPSE_VERSION ${PRODUCT_VERSION}
!endif

!define MODULE_QTJAMBIECLIPSE_QTJAMBIVERSION "1.0.0"

!define MODULE_QTJAMBIECLIPSE_QT_ID "com.trolltech.qt_${MODULE_QTJAMBIECLIPSE_QTJAMBIVERSION}"
!define MODULE_QTJAMBIECLIPSE_QTJAMBI_ID "com.trolltech.qtjambi_${MODULE_QTJAMBIECLIPSE_QTJAMBIVERSION}"
!define MODULE_QTJAMBIECLIPSE_QTDESIGNER_ID "com.trolltech.qtdesigner_${MODULE_QTJAMBIECLIPSE_QTJAMBIVERSION}"
!define MODULE_QTJAMBIECLIPSE_QTDESIGNER_QTJAMBI_ID "com.trolltech.qtdesigner.qtjambi_${MODULE_QTJAMBIECLIPSE_QTJAMBIVERSION}"
!define MODULE_QTJAMBIECLIPSE_QTDESIGNERPLUGINS_ID "com.trolltech.qtdesignerplugins"

!define MODULE_QTJAMBIECLIPSE_BINARIES "${MODULE_QTJAMBIECLIPSE_ROOT}\plugins\com.trolltech.qtdesigner.win32.x86_${MODULE_QTJAMBIECLIPSE_QTJAMBIVERSION}"

LangString ModuleQtjambieclipsePageTitle ${LANG_ENGLISH} "Eclipse Installation Location"
LangString ModuleQtjambieclipsePageDescription ${LANG_ENGLISH} "Select where eclipse is installed."

!define MODULE_QTJAMBIECLIPSE_PAGE "qtjambieclipse.ini"
Page custom ModuleQtjambieclipsePageEnter ModuleQtjambieclipsePageExit

!include "includes\regsvr.nsh"

!define MODULE_QTJAMBIECLIPSE_INCOMPATIBLEPRODUCT "Qt Eclipse Integration"

!macroend ;QTJAMBIECLIPSE_INITIALIZE

;------------------------------------------------------------------------------------------------
!macro QTJAMBIECLIPSE_SECTIONS

Section -PreEclipseSection
  WriteRegStr SHCTX "$PRODUCT_UNIQUE_KEY" "${ECLIPSE_LOCATION_KEY}" $ECLIPSE_LOCATION
SectionEnd

SectionGroup "Eclipse Integration"

Section "Qt Jambi Eclipse Integration" QTJAMBIECLIPSE_SEC01
  SetOutPath "$ECLIPSE_LOCATION\plugins\"
  SetOverwrite ifnewer
  File "${MODULE_QTJAMBIECLIPSE_ROOT}\plugins\${MODULE_QTJAMBIECLIPSE_QT_ID}.jar"
  File "${MODULE_QTJAMBIECLIPSE_ROOT}\plugins\${MODULE_QTJAMBIECLIPSE_QTJAMBI_ID}.jar"
  File "${MODULE_QTJAMBIECLIPSE_ROOT}\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNER_ID}.jar"
  File "${MODULE_QTJAMBIECLIPSE_ROOT}\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNER_QTJAMBI_ID}.jar"

  SetOutPath "$ECLIPSE_LOCATION\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNERPLUGINS_ID}"
  SetOverwrite ifnewer
  File "${MODULE_QTJAMBIECLIPSE_ROOT}\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNERPLUGINS_ID}\JambiCustomWidget.dll"
  File "${MODULE_QTJAMBIECLIPSE_ROOT}\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNERPLUGINS_ID}\JambiLanguage.dll"
  
  SetOutPath "$QTJAMBIECLIPSE_INSTDIR"
  SetOverwrite ifnewer
  File "${MODULE_QTJAMBIECLIPSE_ROOT}\LICENSE.QT_JAMBI_ECLIPSE_INTEGRATION"
  File "${MODULE_QTJAMBIECLIPSE_BINARIES}\msvcp71.dll"
  File "${MODULE_QTJAMBIECLIPSE_BINARIES}\msvcr71.dll"
  File "${MODULE_QTJAMBIECLIPSE_BINARIES}\QtCore4.dll"
  File "${MODULE_QTJAMBIECLIPSE_BINARIES}\QtGui4.dll"
  File "${MODULE_QTJAMBIECLIPSE_BINARIES}\QtXml4.dll"
  File "${MODULE_QTJAMBIECLIPSE_BINARIES}\QtScript4.dll"
  File "${MODULE_QTJAMBIECLIPSE_BINARIES}\QtDesigner4.dll"
  File "${MODULE_QTJAMBIECLIPSE_BINARIES}\QtDesignerComponents4.dll"
  File "${MODULE_QTJAMBIECLIPSE_BINARIES}\qtdesigner.dll"
  
  push "$QTJAMBIECLIPSE_INSTDIR\qtdesigner.dll"
  call RegEclipseSvr
  
  push "$QTJAMBIECLIPSE_INSTDIR\qtdesigner.dll"
  call RegEclipseSvr
  
  Rename "$QTJAMBIECLIPSE_INSTDIR\LICENSE.QT_JAMBI_ECLIPSE_INTEGRATION" "$QTJAMBIECLIPSE_INSTDIR\LICENSE.txt"
  !insertmacro CreateConditionalShortCut "$SMPROGRAMS\$STARTMENU_STRING\License.lnk" "$QTJAMBIECLIPSE_INSTDIR\LICENSE.txt"
SectionEnd

SectionGroupEnd

; usage:
; push dll to register
; call RegEclipseSvr
Function RegEclipseSvr
  exch $0 ;filename

  ClearErrors
  push $0
  call RegSvr
  IfErrors 0 +2
    MessageBox MB_OK|MB_ICONEXCLAMATION 'Could not register "$0"'

  pop $0
FunctionEnd

Function ModuleQtjambieclipsePageEnter
  !insertmacro MUI_HEADER_TEXT "$(ModuleQtjambieclipsePageTitle)" "$(ModuleQtjambieclipsePageDescription)"
  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "${MODULE_QTJAMBIECLIPSE_PAGE}"
FunctionEnd

Function ModuleQtjambieclipsePageExit
  push $0
  push $1

  !insertmacro MUI_INSTALLOPTIONS_READ $0 "${MODULE_QTJAMBIECLIPSE_PAGE}" "Field 2" "State"
  IfFileExists "$0\eclipse.exe" eclipse_found
  MessageBox MB_OK|MB_ICONSTOP "$0\eclipse.exe not found!$\nPlease select a valid installation directory."
  Goto failed
  eclipse_found:
  
  ClearErrors
  FileOpen $1 "$0\plugins\com.trolltech.writetest" a
  IfErrors 0 has_write_access
  MessageBox MB_OK|MB_ICONSTOP "Can't write to $0\plugins.$\nPlease select a valid installation directory."
  Goto failed
  has_write_access:

  FileClose $1
  Delete "$0\plugins\com.trolltech.writetest"
  StrCpy $ECLIPSE_LOCATION $0
  
  Goto done
  failed:
  pop $1
  pop $0
  Abort
  
  done:
  pop $1
  pop $0
FunctionEnd

!macroend ;QTJAMBIECLIPSE_SECTIONS

;------------------------------------------------------------------------------------------------
!macro QTJAMBIECLIPSE_DESCRIPTION
!ifdef QTJAMBIECLIPSE_SEC01
  !insertmacro MUI_DESCRIPTION_TEXT ${QTJAMBIECLIPSE_SEC01} "This installs the Qt Jambi plugin into Eclipse."
!endif
!macroend

;------------------------------------------------------------------------------------------------
!macro QTJAMBIECLIPSE_STARTUP
  push "${MODULE_QTJAMBIECLIPSE_INCOMPATIBLEPRODUCT}"
  call WarnIfInstalledProductDetected
  
  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "${MODULE_QTJAMBIECLIPSE_PAGE}"
  SectionSetFlags ${QTJAMBIECLIPSE_SEC01} 17
  
  strcpy $QTJAMBIECLIPSE_INSTDIR "$PROGRAMFILES\Trolltech\Qt Jambi Eclipse Integration"
!macroend ;QTJAMBIECLIPSE_STATUP

;------------------------------------------------------------------------------------------------
!macro QTJAMBIECLIPSE_FINISH
!macroend ;QTJAMBIECLIPSE_FINISH

;------------------------------------------------------------------------------------------------
!macro QTJAMBIECLIPSE_UNSTARTUP
  ReadRegStr $ECLIPSE_LOCATION SHCTX "$PRODUCT_UNIQUE_KEY" "${ECLIPSE_LOCATION_KEY}"
!macroend ;QTJAMBIECLIPSE_UNSTARTUP

;------------------------------------------------------------------------------------------------
!macro QTJAMBIECLIPSE_UNINSTALL
Section un."Eclipse Integration"
  push "$QTJAMBIECLIPSE_INSTDIR\qtdesigner.dll"
  call un.RegSvr

  Delete "$ECLIPSE_LOCATION\plugins\${MODULE_QTJAMBIECLIPSE_QT_ID}.jar"
  Delete "$ECLIPSE_LOCATION\plugins\${MODULE_QTJAMBIECLIPSE_QTJAMBI_ID}.jar"
  Delete "$ECLIPSE_LOCATION\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNER_ID}.jar"
  Delete "$ECLIPSE_LOCATION\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNER_QTJAMBI_ID}.jar"

  Delete "$ECLIPSE_LOCATION\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNERPLUGINS_ID}\JambiCustomWidget.dll"
  Delete "$ECLIPSE_LOCATION\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNERPLUGINS_ID}\JambiLanguage.dll"
  RMDir "$ECLIPSE_LOCATION\plugins\${MODULE_QTJAMBIECLIPSE_QTDESIGNERPLUGINS_ID}"

  Delete "$SMPROGRAMS\$STARTMENU_STRING\License.lnk"
  
  Delete "$QTJAMBIECLIPSE_INSTDIR\LICENSE.txt"
  Delete "$QTJAMBIECLIPSE_INSTDIR\msvcp71.dll"
  Delete "$QTJAMBIECLIPSE_INSTDIR\msvcr71.dll"
  Delete "$QTJAMBIECLIPSE_INSTDIR\QtCore4.dll"
  Delete "$QTJAMBIECLIPSE_INSTDIR\QtGui4.dll"
  Delete "$QTJAMBIECLIPSE_INSTDIR\QtXml4.dll"
  Delete "$QTJAMBIECLIPSE_INSTDIR\QtScript4.dll"
  Delete "$QTJAMBIECLIPSE_INSTDIR\QtDesigner4.dll"
  Delete "$QTJAMBIECLIPSE_INSTDIR\QtDesignerComponents4.dll"
  Delete "$QTJAMBIECLIPSE_INSTDIR\qtdesigner.dll"
  
  RMDir "$QTJAMBIECLIPSE_INSTDIR"
SectionEnd
!macroend ;QTJAMBIECLIPSE_UNINSTALL

;------------------------------------------------------------------------------------------------
!macro QTJAMBIECLIPSE_UNFINISH
!macroend

!else ;MODULE_QTJAMBIECLIPSE
!macro QTJAMBIECLIPSE_INITIALIZE
!macroend
!macro QTJAMBIECLIPSE_SECTIONS
!macroend
!macro QTJAMBIECLIPSE_DESCRIPTION
!macroend
!macro QTJAMBIECLIPSE_STARTUP
!macroend
!macro QTJAMBIECLIPSE_FINISH
!macroend
!macro QTJAMBIECLIPSE_UNSTARTUP
!macroend
!macro QTJAMBIECLIPSE_UNINSTALL
!macroend
!macro QTJAMBIECLIPSE_UNFINISH
!macroend
!endif ;MODULE_QTJAMBIECLIPSE