NETProjectGen.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include <Poco/UUID.h>
  23. #include <Poco/UUIDGenerator.h>
  24. #include <Atomic/IO/Log.h>
  25. #include <Atomic/IO/File.h>
  26. #include <Atomic/IO/FileSystem.h>
  27. #include "../ToolEnvironment.h"
  28. #include "../ToolSystem.h"
  29. #include "../Project/Project.h"
  30. #include "NETProjectGen.h"
  31. namespace ToolCore
  32. {
  33. NETProjectBase::NETProjectBase(Context* context, NETProjectGen* projectGen) :
  34. Object(context), xmlFile_(new XMLFile(context)), projectGen_(projectGen)
  35. {
  36. }
  37. NETProjectBase::~NETProjectBase()
  38. {
  39. }
  40. void NETProjectBase::ReplacePathStrings(String& path)
  41. {
  42. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  43. String atomicRoot = tenv->GetRootSourceDir();
  44. atomicRoot = RemoveTrailingSlash(atomicRoot);
  45. const String& scriptPlatform = projectGen_->GetScriptPlatform();
  46. path.Replace("$ATOMIC_ROOT$", atomicRoot, false);
  47. path.Replace("$SCRIPT_PLATFORM$", scriptPlatform, false);
  48. }
  49. NETCSProject::NETCSProject(Context* context, NETProjectGen* projectGen) : NETProjectBase(context, projectGen)
  50. {
  51. }
  52. NETCSProject::~NETCSProject()
  53. {
  54. }
  55. bool NETCSProject::CreateProjectFolder(const String& path)
  56. {
  57. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  58. if (fileSystem->DirExists(path))
  59. return true;
  60. fileSystem->CreateDirsRecursive(path);
  61. if (!fileSystem->DirExists(path))
  62. {
  63. LOGERRORF("Unable to create dir: %s", path.CString());
  64. return false;
  65. }
  66. return true;
  67. }
  68. void NETCSProject::CreateCompileItemGroup(XMLElement &projectRoot)
  69. {
  70. FileSystem* fs = GetSubsystem<FileSystem>();
  71. XMLElement igroup = projectRoot.CreateChild("ItemGroup");
  72. // Compile AssemblyInfo.cs
  73. igroup.CreateChild("Compile").SetAttribute("Include", "Properties\\AssemblyInfo.cs");
  74. for (unsigned i = 0; i < sourceFolders_.Size(); i++)
  75. {
  76. const String& sourceFolder = sourceFolders_[i];
  77. Vector<String> result;
  78. fs->ScanDir(result, sourceFolder, "*.cs", SCAN_FILES, true);
  79. for (unsigned j = 0; j < result.Size(); j++)
  80. {
  81. XMLElement compile = igroup.CreateChild("Compile");
  82. // IMPORTANT: / Slash direction breaks intellisense :/
  83. String path = sourceFolder + result[j];
  84. path.Replace('/', '\\');
  85. compile.SetAttribute("Include", path.CString());
  86. // put generated files into generated folder
  87. if (sourceFolder.Contains("Generated") && sourceFolder.Contains("CSharp") && sourceFolder.Contains("Packages"))
  88. {
  89. compile.CreateChild("Link").SetValue("Generated\\" + result[j]);
  90. }
  91. else
  92. {
  93. compile.CreateChild("Link").SetValue(result[j]);
  94. }
  95. }
  96. }
  97. }
  98. void NETProjectBase::CopyXMLElementRecursive(XMLElement source, XMLElement dest)
  99. {
  100. Vector<String> attrNames = source.GetAttributeNames();
  101. for (unsigned i = 0; i < attrNames.Size(); i++)
  102. {
  103. String value = source.GetAttribute(attrNames[i]);
  104. dest.SetAttribute(attrNames[i], value);
  105. }
  106. dest.SetValue(source.GetValue());
  107. XMLElement child = source.GetChild();
  108. while (child.NotNull() && child.GetName().Length())
  109. {
  110. XMLElement childDest = dest.CreateChild(child.GetName());
  111. CopyXMLElementRecursive(child, childDest);
  112. child = child.GetNext();
  113. }
  114. }
  115. void NETCSProject::CreateReferencesItemGroup(XMLElement &projectRoot)
  116. {
  117. XMLElement xref;
  118. XMLElement igroup = projectRoot.CreateChild("ItemGroup");
  119. for (unsigned i = 0; i < references_.Size(); i++)
  120. {
  121. String ref = references_[i];
  122. // project reference
  123. if (projectGen_->GetCSProjectByName(ref))
  124. continue;
  125. // NuGet project
  126. if (ref.StartsWith("<"))
  127. {
  128. XMLFile xmlFile(context_);
  129. if (!xmlFile.FromString(ref))
  130. {
  131. LOGERROR("NETCSProject::CreateReferencesItemGroup - Unable to parse reference XML");
  132. }
  133. xref = igroup.CreateChild("Reference");
  134. CopyXMLElementRecursive(xmlFile.GetRoot(), xref);
  135. continue;
  136. }
  137. String refpath = ref + ".dll";
  138. xref = igroup.CreateChild("Reference");
  139. xref.SetAttribute("Include", ref);
  140. }
  141. }
  142. void NETCSProject::CreateProjectReferencesItemGroup(XMLElement &projectRoot)
  143. {
  144. XMLElement igroup = projectRoot.CreateChild("ItemGroup");
  145. for (unsigned i = 0; i < references_.Size(); i++)
  146. {
  147. const String& ref = references_[i];
  148. NETCSProject* project = projectGen_->GetCSProjectByName(ref);
  149. if (!project)
  150. continue;
  151. XMLElement projectRef = igroup.CreateChild("ProjectReference");
  152. projectRef.SetAttribute("Include", ToString("..\\%s\\%s.csproj", ref.CString(), ref.CString()));
  153. XMLElement xproject = projectRef.CreateChild("Project");
  154. xproject.SetValue(ToString("{%s}", project->GetProjectGUID().ToLower().CString()));
  155. XMLElement xname = projectRef.CreateChild("Name");
  156. xname.SetValue(project->GetName());
  157. }
  158. }
  159. void NETCSProject::CreatePackagesItemGroup(XMLElement &projectRoot)
  160. {
  161. if (!packages_.Size())
  162. return;
  163. XMLElement xref;
  164. XMLElement igroup = projectRoot.CreateChild("ItemGroup");
  165. xref = igroup.CreateChild("None");
  166. xref.SetAttribute("Include", "packages.config");
  167. XMLFile packageConfig(context_);
  168. XMLElement packageRoot = packageConfig.CreateRoot("packages");
  169. for (unsigned i = 0; i < packages_.Size(); i++)
  170. {
  171. XMLFile xmlFile(context_);
  172. if (!xmlFile.FromString(packages_[i]))
  173. {
  174. LOGERROR("NETCSProject::CreatePackagesItemGroup - Unable to parse package xml");
  175. }
  176. xref = packageRoot.CreateChild("package");
  177. CopyXMLElementRecursive(xmlFile.GetRoot(), xref);
  178. }
  179. SharedPtr<File> output(new File(context_, projectPath_ + "packages.config", FILE_WRITE));
  180. String source = packageConfig.ToString();
  181. output->Write(source.CString(), source.Length());
  182. }
  183. void NETCSProject::GetAssemblySearchPaths(String& paths)
  184. {
  185. paths.Clear();
  186. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  187. Vector<String> searchPaths;
  188. if (assemblySearchPaths_.Length())
  189. searchPaths.Push(assemblySearchPaths_);
  190. paths.Join(searchPaths, ";");
  191. }
  192. void NETCSProject::CreateReleasePropertyGroup(XMLElement &projectRoot)
  193. {
  194. XMLElement pgroup = projectRoot.CreateChild("PropertyGroup");
  195. pgroup.SetAttribute("Condition", " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ");
  196. pgroup.CreateChild("DebugType").SetValue("full");
  197. pgroup.CreateChild("Optimize").SetValue("true");
  198. pgroup.CreateChild("OutputPath").SetValue(assemblyOutputPath_ + "Release\\");
  199. pgroup.CreateChild("DefineConstants").SetValue("TRACE");
  200. pgroup.CreateChild("ErrorReport").SetValue("prompt");
  201. pgroup.CreateChild("WarningLevel").SetValue("4");
  202. pgroup.CreateChild("ConsolePause").SetValue("false");
  203. pgroup.CreateChild("AllowUnsafeBlocks").SetValue("true");
  204. pgroup.CreateChild("PlatformTarget").SetValue("x64");
  205. }
  206. void NETCSProject::CreateDebugPropertyGroup(XMLElement &projectRoot)
  207. {
  208. XMLElement pgroup = projectRoot.CreateChild("PropertyGroup");
  209. pgroup.SetAttribute("Condition", " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ");
  210. pgroup.CreateChild("DebugSymbols").SetValue("true");
  211. pgroup.CreateChild("DebugType").SetValue("full");
  212. pgroup.CreateChild("Optimize").SetValue("false");
  213. pgroup.CreateChild("OutputPath").SetValue(assemblyOutputPath_ + "Debug\\");
  214. pgroup.CreateChild("DefineConstants").SetValue("DEBUG;TRACE");
  215. pgroup.CreateChild("ErrorReport").SetValue("prompt");
  216. pgroup.CreateChild("WarningLevel").SetValue("4");
  217. pgroup.CreateChild("ConsolePause").SetValue("false");
  218. pgroup.CreateChild("AllowUnsafeBlocks").SetValue("true");
  219. pgroup.CreateChild("PlatformTarget").SetValue("x64");
  220. }
  221. void NETCSProject::CreateAssemblyInfo()
  222. {
  223. String info = "using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n\n";
  224. info += ToString("[assembly:AssemblyTitle(\"%s\")]\n", name_.CString());
  225. info += "[assembly:AssemblyDescription(\"\")]\n";
  226. info += "[assembly:AssemblyConfiguration(\"\")]\n";
  227. info += "[assembly:AssemblyCompany(\"\")]\n";
  228. info += ToString("[assembly:AssemblyProduct(\"%s\")]\n", name_.CString());
  229. info += "\n\n\n";
  230. info += "[assembly:ComVisible(false)]\n";
  231. info += "\n\n";
  232. info += ToString("[assembly:Guid(\"%s\")]\n", projectGuid_.CString());
  233. info += "\n\n";
  234. info += "[assembly:AssemblyVersion(\"1.0.0.0\")]\n";
  235. info += "[assembly:AssemblyFileVersion(\"1.0.0.0\")]\n";
  236. SharedPtr<File> output(new File(context_, projectPath_ + "Properties/AssemblyInfo.cs", FILE_WRITE));
  237. output->Write(info.CString(), info.Length());
  238. }
  239. void NETCSProject::CreateMainPropertyGroup(XMLElement& projectRoot)
  240. {
  241. XMLElement pgroup = projectRoot.CreateChild("PropertyGroup");
  242. // Configuration
  243. XMLElement config = pgroup.CreateChild("Configuration");
  244. config.SetAttribute("Condition", " '$(Configuration)' == '' ");
  245. config.SetValue("Debug");
  246. // Platform
  247. XMLElement platform = pgroup.CreateChild("Platform");
  248. platform.SetAttribute("Condition", " '$(Platform)' == '' ");
  249. platform.SetValue("AnyCPU");
  250. // ProjectGuid
  251. XMLElement guid = pgroup.CreateChild("ProjectGuid");
  252. guid.SetValue("{" + projectGuid_ + "}");
  253. // OutputType
  254. XMLElement outputType = pgroup.CreateChild("OutputType");
  255. outputType.SetValue(outputType_);
  256. pgroup.CreateChild("AppDesignerFolder").SetValue("Properties");
  257. // RootNamespace
  258. XMLElement rootNamespace = pgroup.CreateChild("RootNamespace");
  259. rootNamespace.SetValue(rootNamespace_);
  260. // AssemblyName
  261. XMLElement assemblyName = pgroup.CreateChild("AssemblyName");
  262. assemblyName.SetValue(assemblyName_);
  263. // TargetFrameworkVersion
  264. XMLElement targetFrameWork = pgroup.CreateChild("TargetFrameworkVersion");
  265. targetFrameWork.SetValue("v4.6");
  266. pgroup.CreateChild("FileAlignment").SetValue("512");
  267. }
  268. bool NETCSProject::Generate()
  269. {
  270. NETSolution* solution = projectGen_->GetSolution();
  271. projectPath_ = solution->GetOutputPath() + name_ + "/";
  272. if (!CreateProjectFolder(projectPath_))
  273. return false;
  274. if (!CreateProjectFolder(projectPath_ + "Properties"))
  275. return false;
  276. XMLElement project = xmlFile_->CreateRoot("Project");
  277. project.SetAttribute("DefaultTargets", "Build");
  278. project.SetAttribute("ToolsVersion", "14.0");
  279. project.SetAttribute("DefaultTargets", "Build");
  280. project.SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
  281. XMLElement import = project.CreateChild("Import");
  282. import.SetAttribute("Project", "$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props");
  283. import.SetAttribute("Condition", "Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')");
  284. CreateMainPropertyGroup(project);
  285. CreateDebugPropertyGroup(project);
  286. CreateReleasePropertyGroup(project);
  287. CreateReferencesItemGroup(project);
  288. CreateProjectReferencesItemGroup(project);
  289. CreateCompileItemGroup(project);
  290. CreatePackagesItemGroup(project);
  291. CreateAssemblyInfo();
  292. project.CreateChild("Import").SetAttribute("Project", "$(MSBuildToolsPath)\\Microsoft.CSharp.targets");
  293. String projectSource = xmlFile_->ToString();
  294. SharedPtr<File> output(new File(context_, projectPath_ + name_ + ".csproj", FILE_WRITE));
  295. output->Write(projectSource.CString(), projectSource.Length());
  296. return true;
  297. }
  298. bool NETCSProject::Load(const JSONValue& root)
  299. {
  300. name_ = root["name"].GetString();
  301. projectGuid_ = projectGen_->GenerateUUID();
  302. outputType_ = root["outputType"].GetString();
  303. rootNamespace_ = root["rootNamespace"].GetString();
  304. assemblyName_ = root["assemblyName"].GetString();
  305. assemblyOutputPath_ = root["assemblyOutputPath"].GetString();
  306. ReplacePathStrings(assemblyOutputPath_);
  307. assemblySearchPaths_ = root["assemblySearchPaths"].GetString();
  308. ReplacePathStrings(assemblySearchPaths_);
  309. const JSONArray& references = root["references"].GetArray();
  310. for (unsigned i = 0; i < references.Size(); i++)
  311. {
  312. String reference = references[i].GetString();
  313. ReplacePathStrings(reference);
  314. references_.Push(reference);
  315. }
  316. const JSONArray& packages = root["packages"].GetArray();
  317. for (unsigned i = 0; i < packages.Size(); i++)
  318. {
  319. String package = packages[i].GetString();
  320. packages_.Push(package);
  321. }
  322. const JSONArray& sources = root["sources"].GetArray();
  323. for (unsigned i = 0; i < sources.Size(); i++)
  324. {
  325. String source = sources[i].GetString();
  326. ReplacePathStrings(source);
  327. sourceFolders_.Push(AddTrailingSlash(source));
  328. }
  329. return true;
  330. }
  331. NETSolution::NETSolution(Context* context, NETProjectGen* projectGen) : NETProjectBase(context, projectGen)
  332. {
  333. }
  334. NETSolution::~NETSolution()
  335. {
  336. }
  337. bool NETSolution::Generate()
  338. {
  339. String slnPath = outputPath_ + name_ + ".sln";
  340. GenerateSolution(slnPath);
  341. return true;
  342. }
  343. void NETSolution::GenerateSolution(const String &slnPath)
  344. {
  345. String source = "Microsoft Visual Studio Solution File, Format Version 12.00\n";
  346. source += "# Visual Studio 14\n";
  347. source += "VisualStudioVersion = 14.0.25420.1\n";
  348. source += "MinimumVisualStudioVersion = 10.0.40219.1\n";
  349. solutionGUID_ = projectGen_->GenerateUUID();
  350. PODVector<NETCSProject*> depends;
  351. const Vector<SharedPtr<NETCSProject>>& projects = projectGen_->GetCSProjects();
  352. for (unsigned i = 0; i < projects.Size(); i++)
  353. {
  354. NETCSProject* p = projects.At(i);
  355. const String& projectName = p->GetName();
  356. const String& projectGUID = p->GetProjectGUID();
  357. source += ToString("Project(\"{%s}\") = \"%s\", \"%s\\%s.csproj\", \"{%s}\"\n",
  358. solutionGUID_.CString(), projectName.CString(), projectName.CString(),
  359. projectName.CString(), projectGUID.CString());
  360. projectGen_->GetCSProjectDependencies(p, depends);
  361. if (depends.Size())
  362. {
  363. source += "\tProjectSection(ProjectDependencies) = postProject\n";
  364. for (unsigned j = 0; j < depends.Size(); j++)
  365. {
  366. source += ToString("\t{%s} = {%s}\n",
  367. depends[j]->GetProjectGUID().CString(), depends[j]->GetProjectGUID().CString());
  368. }
  369. source += "\tEndProjectSection\n";
  370. }
  371. source += "\tEndProject\n";
  372. }
  373. source += "Global\n";
  374. source += " GlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
  375. source += " Debug|Any CPU = Debug|Any CPU\n";
  376. source += " Release|Any CPU = Release|Any CPU\n";
  377. source += " EndGlobalSection\n";
  378. source += " GlobalSection(ProjectConfigurationPlatforms) = postSolution\n";
  379. for (unsigned i = 0; i < projects.Size(); i++)
  380. {
  381. NETCSProject* p = projects.At(i);
  382. source += ToString(" {%s}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n", p->GetProjectGUID().CString());
  383. source += ToString(" {%s}.Debug|Any CPU.Build.0 = Debug|Any CPU\n", p->GetProjectGUID().CString());
  384. source += ToString(" {%s}.Release|Any CPU.ActiveCfg = Release|Any CPU\n", p->GetProjectGUID().CString());
  385. source += ToString(" {%s}.Release|Any CPU.Build.0 = Release|Any CPU\n", p->GetProjectGUID().CString());
  386. }
  387. source += " EndGlobalSection\n";
  388. source += "EndGlobal\n";
  389. SharedPtr<File> output(new File(context_, slnPath, FILE_WRITE));
  390. output->Write(source.CString(), source.Length());
  391. output->Close();
  392. }
  393. bool NETSolution::Load(const JSONValue& root)
  394. {
  395. FileSystem* fs = GetSubsystem<FileSystem>();
  396. name_ = root["name"].GetString();
  397. outputPath_ = AddTrailingSlash(root["outputPath"].GetString());
  398. ReplacePathStrings(outputPath_);
  399. // TODO: use poco mkdirs
  400. if (!fs->DirExists(outputPath_))
  401. fs->CreateDirsRecursive(outputPath_);
  402. return true;
  403. }
  404. NETProjectGen::NETProjectGen(Context* context) : Object(context)
  405. {
  406. }
  407. NETProjectGen::~NETProjectGen()
  408. {
  409. }
  410. NETCSProject* NETProjectGen::GetCSProjectByName(const String & name)
  411. {
  412. for (unsigned i = 0; i < projects_.Size(); i++)
  413. {
  414. if (projects_[i]->GetName() == name)
  415. return projects_[i];
  416. }
  417. return nullptr;
  418. }
  419. bool NETProjectGen::GetCSProjectDependencies(NETCSProject* source, PODVector<NETCSProject*>& depends) const
  420. {
  421. depends.Clear();
  422. const Vector<String>& references = source->GetReferences();
  423. for (unsigned i = 0; i < projects_.Size(); i++)
  424. {
  425. NETCSProject* pdepend = projects_.At(i);
  426. if (source == pdepend)
  427. continue;
  428. for (unsigned j = 0; j < references.Size(); j++)
  429. {
  430. if (pdepend->GetName() == references[j])
  431. {
  432. depends.Push(pdepend);
  433. }
  434. }
  435. }
  436. return depends.Size() != 0;
  437. }
  438. bool NETProjectGen::Generate()
  439. {
  440. solution_->Generate();
  441. for (unsigned i = 0; i < projects_.Size(); i++)
  442. {
  443. if (!projects_[i]->Generate())
  444. return false;
  445. }
  446. return true;
  447. }
  448. bool NETProjectGen::LoadProject(const JSONValue &root)
  449. {
  450. solution_ = new NETSolution(context_, this);
  451. solution_->Load(root["solution"]);
  452. const JSONValue& jprojects = root["projects"];
  453. if (!jprojects.IsArray() || !jprojects.Size())
  454. return false;
  455. for (unsigned i = 0; i < jprojects.Size(); i++)
  456. {
  457. const JSONValue& jproject = jprojects[i];
  458. if (!jproject.IsObject())
  459. return false;
  460. SharedPtr<NETCSProject> csProject(new NETCSProject(context_, this));
  461. if (!csProject->Load(jproject))
  462. return false;
  463. projects_.Push(csProject);
  464. }
  465. return true;
  466. }
  467. bool NETProjectGen::LoadProject(const String& projectPath)
  468. {
  469. SharedPtr<File> file(new File(context_));
  470. if (!file->Open(projectPath))
  471. return false;
  472. String json;
  473. file->ReadText(json);
  474. JSONValue jvalue;
  475. if (!JSONFile::ParseJSON(json, jvalue))
  476. return false;
  477. return LoadProject(jvalue);
  478. }
  479. String NETProjectGen::GenerateUUID()
  480. {
  481. Poco::UUIDGenerator& generator = Poco::UUIDGenerator::defaultGenerator();
  482. Poco::UUID uuid(generator.create()); // time based
  483. return String(uuid.toString().c_str()).ToUpper();
  484. }
  485. }