249 |
bj |
1 |
!include "LogicLib.nsh"
|
|
|
2 |
!include "WinMessages.NSH"
|
|
|
3 |
|
253 |
bj |
4 |
!define TEMP1 $R0 ;Temp variable
|
|
|
5 |
|
249 |
bj |
6 |
; The name of the installer
|
|
|
7 |
Name "GEL Externals"
|
|
|
8 |
|
|
|
9 |
; The file to write
|
|
|
10 |
OutFile "GELsetup.exe"
|
|
|
11 |
|
|
|
12 |
; The default installation directory
|
|
|
13 |
InstallDir $DOCUMENTS\GEL
|
|
|
14 |
|
253 |
bj |
15 |
; Show install details
|
|
|
16 |
ShowInstDetails show
|
|
|
17 |
|
|
|
18 |
;Things that need to be extracted on startup (keep these lines before any File command!)
|
|
|
19 |
;Only useful for BZIP2 compression
|
|
|
20 |
;Use ReserveFile for your own InstallOptions INI files too!
|
|
|
21 |
|
|
|
22 |
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
|
|
|
23 |
ReserveFile "custdir.ini"
|
|
|
24 |
|
|
|
25 |
|
249 |
bj |
26 |
;--------------------------------
|
|
|
27 |
|
|
|
28 |
; Pages
|
|
|
29 |
|
253 |
bj |
30 |
;Page directory
|
|
|
31 |
Page custom SetCustom "" ": Installation Folder"
|
249 |
bj |
32 |
Page components
|
|
|
33 |
|
|
|
34 |
InstType "Externals only"
|
|
|
35 |
InstType "Full"
|
|
|
36 |
|
|
|
37 |
Section "Externals" Externals_flag
|
|
|
38 |
SectionIn 1 2
|
|
|
39 |
SectionEnd
|
|
|
40 |
|
|
|
41 |
SectionGroup "GEL binary (ver. 0.1)"
|
|
|
42 |
|
|
|
43 |
Section "CGLA" CGLA_flag
|
|
|
44 |
SectionIn 2
|
|
|
45 |
SectionEnd
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
Section "Geometry" Geometry_flag
|
|
|
49 |
SectionIn 2
|
|
|
50 |
SectionEnd
|
|
|
51 |
|
|
|
52 |
Section "GLGraphics" GLGraphics_flag
|
|
|
53 |
SectionIn 2
|
|
|
54 |
SectionEnd
|
|
|
55 |
|
|
|
56 |
Section "HMesh" HMesh_flag
|
|
|
57 |
SectionIn 2
|
|
|
58 |
SectionEnd
|
|
|
59 |
|
|
|
60 |
Section "LinAlg" LinAlg_flag
|
|
|
61 |
SectionIn 2
|
|
|
62 |
SectionEnd
|
|
|
63 |
|
|
|
64 |
Section "Util" Util_flag
|
|
|
65 |
SectionIn 2
|
|
|
66 |
SectionEnd
|
|
|
67 |
|
|
|
68 |
SectionGroupEnd
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
Page instfiles
|
|
|
73 |
|
|
|
74 |
;--------------------------------
|
|
|
75 |
|
253 |
bj |
76 |
|
|
|
77 |
|
249 |
bj |
78 |
Section ""
|
|
|
79 |
|
253 |
bj |
80 |
ReadINIStr $INSTDIR "$PLUGINSDIR\custdir.ini" "Field 2" "State"
|
|
|
81 |
|
249 |
bj |
82 |
Var /GLOBAL Externals
|
|
|
83 |
Var /GLOBAL CGLA
|
|
|
84 |
Var /GLOBAL Geometry
|
|
|
85 |
Var /GLOBAL GLGraphics
|
|
|
86 |
Var /GLOBAL HMesh
|
|
|
87 |
Var /GLOBAL LinAlg
|
|
|
88 |
Var /GLOBAL Util
|
|
|
89 |
|
|
|
90 |
# Get flags of each section into appropriate variables
|
|
|
91 |
SectionGetFlags ${Externals_flag} $Externals
|
|
|
92 |
SectionGetFlags ${CGLA_flag} $CGLA
|
|
|
93 |
SectionGetFlags ${Geometry_flag} $Geometry
|
|
|
94 |
SectionGetFlags ${GLGraphics_flag} $GLGraphics
|
|
|
95 |
SectionGetFlags ${HMesh_flag} $HMesh
|
|
|
96 |
SectionGetFlags ${LinAlg_flag} $LinAlg
|
|
|
97 |
SectionGetFlags ${Util_flag} $Util
|
|
|
98 |
|
|
|
99 |
;MessageBox MB_OK "Externals: $0 $\r$\n GEL: $1 $\r$\n "
|
|
|
100 |
|
|
|
101 |
${If} $Externals = 1
|
|
|
102 |
SetOutPath $INSTDIR\bin
|
|
|
103 |
File externals\bin\*.dll
|
|
|
104 |
|
|
|
105 |
SetOutPath $INSTDIR\lib
|
|
|
106 |
File externals\lib\*.lib
|
|
|
107 |
|
|
|
108 |
SetOutPath $INSTDIR
|
|
|
109 |
File /r externals\include
|
|
|
110 |
${EndIf}
|
|
|
111 |
|
|
|
112 |
!macro GELModule mvar mstring
|
|
|
113 |
${If} ${mvar} = 1
|
|
|
114 |
SetOutPath $INSTDIR\lib
|
|
|
115 |
File current\lib\${mstring}.lib
|
|
|
116 |
|
|
|
117 |
SetOutPath $INSTDIR\include
|
|
|
118 |
File /r current\include\${mstring}
|
|
|
119 |
${EndIf}
|
|
|
120 |
!macroend
|
|
|
121 |
|
|
|
122 |
!insertmacro GELModule $CGLA "CGLA"
|
|
|
123 |
!insertmacro GELModule $Geometry "Geometry"
|
|
|
124 |
!insertmacro GELModule $GLGraphics "GLGraphics"
|
|
|
125 |
!insertmacro GELModule $HMesh "HMesh"
|
|
|
126 |
!insertmacro GELModule $LinAlg "LinAlg"
|
|
|
127 |
!insertmacro GELModule $Util "Util"
|
|
|
128 |
|
|
|
129 |
# Create Environment variables
|
|
|
130 |
|
253 |
bj |
131 |
ReadINIStr $R2 "$PLUGINSDIR\custdir.ini" "Field 3" "State"
|
|
|
132 |
ReadINIStr $R3 "$PLUGINSDIR\custdir.ini" "Field 4" "State"
|
|
|
133 |
|
|
|
134 |
${If} $R2 = 0
|
|
|
135 |
WriteRegExpandStr 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GEL_INCLUDE" "$INSTDIR\include"
|
|
|
136 |
WriteRegExpandStr 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GEL_LIB" "$INSTDIR\lib"
|
|
|
137 |
WriteRegExpandStr 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GEL_BIN" "$INSTDIR\bin"
|
|
|
138 |
|
|
|
139 |
${Else}
|
|
|
140 |
WriteRegExpandStr 'HKCU' "Environment" "GEL_INCLUDE" "$INSTDIR\include"
|
|
|
141 |
WriteRegExpandStr 'HKCU' "Environment" "GEL_LIB" "$INSTDIR\lib"
|
|
|
142 |
WriteRegExpandStr 'HKCU' "Environment" "GEL_BIN" "$INSTDIR\bin"
|
|
|
143 |
|
|
|
144 |
${EndIf}
|
|
|
145 |
|
286 |
bj |
146 |
ClearErrors
|
|
|
147 |
FileOpen $0 $INSTDIR\bin\setenvvars.bat w
|
|
|
148 |
IfErrors done
|
|
|
149 |
FileWrite $0 "set GEL_INCLUDE=$INSTDIR\include"
|
|
|
150 |
FileWrite $0 "set GEL_LIB=$INSTDIR\lib"
|
|
|
151 |
FileWrite $0 "set GEL_BIN=$INSTDIR\bin"
|
|
|
152 |
FileClose $0
|
|
|
153 |
done:
|
253 |
bj |
154 |
|
249 |
bj |
155 |
# Add %GEL_BIN% to path
|
253 |
bj |
156 |
|
|
|
157 |
${If} $R2 = 0
|
|
|
158 |
ReadRegStr $1 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
|
|
|
159 |
${Else}
|
|
|
160 |
ReadRegStr $1 'HKCU' "Environment" "PATH"
|
|
|
161 |
${EndIf}
|
|
|
162 |
|
249 |
bj |
163 |
StrCpy $2 $1 1 -1 # copy last char
|
|
|
164 |
StrCmp $2 ";" 0 +2 # if last char == ;
|
|
|
165 |
StrCpy $1 $1 -1 # remove last char
|
|
|
166 |
StrCmp $1 "" AddToPath_NTdoIt
|
|
|
167 |
StrCpy $0 "$1;%GEL_BIN%"
|
|
|
168 |
AddToPath_NTdoIt:
|
253 |
bj |
169 |
${If} $R2 = 0
|
|
|
170 |
WriteRegExpandStr 'HKLM' "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $0
|
|
|
171 |
${Else}
|
|
|
172 |
WriteRegExpandStr 'HKCU' "Environment" "PATH" $0
|
|
|
173 |
${EndIf}
|
249 |
bj |
174 |
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
SectionEnd ; end the section
|
253 |
bj |
178 |
|
|
|
179 |
Function .onInit
|
|
|
180 |
|
|
|
181 |
;Extract InstallOptions files
|
|
|
182 |
;$PLUGINSDIR will automatically be removed when the installer closes
|
|
|
183 |
|
|
|
184 |
InitPluginsDir
|
|
|
185 |
File /oname=$PLUGINSDIR\custdir.ini "custdir.ini"
|
|
|
186 |
WriteINIStr "$PLUGINSDIR\custdir.ini" "Field 2" "State" $INSTDIR
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
FunctionEnd
|
|
|
190 |
|
|
|
191 |
Function SetCustom
|
|
|
192 |
|
|
|
193 |
;Display the InstallOptions dialog
|
|
|
194 |
|
|
|
195 |
Push ${TEMP1}
|
|
|
196 |
|
|
|
197 |
InstallOptions::dialog "$PLUGINSDIR\custdir.ini"
|
|
|
198 |
Pop ${TEMP1}
|
|
|
199 |
|
|
|
200 |
Pop ${TEMP1}
|
|
|
201 |
|
|
|
202 |
FunctionEnd
|