Skip to content

Commit 46f5275

Browse files
committed
BuildTools: Add native git support, Add improved build artifacts
1 parent 4df9480 commit 46f5275

File tree

11 files changed

+523
-696
lines changed

11 files changed

+523
-696
lines changed

tools/CustomBuildTool/Build.cs

Lines changed: 251 additions & 441 deletions
Large diffs are not rendered by default.

tools/CustomBuildTool/CustomBuildTool.csproj

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
1111
<TrimUnusedDependencies>true</TrimUnusedDependencies>
1212
<ApplicationManifest>app.manifest</ApplicationManifest>
13-
<FileUpgradeFlags>
14-
</FileUpgradeFlags>
15-
<UpgradeBackupLocation>
16-
</UpgradeBackupLocation>
1713
<OldToolsVersion>Current</OldToolsVersion>
14+
<Version>1.0</Version>
1815
<ProjectGuid>{CD644DF2-A658-4CBC-9497-CA5DD13CFEC3}</ProjectGuid>
1916
</PropertyGroup>
2017
<PropertyGroup Condition="'$(Platform)'=='x86'">
@@ -40,24 +37,19 @@
4037
<DebugSymbols>true</DebugSymbols>
4138
</PropertyGroup>
4239
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
43-
<DefineConstants />
4440
<DebugType>embedded</DebugType>
4541
<DebugSymbols>true</DebugSymbols>
4642
</PropertyGroup>
4743
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
48-
<DefineConstants />
4944
<DebugType>embedded</DebugType>
5045
<DebugSymbols>true</DebugSymbols>
5146
</PropertyGroup>
5247
<ItemGroup>
5348
<None Include="app.manifest" />
5449
<None Include="Properties\PublishProfiles\32bit.pubxml" />
55-
<None Include="Properties\PublishProfiles\64bit.pubxml" />
56-
</ItemGroup>
57-
<ItemGroup>
58-
<Content Include="Properties\PublishProfiles\32bit.pubxml.user" />
5950
</ItemGroup>
6051
<ItemGroup>
52+
<PackageReference Include="LibGit2Sharp" Version="0.26.2" />
6153
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
6254
</ItemGroup>
6355
</Project>

tools/CustomBuildTool/HeaderGen.cs

Lines changed: 66 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -61,86 +61,78 @@ public bool Equals(HeaderFile other)
6161
}
6262
}
6363

