Enable building of the installer with MinGW-w64, patch by Caleb Joseph (Dobz) thanks...
[blender.git] / release / windows / installer / 00.sconsblender.nsi
1 ;
2 ;
3 ; Blender Self-Installer for Windows (NSIS - http://nsis.sourceforge.net)
4 ;
5
6 SetCompressor /SOLID lzma
7
8 Name "Blender [VERSION]" 
9
10 RequestExecutionLevel admin
11
12 !include "MUI.nsh"
13 !include "WinVer.nsh"
14 !include "FileFunc.nsh"
15 !include "WordFunc.nsh"
16 !include "nsDialogs.nsh"
17 !include "x64.nsh"
18
19 !define MUI_ABORTWARNING
20
21 !define MUI_WELCOMEPAGE_TEXT  "This wizard will guide you through the installation of Blender. It is recommended that you close all other applications before starting Setup."
22 !define MUI_WELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp"
23 !define MUI_HEADERIMAGE
24 !define MUI_HEADERIMAGE_BITMAP  "[RELDIR]\00.header.bmp"
25 !define MUI_COMPONENTSPAGE_SMALLDESC
26 !define MUI_FINISHPAGE_RUN "$INSTDIR\blender.exe"
27 !define MUI_CHECKBITMAP "[RELDIR]\00.checked.bmp"
28 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp"
29
30 !insertmacro MUI_PAGE_WELCOME
31 !insertmacro MUI_PAGE_LICENSE "[DISTDIR]\Copyright.txt"
32 !insertmacro MUI_PAGE_COMPONENTS
33     
34 !insertmacro MUI_PAGE_DIRECTORY
35 !insertmacro MUI_PAGE_INSTFILES
36 !insertmacro MUI_PAGE_FINISH
37   
38 !insertmacro MUI_UNPAGE_WELCOME
39 UninstPage custom un.OptionalRemoveConfig un.OptionalRemoveConfigOnLeave
40 !insertmacro MUI_UNPAGE_CONFIRM
41 !insertmacro MUI_UNPAGE_INSTFILES
42 !insertmacro MUI_UNPAGE_FINISH
43
44 !insertmacro Locate
45 !insertmacro VersionCompare
46
47
48 Icon "[RELDIR]\00.installer.ico"
49 UninstallIcon "[RELDIR]\00.installer.ico"
50
51 ;--------------------------------
52 ;Languages
53  
54   !insertmacro MUI_LANGUAGE "English"
55     
56 ;--------------------------------
57 ;Language Strings
58
59   ;Description
60   LangString DESC_InstallFiles ${LANG_ENGLISH} "Copy all required files to the application folder."
61   LangString DESC_StartMenu ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)"
62   LangString DESC_DesktopShortcut ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop."
63   LangString DESC_BlendRegister ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc."
64 ;--------------------------------
65 ;Data
66
67 Caption "Blender [VERSION] Installer"
68 OutFile "[DISTDIR]\..\blender-[VERSION]-windows[BITNESS].exe"
69 InstallDir $INSTDIR ; $INSTDIR is set inside .onInit
70 BrandingText "Blender Foundation | http://www.blender.org"
71 ComponentText "This will install Blender [VERSION] on your computer."
72
73 DirText "Use the field below to specify the folder where you want Blender to be copied to. To specify a different folder, type a new name or use the Browse button to select an existing folder."
74
75 SilentUnInstall normal
76
77 Var SHORTVERSION ; This is blender_version_decimal() from path_util.c
78 Var BLENDERCONFIG
79 Var REMOVECONFIG
80
81 ; Custom controls
82 Var HWND
83
84 Var HWND_KEEPCONFIG
85 Var HWND_REMOVECONFIG
86
87 Function .onInit
88   ClearErrors
89   StrCpy $SHORTVERSION "[SHORTVERSION]"
90
91   ${If} ${RunningX64}
92     ${If} "[BITNESS]" == "32"
93       StrCpy $INSTDIR "$PROGRAMFILES32\Blender Foundation\Blender" ; Can't use InstallDir inside Section
94     ${ElseIf} "[BITNESS]" == "64"
95       StrCpy $INSTDIR "$PROGRAMFILES64\Blender Foundation\Blender"
96     ${EndIf}
97   ${Else}
98     StrCpy $INSTDIR "$PROGRAMFILES\Blender Foundation\Blender"
99   ${EndIf}
100 FunctionEnd
101
102 Function un.onInit
103   SetShellVarContext current
104   StrCpy $BLENDERCONFIG "$APPDATA\Blender Foundation\Blender"
105   SetShellVarContext all
106 FunctionEnd
107
108 Function un.OptionalRemoveConfig
109   nsDialogs::Create /NOUNLOAD 1018
110   Pop $HWND
111   
112   ${If} $HWND == error
113     Abort
114   ${EndIf}
115   
116   ${NSD_CreateRadioButton} 0 50 100% 12u "Keep configuration files, autosaved .blend files and installed addons (recommended)"
117   Pop $HWND_KEEPCONFIG
118   ${NSD_CreateRadioButton} 0 80 100% 12u "Remove all files, including configuration files, autosaved .blend files and installed addons"
119   Pop $HWND_REMOVECONFIG
120
121   SendMessage $HWND_KEEPCONFIG ${BM_SETCHECK} 1 0
122   
123   nsDialogs::Show
124   
125 FunctionEnd
126
127 Function un.OptionalRemoveConfigOnLeave
128   ${NSD_GetState} $HWND_REMOVECONFIG $R0
129   ${If} $R0 == "1"
130     StrCpy $REMOVECONFIG "1"
131   ${Else}
132     StrCpy $REMOVECONFIG "0"
133   ${EndIf}
134 FunctionEnd
135
136
137 Section "Blender [VERSION] (required)" InstallFiles
138   SectionIn RO
139
140   ; Set output path to the installation directory.
141   SetOutPath $INSTDIR
142   ; The contents of Blender installation root dir
143   [ROOTDIRCONTS]
144   
145   ; All datafiles (python, scripts, datafiles)
146   [DODATAFILES]
147   
148   SetOutPath $INSTDIR
149   ${If} ${RunningX64}
150     SetRegView 64
151   ${EndIf}
152   ; Write the installation path into the registry
153   WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" "$INSTDIR"
154   WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]"
155   ; Write the uninstall keys for Windows
156   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender"
157   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "Publisher" "Blender Foundation"
158   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "URLInfoAbout" "http://www.blender.org/"
159   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayVersion" "[VERSION]"
160   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayIcon" "$INSTDIR\blender.exe"
161   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "UninstallString" '"$INSTDIR\uninstall.exe"'
162   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoModify" 1
163   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoRepair " 1
164   WriteUninstaller "uninstall.exe"
165
166 SectionEnd
167
168 Section "Add Start Menu Shortcuts" StartMenu
169   SetShellVarContext all
170   CreateDirectory "$SMPROGRAMS\Blender Foundation\Blender\"
171   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
172   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Blender.lnk" "$INSTDIR\Blender.exe" "" "$INSTDIR\blender.exe" 0
173   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Readme.lnk" "$INSTDIR\readme.html" "" "" 0
174   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Copyright.lnk" "$INSTDIR\Copyright.txt" "" "$INSTDIR\copyright.txt" 0
175   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\GPL-license.lnk" "$INSTDIR\GPL-license.txt" "" "$INSTDIR\GPL-license.txt" 0
176   System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
177 SectionEnd
178
179 Section "Add Desktop Shortcut" DesktopShortcut
180   CreateShortCut "$DESKTOP\Blender.lnk" "$INSTDIR\blender.exe" "" "$INSTDIR\blender.exe" 0
181   System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
182 SectionEnd
183
184 Section "Open .blend files with Blender" BlendRegister
185   ExecWait '"$INSTDIR\blender.exe" -r'
186 SectionEnd
187
188 UninstallText "This will uninstall Blender [VERSION], and all installed files. Hit 'Uninstall' to continue."
189
190 Section "Uninstall"
191   ; Remove registry keys
192   ${If} ${RunningX64}
193     SetRegView 64
194   ${EndIf}
195   
196   ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion"
197   DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blender"
198   DeleteRegKey HKLM "SOFTWARE\BlenderFoundation"
199   DeleteRegKey HKCR ".blend"
200   DeleteRegKey HKCR "blendfile"
201   DeleteRegKey HKCR "CLSID\{D45F043D-F17F-4e8a-8435-70971D9FA46D}"
202   SetShellVarContext all
203  
204   ; Remove files
205   [DELROOTDIRCONTS]
206   [DELDATAFILES]
207   [DELDATADIRS]
208
209   Delete "$INSTDIR\uninstall.exe"
210
211   ${If} $REMOVECONFIG == "1"
212     RMDir /r "$BLENDERCONFIG\$SHORTVERSION"
213   ${Endif}
214
215   ; Remove install directory if it's empty
216   RMDir $INSTDIR
217   ; Remove shortcuts
218   Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*"
219   Delete "$DESKTOP\Blender.lnk"
220   ; Remove all link related directories and files
221   RMDir "$SMPROGRAMS\Blender Foundation\Blender"
222   RMDir "$SMPROGRAMS\Blender Foundation"
223   
224   System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; Refresh icons
225 SectionEnd
226
227 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
228   !insertmacro MUI_DESCRIPTION_TEXT ${InstallFiles} $(DESC_InstallFiles)
229   !insertmacro MUI_DESCRIPTION_TEXT ${StartMenu} $(DESC_StartMenu)
230   !insertmacro MUI_DESCRIPTION_TEXT ${DesktopShortcut} $(DESC_DesktopShortcut)
231   !insertmacro MUI_DESCRIPTION_TEXT ${BlendRegister} $(DESC_BlendRegister)
232 !insertmacro MUI_FUNCTION_DESCRIPTION_END
233