NETProjectGen.cpp 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881
  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/ProjectSettings.h"
  30. #include "../Project/Project.h"
  31. #include "NETProjectGen.h"
  32. namespace ToolCore
  33. {
  34. NETProjectBase::NETProjectBase(Context* context, NETProjectGen* projectGen) :
  35. Object(context), xmlFile_(new XMLFile(context)), projectGen_(projectGen)
  36. {
  37. }
  38. NETProjectBase::~NETProjectBase()
  39. {
  40. }
  41. void NETProjectBase::ReplacePathStrings(String& path)
  42. {
  43. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  44. String atomicRoot = tenv->GetRootSourceDir();
  45. atomicRoot = RemoveTrailingSlash(atomicRoot);
  46. path.Replace("$ATOMIC_ROOT$", atomicRoot, false);
  47. String atomicProjectPath = projectGen_->GetAtomicProjectPath();
  48. // TODO: This is the cause of a bunch of "GetSanitizedPath" calls,
  49. // It should be removed, and the few places in csproj/sln that need backslash
  50. // adjusted there
  51. atomicProjectPath.Replace("/", "\\");
  52. if (atomicProjectPath.Length())
  53. {
  54. path.Replace("$ATOMIC_PROJECT_ROOT$", atomicProjectPath, false);
  55. }
  56. }
  57. NETCSProject::NETCSProject(Context* context, NETProjectGen* projectGen) : NETProjectBase(context, projectGen),
  58. genAssemblyDocFile_(false),
  59. playerApplication_(false),
  60. androidApplication_(false)
  61. {
  62. }
  63. NETCSProject::~NETCSProject()
  64. {
  65. }
  66. bool NETCSProject::SupportsDesktop() const
  67. {
  68. if (!platforms_.Size())
  69. return true;
  70. if (platforms_.Contains("desktop") || platforms_.Contains("windows") || platforms_.Contains("macosx") || platforms_.Contains("linux"))
  71. return true;
  72. return false;
  73. }
  74. bool NETCSProject::SupportsPlatform(const String& platform, bool explicitCheck) const
  75. {
  76. if (!explicitCheck && !platforms_.Size())
  77. return true;
  78. if (platforms_.Contains(platform.ToLower()))
  79. return true;
  80. return false;
  81. }
  82. bool NETCSProject::CreateProjectFolder(const String& path)
  83. {
  84. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  85. if (fileSystem->DirExists(path))
  86. return true;
  87. fileSystem->CreateDirsRecursive(path);
  88. if (!fileSystem->DirExists(path))
  89. {
  90. ATOMIC_LOGERRORF("Unable to create dir: %s", path.CString());
  91. return false;
  92. }
  93. return true;
  94. }
  95. void NETCSProject::CreateCompileItemGroup(XMLElement &projectRoot)
  96. {
  97. FileSystem* fs = GetSubsystem<FileSystem>();
  98. XMLElement igroup = projectRoot.CreateChild("ItemGroup");
  99. // Compile AssemblyInfo.cs
  100. if (!GetIsPCL() && !sharedReferences_.Size() && outputType_ != "Shared")
  101. igroup.CreateChild("Compile").SetAttribute("Include", "Properties\\AssemblyInfo.cs");
  102. for (unsigned i = 0; i < sourceFolders_.Size(); i++)
  103. {
  104. const String& sourceFolder = sourceFolders_[i];
  105. Vector<String> result;
  106. fs->ScanDir(result, sourceFolder, "*.cs", SCAN_FILES, true);
  107. for (unsigned j = 0; j < result.Size(); j++)
  108. {
  109. XMLElement compile = igroup.CreateChild("Compile");
  110. String path = sourceFolder + result[j];
  111. String relativePath;
  112. if (GetRelativePath(projectPath_, GetPath(path), relativePath))
  113. {
  114. path = relativePath + GetFileName(path) + GetExtension(path);
  115. }
  116. // IMPORTANT: / Slash direction breaks intellisense :/
  117. path.Replace('/', '\\');
  118. compile.SetAttribute("Include", path.CString());
  119. // put generated files into generated folder
  120. if (sourceFolder.Contains("Generated") && sourceFolder.Contains("CSharp") && sourceFolder.Contains("Packages"))
  121. {
  122. compile.CreateChild("Link").SetValue("Generated\\" + result[j]);
  123. }
  124. else
  125. {
  126. compile.CreateChild("Link").SetValue(result[j]);
  127. }
  128. }
  129. }
  130. }
  131. void NETProjectBase::CopyXMLElementRecursive(XMLElement source, XMLElement dest)
  132. {
  133. Vector<String> attrNames = source.GetAttributeNames();
  134. for (unsigned i = 0; i < attrNames.Size(); i++)
  135. {
  136. String value = source.GetAttribute(attrNames[i]);
  137. dest.SetAttribute(attrNames[i], value);
  138. }
  139. dest.SetValue(source.GetValue());
  140. XMLElement child = source.GetChild();
  141. while (child.NotNull() && child.GetName().Length())
  142. {
  143. XMLElement childDest = dest.CreateChild(child.GetName());
  144. CopyXMLElementRecursive(child, childDest);
  145. child = child.GetNext();
  146. }
  147. }
  148. void NETCSProject::CreateReferencesItemGroup(XMLElement &projectRoot)
  149. {
  150. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  151. XMLElement xref;
  152. XMLElement igroup = projectRoot.CreateChild("ItemGroup");
  153. for (unsigned i = 0; i < references_.Size(); i++)
  154. {
  155. String ref = references_[i];
  156. // project reference
  157. if (projectGen_->GetCSProjectByName(ref))
  158. continue;
  159. String platform;
  160. if (projectGen_->GetAtomicProjectPath().Length() && ref.StartsWith("AtomicNET"))
  161. {
  162. if (GetIsPCL())
  163. {
  164. ref = "AtomicNET";
  165. platform = "Portable";
  166. }
  167. else if (SupportsDesktop())
  168. {
  169. ref = "AtomicNET";
  170. platform = "Desktop";
  171. }
  172. else if (SupportsPlatform("android"))
  173. {
  174. if (ref != "AtomicNET.Android.SDL")
  175. ref = "AtomicNET";
  176. platform = "Android";
  177. }
  178. else if (SupportsPlatform("ios"))
  179. {
  180. ref = "AtomicNET";
  181. platform = "iOS";
  182. }
  183. if (platform.Length())
  184. {
  185. String atomicNETAssembly = tenv->GetAtomicNETCoreAssemblyDir() + ToString("%s/%s.dll", platform.CString(), ref.CString());
  186. xref = igroup.CreateChild("Reference");
  187. xref.SetAttribute("Include", atomicNETAssembly);
  188. }
  189. continue;
  190. }
  191. // NuGet project
  192. if (ref.StartsWith("<"))
  193. {
  194. XMLFile xmlFile(context_);
  195. if (!xmlFile.FromString(ref))
  196. {
  197. ATOMIC_LOGERROR("NETCSProject::CreateReferencesItemGroup - Unable to parse reference XML");
  198. }
  199. xref = igroup.CreateChild("Reference");
  200. CopyXMLElementRecursive(xmlFile.GetRoot(), xref);
  201. continue;
  202. }
  203. xref = igroup.CreateChild("Reference");
  204. xref.SetAttribute("Include", ref);
  205. }
  206. const String atomicProjectPath = projectGen_->GetAtomicProjectPath();
  207. if (atomicProjectPath.Length())
  208. {
  209. String resourceDir = AddTrailingSlash(atomicProjectPath) + "Resources/";
  210. Vector<String> result;
  211. GetSubsystem<FileSystem>()->ScanDir(result, resourceDir , "*.dll", SCAN_FILES, true);
  212. for (unsigned j = 0; j < result.Size(); j++)
  213. {
  214. String path = resourceDir + result[j];
  215. String relativePath;
  216. if (GetRelativePath(projectPath_, GetPath(path), relativePath))
  217. {
  218. if (projectGen_->GetCSProjectByName(GetFileName(path)))
  219. continue;
  220. path = relativePath + GetFileName(path) + GetExtension(path);
  221. }
  222. xref = igroup.CreateChild("Reference");
  223. xref.SetAttribute("Include", path);
  224. }
  225. }
  226. }
  227. void NETCSProject::CreateProjectReferencesItemGroup(XMLElement &projectRoot)
  228. {
  229. XMLElement igroup = projectRoot.CreateChild("ItemGroup");
  230. for (unsigned i = 0; i < references_.Size(); i++)
  231. {
  232. const String& ref = references_[i];
  233. NETCSProject* project = projectGen_->GetCSProjectByName(ref);
  234. if (!project)
  235. continue;
  236. XMLElement projectRef = igroup.CreateChild("ProjectReference");
  237. projectRef.SetAttribute("Include", ToString("..\\%s\\%s.csproj", ref.CString(), ref.CString()));
  238. XMLElement xproject = projectRef.CreateChild("Project");
  239. xproject.SetValue(ToString("{%s}", project->GetProjectGUID().ToLower().CString()));
  240. XMLElement xname = projectRef.CreateChild("Name");
  241. xname.SetValue(project->GetName());
  242. }
  243. }
  244. void NETCSProject::CreatePackagesItemGroup(XMLElement &projectRoot)
  245. {
  246. if (!packages_.Size())
  247. return;
  248. XMLElement xref;
  249. XMLElement igroup = projectRoot.CreateChild("ItemGroup");
  250. xref = igroup.CreateChild("None");
  251. xref.SetAttribute("Include", "packages.config");
  252. XMLFile packageConfig(context_);
  253. XMLElement packageRoot = packageConfig.CreateRoot("packages");
  254. for (unsigned i = 0; i < packages_.Size(); i++)
  255. {
  256. XMLFile xmlFile(context_);
  257. if (!xmlFile.FromString(packages_[i]))
  258. {
  259. ATOMIC_LOGERROR("NETCSProject::CreatePackagesItemGroup - Unable to parse package xml");
  260. }
  261. xref = packageRoot.CreateChild("package");
  262. CopyXMLElementRecursive(xmlFile.GetRoot(), xref);
  263. }
  264. SharedPtr<File> output(new File(context_, GetSanitizedPath(projectPath_ + "packages.config"), FILE_WRITE));
  265. String source = packageConfig.ToString();
  266. output->Write(source.CString(), source.Length());
  267. }
  268. void NETCSProject::GetAssemblySearchPaths(String& paths)
  269. {
  270. paths.Clear();
  271. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  272. Vector<String> searchPaths;
  273. if (assemblySearchPaths_.Length())
  274. searchPaths.Push(assemblySearchPaths_);
  275. paths.Join(searchPaths, ";");
  276. }
  277. void NETCSProject::ProcessDefineConstants(StringVector& constants)
  278. {
  279. const Vector<String>& globalConstants = projectGen_->GetGlobalDefineConstants();
  280. constants += globalConstants;
  281. if (constants.Contains("ATOMIC_IOS") || constants.Contains("ATOMIC_ANDROID"))
  282. constants.Push("ATOMIC_MOBILE");
  283. }
  284. void NETCSProject::CreateReleasePropertyGroup(XMLElement &projectRoot)
  285. {
  286. XMLElement pgroup = projectRoot.CreateChild("PropertyGroup");
  287. if (playerApplication_ && SupportsPlatform("ios"))
  288. pgroup.SetAttribute("Condition", " '$(Configuration)|$(Platform)' == 'Release|iPhone' ");
  289. else
  290. pgroup.SetAttribute("Condition", " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ");
  291. pgroup.CreateChild("Optimize").SetValue("true");
  292. String outputPath = assemblyOutputPath_;
  293. outputPath.Replace("$ATOMIC_CONFIG$", "Release");
  294. pgroup.CreateChild("OutputPath").SetValue(outputPath);
  295. Vector<String> constants;
  296. constants.Push("TRACE");
  297. constants += defineConstants_;
  298. ProcessDefineConstants(constants);
  299. pgroup.CreateChild("DefineConstants").SetValue(String::Joined(constants, ";").CString());
  300. pgroup.CreateChild("ErrorReport").SetValue("prompt");
  301. pgroup.CreateChild("WarningLevel").SetValue("4");
  302. pgroup.CreateChild("ConsolePause").SetValue("false");
  303. pgroup.CreateChild("AllowUnsafeBlocks").SetValue("true");
  304. // Don't warn on missing XML documentation
  305. pgroup.CreateChild("NoWarn").SetValue("1591");
  306. if (genAssemblyDocFile_)
  307. {
  308. pgroup.CreateChild("DocumentationFile").SetValue(outputPath + assemblyName_ + ".xml");
  309. }
  310. if (SupportsDesktop())
  311. {
  312. pgroup.CreateChild("DebugType").SetValue(GetIsPCL() ? "pdbonly": "full");
  313. if (!GetIsPCL())
  314. pgroup.CreateChild("PlatformTarget").SetValue("x64");
  315. #ifndef ATOMIC_PLATFORM_WINDOWS
  316. String startArguments;
  317. #ifndef ATOMIC_DEV_BUILD
  318. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  319. #ifdef ATOMIC_PLATFORM_OSX
  320. startArguments += ToString("--resourcePrefix \"%s\" ", (fileSystem->GetProgramDir() + "../Resources/").CString());
  321. #else
  322. startArguments += ToString("--resourcePrefix \"%s\" ", (fileSystem->GetProgramDir() + "Resources/").CString());
  323. #endif
  324. #endif
  325. startArguments += ToString("--project \"%s\"", projectGen_->GetAtomicProjectPath().CString());
  326. pgroup.CreateChild("Commandlineparameters").SetValue(startArguments);
  327. #endif
  328. }
  329. else
  330. {
  331. if (SupportsPlatform("android"))
  332. {
  333. pgroup.CreateChild("DebugType").SetValue("pdbonly");
  334. if (outputType_.ToLower() != "library")
  335. {
  336. pgroup.CreateChild("AndroidUseSharedRuntime").SetValue("False");
  337. pgroup.CreateChild("AndroidLinkMode").SetValue("SdkOnly");
  338. }
  339. }
  340. else if (playerApplication_ && SupportsPlatform("ios"))
  341. {
  342. pgroup.CreateChild("DebugType").SetValue("none");
  343. pgroup.CreateChild("MtouchArch").SetValue("ARMv7, ARM64");
  344. pgroup.CreateChild("CodesignEntitlements").SetValue(GetSanitizedPath(codesignEntitlements_));
  345. pgroup.CreateChild("CodesignKey").SetValue("iPhone Developer");
  346. pgroup.CreateChild("MtouchDebug").SetValue("true");
  347. pgroup.CreateChild("MtouchOptimizePNGs").SetValue("False");
  348. }
  349. }
  350. }
  351. void NETCSProject::CreateDebugPropertyGroup(XMLElement &projectRoot)
  352. {
  353. XMLElement pgroup = projectRoot.CreateChild("PropertyGroup");
  354. if (playerApplication_ && SupportsPlatform("ios"))
  355. pgroup.SetAttribute("Condition", " '$(Configuration)|$(Platform)' == 'Debug|iPhone' ");
  356. else
  357. pgroup.SetAttribute("Condition", " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ");
  358. pgroup.CreateChild("Optimize").SetValue("false");
  359. String outputPath = assemblyOutputPath_;
  360. outputPath.Replace("$ATOMIC_CONFIG$", "Debug");
  361. pgroup.CreateChild("OutputPath").SetValue(outputPath);
  362. Vector<String> constants;
  363. constants.Push("DEBUG");
  364. constants.Push("TRACE");
  365. constants += defineConstants_;
  366. ProcessDefineConstants(constants);
  367. pgroup.CreateChild("DefineConstants").SetValue(String::Joined(constants, ";").CString());
  368. pgroup.CreateChild("ErrorReport").SetValue("prompt");
  369. pgroup.CreateChild("WarningLevel").SetValue("4");
  370. pgroup.CreateChild("ConsolePause").SetValue("false");
  371. pgroup.CreateChild("AllowUnsafeBlocks").SetValue("true");
  372. // Don't warn on missing XML documentation
  373. pgroup.CreateChild("NoWarn").SetValue("1591");
  374. pgroup.CreateChild("DebugSymbols").SetValue("true");
  375. if (genAssemblyDocFile_)
  376. {
  377. pgroup.CreateChild("DocumentationFile").SetValue(outputPath + assemblyName_ + ".xml");
  378. }
  379. if (SupportsDesktop())
  380. {
  381. pgroup.CreateChild("DebugType").SetValue(GetIsPCL() ? "pdbonly": "full");
  382. if (!GetIsPCL())
  383. pgroup.CreateChild("PlatformTarget").SetValue("x64");
  384. #ifndef ATOMIC_PLATFORM_WINDOWS
  385. String startArguments;
  386. #ifndef ATOMIC_DEV_BUILD
  387. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  388. #ifdef ATOMIC_PLATFORM_OSX
  389. startArguments += ToString("--resourcePrefix \"%s\" ", (fileSystem->GetProgramDir() + "../Resources/").CString());
  390. #else
  391. startArguments += ToString("--resourcePrefix \"%s\" ", (fileSystem->GetProgramDir() + "Resources/").CString());
  392. #endif
  393. #endif
  394. startArguments += ToString("--project \"%s\"", projectGen_->GetAtomicProjectPath().CString());
  395. pgroup.CreateChild("Commandlineparameters").SetValue(startArguments);
  396. #endif
  397. }
  398. else
  399. {
  400. pgroup.CreateChild("DebugType").SetValue(GetIsPCL() ? "pdbonly": "full");
  401. if (androidApplication_)
  402. {
  403. pgroup.CreateChild("AndroidUseSharedRuntime").SetValue("False");
  404. pgroup.CreateChild("AndroidLinkMode").SetValue("None");
  405. pgroup.CreateChild("EmbedAssembliesIntoApk").SetValue("True");
  406. pgroup.CreateChild("BundleAssemblies").SetValue("False");
  407. pgroup.CreateChild("AndroidCreatePackagePerAbi").SetValue("False");
  408. pgroup.CreateChild("Debugger").SetValue("Xamarin");
  409. pgroup.CreateChild("AndroidEnableMultiDex").SetValue("False");
  410. pgroup.CreateChild("AndroidSupportedAbis").SetValue("armeabi-v7a");
  411. }
  412. else if (playerApplication_ && SupportsPlatform("ios"))
  413. {
  414. pgroup.CreateChild("MtouchArch").SetValue("ARMv7, ARM64");
  415. pgroup.CreateChild("CodesignEntitlements").SetValue(GetSanitizedPath(codesignEntitlements_));
  416. pgroup.CreateChild("CodesignKey").SetValue("iPhone Developer");
  417. pgroup.CreateChild("MtouchDebug").SetValue("true");
  418. pgroup.CreateChild("MtouchFastDev").SetValue("true");
  419. pgroup.CreateChild("IpaPackageName").SetValue("");
  420. pgroup.CreateChild("OptimizePNGs").SetValue("false");
  421. pgroup.CreateChild("MtouchOptimizePNGs").SetValue("False");
  422. }
  423. }
  424. }
  425. void NETCSProject::CreateApplicationItems(XMLElement &projectRoot)
  426. {
  427. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  428. XMLElement itemGroup = projectRoot.CreateChild("ItemGroup");
  429. if (SupportsDesktop())
  430. {
  431. // AtomicNETNative
  432. XMLElement atomicNETNativeDLL = itemGroup.CreateChild("None");
  433. #ifdef ATOMIC_DEBUG
  434. String config = "Debug";
  435. #else
  436. String config = "Release";
  437. #endif
  438. #ifdef ATOMIC_PLATFORM_WINDOWS
  439. String platform = "Windows";
  440. String filename = "AtomicNETNative.dll";
  441. #elif defined(ATOMIC_PLATFORM_OSX)
  442. String platform = "Mac";
  443. String filename = "libAtomicNETNative.dylib";
  444. #elif defined(ATOMIC_PLATFORM_LINUX)
  445. String platform = "Linux";
  446. String filename = "libAtomicNETNative.so";
  447. #endif
  448. #ifdef ATOMIC_DEV_BUILD
  449. String nativePath = AddTrailingSlash(tenv->GetAtomicNETRootDir()) + config + "/Native/" + platform + "/" + filename;
  450. #else
  451. String nativePath = AddTrailingSlash(tenv->GetAtomicNETRootDir()) + config + "/Native/" + platform + "/" + filename;
  452. #endif
  453. atomicNETNativeDLL.SetAttribute("Include", nativePath);
  454. atomicNETNativeDLL.CreateChild("Link").SetValue(filename);
  455. atomicNETNativeDLL.CreateChild("CopyToOutputDirectory").SetValue("PreserveNewest");
  456. #ifdef ATOMIC_PLATFORM_WINDOWS
  457. XMLElement d3dCompilerDLL = itemGroup.CreateChild("None");
  458. String d3dCompilerPath = AddTrailingSlash(tenv->GetAtomicNETRootDir()) + config + "/Native/" + platform + "/D3DCompiler_47.dll";
  459. d3dCompilerDLL.SetAttribute("Include", d3dCompilerPath);
  460. d3dCompilerDLL.CreateChild("Link").SetValue("D3DCompiler_47.dll");
  461. d3dCompilerDLL.CreateChild("CopyToOutputDirectory").SetValue("PreserveNewest");
  462. #endif
  463. }
  464. else
  465. {
  466. const String& projectPath = projectGen_->GetAtomicProjectPath();
  467. if (!playerApplication_ || !projectPath.Length())
  468. return;
  469. if (androidApplication_)
  470. {
  471. XMLElement androidAsset = itemGroup.CreateChild("AndroidAsset");
  472. androidAsset.SetAttribute("Include", projectPath + "AtomicNET/Resources/AtomicResources.pak");
  473. androidAsset.CreateChild("Link").SetValue("Assets\\AtomicResources.pak");
  474. }
  475. else
  476. {
  477. XMLElement bundleResource = itemGroup.CreateChild("BundleResource");
  478. bundleResource.SetAttribute("Include", projectPath + "AtomicNET/Resources/AtomicResources.pak");
  479. bundleResource.CreateChild("Link").SetValue("Resources\\AtomicResources.pak");
  480. bundleResource.CreateChild("CopyToOutputDirectory").SetValue("PreserveNewest");
  481. }
  482. }
  483. }
  484. void NETCSProject::CreateIOSItems(XMLElement &projectRoot)
  485. {
  486. XMLElement iosGroup = projectRoot.CreateChild("ItemGroup");
  487. if (objcBindingApiDefinition_.Length())
  488. {
  489. iosGroup.CreateChild("ObjcBindingApiDefinition").SetAttribute("Include", GetSanitizedPath(objcBindingApiDefinition_));
  490. }
  491. if (name_ == "AtomicNET.iOS")
  492. {
  493. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  494. #ifdef ATOMIC_DEBUG
  495. String config = "Debug";
  496. #else
  497. String config = "Release";
  498. #endif
  499. String nativePath = AddTrailingSlash(tenv->GetAtomicNETRootDir()) + config + "/Native/iOS/AtomicNETNative.framework";
  500. iosGroup.CreateChild("ObjcBindingNativeFramework").SetAttribute("Include", GetSanitizedPath(nativePath));
  501. // framework copy
  502. XMLElement none = iosGroup.CreateChild("None");
  503. none.SetAttribute("Include", nativePath + ".zip");
  504. none.CreateChild("Link").SetValue("AtomicNETNative.framework.zip");
  505. none.CreateChild("CopyToOutputDirectory").SetValue("Always");
  506. }
  507. else if (playerApplication_)
  508. {
  509. XMLElement plist = iosGroup.CreateChild("None");
  510. plist.SetAttribute("Include", GetSanitizedPath(infoPList_));
  511. plist.CreateChild("Link").SetValue("Info.plist");
  512. XMLElement entitlements = iosGroup.CreateChild("Content");
  513. entitlements.SetAttribute("Include", GetSanitizedPath(codesignEntitlements_));
  514. entitlements.CreateChild("Link").SetValue("Entitlements.plist");
  515. }
  516. }
  517. void NETCSProject::CreateAndroidItems(XMLElement &projectRoot)
  518. {
  519. if (!libraryProjectZips_.Size())
  520. {
  521. }
  522. if (libraryProjectZips_.Size())
  523. {
  524. XMLElement libraryGroup = projectRoot.CreateChild("ItemGroup");
  525. for (unsigned i = 0; i < libraryProjectZips_.Size(); i++)
  526. {
  527. libraryGroup.CreateChild("LibraryProjectZip").SetAttribute("Include", libraryProjectZips_[i].CString());
  528. }
  529. }
  530. if (transformFiles_.Size())
  531. {
  532. XMLElement transformGroup = projectRoot.CreateChild("ItemGroup");
  533. for (unsigned i = 0; i < transformFiles_.Size(); i++)
  534. {
  535. transformGroup.CreateChild("TransformFile").SetAttribute("Include", transformFiles_[i].CString());
  536. }
  537. }
  538. if (!importProjects_.Size())
  539. {
  540. projectRoot.CreateChild("Import").SetAttribute("Project", "$(MSBuildExtensionsPath)\\Xamarin\\Android\\Xamarin.Android.CSharp.targets");
  541. }
  542. if (androidApplication_)
  543. {
  544. // TODO: other abi
  545. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  546. #ifdef ATOMIC_DEBUG
  547. String config = "Debug";
  548. #else
  549. String config = "Release";
  550. #endif
  551. // TODO: more than armeabi-v7a (which this is)
  552. String nativePath = AddTrailingSlash(tenv->GetAtomicNETRootDir()) + config + "/Native/Android/libAtomicNETNative.so";
  553. XMLElement nativeLibrary = projectRoot.CreateChild("ItemGroup").CreateChild("AndroidNativeLibrary");
  554. nativeLibrary.SetAttribute("Include", nativePath);
  555. nativeLibrary.CreateChild("Link").SetValue("Libs\\armeabi-v7a\\libAtomicNETNative.so");
  556. XMLElement resourceGroup = projectRoot.CreateChild("ItemGroup");
  557. String relativePath;
  558. if (GetRelativeProjectPath("$ATOMIC_PROJECT_ROOT$/Project/AtomicNET/Platforms/Android/Resources/values/Strings.xml", projectPath_, relativePath))
  559. {
  560. relativePath.Replace("/", "\\");
  561. XMLElement strings = resourceGroup.CreateChild("AndroidResource");
  562. strings.SetAttribute("Include", relativePath);
  563. // Link has to exist for manifest to find resource!
  564. strings.CreateChild("Link").SetValue("Resources\\values\\Strings.xml");
  565. }
  566. else
  567. {
  568. ATOMIC_LOGERROR("Unabled to get relative path for Strings.xml");
  569. }
  570. if (GetRelativeProjectPath("$ATOMIC_PROJECT_ROOT$/Project/AtomicNET/Platforms/Android/Resources/drawable/icon.png", projectPath_, relativePath))
  571. {
  572. relativePath.Replace("/", "\\");
  573. XMLElement icon = resourceGroup.CreateChild("AndroidResource");
  574. icon.SetAttribute("Include", relativePath);
  575. // Link has to exist for manifest to find resource!
  576. icon.CreateChild("Link").SetValue("Resources\\drawable\\icon.png");
  577. }
  578. else
  579. {
  580. ATOMIC_LOGERROR("Unabled to get relative path for Icon.png");
  581. }
  582. }
  583. }
  584. void NETCSProject::CreateAssemblyInfo()
  585. {
  586. String info = "using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n\n";
  587. info += ToString("[assembly:AssemblyTitle(\"%s\")]\n", name_.CString());
  588. info += "[assembly:AssemblyDescription(\"\")]\n";
  589. info += "[assembly:AssemblyConfiguration(\"\")]\n";
  590. info += "[assembly:AssemblyCompany(\"\")]\n";
  591. info += ToString("[assembly:AssemblyProduct(\"%s\")]\n", name_.CString());
  592. info += "\n\n\n";
  593. info += "[assembly:ComVisible(false)]\n";
  594. info += "\n\n";
  595. info += ToString("[assembly:Guid(\"%s\")]\n", projectGuid_.CString());
  596. info += "\n\n";
  597. info += "[assembly:AssemblyVersion(\"1.0.0.0\")]\n";
  598. info += "[assembly:AssemblyFileVersion(\"1.0.0.0\")]\n";
  599. SharedPtr<File> output(new File(context_, GetSanitizedPath(projectPath_ + "Properties/AssemblyInfo.cs"), FILE_WRITE));
  600. output->Write(info.CString(), info.Length());
  601. }
  602. bool NETCSProject::GetRelativeProjectPath(const String& fromPath, const String& toPath, String& output)
  603. {
  604. String path = fromPath;
  605. ReplacePathStrings(path);
  606. path = GetSanitizedPath(path);
  607. String relativePath;
  608. if (GetRelativePath(projectPath_, GetPath(path), relativePath))
  609. {
  610. path = relativePath + GetFileName(path) + GetExtension(path);
  611. output = path;
  612. return true;
  613. }
  614. output = fromPath;
  615. return false;
  616. }
  617. void NETCSProject::CreateMainPropertyGroup(XMLElement& projectRoot)
  618. {
  619. XMLElement pgroup = projectRoot.CreateChild("PropertyGroup");
  620. // Configuration
  621. XMLElement config = pgroup.CreateChild("Configuration");
  622. config.SetAttribute("Condition", " '$(Configuration)' == '' ");
  623. config.SetValue("Debug");
  624. // Platform
  625. XMLElement platform = pgroup.CreateChild("Platform");
  626. platform.SetAttribute("Condition", " '$(Platform)' == '' ");
  627. if (playerApplication_ && SupportsPlatform("ios"))
  628. platform.SetValue("iPhone");
  629. else
  630. platform.SetValue("AnyCPU");
  631. // ProjectGuid
  632. XMLElement guid = pgroup.CreateChild("ProjectGuid");
  633. guid.SetValue("{" + projectGuid_ + "}");
  634. // OutputType
  635. XMLElement outputType = pgroup.CreateChild("OutputType");
  636. String oType = outputType_;
  637. #ifdef ATOMIC_PLATFORM_WINDOWS
  638. #ifndef ATOMIC_DEBUG
  639. if (oType.ToLower() == "exe")
  640. {
  641. // use windows subsystem for release builds
  642. // TODO: make this an option in the json?
  643. oType = "WinExe";
  644. }
  645. #endif
  646. #endif
  647. outputType.SetValue(oType);
  648. pgroup.CreateChild("AppDesignerFolder").SetValue("Properties");
  649. // RootNamespace
  650. XMLElement rootNamespace = pgroup.CreateChild("RootNamespace");
  651. rootNamespace.SetValue(rootNamespace_);
  652. // AssemblyName
  653. XMLElement assemblyName = pgroup.CreateChild("AssemblyName");
  654. assemblyName.SetValue(assemblyName_);
  655. pgroup.CreateChild("FileAlignment").SetValue("512");
  656. if (projectTypeGuids_.Size())
  657. {
  658. pgroup.CreateChild("ProjectTypeGuids").SetValue(String::Joined(projectTypeGuids_, ";"));
  659. }
  660. if (SupportsDesktop())
  661. {
  662. pgroup.CreateChild("TargetFrameworkVersion").SetValue("v4.5");
  663. }
  664. else
  665. {
  666. pgroup.CreateChild("ProductVersion").SetValue("8.0.30703");
  667. pgroup.CreateChild("SchemaVersion").SetValue("2.0");
  668. if (SupportsPlatform("ios"))
  669. {
  670. pgroup.CreateChild("IPhoneResourcePrefix").SetValue("Resources");
  671. }
  672. else
  673. {
  674. pgroup.CreateChild("TargetFrameworkVersion").SetValue("v6.0");
  675. }
  676. if (SupportsPlatform("android"))
  677. {
  678. if (!projectTypeGuids_.Size())
  679. {
  680. pgroup.CreateChild("ProjectTypeGuids").SetValue("{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}");
  681. }
  682. pgroup.CreateChild("AndroidUseLatestPlatformSdk").SetValue("True");
  683. if (!androidApplication_)
  684. {
  685. // 10368E6C-D01B-4462-8E8B-01FC667A7035 is a binding library
  686. if (!projectTypeGuids_.Contains("{10368E6C-D01B-4462-8E8B-01FC667A7035}"))
  687. pgroup.CreateChild("GenerateSerializationAssemblies").SetValue("Off");
  688. }
  689. else
  690. {
  691. // Android Application
  692. pgroup.CreateChild("AndroidApplication").SetValue("true");
  693. // AndroidManifest.xml must reside in Properties/AndroidManifest.xml, which introduces sync issues :/
  694. pgroup.CreateChild("AndroidManifest").SetValue("Properties\\AndroidManifest.xml");
  695. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  696. String manifestSourceFile = "$ATOMIC_PROJECT_ROOT$/Project/AtomicNET/Platforms/Android/Properties/AndroidManifest.xml";
  697. ReplacePathStrings(manifestSourceFile);
  698. manifestSourceFile = GetSanitizedPath(manifestSourceFile);
  699. if (fileSystem->FileExists(manifestSourceFile))
  700. {
  701. String manifestDest = GetSanitizedPath(projectPath_ + "Properties/");
  702. if (!fileSystem->DirExists(manifestDest))
  703. {
  704. fileSystem->CreateDirs(GetSanitizedPath(projectGen_->GetAtomicProjectPath()), ToString("/AtomicNET/Solution/%s/Properties/", name_.CString()));
  705. }
  706. if (fileSystem->DirExists(manifestDest))
  707. {
  708. if (!fileSystem->Copy(manifestSourceFile, manifestDest + "AndroidManifest.xml"))
  709. {
  710. ATOMIC_LOGERRORF("Unable to copy AndroidManifest from %s to %s", manifestSourceFile.CString(), manifestDest.CString());
  711. }
  712. }
  713. else
  714. {
  715. ATOMIC_LOGERRORF("Unable to create folder %s for AndroidManifest.xml", manifestDest.CString());
  716. }
  717. }
  718. else
  719. {
  720. ATOMIC_LOGERRORF("No AndroidManifest.xml, project will not deploy (%s)", manifestSourceFile.CString());
  721. }
  722. String relativePath;
  723. if (GetRelativeProjectPath("$ATOMIC_PROJECT_ROOT$/Project/AtomicNET/Platforms/Android/Resources/Resource.Designer.cs", projectPath_, relativePath))
  724. {
  725. relativePath.Replace("/", "\\");
  726. pgroup.CreateChild("AndroidResgenFile").SetValue(relativePath);
  727. }
  728. else
  729. {
  730. ATOMIC_LOGERROR("Unabled to get relative path for AndroidResgenFile");
  731. }
  732. pgroup.CreateChild("GenerateSerializationAssemblies").SetValue("Off");
  733. }
  734. }
  735. }
  736. if (targetFrameworkProfile_.Length())
  737. {
  738. pgroup.CreateChild("TargetFrameworkProfile").SetValue(targetFrameworkProfile_);
  739. }
  740. }
  741. bool NETCSProject::GenerateShared()
  742. {
  743. // .shproj
  744. XMLElement project = xmlFile_->CreateRoot("Project");
  745. project.SetAttribute("DefaultTargets", "Build");
  746. project.SetAttribute("ToolsVersion", "14.0");
  747. project.SetAttribute("DefaultTargets", "Build");
  748. project.SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
  749. // Project Group
  750. XMLElement projectGroup = project.CreateChild("PropertyGroup");
  751. projectGroup.SetAttribute("Label", "Globals");
  752. projectGroup.CreateChild("ProjectGuid").SetValue(projectGuid_);
  753. projectGroup.CreateChild("MinimumVisualStudioVersion").SetValue("14.0");
  754. XMLElement import = project.CreateChild("Import");
  755. import.SetAttribute("Project", "$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props");
  756. import.SetAttribute("Condition", "Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')");
  757. import = project.CreateChild("Import");
  758. import.SetAttribute("Project", "$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.Default.props");
  759. import = project.CreateChild("Import");
  760. import.SetAttribute("Project", "$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.props");
  761. import = project.CreateChild("Import");
  762. import.SetAttribute("Project", ToString("%s.projitems", name_.CString()));
  763. import.SetAttribute("Label", "Shared");
  764. import = project.CreateChild("Import");
  765. import.SetAttribute("Project", "$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.CSharp.targets");
  766. String projectSource = xmlFile_->ToString();
  767. SharedPtr<File> output(new File(context_, GetSanitizedPath(projectPath_ + name_ + ".shproj"), FILE_WRITE));
  768. output->Write(projectSource.CString(), projectSource.Length());
  769. // projitems
  770. SharedPtr<XMLFile> itemsXMLFile(new XMLFile(context_));
  771. XMLElement itemsProject = itemsXMLFile->CreateRoot("Project");
  772. itemsProject.SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
  773. XMLElement propertyGroup = itemsProject.CreateChild("PropertyGroup");
  774. propertyGroup.CreateChild("MSBuildAllProjects").SetValue("$(MSBuildAllProjects);$(MSBuildThisFileFullPath)");
  775. propertyGroup.CreateChild("HasSharedItems").SetValue("true");
  776. propertyGroup.CreateChild("SharedGUID").SetValue(projectGuid_);
  777. propertyGroup = itemsProject.CreateChild("PropertyGroup");
  778. propertyGroup.SetAttribute("Label", "Configuration");
  779. propertyGroup.CreateChild("Import_RootNamespace").SetValue("AtomicEngine");
  780. CreateCompileItemGroup(itemsProject);
  781. String itemSource = itemsXMLFile->ToString();
  782. SharedPtr<File> itemsOutput(new File(context_, GetSanitizedPath(projectPath_ + name_ + ".projitems"), FILE_WRITE));
  783. itemsOutput->Write(itemSource.CString(), itemSource.Length());
  784. return true;
  785. }
  786. bool NETCSProject::GenerateStandard()
  787. {
  788. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  789. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  790. NETSolution* solution = projectGen_->GetSolution();
  791. XMLElement project = xmlFile_->CreateRoot("Project");
  792. project.SetAttribute("DefaultTargets", "Build");
  793. project.SetAttribute("ToolsVersion", "14.0");
  794. project.SetAttribute("DefaultTargets", "Build");
  795. project.SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
  796. XMLElement import = project.CreateChild("Import");
  797. import.SetAttribute("Project", "$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props");
  798. import.SetAttribute("Condition", "Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')");
  799. CreateMainPropertyGroup(project);
  800. CreateDebugPropertyGroup(project);
  801. CreateReleasePropertyGroup(project);
  802. CreateReferencesItemGroup(project);
  803. CreateProjectReferencesItemGroup(project);
  804. CreateCompileItemGroup(project);
  805. CreatePackagesItemGroup(project);
  806. if (SupportsPlatform("android"))
  807. {
  808. CreateAndroidItems(project);
  809. }
  810. if (SupportsPlatform("ios"))
  811. {
  812. CreateIOSItems(project);
  813. }
  814. if (SupportsDesktop() && !GetIsPCL())
  815. project.CreateChild("Import").SetAttribute("Project", "$(MSBuildToolsPath)\\Microsoft.CSharp.targets");
  816. if (outputType_.ToLower() == "exe" || androidApplication_)
  817. {
  818. CreateApplicationItems(project);
  819. }
  820. if (!GetIsPCL() && !sharedReferences_.Size() && outputType_ != "Shared")
  821. CreateAssemblyInfo();
  822. const String& atomicProjectPath = projectGen_->GetAtomicProjectPath();
  823. if (atomicProjectPath.Length())
  824. {
  825. // Create the AtomicProject.csproj.user file if it doesn't exist
  826. String userSettingsFilename = projectPath_ + name_ + ".csproj.user";
  827. if (!fileSystem->FileExists(userSettingsFilename))
  828. {
  829. SharedPtr<XMLFile> userSettings(new XMLFile(context_));
  830. XMLElement project = userSettings->CreateRoot("Project");
  831. project.SetAttribute("ToolsVersion", "14.0");
  832. project.SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
  833. StringVector configs;
  834. configs.Push("Debug");
  835. configs.Push("Release");
  836. for (unsigned i = 0; i < configs.Size(); i++)
  837. {
  838. String cfg = configs[i];
  839. XMLElement propertyGroup = project.CreateChild("PropertyGroup");
  840. propertyGroup.SetAttribute("Condition", ToString("'$(Configuration)|$(Platform)' == '%s|AnyCPU'", cfg.CString()));
  841. String startArguments;
  842. #ifndef ATOMIC_DEV_BUILD
  843. #ifdef ATOMIC_PLATFORM_OSX
  844. startArguments += ToString("--resourcePrefix \"%s\" ", (fileSystem->GetProgramDir() + "../Resources/").CString());
  845. #else
  846. startArguments += ToString("--resourcePrefix \"%s\" ", (fileSystem->GetProgramDir() + "Resources/").CString());
  847. #endif
  848. #endif
  849. propertyGroup.CreateChild("StartAction").SetValue("Project");
  850. startArguments += ToString("--project \"%s\"", atomicProjectPath.CString());
  851. propertyGroup.CreateChild("StartArguments").SetValue(startArguments);
  852. #ifdef ATOMIC_DEBUG
  853. // When building a debug build, default native code debugging to true
  854. if (cfg == "Debug")
  855. {
  856. propertyGroup.CreateChild("EnableUnmanagedDebugging").SetValue("true");
  857. }
  858. #endif
  859. }
  860. String userSettingsSource = userSettings->ToString();
  861. SharedPtr<File> output(new File(context_, GetSanitizedPath(userSettingsFilename), FILE_WRITE));
  862. output->Write(userSettingsSource.CString(), userSettingsSource.Length());
  863. output->Close();
  864. }
  865. }
  866. for (unsigned i = 0; i < sharedReferences_.Size(); i++)
  867. {
  868. NETCSProject* sharedProject = projectGen_->GetCSProjectByName(sharedReferences_[i]);
  869. if (!sharedProject)
  870. {
  871. ATOMIC_LOGERRORF("Unable to get shared project %s", sharedReferences_[i].CString());
  872. continue;
  873. }
  874. String path = sharedProject->projectPath_ + sharedReferences_[i] + ".projitems";
  875. String relativePath;
  876. if (GetRelativePath(projectPath_, GetPath(path), relativePath))
  877. {
  878. path = relativePath + GetFileName(path) + GetExtension(path);
  879. }
  880. XMLElement shared = project.CreateChild("Import");
  881. shared.SetAttribute("Project", path);
  882. shared.SetAttribute("Label", "Shared");
  883. }
  884. for (unsigned i = 0; i < importProjects_.Size(); i++)
  885. {
  886. project.CreateChild("Import").SetAttribute("Project", importProjects_[i].CString());
  887. }
  888. // Have to come after the imports, so AfterBuild exists
  889. String projectName = "AtomicProject";
  890. if (projectGen_->GetProjectSettings())
  891. projectName = projectGen_->GetProjectSettings()->GetName();
  892. if (name_ == projectName)
  893. {
  894. XMLElement afterBuild = project.CreateChild("Target");
  895. afterBuild.SetAttribute("Name", "AfterBuild");
  896. XMLElement copy = afterBuild.CreateChild("Copy");
  897. copy.SetAttribute("SourceFiles", "$(TargetPath)");
  898. String destPath = projectPath_ + "../../../Resources/";
  899. String relativePath;
  900. String resourceDir = AddTrailingSlash(atomicProjectPath) + "Resources/";
  901. if (GetRelativePath(projectPath_, resourceDir, relativePath))
  902. {
  903. destPath = AddTrailingSlash(relativePath);
  904. }
  905. copy.SetAttribute("DestinationFolder", destPath);
  906. }
  907. String projectSource = xmlFile_->ToString();
  908. SharedPtr<File> output(new File(context_, GetSanitizedPath(projectPath_ + name_ + ".csproj"), FILE_WRITE));
  909. output->Write(projectSource.CString(), projectSource.Length());
  910. return true;
  911. }
  912. bool NETCSProject::Generate()
  913. {
  914. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  915. NETSolution* solution = projectGen_->GetSolution();
  916. projectPath_ = solution->GetOutputPath() + name_ + "/";
  917. if (!CreateProjectFolder(projectPath_))
  918. return false;
  919. if (!CreateProjectFolder(projectPath_ + "Properties"))
  920. return false;
  921. if (outputType_ == "Shared")
  922. {
  923. return GenerateShared();
  924. }
  925. return GenerateStandard();
  926. }
  927. bool NETCSProject::Load(const JSONValue& root)
  928. {
  929. name_ = root["name"].GetString();
  930. projectGuid_ = root["projectGuid"].GetString();
  931. if (!projectGuid_.Length())
  932. {
  933. ATOMIC_LOGINFOF("GUID not provided for project %s, generating one", name_.CString());
  934. projectGuid_ = projectGen_->GenerateUUID();
  935. }
  936. outputType_ = root["outputType"].GetString();
  937. androidApplication_ = root["androidApplication"].GetBool();
  938. playerApplication_ = root["playerApplication"].GetBool();
  939. genAssemblyDocFile_ = root["assemblyDocFile"].GetBool();
  940. rootNamespace_ = root["rootNamespace"].GetString();
  941. assemblyName_ = root["assemblyName"].GetString();
  942. assemblyOutputPath_ = root["assemblyOutputPath"].GetString();
  943. ReplacePathStrings(assemblyOutputPath_);
  944. assemblyOutputPath_ = GetSanitizedPath(assemblyOutputPath_);
  945. assemblySearchPaths_ = root["assemblySearchPaths"].GetString();
  946. ReplacePathStrings(assemblySearchPaths_);
  947. assemblySearchPaths_ = GetSanitizedPath(assemblySearchPaths_);
  948. const JSONArray& platforms = root["platforms"].GetArray();
  949. for (unsigned i = 0; i < platforms.Size(); i++)
  950. {
  951. String platform = platforms[i].GetString();
  952. platforms_.Push(platform.ToLower());
  953. }
  954. const JSONArray& references = root["references"].GetArray();
  955. for (unsigned i = 0; i < references.Size(); i++)
  956. {
  957. String reference = references[i].GetString();
  958. ReplacePathStrings(reference);
  959. references_.Push(reference);
  960. }
  961. const JSONArray& packages = root["packages"].GetArray();
  962. for (unsigned i = 0; i < packages.Size(); i++)
  963. {
  964. String package = packages[i].GetString();
  965. if (packages_.Find(package) != packages_.End())
  966. {
  967. ATOMIC_LOGERRORF("Duplicate package found %s", package.CString());
  968. continue;
  969. }
  970. projectGen_->GetSolution()->RegisterPackage(package);
  971. packages_.Push(package);
  972. }
  973. const JSONArray& sources = root["sources"].GetArray();
  974. for (unsigned i = 0; i < sources.Size(); i++)
  975. {
  976. String source = sources[i].GetString();
  977. ReplacePathStrings(source);
  978. sourceFolders_.Push(AddTrailingSlash(source));
  979. }
  980. const JSONArray& defineConstants = root["defineConstants"].GetArray();
  981. for (unsigned i = 0; i < defineConstants.Size(); i++)
  982. {
  983. defineConstants_.Push(defineConstants[i].GetString());
  984. }
  985. const JSONArray& projectTypeGuids = root["projectTypeGuids"].GetArray();
  986. for (unsigned i = 0; i < projectTypeGuids.Size(); i++)
  987. {
  988. String guid = projectTypeGuids[i].GetString();
  989. projectTypeGuids_.Push(ToString("{%s}", guid.CString()));
  990. }
  991. const JSONArray& importProjects = root["importProjects"].GetArray();
  992. for (unsigned i = 0; i < importProjects.Size(); i++)
  993. {
  994. importProjects_.Push(importProjects[i].GetString());
  995. }
  996. const JSONArray& libraryProjectZips = root["libraryProjectZips"].GetArray();
  997. for (unsigned i = 0; i < libraryProjectZips.Size(); i++)
  998. {
  999. String zipPath = libraryProjectZips[i].GetString();
  1000. ReplacePathStrings(zipPath);
  1001. libraryProjectZips_.Push(zipPath);
  1002. }
  1003. const JSONArray& transformFiles = root["transformFiles"].GetArray();
  1004. for (unsigned i = 0; i < transformFiles.Size(); i++)
  1005. {
  1006. String transformFile = transformFiles[i].GetString();
  1007. ReplacePathStrings(transformFile);
  1008. transformFiles_.Push(transformFile);
  1009. }
  1010. const JSONArray& sharedReferences = root["sharedReferences"].GetArray();
  1011. for (unsigned i = 0; i < sharedReferences.Size(); i++)
  1012. {
  1013. sharedReferences_.Push(sharedReferences[i].GetString());
  1014. }
  1015. targetFrameworkProfile_ = root["targetFrameworkProfile"].GetString();
  1016. // iOS
  1017. objcBindingApiDefinition_ = root["objcBindingApiDefinition"].GetString();
  1018. ReplacePathStrings(objcBindingApiDefinition_);
  1019. codesignEntitlements_ = root["codesignEntitlements"].GetString();
  1020. ReplacePathStrings(codesignEntitlements_);
  1021. infoPList_ = root["infoPList"].GetString();
  1022. ReplacePathStrings(infoPList_);
  1023. return true;
  1024. }
  1025. NETSolution::NETSolution(Context* context, NETProjectGen* projectGen, bool rewrite) : NETProjectBase(context, projectGen),
  1026. rewriteSolution_(rewrite)
  1027. {
  1028. }
  1029. NETSolution::~NETSolution()
  1030. {
  1031. }
  1032. bool NETSolution::Generate()
  1033. {
  1034. String slnPath = outputPath_ + name_ + ".sln";
  1035. GenerateSolution(slnPath);
  1036. return true;
  1037. }
  1038. void NETSolution::GenerateSolution(const String &slnPath)
  1039. {
  1040. String source = "Microsoft Visual Studio Solution File, Format Version 12.00\n";
  1041. source += "# Visual Studio 14\n";
  1042. source += "VisualStudioVersion = 14.0.25420.1\n";
  1043. source += "MinimumVisualStudioVersion = 10.0.40219.1\n";
  1044. solutionGUID_ = projectGen_->GenerateUUID();
  1045. PODVector<NETCSProject*> depends;
  1046. const Vector<SharedPtr<NETCSProject>>& projects = projectGen_->GetCSProjects();
  1047. for (unsigned i = 0; i < projects.Size(); i++)
  1048. {
  1049. NETCSProject* p = projects.At(i);
  1050. const String& projectName = p->GetName();
  1051. const String& projectGUID = p->GetProjectGUID();
  1052. String CSharpProjectGUID = "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
  1053. String ext = "csproj";
  1054. if (p->outputType_ == "Shared")
  1055. {
  1056. CSharpProjectGUID = "D954291E-2A0B-460D-934E-DC6B0785DB48";
  1057. ext = "shproj";
  1058. }
  1059. source += ToString("Project(\"{%s}\") = \"%s\", \"%s\\%s.%s\", \"{%s}\"\n",
  1060. CSharpProjectGUID.CString(), projectName.CString(), projectName.CString(),
  1061. projectName.CString(), ext.CString(), projectGUID.CString());
  1062. projectGen_->GetCSProjectDependencies(p, depends);
  1063. if (depends.Size())
  1064. {
  1065. source += "\tProjectSection(ProjectDependencies) = postProject\n";
  1066. for (unsigned j = 0; j < depends.Size(); j++)
  1067. {
  1068. source += ToString("\t{%s} = {%s}\n",
  1069. depends[j]->GetProjectGUID().CString(), depends[j]->GetProjectGUID().CString());
  1070. }
  1071. source += "\tEndProjectSection\n";
  1072. }
  1073. source += "EndProject\n";
  1074. }
  1075. source += "Global\n";
  1076. // SharedMSBuildProjectFiles
  1077. source += " GlobalSection(SharedMSBuildProjectFiles) = preSolution\n";
  1078. for (unsigned i = 0; i < projects.Size(); i++)
  1079. {
  1080. NETCSProject* p = projects.At(i);
  1081. if (p->outputType_ == "Shared")
  1082. {
  1083. for (unsigned j = 0; j < projects.Size(); j++)
  1084. {
  1085. NETCSProject* p2 = projects.At(j);
  1086. if (p == p2)
  1087. {
  1088. source += ToString(" %s\\%s.projitems*{%s}*SharedItemsImports = 13\n", p->name_.CString(), p->name_.CString(), p->projectGuid_.CString());
  1089. }
  1090. else
  1091. {
  1092. if (p2->sharedReferences_.Contains(p->name_))
  1093. {
  1094. source += ToString(" %s\\%s.projitems*{%s}*SharedItemsImports = 4\n", p->name_.CString(), p->name_.CString(), p2->projectGuid_.CString());
  1095. }
  1096. }
  1097. }
  1098. }
  1099. }
  1100. source += " EndGlobalSection\n";
  1101. source += " GlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
  1102. source += " Debug|Any CPU = Debug|Any CPU\n";
  1103. source += " Release|Any CPU = Release|Any CPU\n";
  1104. source += " Debug|iPhone = Debug|iPhone\n";
  1105. source += " Release|iPhone = Release|iPhone\n";
  1106. source += " EndGlobalSection\n";
  1107. source += " GlobalSection(ProjectConfigurationPlatforms) = postSolution\n";
  1108. for (unsigned i = 0; i < projects.Size(); i++)
  1109. {
  1110. NETCSProject* p = projects.At(i);
  1111. if (p->outputType_ == "Shared")
  1112. continue;
  1113. String cpu = "Any CPU";
  1114. if (p->GetIsPlayerApp() && p->SupportsPlatform("ios"))
  1115. cpu = "iPhone";
  1116. source += ToString(" {%s}.Debug|%s.ActiveCfg = Debug|%s\n", p->GetProjectGUID().CString(), cpu.CString(), cpu.CString());
  1117. source += ToString(" {%s}.Debug|%s.Build.0 = Debug|%s\n", p->GetProjectGUID().CString(), cpu.CString(), cpu.CString());
  1118. source += ToString(" {%s}.Release|%s.ActiveCfg = Release|%s\n", p->GetProjectGUID().CString(), cpu.CString(), cpu.CString());
  1119. source += ToString(" {%s}.Release|%s.Build.0 = Release|%s\n", p->GetProjectGUID().CString(), cpu.CString(), cpu.CString());
  1120. if (cpu != "iPhone" && (p->SupportsPlatform("ios", false)))
  1121. {
  1122. source += ToString(" {%s}.Debug|iPhone.ActiveCfg = Debug|Any CPU\n", p->GetProjectGUID().CString());
  1123. source += ToString(" {%s}.Debug|iPhone.Build.0 = Debug|Any CPU\n", p->GetProjectGUID().CString());
  1124. source += ToString(" {%s}.Release|iPhone.ActiveCfg = Release|Any CPU\n", p->GetProjectGUID().CString());
  1125. source += ToString(" {%s}.Release|iPhone.Build.0 = Release|Any CPU\n", p->GetProjectGUID().CString());
  1126. }
  1127. }
  1128. source += " EndGlobalSection\n";
  1129. source += "EndGlobal\n";
  1130. if (!rewriteSolution_)
  1131. {
  1132. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  1133. if (fileSystem->Exists(slnPath))
  1134. return;
  1135. }
  1136. SharedPtr<File> output(new File(context_, GetSanitizedPath(slnPath), FILE_WRITE));
  1137. output->Write(source.CString(), source.Length());
  1138. output->Close();
  1139. }
  1140. bool NETSolution::Load(const JSONValue& root)
  1141. {
  1142. FileSystem* fs = GetSubsystem<FileSystem>();
  1143. name_ = root["name"].GetString();
  1144. outputPath_ = AddTrailingSlash(root["outputPath"].GetString());
  1145. ReplacePathStrings(outputPath_);
  1146. // TODO: use poco mkdirs
  1147. if (!fs->DirExists(outputPath_))
  1148. fs->CreateDirsRecursive(outputPath_);
  1149. return true;
  1150. }
  1151. bool NETSolution::RegisterPackage(const String& package)
  1152. {
  1153. if (packages_.Find(package) != packages_.End())
  1154. return false;
  1155. packages_.Push(package);
  1156. return true;
  1157. }
  1158. NETProjectGen::NETProjectGen(Context* context) : Object(context),
  1159. rewriteSolution_(false)
  1160. {
  1161. }
  1162. NETProjectGen::~NETProjectGen()
  1163. {
  1164. }
  1165. NETCSProject* NETProjectGen::GetCSProjectByName(const String & name)
  1166. {
  1167. for (unsigned i = 0; i < projects_.Size(); i++)
  1168. {
  1169. if (projects_[i]->GetName() == name)
  1170. return projects_[i];
  1171. }
  1172. return nullptr;
  1173. }
  1174. bool NETProjectGen::GetCSProjectDependencies(NETCSProject* source, PODVector<NETCSProject*>& depends) const
  1175. {
  1176. depends.Clear();
  1177. const Vector<String>& references = source->GetReferences();
  1178. for (unsigned i = 0; i < projects_.Size(); i++)
  1179. {
  1180. NETCSProject* pdepend = projects_.At(i);
  1181. if (source == pdepend)
  1182. continue;
  1183. for (unsigned j = 0; j < references.Size(); j++)
  1184. {
  1185. if (pdepend->GetName() == references[j])
  1186. {
  1187. depends.Push(pdepend);
  1188. }
  1189. }
  1190. }
  1191. return depends.Size() != 0;
  1192. }
  1193. bool NETProjectGen::Generate()
  1194. {
  1195. solution_->Generate();
  1196. for (unsigned i = 0; i < projects_.Size(); i++)
  1197. {
  1198. if (!projects_[i]->Generate())
  1199. return false;
  1200. }
  1201. return true;
  1202. }
  1203. void NETProjectGen::SetRewriteSolution(bool rewrite)
  1204. {
  1205. rewriteSolution_ = rewrite;
  1206. if (solution_.NotNull())
  1207. solution_->SetRewriteSolution(rewrite);
  1208. }
  1209. bool NETProjectGen::IncludeProjectOnPlatform(const JSONValue& projectRoot, const String& platform)
  1210. {
  1211. const JSONArray& platforms = projectRoot["platforms"].GetArray();
  1212. if (!platforms.Size())
  1213. return true; // all platforms
  1214. String scriptPlatform = platform.ToLower();
  1215. for (unsigned i = 0; i < platforms.Size(); i++)
  1216. {
  1217. String platform = platforms[i].GetString().ToLower();
  1218. if (platform == "desktop")
  1219. {
  1220. if (scriptPlatform == "windows" || scriptPlatform == "macosx" || scriptPlatform == "linux")
  1221. return true;
  1222. return false;
  1223. }
  1224. if (platform == "android" && scriptPlatform != "android")
  1225. return false;
  1226. }
  1227. return true;
  1228. }
  1229. bool NETProjectGen::LoadProject(const JSONValue &root)
  1230. {
  1231. solution_ = new NETSolution(context_, this, rewriteSolution_);
  1232. solution_->Load(root["solution"]);
  1233. const JSONValue& jprojects = root["projects"];
  1234. if (!jprojects.IsArray() || !jprojects.Size())
  1235. return false;
  1236. for (unsigned i = 0; i < jprojects.Size(); i++)
  1237. {
  1238. const JSONValue& jproject = jprojects[i];
  1239. if (!jproject.IsObject())
  1240. return false;
  1241. JSONArray platforms = jproject["platforms"].GetArray();
  1242. if (platforms.Size())
  1243. {
  1244. bool found = false;
  1245. for (unsigned j = 0; j < platforms.Size(); j++)
  1246. {
  1247. if (GetSupportsPlatform(platforms[j].GetString()))
  1248. {
  1249. found = true;
  1250. break;
  1251. }
  1252. }
  1253. if (!found)
  1254. {
  1255. continue;
  1256. }
  1257. }
  1258. // HACK! Do not generate AtomicNETService in the AtomicProject solution
  1259. if (jproject["name"].GetString() == "AtomicNETService" && atomicProjectPath_.Length())
  1260. {
  1261. continue;
  1262. }
  1263. SharedPtr<NETCSProject> csProject(new NETCSProject(context_, this));
  1264. if (!csProject->Load(jproject))
  1265. return false;
  1266. projects_.Push(csProject);
  1267. }
  1268. return true;
  1269. }
  1270. bool NETProjectGen::LoadJSONProject(const String& jsonProjectPath)
  1271. {
  1272. SharedPtr<File> file(new File(context_));
  1273. if (!file->Open(GetSanitizedPath(jsonProjectPath)))
  1274. return false;
  1275. String json;
  1276. file->ReadText(json);
  1277. JSONValue jvalue;
  1278. if (!JSONFile::ParseJSON(json, jvalue))
  1279. return false;
  1280. return LoadProject(jvalue);
  1281. }
  1282. bool NETProjectGen::LoadAtomicProject(const String& atomicProjectPath)
  1283. {
  1284. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  1285. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  1286. String pathname, filename, ext;
  1287. SplitPath(atomicProjectPath, pathname, filename, ext);
  1288. if (ext == ".atomic")
  1289. {
  1290. atomicProjectPath_ = AddTrailingSlash(pathname);
  1291. }
  1292. else
  1293. {
  1294. atomicProjectPath_ = AddTrailingSlash(atomicProjectPath);
  1295. }
  1296. // Do we have a loaded project?
  1297. if (Project* project = tsystem->GetProject())
  1298. {
  1299. // If so, use loaded project settings
  1300. projectSettings_ = project->GetProjectSettings();
  1301. }
  1302. else
  1303. {
  1304. // Nope, load them up
  1305. projectSettings_ = SharedPtr<ProjectSettings>(new ProjectSettings(context_));
  1306. projectSettings_->Load(atomicProjectPath_ + "Settings/Project.json");
  1307. }
  1308. #ifdef ATOMIC_DEV_BUILD
  1309. JSONValue netJSON;
  1310. SharedPtr<File> netJSONFile(new File(context_));
  1311. String atomicNETProject = tenv->GetRootSourceDir() + "Script/AtomicNET/AtomicNETProject.json";
  1312. if (!netJSONFile->Open(GetSanitizedPath(atomicNETProject)))
  1313. return false;
  1314. String netJSONString;
  1315. netJSONFile->ReadText(netJSONString);
  1316. if (!JSONFile::ParseJSON(netJSONString, netJSON))
  1317. return false;
  1318. #endif
  1319. #ifdef ATOMIC_DEV_BUILD
  1320. String projectPath = tenv->GetRootSourceDir() + "Script/AtomicNET/AtomicProject.json";
  1321. #else
  1322. String projectPath = tenv->GetAtomicNETRootDir() + "Build/Projects/AtomicProject.json";
  1323. #endif
  1324. SharedPtr<File> file(new File(context_));
  1325. if (!file->Open(GetSanitizedPath(projectPath)))
  1326. return false;
  1327. String json;
  1328. file->ReadText(json);
  1329. json.Replace("$ATOMIC_PROJECT_NAME$", projectSettings_->GetName());
  1330. JSONValue jvalue;
  1331. if (!JSONFile::ParseJSON(json, jvalue))
  1332. return false;
  1333. #ifdef ATOMIC_DEV_BUILD
  1334. // patch projects
  1335. JSONArray netProjects = netJSON["projects"].GetArray();
  1336. JSONArray projects = jvalue["projects"].GetArray();
  1337. for (unsigned i = 0; i < projects.Size(); i++)
  1338. {
  1339. netProjects.Push(JSONValue(projects[i].GetObject()));
  1340. }
  1341. jvalue["projects"] = netProjects;
  1342. return LoadProject(jvalue);
  1343. #else
  1344. return LoadProject(jvalue);
  1345. #endif
  1346. }
  1347. void NETProjectGen::SetSupportedPlatforms(const StringVector& platforms)
  1348. {
  1349. projectSettings_ = SharedPtr<ProjectSettings>(new ProjectSettings(context_));
  1350. for (unsigned i = 0; i < platforms.Size(); i++)
  1351. {
  1352. projectSettings_->AddSupportedPlatform(platforms[i]);
  1353. }
  1354. }
  1355. bool NETProjectGen::GetSupportsPlatform(const String& platform) const
  1356. {
  1357. // If no project platform settings are loaded, always supports
  1358. if (projectSettings_.Null())
  1359. {
  1360. return true;
  1361. }
  1362. return projectSettings_->GetSupportsPlatform(platform);
  1363. }
  1364. bool NETProjectGen::GetRequiresNuGet()
  1365. {
  1366. if (solution_.Null())
  1367. {
  1368. ATOMIC_LOGERROR("NETProjectGen::GetRequiresNuGet() - called without a solution loaded");
  1369. return false;
  1370. }
  1371. return solution_->GetPackages().Size() != 0;
  1372. }
  1373. String NETProjectGen::GenerateUUID()
  1374. {
  1375. Poco::UUIDGenerator& generator = Poco::UUIDGenerator::defaultGenerator();
  1376. Poco::UUID uuid(generator.create()); // time based
  1377. return String(uuid.toString().c_str()).ToUpper();
  1378. }
  1379. }