forked from AtomicGameEngine/AtomicGameEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNETProjectGen.h
More file actions
261 lines (174 loc) · 7.98 KB
/
NETProjectGen.h
File metadata and controls
261 lines (174 loc) · 7.98 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
//
// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#pragma once
#include <Atomic/Core/Object.h>
#include <Atomic/Resource/XMLFile.h>
#include <Atomic/Resource/JSONFile.h>
using namespace Atomic;
namespace ToolCore
{
class ProjectSettings;
class NETProjectGen;
class NETProjectBase : public Object
{
ATOMIC_OBJECT(NETProjectBase, Object)
public:
NETProjectBase(Context* context, NETProjectGen* projectGen);
virtual ~NETProjectBase();
void ReplacePathStrings(String& path) const;
void CopyXMLElementRecursive(XMLElement source, XMLElement dest);
protected:
SharedPtr<XMLFile> xmlFile_;
WeakPtr<NETProjectGen> projectGen_;
};
class NETCSProject : public NETProjectBase
{
friend class NETSolution;
ATOMIC_OBJECT(NETCSProject, NETProjectBase)
public:
NETCSProject(Context* context, NETProjectGen* projectGen);
virtual ~NETCSProject();
bool Load(const JSONValue& root);
const String& GetName() { return name_; }
const String& GetProjectGUID() { return projectGuid_; }
const Vector<String>& GetReferences() const { return references_; }
const Vector<String>& GetPackages() const { return packages_; }
bool GetIsPCL() const { return projectTypeGuids_.Contains("{786C830F-07A1-408B-BD7F-6EE04809D6DB}"); }
bool GetIsPlayerApp() const { return playerApplication_; }
bool SupportsDesktop() const;
bool SupportsPlatform(const String& platform, bool explicitCheck = true) const;
/// Returns true if this project is part of core AtomicNET
bool GetAtomicNETProject() const { return atomicNETProject_; }
bool Generate();
private:
/// Returns true if this project is part of core AtomicNET
void SetAtomicNETProject(bool value) { atomicNETProject_ = value; }
// Portable Class Library
bool GenerateShared();
bool GenerateStandard();
bool GetRelativeProjectPath(const String& fromPath, const String& toPath, String& output) const;
bool CreateProjectFolder(const String& path);
void CreateCompileItemGroup(XMLElement &projectRoot);
void CreateReferencesItemGroup(XMLElement &projectRoot);
void CreatePackagesItemGroup(XMLElement &projectRoot);
void CreateMainPropertyGroup(XMLElement &projectRoot);
void CreateDebugPropertyGroup(XMLElement &projectRoot);
void CreateReleasePropertyGroup(XMLElement &projectRoot);
void CreateApplicationItems(XMLElement &projectRoot);
void CreateAndroidItems(XMLElement &projectRoot);
void CreateIOSItems(XMLElement &projectRoot);
void CreateAssemblyInfo();
void GetAssemblySearchPaths(String& paths);
void ProcessDefineConstants(StringVector& constants);
/// Return a relative path to the output folder, config can be Release/Debug/Lib
String GetRelativeOutputPath(const String& config) const;
String name_;
String projectGuid_;
String outputType_;
String rootNamespace_;
String assemblyName_;
String assemblyOutputPath_;
String assemblySearchPaths_;
bool atomicNETProject_;
// project paths
String projectPath_;
XMLElement xmlRoot_;
Vector<String> platforms_;
Vector<String> references_;
Vector<String> packages_;
Vector<String> sourceFolders_;
Vector<String> defineConstants_;
Vector<String> projectTypeGuids_;
Vector<String> importProjects_;
Vector<String> libraryProjectZips_;
Vector<String> transformFiles_;
String targetFrameworkProfile_;
Vector<String> sharedReferences_;
bool genAssemblyDocFile_;
bool playerApplication_;
// Android
bool androidApplication_;
// iOS
String objcBindingApiDefinition_;
String codesignEntitlements_;
String infoPList_;
};
class NETSolution : public NETProjectBase
{
ATOMIC_OBJECT(NETSolution, NETProjectBase)
public:
NETSolution(Context* context, NETProjectGen* projectGen, bool rewrite = false);
virtual ~NETSolution();
bool Load(const JSONValue& root);
bool Generate();
const String& GetOutputPath() { return outputPath_; }
String GetOutputFilename() { return outputPath_ + name_ + ".sln"; }
Vector<String>& GetPackages() { return packages_; }
// Registers a NuGet package, returns true if the package hasn't been previously registered
bool RegisterPackage(const String& package);
/// If true, the sln file will rewritten if it exists, default is false
void SetRewriteSolution(bool rewrite) { rewriteSolution_ = rewrite; }
private:
void GenerateSolution(const String& slnPath);
String name_;
String outputPath_;
String solutionGUID_;
Vector<String> packages_;
bool rewriteSolution_;
};
class NETProjectGen : public Object
{
ATOMIC_OBJECT(NETProjectGen, Object)
public:
NETProjectGen(Context* context);
virtual ~NETProjectGen();
NETSolution* GetSolution() { return solution_; }
const Vector<SharedPtr<NETCSProject>>& GetCSProjects() { return projects_; }
NETCSProject* GetCSProjectByName(const String& name);
bool GetCSProjectDependencies(NETCSProject * source, PODVector<NETCSProject*>& depends) const;
const String& GetAtomicProjectPath() const { return atomicProjectPath_; }
bool Generate();
/// Returns true if the generated solution requires NuGet
bool GetRequiresNuGet();
String GenerateUUID();
/// If true, the sln file will rewritten if it exists, default is false
void SetRewriteSolution(bool rewrite);
bool LoadJSONProject(const String& jsonProjectPath);
bool LoadAtomicProject(const String& atomicProjectPath);
void AddGlobalDefineConstant(const String& constant) { globalDefineConstants_.Push(constant); }
const Vector<String>& GetGlobalDefineConstants() const { return globalDefineConstants_; }
void SetSupportedPlatforms(const StringVector& platforms);
bool GetSupportsPlatform(const String& platform) const;
ProjectSettings* GetProjectSettings() { return projectSettings_; }
private:
bool LoadProject(const JSONValue& root);
/// Returns true if a project is included on the specifed platform
bool IncludeProjectOnPlatform(const JSONValue& projectRoot, const String& platform);
// if true, the solution (sln) file will be recreated if it exists
bool rewriteSolution_;
String atomicProjectPath_;
SharedPtr<NETSolution> solution_;
Vector<String> globalDefineConstants_;
Vector<SharedPtr<NETCSProject>> projects_;
SharedPtr<ProjectSettings> projectSettings_;
};
}