Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit efb426c

Browse files
authored
Fix #1216 - remove create shortcut item task and move download llamacpp engine to install dialog (#1219)
* Fix #1216 - remove create shortcut item task and move download llamacpp engine to install dialog * Resolved comment typo llama.cpp --------- Co-authored-by: Hien To <[email protected]>
1 parent 7875eda commit efb426c

File tree

3 files changed

+84
-117
lines changed

3 files changed

+84
-117
lines changed

engine/templates/windows/installer-beta.iss

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,56 +26,37 @@ Source: "vcruntime140_1.dll"; DestDir: "{app}"; Flags: ignoreversion
2626
[Icons]
2727
Name: "{group}\cortexcpp-beta"; Filename: "{app}\cortex-beta.exe"
2828

29-
; Define the run section to execute the application after installation
30-
[Run]
31-
Filename: "{app}\cortex-beta.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-beta.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-beta service..."; Flags: runhidden
32+
33+
; Combine all Pascal scripting code in one [Code] section
3234
[Code]
33-
procedure AddToUserPath;
35+
procedure AddToUserPathAndInstallEngines;
3436
var
3537
ExpandedAppDir: String;
36-
CmdLine: String;
38+
CmdLine, CortexInstallCmd: String;
3739
ResultCode: Integer;
3840
begin
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-beta.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-beta"; Filename: "{app}\cortex-beta.exe"; Tasks: desktopicon
71-
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\cortexcpp-beta"; Filename: "{app}\cortex-beta.exe"; Tasks: quicklaunchicon
72-
73-
; Define the uninstall run section to execute commands before uninstallation
74-
[UninstallRun]
75-
Filename: "{app}\cortex-beta.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-beta 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 cortexcpp-beta folder and .cortexrc-beta file
78-
[Code]
7960
procedure DeleteCurrentUserCortexFolderAndConfig;
8061
var
8162
UserCortexFolder: String;
@@ -104,6 +85,14 @@ begin
10485
end;
10586
end;
10687
88+
procedure CurStepChanged(CurStep: TSetupStep);
89+
begin
90+
if CurStep = ssPostInstall then
91+
begin
92+
AddToUserPathAndInstallEngines;
93+
end;
94+
end;
95+
10796
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
10897
begin
10998
if CurUninstallStep = usPostUninstall then

engine/templates/windows/installer-nightly.iss

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,56 +26,37 @@ Source: "vcruntime140_1.dll"; DestDir: "{app}"; Flags: ignoreversion
2626
[Icons]
2727
Name: "{group}\cortexcpp-nightly"; Filename: "{app}\cortex-nightly.exe"
2828

29-
; Define the run section to execute the application after installation
30-
[Run]
31-
Filename: "{app}\cortex-nightly.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-nightly.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-nightly service..."; Flags: runhidden
32+
33+
; Combine all Pascal scripting code in one [Code] section
3234
[Code]
33-
procedure AddToUserPath;
35+
procedure AddToUserPathAndInstallEngines;
3436
var
3537
ExpandedAppDir: String;
36-
CmdLine: String;
38+
CmdLine, CortexInstallCmd: String;
3739
ResultCode: Integer;
3840
begin
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;
55-
56-
procedure CurStepChanged(CurStep: TSetupStep);
57-
begin
58-
if CurStep = ssPostInstall then
59-
begin
60-
AddToUserPath;
61-
end;
62-
end;
45+
Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
6346
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
47+
// Update status message for downloading llamacpp engine
48+
WizardForm.StatusLabel.Caption := 'Downloading llama.cpp engine and dependencies ...';
49+
WizardForm.StatusLabel.Update;
6750
68-
; Define icons for the additional tasks
69-
[Icons]
70-
Name: "{commondesktop}\cortexcpp-nightly"; Filename: "{app}\cortex-nightly.exe"; Tasks: desktopicon
71-
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\cortexcpp-nightly"; Filename: "{app}\cortex-nightly.exe"; Tasks: quicklaunchicon
51+
// Download llamacpp engine by default
52+
CortexInstallCmd := Format('"%s\cortex-nightly.exe" engines install cortex.llamacpp', [ExpandedAppDir]);
53+
Exec('cmd.exe', '/C ' + CortexInstallCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
7254
73-
; Define the uninstall run section to execute commands before uninstallation
74-
[UninstallRun]
75-
Filename: "{app}\cortex-nightly.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-nightly 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 cortexcpp-nightly folder and .cortexrc-nightly file
78-
[Code]
7960
procedure DeleteCurrentUserCortexFolderAndConfig;
8061
var
8162
UserCortexFolder: String;
@@ -104,10 +85,18 @@ begin
10485
end;
10586
end;
10687
88+
procedure CurStepChanged(CurStep: TSetupStep);
89+
begin
90+
if CurStep = ssPostInstall then
91+
begin
92+
AddToUserPathAndInstallEngines;
93+
end;
94+
end;
95+
10796
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
10897
begin
10998
if CurUninstallStep = usPostUninstall then
11099
begin
111100
DeleteCurrentUserCortexFolderAndConfig;
112101
end;
113-
end;
102+
end;

engine/templates/windows/installer.iss

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,68 +26,49 @@ Source: "vcruntime140_1.dll"; DestDir: "{app}"; Flags: ignoreversion
2626
[Icons]
2727
Name: "{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;
3436
var
3537
ExpandedAppDir: String;
36-
CmdLine: String;
38+
CmdLine, CortexInstallCmd: String;
3739
ResultCode: Integer;
3840
begin
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]
7960
procedure DeleteCurrentUserCortexFolderAndConfig;
8061
var
8162
UserCortexFolder: String;
8263
UserCortexConfig: String;
8364
ShouldDelete: Integer;
8465
begin
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;
10586
end;
10687
88+
procedure CurStepChanged(CurStep: TSetupStep);
89+
begin
90+
if CurStep = ssPostInstall then
91+
begin
92+
AddToUserPathAndInstallEngines;
93+
end;
94+
end;
95+
10796
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
10897
begin
10998
if CurUninstallStep = usPostUninstall then

0 commit comments

Comments
 (0)