64-
public class HeaderGen
64+
public static class HeaderGen
6565
{
66-
private readonly string BaseDirectory;
67-
private readonly string[] Modes;
68-
private readonly string[] Files;
69-
private readonly string OutputFile;
70-
private readonly string Header;
71-
private readonly string Footer;
72-
73-
public HeaderGen()
74-
{
75-
this.OutputFile = "..\\sdk\\phapppub.h";
76-
this.BaseDirectory = "ProcessHacker\\include";
77-
this.Modes = new[] { "phapppub" };
78-
this.Files = new[]
79-
{
80-
"phapp.h",
81-
"appsup.h",
82-
"phfwddef.h",
83-
"procprv.h",
84-
"srvprv.h",
85-
"netprv.h",
86-
"modprv.h",
87-
"thrdprv.h",
88-
"hndlprv.h",
89-
"memprv.h",
90-
"phuisup.h",
91-
"colmgr.h",
92-
"proctree.h",
93-
"srvlist.h",
94-
"netlist.h",
95-
"thrdlist.h",
96-
"modlist.h",
97-
"hndllist.h",
98-
"memlist.h",
99-
"extmgr.h",
100-
"mainwnd.h",
101-
"notifico.h",
102-
"phplug.h",
103-
"actions.h",
104-
"procprp.h",
105-
"procprpp.h",
106-
"phsvccl.h",
107-
"sysinfo.h",
108-
"procgrp.h",
109-
"miniinfo.h"
110-
};
111-
this.Header = "#ifndef _PH_PHAPPPUB_H\r\n#define _PH_PHAPPPUB_H\r\n\r\n// This file was automatically generated. Do not edit.\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n";
112-
this.Footer = "\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif\r\n";
113-
}
66+
private static readonly string Header = "#ifndef _PH_PHAPPPUB_H\r\n#define _PH_PHAPPPUB_H\r\n\r\n// This file was automatically generated. Do not edit.\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n";
67+
private static readonly string Footer = "\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif\r\n";
68+
69+
private static readonly string BaseDirectory = "ProcessHacker\\include";
70+
private static readonly string OutputFile = "..\\sdk\\phapppub.h";
11471

115-
private List<HeaderFile> OrderHeaderFiles(List<HeaderFile> headerFiles)
72+
private static readonly string[] Modes = new[] { "phapppub" };
73+
private static readonly string[] Files = new[]
11674
{
117-
var result = new List<HeaderFile>();
118-
var done = new List<HeaderFile>();
75+
"phapp.h",
76+
"appsup.h",
77+
"phfwddef.h",
78+
"procprv.h",
79+
"srvprv.h",
80+
"netprv.h",
81+
"modprv.h",
82+
"thrdprv.h",
83+
"hndlprv.h",
84+
"memprv.h",
85+
"phuisup.h",
86+
"colmgr.h",
87+
"proctree.h",
88+
"srvlist.h",
89+
"netlist.h",
90+
"thrdlist.h",
91+
"modlist.h",
92+
"hndllist.h",
93+
"memlist.h",
94+
"extmgr.h",
95+
"mainwnd.h",
96+
"notifico.h",
97+
"phplug.h",
98+
"actions.h",
99+
"procprp.h",
100+
"procprpp.h",
101+
"phsvccl.h",
102+
"sysinfo.h",
103+
"procgrp.h",
104+
"miniinfo.h"
105+
};
106+
107+
private static List<HeaderFile> OrderHeaderFiles(List<HeaderFile> headerFiles)
108+
{
109+
List<HeaderFile> result = new List<HeaderFile>();
110+
List<HeaderFile> done = new List<HeaderFile>();
119111

120-
foreach (var h in headerFiles)
112+
foreach (HeaderFile h in headerFiles)
121113
OrderHeaderFiles(result, done, h);
122114

123115
return result;
124116
}
125117

126-
private void OrderHeaderFiles(List<HeaderFile> result, List<HeaderFile> done, HeaderFile headerFile)
118+
private static void OrderHeaderFiles(List<HeaderFile> result, List<HeaderFile> done, HeaderFile headerFile)
127119
{
128120
if (done.Contains(headerFile))
129121
return;
130122

131123
done.Add(headerFile);
132124

133-
foreach (var h in headerFile.Dependencies)
125+
foreach (HeaderFile h in headerFile.Dependencies)
134126
OrderHeaderFiles(result, done, h);
135127

136128
result.Add(headerFile);
137129
}
138130

139-
private List<string> ProcessHeaderLines(List<string> lines)
131+
private static List<string> ProcessHeaderLines(List<string> lines)
140132
{
141-
var result = new List<string>();
142-
var modes = new List<string>();
143-
var blankLine = false;
133+
List<string> result = new List<string>();
134+
List<string> modes = new List<string>();
135+
bool blankLine = false;
144136

145137
foreach (string line in lines)
146138
{
@@ -156,8 +148,8 @@ private List<string> ProcessHeaderLines(List<string> lines)
156148
}
157149
else
158150
{
159-
bool blockMode = this.Modes.Any(mode => modes.Contains(mode, StringComparer.OrdinalIgnoreCase));
160-
bool lineMode = this.Modes.Any(mode =>
151+
bool blockMode = Modes.Any(mode => modes.Contains(mode, StringComparer.OrdinalIgnoreCase));
152+
bool lineMode = Modes.Any(mode =>
161153
{
162154
int indexOfMarker = text.LastIndexOf("// " + mode, StringComparison.OrdinalIgnoreCase);
163155
if (indexOfMarker == -1)
@@ -184,16 +176,15 @@ private List<string> ProcessHeaderLines(List<string> lines)
184176
return result;
185177
}
186178

187-
public void Execute()
179+
public static void Execute()
188180
{
189181
// Read in all header files.
182+
Dictionary<string, HeaderFile> headerFiles = new Dictionary<string, HeaderFile>(StringComparer.OrdinalIgnoreCase);
190183

191-
var headerFiles = new Dictionary<string, HeaderFile>(StringComparer.OrdinalIgnoreCase);
192-
193-
foreach (string name in this.Files)
184+
foreach (string name in Files)
194185
{
195-
var file = this.BaseDirectory + Path.DirectorySeparatorChar + name;
196-
var lines = File.ReadAllLines(file).ToList();
186+
string file = BaseDirectory + Path.DirectorySeparatorChar + name;
187+
List<string> lines = File.ReadAllLines(file).ToList();
197188

198189
headerFiles.Add(name, new HeaderFile
199190
{
@@ -204,9 +195,9 @@ public void Execute()
204195

205196
foreach (HeaderFile h in headerFiles.Values)
206197
{
207-
var partitions = h.Lines.Select(s =>
198+
ILookup<bool, Tuple<string, HeaderFile>> partitions = h.Lines.Select(s =>
208199
{
209-
var trimmed = s.Trim();
200+
string trimmed = s.Trim();
210201

211202
if (trimmed.StartsWith("#include <", StringComparison.OrdinalIgnoreCase) && trimmed.EndsWith(">", StringComparison.OrdinalIgnoreCase))
212203
{
@@ -228,9 +219,9 @@ public void Execute()
228219

229220
// Generate the ordering.
230221

231-
var orderedHeaderFilesList = new List<HeaderFile>();
222+
List<HeaderFile> orderedHeaderFilesList = new List<HeaderFile>();
232223

233-
foreach (string file in this.Files)
224+
foreach (string file in Files)
234225
{
235226
string name = Path.GetFileName(file);
236227

@@ -240,17 +231,17 @@ public void Execute()
240231
}
241232
}
242233

243-
var orderedHeaderFiles = OrderHeaderFiles(orderedHeaderFilesList);
234+
List<HeaderFile> orderedHeaderFiles = OrderHeaderFiles(orderedHeaderFilesList);
244235

245236
// Process each header file and remove irrelevant content.
246237
foreach (HeaderFile h in orderedHeaderFiles)
247238
h.Lines = ProcessHeaderLines(h.Lines);
248239

249240
// Write out the result.
250-
using (StreamWriter sw = new StreamWriter(this.BaseDirectory + Path.DirectorySeparatorChar + this.OutputFile))
241+
using (StreamWriter sw = new StreamWriter(BaseDirectory + Path.DirectorySeparatorChar + OutputFile))
251242
{
252243
// Header
253-
sw.Write(this.Header);
244+
sw.Write(Header);
254245

255246
// Header files
256247
foreach (HeaderFile h in orderedHeaderFiles)
@@ -267,8 +258,7 @@ public void Execute()
267258
}
268259

269260
// Footer
270-
271-
sw.Write(this.Footer);
261+
sw.Write(Footer);
272262
}
273263
}
274264
}

tools/CustomBuildTool/Program.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static void Main(string[] args)
7777
}
7878
else if (ProgramArgs.ContainsKey("-bin"))
7979
{
80-
Build.ShowBuildEnvironment(false);
80+
Build.SetupBuildEnvironment(false);
8181

8282
if (!Build.BuildSolution("ProcessHacker.sln",
8383
BuildFlags.Build32bit | BuildFlags.Build64bit |
@@ -113,7 +113,7 @@ public static void Main(string[] args)
113113
}
114114
else if (ProgramArgs.ContainsKey("-debug"))
115115
{
116-
Build.ShowBuildEnvironment(true);
116+
Build.SetupBuildEnvironment(true);
117117

118118
if (!Build.BuildSolution("ProcessHacker.sln",
119119
BuildFlags.Build32bit | BuildFlags.Build64bit |
@@ -159,7 +159,7 @@ public static void Main(string[] args)
159159
}
160160
else if (ProgramArgs.ContainsKey("-appveyor"))
161161
{
162-
Build.ShowBuildEnvironment(true);
162+
Build.SetupBuildEnvironment(true);
163163

164164
if (!Build.BuildSolution("ProcessHacker.sln",
165165
BuildFlags.Build32bit | BuildFlags.Build64bit |
@@ -196,19 +196,16 @@ public static void Main(string[] args)
196196
// Environment.Exit(1);
197197
//if (!Build.BuildSrcZip())
198198
// Environment.Exit(1);
199-
if (!Build.BuildChecksumsFile())
200-
Environment.Exit(1);
201-
if (!Build.BuildUpdateSignature())
202-
Environment.Exit(1);
203-
199+
//if (!Build.BuildChecksumsFile())
200+
// Environment.Exit(1);
204201
if (!Build.BuildDeployUploadArtifacts())
205202
Environment.Exit(1);
206203
if (!Build.BuildDeployUpdateConfig())
207204
Environment.Exit(1);
208205
}
209206
else
210207
{
211-
Build.ShowBuildEnvironment(true);
208+
Build.SetupBuildEnvironment(true);
212209

213210
if (!Build.BuildSolution("ProcessHacker.sln",
214211
BuildFlags.Build32bit | BuildFlags.Build64bit |
@@ -240,9 +237,8 @@ public static void Main(string[] args)
240237
return;
241238
Build.BuildPdbZip();
242239
Build.BuildSdkZip();
243-
Build.BuildSrcZip();
240+
//Build.BuildSrcZip();
244241
Build.BuildChecksumsFile();
245-
246242
Build.ShowBuildStats();
247243
}
248244

tools/CustomBuildTool/Properties/PublishProfiles/64bit.pubxml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)