-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathInstaller.nsi
More file actions
572 lines (460 loc) · 20.3 KB
/
Installer.nsi
File metadata and controls
572 lines (460 loc) · 20.3 KB
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
; Lemonade Server Installer Script
!define /ifndef NPU_DRIVER_VERSION "32.0.203.237"
; Define main variables
Name "Lemonade Server"
OutFile "Lemonade_Server_Installer.exe"
; Include modern UI elements
!include "MUI2.nsh"
!include FileFunc.nsh
; Include LogicLib for logging in silent mode
!include LogicLib.nsh
Var LogHandle
Var LEMONADE_SERVER_STRING
Var LEMONADE_CONDA_ENV
Var HYBRID_SELECTED
Var HYBRID_CLI_OPTION
; Variables for CPU detection
Var cpuName
Var isCpuSupported
Var ryzenAiPos
Var seriesStartPos
Var currentChar
; Used for string manipulation
!include "StrFunc.nsh"
${StrLoc}
; Define a section for the installation
Section "Install Main Components" SEC01
SectionIn RO ; Read only, always installed
DetailPrint "------------------------"
DetailPrint "- Installation Section -"
DetailPrint "------------------------"
; Once we're done downloading and installing the pip packages the size comes out to about 2GB
AddSize 2097152
; Check if directory exists before proceeding
IfFileExists "$INSTDIR\*.*" 0 continue_install
${IfNot} ${Silent}
MessageBox MB_YESNO "An existing $LEMONADE_SERVER_STRING installation was found at $INSTDIR.$\n$\nWould you like to remove it and continue with the installation?" IDYES remove_dir
; If user selects No, show exit message and quit the installer
MessageBox MB_OK "Installation cancelled. Exiting installer..."
Quit
${Else}
Goto remove_dir
${EndIf}
remove_dir:
; Try to remove directory and verify it was successful
; Attempt conda remove of the env, to help speed things up
ExecWait 'conda env remove -yp "$INSTDIR\$LEMONADE_CONDA_ENV"'
; Delete all remaining files
RMDir /r "$INSTDIR"
IfFileExists "$INSTDIR\*.*" 0 continue_install
${IfNot} ${Silent}
MessageBox MB_OK "Unable to remove existing installation. Please close any applications using $LEMONADE_SERVER_STRING and try again."
${EndIf}
Quit
continue_install:
; Create fresh directory
CreateDirectory "$INSTDIR"
DetailPrint "*** INSTALLATION STARTED ***"
; Attach console to installation to enable logging
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
StrCpy $LogHandle $0 ; Save the handle to LogHandle variable
System::Call 'kernel32::AttachConsole(i -1)i.r1'
${If} $LogHandle = 0
${OrIf} $1 = 0
System::Call 'kernel32::AllocConsole()'
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
StrCpy $LogHandle $0 ; Update the LogHandle variable if the console was allocated
${EndIf}
DetailPrint "- Initialized logging"
; Set the output path for future operations
SetOutPath "$INSTDIR"
DetailPrint "Starting '$LEMONADE_SERVER_STRING' Installation..."
DetailPrint 'Configuration:'
DetailPrint ' Install Dir: $INSTDIR'
DetailPrint ' Minimum NPU Driver Version: ${NPU_DRIVER_VERSION}'
DetailPrint '-------------------------------------------'
# Pack turnkeyml repo into the installer
# Exclude hidden files (like .git, .gitignore) and the installation folder itself
File /r /x nsis.exe /x installer /x .* /x *.pyc /x docs /x examples /x utilities ..\*.* lemonade_server.bat
# Create bin directory and move lemonade_server.bat there
CreateDirectory "$INSTDIR\bin"
Rename "$INSTDIR\lemonade_server.bat" "$INSTDIR\bin\lemonade_server.bat"
DetailPrint "- Packaged repo"
; Check if conda is available
ExecWait 'where conda' $2
DetailPrint "- Checked if conda is available"
; If conda is not found, show a message
; Otherwise, continue with the installation
StrCmp $2 "0" create_env conda_not_available
conda_not_available:
DetailPrint "- Conda not installed."
${IfNot} ${Silent}
MessageBox MB_YESNO "Conda is not installed. Would you like to install Miniconda?" IDYES install_miniconda IDNO exit_installer
${Else}
Goto install_miniconda
${EndIf}
exit_installer:
DetailPrint "- Something went wrong. Exiting installer"
Quit
install_miniconda:
DetailPrint "-------------"
DetailPrint "- Miniconda -"
DetailPrint "-------------"
DetailPrint "- Downloading Miniconda installer..."
ExecWait 'curl -s -o "$TEMP\Miniconda3-latest-Windows-x86_64.exe" "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"'
; Install Miniconda silently
ExecWait '"$TEMP\Miniconda3-latest-Windows-x86_64.exe" /InstallationType=JustMe /AddToPath=1 /RegisterPython=0 /S /D=$PROFILE\miniconda3' $2
; Check if Miniconda installation was successful
${If} $2 == 0
DetailPrint "- Miniconda installation successful"
${IfNot} ${Silent}
MessageBox MB_OK "Miniconda has been successfully installed."
${EndIf}
StrCpy $R1 "$PROFILE\miniconda3\Scripts\conda.exe"
Goto create_env
${Else}
DetailPrint "- Miniconda installation failed"
${IfNot} ${Silent}
MessageBox MB_OK "Error: Miniconda installation failed. Installation will be aborted."
${EndIf}
Goto exit_installer
${EndIf}
create_env:
DetailPrint "---------------------"
DetailPrint "- Conda Environment -"
DetailPrint "---------------------"
DetailPrint "- Initializing conda..."
; Use the appropriate conda executable
${If} $R1 == ""
StrCpy $R1 "conda"
${EndIf}
; Initialize conda (needed for systems where conda was previously installed but not initialized)
nsExec::ExecToStack '"$R1" init'
DetailPrint "- Creating a Python 3.10 environment named '$LEMONADE_CONDA_ENV' in the installation directory: $INSTDIR..."
ExecWait '"$R1" create -p "$INSTDIR\$LEMONADE_CONDA_ENV" python=3.10 -y' $R0
; Check if the environment creation was successful (exit code should be 0)
StrCmp $R0 0 install_lemonade env_creation_failed
env_creation_failed:
DetailPrint "- ERROR: Environment creation failed"
; Display an error message and exit
${IfNot} ${Silent}
MessageBox MB_OK "ERROR: Failed to create the Python environment. Installation will be aborted."
${EndIf}
Quit
install_lemonade:
DetailPrint "-------------------------"
DetailPrint "- Lemonade Installation -"
DetailPrint "-------------------------"
DetailPrint "- Installing $LEMONADE_SERVER_STRING..."
${If} $HYBRID_SELECTED == "true"
nsExec::ExecToLog '"$INSTDIR\$LEMONADE_CONDA_ENV\python.exe" -m pip install -e "$INSTDIR"[llm-oga-hybrid] --no-warn-script-location'
${Else}
nsExec::ExecToLog '"$INSTDIR\$LEMONADE_CONDA_ENV\python.exe" -m pip install -e "$INSTDIR"[llm] --no-warn-script-location'
${EndIf}
Pop $R0 ; Return value
DetailPrint "- $LEMONADE_SERVER_STRING install return code: $R0"
; Check if installation was successful (exit code should be 0)
StrCmp $R0 0 install_success install_failed
install_success:
DetailPrint "- $LEMONADE_SERVER_STRING installation successful"
DetailPrint "*** INSTALLATION COMPLETED ***"
# Create a shortcut inside $INSTDIR
CreateShortcut "$INSTDIR\lemonade-server.lnk" "$INSTDIR\bin\lemonade_server.bat" "serve --keep-alive" "$INSTDIR\img\favicon.ico"
; Add bin folder to system PATH
DetailPrint "- Adding bin directory to system PATH..."
; Get the current PATH value from the registry
ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
; Add bin folder (containing 'lemonade-server') to path while avoiding duplicate entries
ExecWait 'setx PATH "$INSTDIR\bin;$0" -m'
DetailPrint "- Successfully updated system PATH"
Goto end
install_failed:
DetailPrint "- $LEMONADE_SERVER_STRING installation failed"
${IfNot} ${Silent}
MessageBox MB_OK "ERROR: $LEMONADE_SERVER_STRING package failed to install using pip. Installation will be aborted."
${EndIf}
Quit
end:
SectionEnd
Section "Install Ryzen AI Hybrid Execution" HybridSec
DetailPrint "------------------------"
DetailPrint "- Ryzen AI Section -"
DetailPrint "------------------------"
; Once we're done downloading and installing the archive the size comes out to about 370MB
AddSize 388882
nsExec::ExecToLog 'conda run --no-capture-output -p $INSTDIR\$LEMONADE_CONDA_ENV lemonade-install --ryzenai hybrid -y'
Pop $R0 ; Return value
DetailPrint "Hybrid execution mode install return code: $R0"
; Check if installation was successful (exit code should be 0)
StrCmp $R0 0 end install_failed
install_failed:
DetailPrint "- Hybrid installation failed"
${IfNot} ${Silent}
MessageBox MB_OK "ERROR: Hybrid mode failed to install using pip. Installation will be aborted."
${EndIf}
Quit
end:
SectionEnd
SubSection /e "Selected Models" ModelsSec
Section /o "Qwen2.5-0.5B-Instruct-CPU" Qwen05Sec
SectionIn 1
AddSize 999604 ;
StrCpy $9 "$9Qwen2.5-0.5B-Instruct-CPU "
SectionEnd
Section "Llama-3.2-1B-Instruct-Hybrid" Llama1BSec
SectionIn 1
AddSize 1884397 ;
StrCpy $9 "$9Llama-3.2-1B-Instruct-Hybrid "
SectionEnd
Section "Llama-3.2-3B-Instruct-Hybrid" Llama3BSec
SectionIn 1
AddSize 4268402 ;
StrCpy $9 "$9Llama-3.2-3B-Instruct-Hybrid "
SectionEnd
Section /o "Phi-3-Mini-Instruct-Hybrid" PhiSec
SectionIn 1
AddSize 4185551 ;
StrCpy $9 "$9Phi-3-Mini-Instruct-Hybrid "
SectionEnd
Section /o "Qwen-1.5-7B-Chat-Hybrid" Qwen7BSec
SectionIn 1
AddSize 8835894 ;
StrCpy $9 "$9Qwen-1.5-7B-Chat-Hybrid "
SectionEnd
Section /o "DeepSeek-R1-Distill-Llama-8B-Hybrid" DeepSeekLlama8BSec
SectionIn 1
AddSize 9084315 ;
StrCpy $9 "$9DeepSeek-R1-Distill-Llama-8B-Hybrid "
SectionEnd
Section /o "DeepSeek-R1-Distill-Qwen-7B-Hybrid" DeepSeekQwen7BSec
SectionIn 1
AddSize 9502412 ;
StrCpy $9 "$9DeepSeek-R1-Distill-Qwen-7B-Hybrid "
SectionEnd
Section "-Download Models" DownloadModels
${If} ${Silent}
${GetParameters} $CMDLINE
${GetOptions} $CMDLINE "/Models=" $R0
${If} $R0 != ""
nsExec::ExecToLog 'conda run --no-capture-output -p $INSTDIR\$LEMONADE_CONDA_ENV lemonade-install --models $R0'
${Else}
; Otherwise, only the default CPU model will be installed
nsExec::ExecToLog 'conda run --no-capture-output -p $INSTDIR\$LEMONADE_CONDA_ENV lemonade-install --models Qwen2.5-0.5B-Instruct-CPU'
${EndIf}
${Else}
nsExec::ExecToLog 'conda run --no-capture-output -p $INSTDIR\$LEMONADE_CONDA_ENV lemonade-install --models $9'
${EndIf}
SectionEnd
SubSectionEnd
Section "-Add Desktop Shortcut" ShortcutSec
; Create a desktop shortcut that passes the conda environment name as a parameter
CreateShortcut "$DESKTOP\lemonade-server.lnk" "$INSTDIR\bin\lemonade_server.bat" "serve --keep-alive" "$INSTDIR\img\favicon.ico"
SectionEnd
Function RunServer
ExecShell "open" "$INSTDIR\LEMONADE-SERVER.lnk"
FunctionEnd
; Define constants for better readability
!define ICON_FILE "..\img\favicon.ico"
; Finish Page settings
!define MUI_TEXT_FINISH_INFO_TITLE "$LEMONADE_SERVER_STRING installed successfully!"
!define MUI_TEXT_FINISH_INFO_TEXT "A shortcut has been added to your Desktop. What would you like to do next?"
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION RunServer
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_RUN_TEXT "Run Lemonade Server"
Function .onSelChange
; Check hybrid selection status
StrCpy $HYBRID_SELECTED "false"
SectionGetFlags ${HybridSec} $0
IntOp $0 $0 & ${SF_SELECTED}
StrCmp $0 ${SF_SELECTED} 0 hybrid_disabled
StrCpy $HYBRID_SELECTED "true"
; If hybrid is enabled, check if at least one hybrid model is selected
SectionGetFlags ${Llama1BSec} $1
IntOp $1 $1 & ${SF_SELECTED}
${If} $1 == ${SF_SELECTED}
Goto end
${EndIf}
SectionGetFlags ${Llama3BSec} $1
IntOp $1 $1 & ${SF_SELECTED}
${If} $1 == ${SF_SELECTED}
Goto end
${EndIf}
SectionGetFlags ${PhiSec} $1
IntOp $1 $1 & ${SF_SELECTED}
${If} $1 == ${SF_SELECTED}
Goto end
${EndIf}
SectionGetFlags ${Qwen7BSec} $1
IntOp $1 $1 & ${SF_SELECTED}
${If} $1 == ${SF_SELECTED}
Goto end
${EndIf}
SectionGetFlags ${DeepSeekLlama8BSec} $1
IntOp $1 $1 & ${SF_SELECTED}
${If} $1 == ${SF_SELECTED}
Goto end
${EndIf}
SectionGetFlags ${DeepSeekQwen7BSec} $1
IntOp $1 $1 & ${SF_SELECTED}
${If} $1 == ${SF_SELECTED}
Goto end
${EndIf}
; If no hybrid model is selected, select Llama-1B by default
SectionGetFlags ${Llama1BSec} $1
IntOp $1 $1 | ${SF_SELECTED}
SectionSetFlags ${Llama1BSec} $1
MessageBox MB_OK "At least one hybrid model must be selected when hybrid execution is enabled. Llama-3.2-1B-Instruct-Hybrid has been automatically selected."
Goto end
hybrid_disabled:
; When hybrid is disabled, select Qwen2.5-0.5B-Instruct-CPU and disable all other hybrid model selections
SectionGetFlags ${Qwen05Sec} $1
IntOp $1 $1 | ${SF_SELECTED}
SectionSetFlags ${Qwen05Sec} $1
SectionGetFlags ${Llama1BSec} $1
IntOp $1 $1 & ${SECTION_OFF}
SectionSetFlags ${Llama1BSec} $1
SectionGetFlags ${Llama3BSec} $1
IntOp $1 $1 & ${SECTION_OFF}
SectionSetFlags ${Llama3BSec} $1
SectionGetFlags ${PhiSec} $1
IntOp $1 $1 & ${SECTION_OFF}
SectionSetFlags ${PhiSec} $1
SectionGetFlags ${Qwen7BSec} $1
IntOp $1 $1 & ${SECTION_OFF}
SectionSetFlags ${Qwen7BSec} $1
SectionGetFlags ${DeepSeekLlama8BSec} $1
IntOp $1 $1 & ${SECTION_OFF}
SectionSetFlags ${DeepSeekLlama8BSec} $1
SectionGetFlags ${DeepSeekQwen7BSec} $1
IntOp $1 $1 & ${SECTION_OFF}
SectionSetFlags ${DeepSeekQwen7BSec} $1
end:
FunctionEnd
Function SkipLicense
${IfNot} ${SectionIsSelected} ${HybridSec}
abort ;skip AMD license if hybrid was not enabled
${EndIf}
FunctionEnd
; MUI Settings
!insertmacro MUI_PAGE_WELCOME
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipLicense
!insertmacro MUI_PAGE_LICENSE "AMD_LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW .onSelChange
; Set the installer icon
Icon ${ICON_FILE}
; Language settings
LangString MUI_TEXT_WELCOME_INFO_TITLE "${LANG_ENGLISH}" "Welcome to the $LEMONADE_SERVER_STRING Installer"
LangString MUI_TEXT_WELCOME_INFO_TEXT "${LANG_ENGLISH}" "This wizard will install $LEMONADE_SERVER_STRING on your computer."
LangString MUI_TEXT_DIRECTORY_TITLE "${LANG_ENGLISH}" "Select Installation Directory"
LangString MUI_TEXT_INSTALLING_TITLE "${LANG_ENGLISH}" "Installing $LEMONADE_SERVER_STRING"
LangString MUI_TEXT_FINISH_TITLE "${LANG_ENGLISH}" "Installation Complete"
LangString MUI_TEXT_FINISH_SUBTITLE "${LANG_ENGLISH}" "Thank you for installing $LEMONADE_SERVER_STRING!"
LangString MUI_TEXT_ABORT_TITLE "${LANG_ENGLISH}" "Installation Aborted"
LangString MUI_TEXT_ABORT_SUBTITLE "${LANG_ENGLISH}" "Installation has been aborted."
LangString MUI_BUTTONTEXT_FINISH "${LANG_ENGLISH}" "Finish"
LangString MUI_TEXT_LICENSE_TITLE ${LANG_ENGLISH} "AMD License Agreement"
LangString MUI_TEXT_LICENSE_SUBTITLE ${LANG_ENGLISH} "Please review the license terms before installing AMD Ryzen AI Hybrid Execution Mode."
LangString DESC_SEC01 ${LANG_ENGLISH} "The minimum set of dependencies for a lemonade server that runs LLMs on CPU."
LangString DESC_HybridSec ${LANG_ENGLISH} "Add support for running LLMs on Ryzen AI hybrid execution mode. Only available on Ryzen AI 300-series processors."
LangString DESC_ModelsSec ${LANG_ENGLISH} "Select which models to install"
LangString DESC_Qwen05Sec ${LANG_ENGLISH} "Small CPU-only Qwen model"
LangString DESC_Llama1BSec ${LANG_ENGLISH} "1B parameter Llama model with hybrid execution"
LangString DESC_Llama3BSec ${LANG_ENGLISH} "3B parameter Llama model with hybrid execution"
LangString DESC_PhiSec ${LANG_ENGLISH} "Phi-3 Mini model with hybrid execution"
LangString DESC_Qwen7BSec ${LANG_ENGLISH} "7B parameter Qwen model with hybrid execution"
LangString DESC_DeepSeekLlama8BSec ${LANG_ENGLISH} "8B parameter DeepSeek Llama model with hybrid execution"
LangString DESC_DeepSeekQwen7BSec ${LANG_ENGLISH} "7B parameter DeepSeek Qwen model with hybrid execution"
; Insert the description macros
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(DESC_SEC01)
!insertmacro MUI_DESCRIPTION_TEXT ${HybridSec} $(DESC_HybridSec)
!insertmacro MUI_DESCRIPTION_TEXT ${ModelsSec} $(DESC_ModelsSec)
!insertmacro MUI_DESCRIPTION_TEXT ${Qwen05Sec} $(DESC_Qwen05Sec)
!insertmacro MUI_DESCRIPTION_TEXT ${Llama1BSec} $(DESC_Llama1BSec)
!insertmacro MUI_DESCRIPTION_TEXT ${Llama3BSec} $(DESC_Llama3BSec)
!insertmacro MUI_DESCRIPTION_TEXT ${PhiSec} $(DESC_PhiSec)
!insertmacro MUI_DESCRIPTION_TEXT ${Qwen7BSec} $(DESC_Qwen7BSec)
!insertmacro MUI_DESCRIPTION_TEXT ${DeepSeekLlama8BSec} $(DESC_DeepSeekLlama8BSec)
!insertmacro MUI_DESCRIPTION_TEXT ${DeepSeekQwen7BSec} $(DESC_DeepSeekQwen7BSec)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Function .onInit
StrCpy $LEMONADE_SERVER_STRING "Lemonade Server"
StrCpy $LEMONADE_CONDA_ENV "lemon_env"
StrCpy $HYBRID_SELECTED "true"
; Create a variable to store selected models
StrCpy $9 "" ; $9 will hold our list of selected models
; Set the install directory, allowing /D override from CLI install
${If} $InstDir != ""
; /D was used
${Else}
; Use the default
StrCpy $InstDir "$LOCALAPPDATA\lemonade_server"
${EndIf}
; Check CPU name to determine if Hybrid section should be enabled
DetailPrint "Checking CPU model..."
; Use registry query to get CPU name
nsExec::ExecToStack 'reg query "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0" /v ProcessorNameString'
Pop $0 ; Return value
Pop $cpuName ; Output (CPU name)
DetailPrint "Detected CPU: $cpuName"
; Check if CPU name contains "Ryzen AI" and a 3-digit number starting with 3
StrCpy $isCpuSupported "false" ; Initialize CPU allowed flag to false
${StrLoc} $ryzenAiPos $cpuName "Ryzen AI" ">"
${If} $ryzenAiPos != ""
; Found "Ryzen AI", now look for 3xx series
${StrLoc} $seriesStartPos $cpuName " 3" ">"
${If} $seriesStartPos != ""
; Check if the character after "3" is a digit (first digit of model number)
StrCpy $currentChar $cpuName 1 $seriesStartPos+2
${If} $currentChar >= "0"
${AndIf} $currentChar <= "9"
; Check if the character after that is also a digit (second digit of model number)
StrCpy $currentChar $cpuName 1 $seriesStartPos+3
${If} $currentChar >= "0"
${AndIf} $currentChar <= "9"
; Check if the character after the third digit is a space or end of string
StrCpy $currentChar $cpuName 1 $seriesStartPos+4
${If} $currentChar == " "
${OrIf} $currentChar == ""
; Found a complete 3-digit number starting with 3
StrCpy $isCpuSupported "true"
DetailPrint "Detected Ryzen AI 3xx series processor"
${EndIf}
${EndIf}
${EndIf}
${EndIf}
${EndIf}
DetailPrint "CPU is compatible with Ryzen AI hybrid software: $isCpuSupported"
; Check if CPU is in the allowed models list
${If} $isCpuSupported != "true"
; Disable Hybrid section if CPU is not in allowed list
SectionGetFlags ${HybridSec} $0
IntOp $0 $0 & ${SECTION_OFF} ; Turn off selection
IntOp $0 $0 | ${SF_RO} ; Make it read-only (can't be selected)
SectionSetFlags ${HybridSec} $0
StrCpy $HYBRID_SELECTED "false"
${EndIf}
; Disable hybrid mode by default in silent mode
; Use /Extras="hybrid" option to enable it
${If} ${Silent}
${GetParameters} $CMDLINE
${GetOptions} $CMDLINE "/Extras=" $HYBRID_CLI_OPTION
${IfNot} $HYBRID_CLI_OPTION == "hybrid"
SectionSetFlags ${HybridSec} 0
StrCpy $HYBRID_SELECTED "false"
${ElseIf} $isCpuSupported != "true"
; Don't allow hybrid mode if CPU is not in allowed list, even if specified in command line
SectionSetFlags ${HybridSec} 0
StrCpy $HYBRID_SELECTED "false"
${EndIf}
${EndIf}
; Call onSelChange to ensure initial model selection state is correct
Call .onSelChange
FunctionEnd