summaryrefslogtreecommitdiff
path: root/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in
blob: 4086df735ad1b09a203826415ecfdd216a721e2e (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
;--------------------------------
;Include Modern UI

!include "MUI2.nsh"

;SetCompress off ; Useful to disable compression under development
SetCompressor /Solid LZMA ; Useful to disable compression under development

; Include FileFunc for command line parsing options
!include "FileFunc.nsh"
!insertmacro GetParameters
!insertmacro GetOptions

;--------------------------------
;General

;Name and file
Name "NumPy super installer"
OutFile "@NUMPY_INSTALLER_NAME@"

;Default installation folder
InstallDir "$TEMP"

;--------------------------------
;Interface Settings

!define MUI_ABORTWARNING

;--------------------------------
;Pages

;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
;!insertmacro MUI_PAGE_COMPONENTS
;!insertmacro MUI_PAGE_DIRECTORY
;!insertmacro MUI_PAGE_INSTFILES

;!insertmacro MUI_UNPAGE_CONFIRM
;!insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Component Sections

!include 'Sections.nsh'
!include LogicLib.nsh

Var HasSSE2
Var HasSSE3
Var CPUSSE
Var option_arch

Function .onInit
        ; Get parameters
        var /GLOBAL cmdLineParams
        Push $R0

        ${GetParameters} $cmdLineParams

        ; XXX; How to get a console output help ? GUI seems useless when using
        ; command line help...
        ; ; /? param (help)
        ; ClearErrors
        ; ${GetOptions} $cmdLineParams '/?' $R0
        ; IfErrors +3 0
        ; MessageBox MB_OK "list all command line options here!"
        ; Abort

        Pop $R0

        ; Initialise options
        StrCpy $option_arch 'native'

        ; Parse Parameters
        Push $R0
        Call parseParameters
        Pop $R0
FunctionEnd

Section "Core" SecCore

        ;SectionIn RO
        SetOutPath "$INSTDIR"

        ;Create uninstaller
        ;WriteUninstaller "$INSTDIR\Uninstall.exe"

        DetailPrint "Install dir for actual installers is $INSTDIR"

        StrCpy $CPUSSE "0"
        CpuCaps::hasSSE2
        Pop $0
        StrCpy $HasSSE2 $0

        CpuCaps::hasSSE3
        Pop $0
        StrCpy $HasSSE3 $0

        ; Debug
        StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2
        include_sse2:
                DetailPrint '"Target CPU handles SSE2"'
                StrCpy $CPUSSE "2"
                goto done_sse2
        no_include_sse2:
                DetailPrint '"Target CPU does NOT handle SSE2"'
                goto done_sse2
        done_sse2:

        StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3
        include_sse3:
                DetailPrint '"Target CPU handles SSE3"'
                StrCpy $CPUSSE "3"
                goto done_sse3
        no_include_sse3:
                DetailPrint '"Target CPU does NOT handle SSE3"'
                goto done_sse3
        done_sse3:

        ClearErrors

        ${Switch} $option_arch
                ${Case} "native"
                DetailPrint '"native install (arch value: $option_arch)"'
                ${Break}
                ${Case} "nosse"
                DetailPrint '"nosse install (arch value: $option_arch)"'
                StrCpy $CPUSSE "0"
                ${Break}
                ${Case} "sse2"
                DetailPrint '"sse2 install (arch value: $option_arch)"'
                StrCpy $CPUSSE "2"
                ${Break}
                ${Case} "sse3"
                DetailPrint '"sse3 install (arch value: $option_arch)"'
                StrCpy $CPUSSE "3"
                ${Break}
                ${Default}
                MessageBox MB_OK "option /arch $option_arch not understood: only native, nosse, and sse3 are valid."
                Abort
                ${Break}
        ${EndSwitch}

        ; Install files conditionaly on detected cpu
        ${Switch} $CPUSSE
                ${Case} "3"
                DetailPrint '"Install SSE 3"'
                File "binaries\@SSE3_BINARY@"
                ExecWait '"$INSTDIR\@SSE3_BINARY@"'
                ${Break}
        ${Case} "2"
                DetailPrint '"Install SSE 2"'
                File "binaries\@SSE2_BINARY@"
                ExecWait '"$INSTDIR\@SSE2_BINARY@"'
                ${Break}
        ${Default}
                DetailPrint '"Install NO SSE"'
                File "binaries\@NOSSE_BINARY@"
                ExecWait '"$INSTDIR\@NOSSE_BINARY@"'
                ${Break}
        ${EndSwitch}

        ; Handle errors when executing installers
        IfErrors error no_error

        error:
                messageBox MB_OK "Executing numpy installer failed"
                goto done
        no_error:
                goto done
        done:

SectionEnd

Function parseParameters
    ; /arch option
    ${GetOptions} $cmdLineParams '/arch' $R0
    IfErrors +2 0
    StrCpy $option_arch $R0
FunctionEnd