-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVCProjectFile.cs
More file actions
169 lines (142 loc) · 6.99 KB
/
Copy pathVCProjectFile.cs
File metadata and controls
169 lines (142 loc) · 6.99 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
using BearBuildTool.Projects;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
namespace BearBuildTool.VisualCode
{
public class VCProjectFile
{
bool General = false;
string Name;
string ProjectDirectory;
public string VCDirectory;
GenerateProjectFile GenerateProject;
public VCProjectFile(string name, string general_name)
{
General = name == general_name;
Name = name;
ProjectDirectory = Path.Combine(Config.Global.IntermediatePath, "..", "VisualCode", general_name, name);
if (!Directory.Exists(ProjectDirectory))
{
Directory.CreateDirectory(ProjectDirectory);
}
GenerateProject = new GenerateProjectFile();
GenerateProject.RegisterProject(name);
VCDirectory = Path.Combine(GenerateProject.ProjectPath[Name], ".vscode");
if (!Directory.Exists(VCDirectory))
{
Directory.CreateDirectory(VCDirectory);
}
}
void GenerateTasksMinGW(ref VCTasks vcLaunch, string name, string configure, string platform)
{
VCTasks.Task task = new VCTasks.Task();
task.command= Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName).Replace('\\', '/');
task.args.Add(name);
task.args.Add(configure);
task.args.Add(platform);
task.label = "build " + configure + "_" + platform;
vcLaunch.tasks.Add(task);
}
string[] Platfroms = { "MinGW" };
string[] Configurations = { "Debug", "Mixed", "Release" };
Config.Platform[] PlatfromsType = { Config.Platform.MinGW };
Config.Configure[] ConfigurationsType = { Config.Configure.Debug, Config.Configure.Mixed, Config.Configure.Release };
void GenerateCPPConfigureMinGW(ref VCCppProperties vcCppProperties, string NameConfigurate,int idp,int idc, string Name, string[] Defines)
{
VCCppProperties.Configurate configurate = new VCCppProperties.Configurate();
List<string> list = new List<string>();
GenerateProject.GetInclude(Name, ref list);
for (int i = 0; i < list.Count; i++)
{
list[i] = list[i].Replace('\\', '/');
}
configurate.includePath = list;
List<string> defines = GenerateProject.MapProjects[PlatfromsType[idp]][ConfigurationsType[idc]][Name].Defines.ToList();
defines.AddRange(Defines);
configurate.defines = defines;
configurate.compilerPath = Path.Combine(Config.Global.MinGWPath, "bin", "g++.exe").Replace('\\', '/');
configurate.name = NameConfigurate;
vcCppProperties.configurations.Add(configurate);
}
void GenerateLaunchMinGW(ref VCLaunch vcLaunch, string configure, string configure_exe)
{
GenerateLaunchMinGW(ref vcLaunch, configure, "MinGW", configure_exe);
}
void GenerateLaunchMinGW(ref VCLaunch vcLaunch, string configure, string platform, string configure_exe)
{
VCLaunch.Configurate configurate = new VCLaunch.Configurate();
configurate.name = configure + "_" + platform;
Config.Global.BinariesPlatformPath = Path.Combine(Config.Global.BinariesPath, platform);
if (!Directory.Exists(Config.Global.BinariesPlatformPath))
{
Directory.CreateDirectory(Config.Global.BinariesPlatformPath);
}
if (String.IsNullOrEmpty(configure_exe))
{
configurate.program = Path.Combine(Config.Global.BinariesPlatformPath, Name + ".exe").Replace('\\', '/');
}
else
{
configurate.program = Path.Combine(Config.Global.BinariesPlatformPath, Name + "_" + configure_exe + ".exe").Replace('\\', '/');
}
configurate.cwd = Config.Global.BinariesPlatformPath.Replace('\\', '/');
configurate.miDebuggerPath = Path.Combine(Config.Global.MinGWPath, "bin", "gdb.exe").Replace('\\', '/');
configurate.preLaunchTask = "build " + configure + "_" + platform; ;
vcLaunch.configurations.Add(configurate);
}
public void Write()
{
if (Config.Global.IsWindows)
{
List<string> GlobalDefines = new List<string>();
GlobalDefines.AddRange(new string[] { "WINDOWS", "LIB", "_LIB" });
if (Config.Global.UNICODE)
{
GlobalDefines.Add("_UNICODE;");
GlobalDefines.Add("UNICODE");
}
VCCppProperties vcCppProperties = new VCCppProperties();
string[][] PlatfromsDefines = { new string[] { "WIN64", "X64" } };
string[][] ConfigurationsDefines = { new string[] { "DEBUG", "_DEBUG", "GCC" }, new string[] { "MIXED", "DEBUG", "GCC" }, new string[] { "NDEBUG", "GCC" } };
{
for (int i = 0; i < Platfroms.Length; i++)
for (int a = 0; a < Configurations.Length; a++)
{
List<string> LocalDefines = new List<string>();
LocalDefines.AddRange(GlobalDefines);
LocalDefines.AddRange(PlatfromsDefines[i]);
LocalDefines.AddRange(ConfigurationsDefines[a]);
GenerateCPPConfigureMinGW(ref vcCppProperties, Platfroms[i],i,a, Name, LocalDefines.ToArray());
}
File.WriteAllText(Path.Combine(VCDirectory, "c_cpp_properties.json"), JsonConvert.SerializeObject(vcCppProperties, Formatting.Indented));
}
if (General)
{
{
VCTasks vcTasks = new VCTasks();
for (int i = 0; i < Platfroms.Length; i++)
for (int a = 0; a < Configurations.Length; a++)
{
GenerateTasksMinGW(ref vcTasks, Name, Configurations[a], Platfroms[i]);
}
File.WriteAllText(Path.Combine(VCDirectory, "tasks.json"), JsonConvert.SerializeObject(vcTasks, Formatting.Indented));
}
{
VCLaunch vcLaunch = new VCLaunch();
GenerateLaunchMinGW(ref vcLaunch, "Debug", "debug");
GenerateLaunchMinGW(ref vcLaunch, "Mixed", "mixed");
GenerateLaunchMinGW(ref vcLaunch, "Release", "");
File.WriteAllText(Path.Combine(VCDirectory, "launch.json"), JsonConvert.SerializeObject(vcLaunch, Formatting.Indented));
}
}
}
else
{
{
}
}
}
}
}