@@ -26,68 +26,49 @@ Source: "vcruntime140_1.dll"; DestDir: "{app}"; Flags: ignoreversion
2626[Icons]
2727Name : " {group} \cortexcpp" ; Filename : " {app} \cortex.exe"
2828
29- ; Define the run section to execute the application after installation
30- [Run]
31- Filename : " {app} \cortex.exe" ; Parameters : " engines install cortex.llamacpp" ; WorkingDir : " {app} " ; StatusMsg : " Initializing cortex configuration..." ; Flags : nowait postinstall
29+ ; Define the uninstall run section to execute commands before uninstallation
30+ [UninstallRun]
31+ Filename : " {app} \cortex.exe" ; Parameters : " stop" ; StatusMsg : " Stopping cortexcpp service..." ; Flags : runhidden
32+
33+ ; Combine all Pascal scripting code in one [Code] section
3234[Code]
33- procedure AddToUserPath ;
35+ procedure AddToUserPathAndInstallEngines ;
3436var
3537 ExpandedAppDir: String;
36- CmdLine: String;
38+ CmdLine, CortexInstallCmd : String;
3739 ResultCode: Integer;
3840begin
3941 ExpandedAppDir := ExpandConstant(' {app}' );
4042
43+ // Add {app} to PATH
4144 CmdLine := Format(' setx PATH "%s;%%PATH%%"' , [ExpandedAppDir]);
42-
43- if Exec(' cmd.exe' , ' /C ' + CmdLine, ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode) then
44- begin
45- if ResultCode = 0 then
46- MsgBox(' Successfully added to user PATH.' , mbInformation, MB_OK)
47- else
48- MsgBox(' Failed to update user PATH. Error code: ' + IntToStr(ResultCode), mbError, MB_OK);
49- end
50- else
51- begin
52- MsgBox(' Failed to execute setx command.' , mbError, MB_OK);
53- end ;
54- end ;
45+ Exec(' cmd.exe' , ' /C ' + CmdLine, ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode);
5546
56- procedure CurStepChanged (CurStep: TSetupStep);
57- begin
58- if CurStep = ssPostInstall then
59- begin
60- AddToUserPath;
61- end ;
62- end ;
47+ // Update status message for downloading llamacpp engine
48+ WizardForm.StatusLabel.Caption := ' Downloading llama.cpp engine and dependencies ...' ;
49+ WizardForm.StatusLabel.Update;
6350
64- [Tasks]
65- Name : " desktopicon " ; Description : " Create a &desktop icon " ; GroupDescription: " Additional icons: " ; Flags : unchecked
66- Name : " quicklaunchicon " ; Description : " Create a &Quick Launch icon " ; GroupDescription: " Additional icons: " ; Flags : unchecked
51+ // Download llamacpp engine by default
52+ CortexInstallCmd := Format( ' "%s\cortex.exe" engines install cortex.llamacpp ' , [ExpandedAppDir]);
53+ Exec( ' cmd.exe ' , ' /C ' + CortexInstallCmd, ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode);
6754
68- ; Define icons for the additional tasks
69- [Icons]
70- Name : " {commondesktop}\cortexcpp" ; Filename : " {app} \cortex.exe" ; Tasks: desktopicon
71- Name : " {userappdata}\Microsoft\Internet Explorer\Quick Launch\cortexcpp" ; Filename : " {app} \cortex.exe" ; Tasks: quicklaunchicon
72-
73- ; Define the uninstall run section to execute commands before uninstallation
74- [UninstallRun]
75- Filename : " {app} \cortex.exe" ; Parameters : " stop" ; StatusMsg : " Stopping cortexcpp service..." ; Flags : runhidden
55+ // Clear the status message after completion
56+ WizardForm.StatusLabel.Caption := ' ' ;
57+ WizardForm.StatusLabel.Update;
58+ end ;
7659
77- ; Use Pascal scripting to ask user if they want to delete the .cortex folder and .cortexrc file
78- [Code]
7960procedure DeleteCurrentUserCortexFolderAndConfig ;
8061var
8162 UserCortexFolder: String;
8263 UserCortexConfig: String;
8364 ShouldDelete: Integer;
8465begin
85- UserCortexFolder := ExpandConstant(' {%USERPROFILE}\.cortex ' );
66+ UserCortexFolder := ExpandConstant(' {%USERPROFILE}\cortexcpp ' );
8667 UserCortexConfig := ExpandConstant(' {%USERPROFILE}\.cortexrc' );
8768
8869 if DirExists(UserCortexFolder) or FileExists(UserCortexConfig) then
8970 begin
90- ShouldDelete := MsgBox(' Do you want to delete the application data in .cortex and the .cortexrc config file (this will remove all user data)?' , mbConfirmation, MB_YESNO);
71+ ShouldDelete := MsgBox(' Do you want to delete the application data in cortexcpp and the .cortexrc config file (this will remove all user data)?' , mbConfirmation, MB_YESNO);
9172
9273 if ShouldDelete = idYes then
9374 begin
@@ -104,6 +85,14 @@ begin
10485 end ;
10586end ;
10687
88+ procedure CurStepChanged (CurStep: TSetupStep);
89+ begin
90+ if CurStep = ssPostInstall then
91+ begin
92+ AddToUserPathAndInstallEngines;
93+ end ;
94+ end ;
95+
10796procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
10897begin
10998 if CurUninstallStep = usPostUninstall then
0 commit comments