-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProject.h
More file actions
162 lines (123 loc) · 4.79 KB
/
Project.h
File metadata and controls
162 lines (123 loc) · 4.79 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
#pragma once
#include "VCConfiguration.h" //VCConfiguration
#include <list>
#include <initializer_list>
#include <functional> //std::functional
#include <guiddef.h> //GUID
typedef enum SPM_DLLEXPORT {
projecttype_Console,
projecttype_CppSharedItemsProject
}EProjectType;
//---------------------------------------------------------
// Project
//---------------------------------------------------------
class SPM_DLLEXPORT Project : public ReflectClassT<Project>
{
public:
Project();
Project(const wchar_t* _name);
//
// It's good to set save directory before adding files to project, as all paths will be relative to project.
//
void SetSaveDirectory(const wchar_t* dir);
//
// Gets project save directory.
//
std::wstring GetSaveDirectory();
std::wstring GetProjectSaveLocation();
std::wstring GetProjectExtension();
//
// Clears existing project
//
void New(EProjectType projectType = projecttype_Console);
//
// Loads .vcxproj file.
//
bool Load(const wchar_t* file);
//
// Saves project file
//
bool Save(const wchar_t* file = nullptr);
virtual void OnAfterSetProperty(ReflectPath& path);
REFLECTABLE(Project,
(ProjectGlobalConf)Globals
);
//
// Sets visual studio version, in year. e.g. 2017, 2019, ...
//
void SetVsVersion(int vsVersion);
//
// Gets project guid, initialized if it's not initialized yet
//
std::wstring GetGuid(void);
//
// Add support for platform or configuration, if not yet added.
//
void AddPlatform(const wchar_t* platform);
void AddPlatforms(std::initializer_list<std::wstring> _platforms);
void AddConfiguration(const wchar_t* configuration);
void AddConfigurations(std::initializer_list<std::wstring> _configuration);
//
// Queries for currently selected toolset, if none is selected, tries to determine from visual studio format version
//
std::string GetToolset();
//
// Adds files to the project.
//
void AddFiles(std::initializer_list<std::wstring> fileList);
//
// Queries if project contains given file, adds it if add is true
//
ProjectFile* File(const wchar_t* file, bool add);
ProjectFile* AddFile(const wchar_t* file)
{
return File(file, true);
}
//
// Visits each project configuration, if configurationName & platformName - uses additional filtering, otherwise visits all configurations.
//
void VisitConfigurations( std::function<void (VCConfiguration&)> visitConf, const wchar_t* configurationName = nullptr, const wchar_t* platformName = nullptr );
protected:
EProjectType projectType;
// Project name, typically used to identify project within solution or specify saved filename if file is not specified during save.
std::wstring name;
// Directory where project shall be saved.
std::wstring saveDir;
// "Win32", "х64", ...
std::vector<std::wstring> platforms;
// "Debug", "Release", user defined
std::vector<std::wstring> configurationNames;
//
// Gets current configuration names, if not initialized yet, returns default "Debug" / "Release" set.
//
std::vector<std::wstring>& GetConfigurationNames();
// Project settings
std::vector< std::shared_ptr<VCConfiguration> > configurations;
// List of files within a project.
std::list< std::shared_ptr<ProjectFile> > files;
// Project guid
GUID guid;
//
// Visual studio version, in year. e.g. 2017, 2019, ...
//
int vsVersion;
// Platform Toolset, e.g. "v141" (for vs2017), "142" (for vs2019), "Clang_5_0" ...
std::string toolset;
// xml document.
pugi::xml_document xmldoc;
pugi::xml_node project( );
pugi::xml_node projectGlobals;
pugi::xml_node markForPropertyGroup;
public:
//
// Selects project node with specific name / label, of specific confName/platform, creates if does not exists
//
pugi::xml_node selectProjectNodes(const wchar_t* name, const wchar_t* label, const wchar_t* confName, const wchar_t* platform);
protected:
//
// Platforms or Configurations arrays updated, bPlatforms == true - platforms false = configurations, bAdd = true - added, bAdd = false - removed.
//
void PlatformConfigurationsUpdated(std::initializer_list<std::wstring> items, bool bPlatforms, bool bAdd);
};
pugi::xml_node LocateInsert(pugi::xml_node current, bool asChild, const wchar_t* name2select,
const wchar_t* confName, const wchar_t* platform, const wchar_t* label = nullptr, bool bLabelAfterCondition = true);