-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
75 lines (62 loc) · 3.37 KB
/
Program.cs
File metadata and controls
75 lines (62 loc) · 3.37 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
using BuildTool.Generators;
using BuildTool.Generators.VisualStudio;
using CommandLine;
namespace BuildTool
{
internal class Program
{
public class Options
{
[Option('g', "generate", Required = false, HelpText = "Generate Visual Studio Project Files.", Group = "Generate")]
public bool GenerateProjects { get; set; }
[Option('s', "solution", Required = false, HelpText = "Name for a Visual Studio Solution.", Group = "Generate")]
public string? SolutionName { get; set; }
[Option('p', "projects", Required = false, HelpText = "Project Output Names.", Group = "Generate")]
public IEnumerable<string>? ProjectNames { get; set; }
[Option('o', "outputs", Required = false, HelpText = "Output Path For Project Files.", Group = "Generate")]
public IEnumerable<string>? ProjectOutputDirectories { get; set; }
[Option('i', "sources", Required = false, HelpText = "Project Source Directories.", Group = "Generate")]
public IEnumerable<string>? ProjectSourceDirectories { get; set; }
}
static void Main(string[] args)
{
Parser.Default.ParseArguments<Options>(args)
.WithParsed<Options>(o =>
{
if(o.GenerateProjects)
{
// We are going to generate a solution
if (o.SolutionName != null)
{
// Check that we have the required parameters
if(o.ProjectNames != null && o.ProjectOutputDirectories != null && o.ProjectSourceDirectories != null)
{
VSGenerator generator = new(o.SolutionName, VSConfig.Platforms, VSConfig.Configurations);
// Make sure our counts match
if (o.ProjectNames.Count() != o.ProjectOutputDirectories.Count())
{
Console.WriteLine("Param Count Mismatch - [ProjectNames] [ProjectOutputDirectories].");
return;
}
for (int i = 0; i < o.ProjectNames.Count(); i++)
{
VSProject proj = new(o.ProjectNames.ElementAt(i),
o.ProjectOutputDirectories.ElementAt(i),
o.ProjectSourceDirectories.ElementAt(i));
proj.SetOutputDir("$(SolutionDir)Binaries\\$(Platform)\\$(Configuration)\\");
proj.SetIntDir("$(SolutionDir)Intermediate\\$(Platform)\\$(Configuration)\\$(ProjectName)\\");
proj.AddIncludeFolder($"{o.ProjectSourceDirectories.ElementAt(i)}\\Public");
proj.AddIncludeFolder($"{o.ProjectSourceDirectories.ElementAt(i)}\\Private");
generator.AddProject(proj);
}
generator.Generate();
}
}
else
{
}
}
});
}
}
}