Skip to content

Commit 1817872

Browse files
committed
Support optional dependencies via components (#75)
1 parent ec3770f commit 1817872

3 files changed

Lines changed: 42 additions & 5 deletions

File tree

CodeDependencies.iss

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,25 @@ type
1111
Checksum: String;
1212
ForceSuccess: Boolean;
1313
RestartAfter: Boolean;
14+
Components: String;
1415
end;
1516
1617
var
17-
Dependency_Memo: String;
1818
Dependency_List: array of TDependency_Entry;
1919
Dependency_NeedToRestart, Dependency_ForceX86, Dependency_ForceX64: Boolean;
20+
Dependency_Components: String;
2021
Dependency_DownloadPage: TDownloadWizardPage;
2122
23+
function Dependency_IsEntryActive(const Entry: TDependency_Entry): Boolean;
24+
begin
25+
Result := (Entry.Components = '') or WizardIsComponentSelected(Entry.Components);
26+
end;
27+
2228
procedure Dependency_Add(const Filename, Parameters, Title, URL, Checksum: String; const ForceSuccess, RestartAfter: Boolean);
2329
var
2430
Dependency: TDependency_Entry;
2531
DependencyCount: Integer;
2632
begin
27-
Dependency_Memo := Dependency_Memo + #13#10 + '%1' + Title;
28-
2933
Dependency.Filename := Filename;
3034
Dependency.Parameters := Parameters;
3135
Dependency.Title := Title;
@@ -39,6 +43,7 @@ begin
3943
Dependency.Checksum := Checksum;
4044
Dependency.ForceSuccess := ForceSuccess;
4145
Dependency.RestartAfter := RestartAfter;
46+
Dependency.Components := Dependency_Components;
4247
4348
DependencyCount := GetArrayLength(Dependency_List);
4449
SetArrayLength(Dependency_List, DependencyCount + 1);
@@ -64,6 +69,9 @@ begin
6469
Dependency_DownloadPage.Show;
6570
6671
for DependencyIndex := 0 to DependencyCount - 1 do begin
72+
if not Dependency_IsEntryActive(Dependency_List[DependencyIndex]) then begin
73+
continue;
74+
end;
6775
if Dependency_List[DependencyIndex].URL <> '' then begin
6876
Dependency_DownloadPage.Clear;
6977
Dependency_DownloadPage.Add(Dependency_List[DependencyIndex].URL, Dependency_List[DependencyIndex].Filename, Dependency_List[DependencyIndex].Checksum);
@@ -96,6 +104,9 @@ begin
96104
97105
if Result = '' then begin
98106
for DependencyIndex := 0 to DependencyCount - 1 do begin
107+
if not Dependency_IsEntryActive(Dependency_List[DependencyIndex]) then begin
108+
continue;
109+
end;
99110
Dependency_DownloadPage.SetText(Dependency_List[DependencyIndex].Title, '');
100111
Dependency_DownloadPage.SetProgress(DependencyIndex + 1, DependencyCount + 1);
101112
@@ -159,6 +170,9 @@ end;
159170
<event('UpdateReadyMemo')>
160171
#endif
161172
function Dependency_UpdateReadyMemo(const Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
173+
var
174+
DependencyIndex: Integer;
175+
DependencyMemo: String;
162176
begin
163177
Result := '';
164178
if MemoUserInfoInfo <> '' then begin
@@ -180,11 +194,18 @@ begin
180194
Result := Result + MemoTasksInfo;
181195
end;
182196
183-
if Dependency_Memo <> '' then begin
197+
DependencyMemo := '';
198+
for DependencyIndex := 0 to GetArrayLength(Dependency_List) - 1 do begin
199+
if Dependency_IsEntryActive(Dependency_List[DependencyIndex]) then begin
200+
DependencyMemo := DependencyMemo + #13#10 + '%1' + Dependency_List[DependencyIndex].Title;
201+
end;
202+
end;
203+
204+
if DependencyMemo <> '' then begin
184205
if MemoTasksInfo = '' then begin
185206
Result := Result + SetupMessage(msgReadyMemoTasks);
186207
end;
187-
Result := Result + FmtMessage(Dependency_Memo, [Space]);
208+
Result := Result + FmtMessage(DependencyMemo, [Space]);
188209
end;
189210
end;
190211

ExampleSetup.iss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ Name: "{commondesktop}\{#MyAppSetupName}"; Filename: "{app}\MyProg.exe"; Tasks:
5353
[Tasks]
5454
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"
5555

56+
; Example component definition for optional-dependency gating:
57+
;[Components]
58+
;Name: "advanced"; Description: "Advanced tools (requires .NET 10)"; Types: full
59+
5660
[Run]
5761
Filename: "{app}\MyProg.exe"; Description: "{cm:LaunchProgram,{#MyAppSetupName}}"; Flags: nowait postinstall skipifsilent
5862

@@ -85,9 +89,11 @@ begin
8589
Dependency_AddDotNet90;
8690
Dependency_AddDotNet90Asp;
8791
Dependency_AddDotNet90Desktop;
92+
//Dependency_Components := 'advanced'; // only install next dependencies if the 'advanced' component is selected
8893
Dependency_AddDotNet100;
8994
Dependency_AddDotNet100Asp;
9095
Dependency_AddDotNet100Desktop;
96+
//Dependency_Components := ''; // disable component gating again
9197
9298
Dependency_AddVC2005;
9399
Dependency_AddVC2008;

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ A similar version exists for forcing 64-bit on arm.
6666

6767
If you only deploy 32-bit binaries and dependencies you can also instead just not define [ArchitecturesInstallIn64BitMode](https://jrsoftware.org/ishelp/index.php?topic=setup_architecturesinstallin64bitmode) in [Setup].
6868

69+
By default all added dependencies are installed for every user. You can tie them to one or more [components](https://jrsoftware.org/ishelp/index.php?topic=componentssection) so they are only downloaded and installed when the matching components are selected:
70+
71+
```iss
72+
Dependency_Components := 'advanced'; // only install next dependencies if the 'advanced' component is selected
73+
Dependency_AddDotNet100;
74+
Dependency_Components := ''; // disable component gating again
75+
```
76+
77+
`Dependency_Components` accepts the same expression syntax as Inno's [Components](https://jrsoftware.org/ishelp/index.php?topic=scriptfunctions) parameter (e.g. `'feature1 or feature2'`).
78+
6979
## Dependencies
7080

7181
* .NET

0 commit comments

Comments
 (0)