forked from KindDragon/vld
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathvld-setup.iss
More file actions
482 lines (442 loc) · 17.8 KB
/
vld-setup.iss
File metadata and controls
482 lines (442 loc) · 17.8 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
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Visual Leak Detector"
#define MyAppVersion "2.5.9"
#define MyAppPublisher "VLD Team"
#define MyAppURL "http://vld.codeplex.com/"
#define MyAppRegKey "Software\Visual Leak Detector"
#define ConfigType "Release"
#define PlatformVersion "v143"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{851FBFF7-5148-40A2-A654-942BE80F5B90}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={reg:HKLM\{#MyAppRegKey},InstallPath|{pf}\{#MyAppName}}
DefaultGroupName={#MyAppName}
LicenseFile=license-free.txt
OutputBaseFilename=vld-{#MyAppVersion}-setup
Compression=lzma
SolidCompression=True
MinVersion=0,5.01
; Tell Windows Explorer to reload the environment
ChangesEnvironment=yes
AllowNoIcons=yes
DisableDirPage=auto
DirExistsWarning=no
WizardImageFile=compiler:WizModernImage-IS.bmp
WizardSmallImageFile=WizSmallImage.bmp
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Icons]
Name: "{group}\View Documentation"; Filename: "http://vld.codeplex.com/documentation"
[Files]
Source: "dbghelp\x64\dbghelp.dll"; DestDir: "{app}\bin\Win64"; Flags: ignoreversion
Source: "dbghelp\x64\Microsoft.DTfW.DHL.manifest"; DestDir: "{app}\bin\Win64"; Flags: ignoreversion
Source: "dbghelp\x86\dbghelp.dll"; DestDir: "{app}\bin\Win32"; Flags: ignoreversion
Source: "dbghelp\x86\Microsoft.DTfW.DHL.manifest"; DestDir: "{app}\bin\Win32"; Flags: ignoreversion
Source: "..\src\bin\Win32\{#ConfigType}-{#PlatformVersion}\vld.lib"; DestDir: "{app}\lib\Win32"; Flags: ignoreversion
Source: "..\src\bin\Win32\{#ConfigType}-{#PlatformVersion}\vld_x86.dll"; DestDir: "{app}\bin\Win32"; Flags: ignoreversion
Source: "..\src\bin\Win32\{#ConfigType}-{#PlatformVersion}\vld_x86.pdb"; DestDir: "{app}\bin\Win32"; Flags: ignoreversion
Source: "..\src\bin\x64\{#ConfigType}-{#PlatformVersion}\vld.lib"; DestDir: "{app}\lib\Win64"; Flags: ignoreversion
Source: "..\src\bin\x64\{#ConfigType}-{#PlatformVersion}\vld_x64.dll"; DestDir: "{app}\bin\Win64"; Flags: ignoreversion
Source: "..\src\bin\x64\{#ConfigType}-{#PlatformVersion}\vld_x64.pdb"; DestDir: "{app}\bin\Win64"; Flags: ignoreversion
Source: "..\src\vld.h"; DestDir: "{app}\include"; Flags: ignoreversion
Source: "..\src\vld_def.h"; DestDir: "{app}\include"; Flags: ignoreversion
Source: "..\vld.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\AUTHORS.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\CHANGES.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\COPYING.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "Microsoft.Cpp.Win32.user.props"; DestDir: "{localappdata}\Microsoft\MSBuild\v4.0\"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "Microsoft.Cpp.x64.user.props"; DestDir: "{localappdata}\Microsoft\MSBuild\v4.0\"; Flags: onlyifdoesntexist uninsneveruninstall
[Tasks]
Name: "modifypath"; Description: "Add VLD directory to your environmental path"
Name: "modifyVS2008Props"; Description: "Add VLD directory to VS 2008"
Name: "modifyVS2010Props"; Description: "Add VLD directory to VS 2010 - VS 2022"
[ThirdParty]
UseRelativePaths=True
[Registry]
Root: "HKLM32"; Subkey: "{#MyAppRegKey}"; Flags: uninsdeletekeyifempty
Root: "HKLM32"; Subkey: "{#MyAppRegKey}"; ValueType: string; ValueName: "InstalledVersion"; ValueData: "{#MyAppVersion}"
Root: "HKLM32"; Subkey: "{#MyAppRegKey}"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}"
Root: "HKLM32"; Subkey: "{#MyAppRegKey}"; ValueType: string; ValueName: "IniFile"; ValueData: "{app}\vld.ini"
Root: "HKLM64"; Subkey: "{#MyAppRegKey}"; Flags: uninsdeletekeyifempty
Root: "HKLM64"; Subkey: "{#MyAppRegKey}"; ValueType: string; ValueName: "InstalledVersion"; ValueData: "{#MyAppVersion}"
Root: "HKLM64"; Subkey: "{#MyAppRegKey}"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}"
Root: "HKLM64"; Subkey: "{#MyAppRegKey}"; ValueType: string; ValueName: "IniFile"; ValueData: "{app}\vld.ini"
[Code]
type
TKey = string;
TValue = string;
TKeyValue = record
Key: TKey;
Value: TValue;
end;
TKeyValueList = array of TKeyValue;
const
ModPathName = 'modifypath';
ModPathType = 'system';
function ModPathDir(): TArrayOfString;
begin
setArrayLength(Result, 2);
Result[0] := ExpandConstant('{app}\bin\Win32');
Result[1] := ExpandConstant('{app}\bin\Win64');
end;
#include "modpath.iss"
function GetUninstallString(regPath: string): String;
var
sUnInstPath: String;
sUnInstString: String;
begin
sUnInstPath := ExpandConstant(regPath);
sUnInstString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstString);
Result := sUnInstString;
end;
function UninstallOldVersion(regPath: string; params: string): Boolean;
var
iResultCode: Integer;
begin
// default return value
Result := False;
if SuppressibleMsgBox('VLD is already installed. Uninstall the current version?',
mbConfirmation, MB_YESNO, IDYES) = IDYES then
begin
regPath := RemoveQuotes(regPath);
if Exec(regPath, params,'', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
Result := True;
end
end;
function UninstallOldVersions(): Boolean;
var
nsisUnInstallString: String;
isUnInstallString: String;
begin
nsisUnInstallString := GetUninstallString('Software\Microsoft\Windows\CurrentVersion\Uninstall\Visual Leak Detector');
isUnInstallString := GetUninstallString('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
Result := True;
if (nsisUnInstallString <> '') then
begin
Result := UninstallOldVersion(nsisUnInstallString, '/S');
end
else if (isUnInstallString <> '') then
begin
Result := UninstallOldVersion(isUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES');
end;
end;
function Count(What, Where: String): Integer;
begin
Result := 0;
if Length(What) = 0 then
exit;
while Pos(What,Where)>0 do
begin
Where := Copy(Where,Pos(What,Where)+Length(What),Length(Where));
Result := Result + 1;
end;
end;
procedure Explode(var ADest: TKeyValueList; aText, aSeparator: String);
var tmp: Integer;
item: TKeyValue;
begin
SetArrayLength(ADest, (Count(aSeparator,aText) / 2) + 1);
tmp := 0;
repeat
item.Key := '';
item.Value := '';
if Pos(aSeparator,aText)>0 then
begin
item.Key := Copy(aText,1,Pos(aSeparator,aText)-1);
aText := Copy(aText,Pos(aSeparator,aText)+Length(aSeparator),Length(aText));
end else
begin
item.Key := aText;
aText := '';
end;
if Pos(aSeparator,aText)>0 then
begin
item.Value := Copy(aText,1,Pos(aSeparator,aText)-1);
aText := Copy(aText,Pos(aSeparator,aText)+Length(aSeparator),Length(aText));
end else
begin
item.Value := aText;
aText := '';
end;
ADest[tmp] := item;
tmp := tmp + 1;
until Length(aText)=0;
end;
function Merge(ADest: TKeyValueList; aSeparator: String): String;
var i, n, l: Integer;
str: String;
begin
n := GetArrayLength(ADest);
l := n + (n - 1);
if l < 0 then l := 0;
Result := '';
for i := 0 to n - 1 do
begin
str := ADest[i].Key + aSeparator + ADest[i].Value;
Result := Result + str;
if i < n - 1 then Result := Result + aSeparator;
end;
end;
function UpdatePath(dirList: String; path: String): String;
begin
if dirList = '' then
Result := path
else if Pos(path, dirList) = 0 then
Result := path + ';' + dirList
else
Result := dirList;
end;
procedure UpdatePaths(var dirList: string; path32: string; path64: string);
var map: TKeyValueList;
i: Integer;
begin
Explode(map, dirList, '|');
for i := 0 to GetArrayLength(map) - 1 do
begin
if map[i].Key = 'Win32' then map[i].Value := UpdatePath(map[i].Value, path32)
else if map[i].Key = 'x64' then map[i].Value := UpdatePath(map[i].Value, path64);
end;
dirList := Merge(map, '|');
Log(dirList);
end;
procedure ModifySettings(filename: string);
var
XMLDocument: Variant;
XMLParent, XMLNode, XMLNodes: Variant;
IncludeDirectoriesNode: Variant;
AdditionalIncludeDirectories: string;
LibraryDirectoriesNode: Variant;
AdditionalLibraryDirectories: string;
libfolder: string;
begin
XMLDocument := CreateOleObject('Msxml2.DOMDocument.3.0');
try
XMLDocument.async := False;
XMLDocument.load(filename);
if (XMLDocument.parseError.errorCode = 0) then
begin
XMLDocument.setProperty('SelectionLanguage', 'XPath');
XMLNodes := XMLDocument.SelectNodes('//UserSettings/ToolsOptions/ToolsOptionsCategory[@name="Projects"]/ToolsOptionsSubCategory[@name="VCDirectories"]');
if XMLNodes.Length = 0 then
Exit;
XMLParent := XMLNodes.Item[0];
XMLNodes := XMLParent.SelectNodes('//PropertyValue[@name="LibraryDirectories"]');
if XMLNodes.Length > 0 then
LibraryDirectoriesNode := XMLNodes.Item[0];
XMLNodes := XMLParent.SelectNodes('//PropertyValue[@name="IncludeDirectories"]');
if XMLNodes.Length > 0 then
IncludeDirectoriesNode := XMLNodes.Item[0];
AdditionalIncludeDirectories := '';
if not VarIsNull(IncludeDirectoriesNode) then
AdditionalIncludeDirectories := IncludeDirectoriesNode.Text;
AdditionalLibraryDirectories := '';
if not VarIsNull(LibraryDirectoriesNode) then
AdditionalLibraryDirectories := LibraryDirectoriesNode.Text;
UpdatePaths(AdditionalIncludeDirectories, ExpandConstant('{app}\include'), ExpandConstant('{app}\include'));
UpdatePaths(AdditionalLibraryDirectories, ExpandConstant('{app}\lib\Win32'), ExpandConstant('{app}\lib\Win64'));
IncludeDirectoriesNode.Text := AdditionalIncludeDirectories;
LibraryDirectoriesNode.Text := AdditionalLibraryDirectories;
XMLDocument.save(filename);
end;
except
ShowExceptionMessage;
end;
end;
procedure ModifyVS2008Settings();
var
Path, CurSettings: string;
begin
if RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Microsoft\VisualStudio\9.0',
'VisualStudioLocation', Path) then
begin
StringChangeEx(Path, '%USERPROFILE%', GetEnv('USERPROFILE'), True);
if RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Microsoft\VisualStudio\9.0\Profile',
'AutoSaveFile', CurSettings) then
begin
StringChangeEx(CurSettings, '%vsspv_visualstudio_dir%', Path, True);
ModifySettings(CurSettings);
end;
end;
end;
function EncodeString(str: string): string;
begin
Result := str;
StringChangeEx(Result, '(', '%28', True);
StringChangeEx(Result, ')', '%29', True);
end;
procedure UpdateString(var dirList: string; path: string; suffix: string);
begin
if dirList = '' then
dirList := path + suffix
else if (Pos(path, dirList) = 0) and (Pos(EncodeString(path), dirList) = 0) then
dirList := path + dirList;
Log(dirList);
end;
function OpenOrCreate(XMLDocument: Variant; baseNode : Variant; nodeId: string) : Variant;
var
nodePath: string;
XMLNodes: Variant;
XMLNode: Variant; // temp for creation
begin
UpdateString(nodePath, '//b:', nodeId);
XMLNodes := baseNode.SelectNodes(nodePath);
if XMLNodes.Length > 0 then
Result := XMLNodes.Item[0]
else
begin
XMLNode := XMLDocument.CreateNode(1, nodeId, 'http://schemas.microsoft.com/developer/msbuild/2003');
Result := baseNode.AppendChild(XMLNode);
end;
end;
procedure ModifyProps(filename: string; libfolder: string; arch: string);
var
XMLDocument: Variant;
XMLParent, IdgNode, XMLNode, XMLNodes: Variant;
ProjNode, PropNode, IpNode, LpNode: Variant; // use the VC Directories options
IncludeDirectoriesNode: Variant;
propAttr: string;
AdditionalIncludeDirectories: string;
DynamicLibraryDirectoriesNode: Variant;
AdditionalDynamicLibraryDirectories: string;
StaticLibraryDirectoriesNode: Variant;
AdditionalStaticLibraryDirectories: string;
begin
if not FileExists(filename) then
Exit;
XMLDocument := CreateOleObject('Msxml2.DOMDocument.3.0');
try
XMLDocument.async := False;
XMLDocument.load(filename);
if (XMLDocument.parseError.errorCode = 0) then
begin
XMLDocument.setProperty('SelectionLanguage', 'XPath');
XMLDocument.setProperty('SelectionNamespaces', 'xmlns:b=''http://schemas.microsoft.com/developer/msbuild/2003''');
ProjNode := XMLDocument.SelectNodes('//b:Project');
// if project node doesn't exist, then bail
if ProjNode.Length = 0 then
Exit;
// ItemDefinitionGroup
IdgNode := OpenOrCreate(XMLDocument, projNode.Item[0], 'ItemDefinitionGroup');
// PropertyGroup - might have the label on it, so look for one without a label, and create if needed
XMLParent := ProjNode.Item[0].SelectNodes('//b:PropertyGroup');
if XMLParent.Length > 0 then
begin
PropNode := XMLParent.Item[0];
propAttr := PropNode.GetAttribute('Label');
if not VarIsNull(propAttr) then
begin
if XMLParent.Length > 1 then
begin
PropNode := XMLParent.Item[1];
end
end
end
if VarIsNull(PropNode) then
begin
XMLNode := XMLDocument.CreateNode(1, 'PropertyGroup','http://schemas.microsoft.com/developer/msbuild/2003');
PropNode := ProjNode.AppendChild(XMLNode);
end
// IncludePath
IpNode := OpenOrCreate(XMLDocument, PropNode, 'IncludePath');
// LibraryPath
LpNode := OpenOrCreate(XMLDocument, PropNode, 'LibraryPath');
// // ClCompile -> puts the directory in the compiler section of the properties
// XMLParent := OpenOrCreate(XMLDocument, IdgNode, 'ClCompile');
// XMLNodes := XMLParent.SelectNodes('//b:ClCompile/b:AdditionalIncludeDirectories');
// if XMLNodes.Length > 0 then
// IncludeDirectoriesNode := XMLNodes.Item[0]
// else
// begin
// XMLNode := XMLDocument.CreateNode(1, 'AdditionalIncludeDirectories', 'http://schemas.microsoft.com/developer/msbuild/2003');
// IncludeDirectoriesNode := XMLParent.AppendChild(XMLNode);
// end;
// // Link -> puts the directory in the linker section of the properties
// XMLParent := OpenOrCreate(XMLDocument, IdgNode, 'Link');
// XMLNodes := XMLParent.SelectNodes('//b:Link/b:AdditionalLibraryDirectories');
// if XMLNodes.Length > 0 then
// DynamicLibraryDirectoriesNode := XMLNodes.Item[0]
// else
// begin
// XMLNode := XMLDocument.CreateNode(1, 'AdditionalLibraryDirectories', 'http://schemas.microsoft.com/developer/msbuild/2003');
// DynamicLibraryDirectoriesNode := XMLParent.AppendChild(XMLNode);
// end;
// Lib (static lib)
XMLParent := OpenOrCreate(XMLDocument, IdgNode, 'Lib');
XMLNodes := XMLParent.SelectNodes('//b:Lib/b:AdditionalLibraryDirectories');
if XMLNodes.Length > 0 then
StaticLibraryDirectoriesNode := XMLNodes.Item[0]
else
begin
XMLNode := XMLDocument.CreateNode(1, 'AdditionalLibraryDirectories', 'http://schemas.microsoft.com/developer/msbuild/2003');
StaticLibraryDirectoriesNode := XMLParent.AppendChild(XMLNode);
end;
AdditionalIncludeDirectories := '';
if not VarIsNull(IpNode) then
AdditionalIncludeDirectories := IpNode.Text;
AdditionalDynamicLibraryDirectories := '';;
if not VarIsNull(LpNode) then
AdditionalDynamicLibraryDirectories := LpNode.Text;
AdditionalStaticLibraryDirectories := '';;
if not VarIsNull(StaticLibraryDirectoriesNode) then
AdditionalStaticLibraryDirectories := StaticLibraryDirectoriesNode.Text;
UpdateString(AdditionalIncludeDirectories, ExpandConstant('{app}\include;'), '$(IncludePath)');
UpdateString(AdditionalDynamicLibraryDirectories, ExpandConstant('{app}\lib\' + libfolder + ';'), '$(LibraryPath)');
UpdateString(AdditionalStaticLibraryDirectories, ExpandConstant('{app}\lib\' + libfolder + ';'), '$(AdditionalLibraryDirectories)');
IpNode.Text := AdditionalIncludeDirectories;
LpNode.Text := AdditionalDynamicLibraryDirectories;
StaticLibraryDirectoriesNode.Text := AdditionalStaticLibraryDirectories;
XMLDocument.save(filename);
end;
except
ShowExceptionMessage;
end;
end;
procedure ModifyAllProps();
var
Path: string;
begin
Path := GetEnv('LOCALAPPDATA')+'\Microsoft\MSBuild\v4.0\';
if DirExists(Path) then
begin
ModifyProps(Path + 'Microsoft.Cpp.Win32.user.props', 'Win32', 'x86');
ModifyProps(Path + 'Microsoft.Cpp.x64.user.props', 'Win64', 'x64');
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
if not UninstallOldVersions() then
Abort();
end;
if CurStep = ssPostInstall then
begin
if IsTaskSelected('modifyVS2008Props') then
ModifyVS2008Settings();
if IsTaskSelected('modifyVS2010Props') then
ModifyAllProps();
end;
CurStepChangedModPath(CurStep);
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
CurUninstallStepChangedModPath(CurUninstallStep);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if CurPageID = wpReady then
SuppressibleMsgBox('Please close Visual Studio before starting the installation.', mbInformation, MB_OK, IDOK);
end;