Skip to content

Commit

Permalink
tools: add checkbox with PowerShell and CMD launcher to the end of in…
Browse files Browse the repository at this point in the history
…stallation process (#17)
  • Loading branch information
georgik authored May 10, 2021
1 parent 8127407 commit bb67ca4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
7 changes: 2 additions & 5 deletions src/InnoSetup/IdfToolsSetup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ Name: "{#COMPONENT_OPTIMIZATION_ESPRESSIF_DOWNLOAD}"; Description: "Use Espressi
;Name: "optimization\windowsdefender"; Description: "Register Windows Defender exceptions"; Types: full


;Name: "ide\eclipse\openjdk"; Description: "OpenJDK"; Types: full
;Name: "idf"; Description: "ESP-IDF"; Types: full
;Name: "idf\tools"; Description: "Chip"; Types: full
;Name: "idf\tools\chip_esp32"; Description: "ESP32"; Types: full
Expand Down Expand Up @@ -225,11 +224,9 @@ Type: filesandordirs; Name: "{app}\python_env"
[Run]
Filename: "{app}\dist\{#GitInstallerName}"; Parameters: "/silent /tasks="""" /norestart"; Description: "Installing Git"; Check: GitInstallRequired
Filename: "{autodesktop}\{#IDFEclipseShortcutFile}"; Flags: runascurrentuser postinstall shellexec unchecked; Description: "Run ESP-IDF Eclipse Environment"; Components: "{#COMPONENT_ECLIPSE_DESKTOP}"
;Filename: "{autodesktop}\{#IDFPsShortcutFile}"; Flags: postinstall shellexec unchecked; Description: "Run ESP-IDF PowerShell Environment"; Components: "{#COMPONENT_POWERSHELL_DESKTOP}"
;Filename: "{autodesktop}\{#IDFCmdExeShortcutFile}"; Flags: postinstall shellexec unchecked; Description: "Run ESP-IDF Command Prompt Environment"; Components: "{#COMPONENT_CMD_DESKTOP}"
Filename: "{code:GetLauncherPathPowerShell}"; Flags: postinstall shellexec; Description: "Run ESP-IDF PowerShell Environment"; Components: "{#COMPONENT_POWERSHELL_DESKTOP} {#COMPONENT_CMD_STARTMENU}"
Filename: "{code:GetLauncherPathCMD}"; Flags: postinstall shellexec; Description: "Run ESP-IDF Command Prompt Environment"; Components: "{#COMPONENT_CMD_DESKTOP} {#COMPONENT_CMD_STARTMENU}";

;Filename: "{group}\{#IDFPsShortcutFile}"; Flags: postinstall shellexec unchecked; Description: "Run ESP-IDF PowerShell Environment"; Check: IsPowerShellInstalled
;Filename: "{group}\{#IDFCmdExeShortcutFile}"; Flags: postinstall shellexec unchecked; Description: "Run ESP-IDF Command Prompt Environment"; Check: IsCmdInstalled
; WD registration checkbox is identified by 'Windows Defender' substring anywhere in its caption, not by the position index in WizardForm.TasksList.Items
; Please, keep this in mind when making changes to the item's description - WD checkbox is to be disabled on systems without the Windows Defender installed
Filename: "{app}\idf-env.exe"; Parameters: "antivirus exclusion add --all"; Flags: postinstall shellexec runhidden; Description: "{cm:OptimizationWindowsDefender}"; Check: GetIsWindowsDefenderEnabled
Expand Down
1 change: 0 additions & 1 deletion src/InnoSetup/Pages/IdfPage.iss
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ function ToolsLocationPageValidate(CurPageID: Integer): Boolean;
var
ToolsDir: String;
IDFDir: String;
Msg: string;
begin
Result := True;
if CurPageID = wpSelectDir then
Expand Down
35 changes: 25 additions & 10 deletions src/InnoSetup/PostInstall.iss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
SPDX-License-Identifier: Apache-2.0 }
{ ------------------------------ Start menu shortcut ------------------------------ }
{ Store launcher paths so they can be invoked in post install phase declared in Run section. }
var LauncherPathPowerShell: String;
var LauncherPathCMD: String;
{ Helper function to retrieve value from variable in Run section. }
function GetLauncherPathPowerShell(Param: String):String;
begin
Result := LauncherPathPowerShell;
end;
{ Helper function to retrieve value from variable in Run section. }
function GetLauncherPathCMD(Param: String):String;
begin
Result := LauncherPathCMD;
end;
{ Get suffix of the text for link so that user can see multiple IDF installed. }
function GetLinkDestination(LinkString: String; Title: String): String;
begin
Expand All @@ -11,54 +28,52 @@ end;
procedure CreateIDFCommandPromptShortcut(LinkString: String);
var
Destination: String;
Description: String;
Command: String;
begin
ForceDirectories(ExpandConstant(LinkString));
Destination := GetLinkDestination(LinkString, 'CMD');
LauncherPathCMD := GetLinkDestination(LinkString, 'CMD');
Description := '{#IDFCmdExeShortcutDescription}';
{ If cmd.exe command argument starts with a quote, the first and last quote chars in the command
will be removed by cmd.exe; each argument needs to be surrounded by quotes as well. }
Command := '/k ""' + ExpandConstant('{app}\idf_cmd_init.bat') + '"';
Log('CreateShellLink Destination=' + Destination + ' Description=' + Description + ' Command=' + Command)
Log('CreateShellLink Destination=' + LauncherPathCMD + ' Description=' + Description + ' Command=' + Command)
try
CreateShellLink(
Destination,
LauncherPathCMD,
Description,
'cmd.exe',
Command,
GetIDFPath(''),
'', 0, SW_SHOWNORMAL);
except
MessageBox('Failed to create the shortcut: ' + Destination, mbError, MB_OK);
MessageBox('Failed to create the shortcut: ' + LauncherPathCMD, mbError, MB_OK);
RaiseException('Failed to create the shortcut');
end;
end;
procedure CreateIDFPowershellShortcut(LinkString: String);
var
Destination: String;
Description: String;
Command: String;
begin
ForceDirectories(ExpandConstant(LinkString));
Destination := GetLinkDestination(LinkString, 'PowerShell');
LauncherPathPowerShell := GetLinkDestination(LinkString, 'PowerShell');
Description := '{#IDFPsShortcutDescription}';
Command := ExpandConstant('-ExecutionPolicy Bypass -NoExit -File "{app}/Initialize-Idf.ps1"');
Log('CreateShellLink Destination=' + Destination + ' Description=' + Description + ' Command=' + Command)
Log('CreateShellLink Destination=' + LauncherPathPowerShell + ' Description=' + Description + ' Command=' + Command)
try
CreateShellLink(
Destination,
LauncherPathPowerShell,
Description,
'powershell.exe',
Command,
GetIDFPath(''),
'', 0, SW_SHOWNORMAL);
except
MessageBox('Failed to create the shortcut: ' + Destination, mbError, MB_OK);
MessageBox('Failed to create the shortcut: ' + LauncherPathPowerShell, mbError, MB_OK);
RaiseException('Failed to create the shortcut');
end;
end;
Expand Down

0 comments on commit bb67ca4

Please sign in to comment.