NETProjectGen.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. #pragma once
  23. #include <Atomic/Core/Object.h>
  24. #include <Atomic/Resource/XMLFile.h>
  25. #include <Atomic/Resource/JSONFile.h>
  26. using namespace Atomic;
  27. namespace ToolCore
  28. {
  29. class NETProjectGen;
  30. class NETProjectBase : public Object
  31. {
  32. OBJECT(NETProjectBase);
  33. public:
  34. NETProjectBase(Context* context, NETProjectGen* projectGen);
  35. virtual ~NETProjectBase();
  36. void ReplacePathStrings(String& path);
  37. void CopyXMLElementRecursive(XMLElement source, XMLElement dest);
  38. protected:
  39. SharedPtr<XMLFile> xmlFile_;
  40. WeakPtr<NETProjectGen> projectGen_;
  41. };
  42. class NETCSProject : public NETProjectBase
  43. {
  44. OBJECT(NETCSProject);
  45. public:
  46. NETCSProject(Context* context, NETProjectGen* projectGen);
  47. virtual ~NETCSProject();
  48. bool Load(const JSONValue& root);
  49. const String& GetName() { return name_; }
  50. const String& GetProjectGUID() { return projectGuid_; }
  51. const Vector<String>& GetReferences() const { return references_; }
  52. bool Generate();
  53. private:
  54. bool CreateProjectFolder(const String& path);
  55. void CreateCompileItemGroup(XMLElement &projectRoot);
  56. void CreateReferencesItemGroup(XMLElement &projectRoot);
  57. void CreateProjectReferencesItemGroup(XMLElement & projectRoot);
  58. void CreatePackagesItemGroup(XMLElement &projectRoot);
  59. void CreateMainPropertyGroup(XMLElement &projectRoot);
  60. void CreateDebugPropertyGroup(XMLElement &projectRoot);
  61. void CreateReleasePropertyGroup(XMLElement &projectRoot);
  62. void CreateAssemblyInfo();
  63. void GetAssemblySearchPaths(String& paths);
  64. String name_;
  65. String projectGuid_;
  66. String outputType_;
  67. String rootNamespace_;
  68. String assemblyName_;
  69. String assemblyOutputPath_;
  70. String assemblySearchPaths_;
  71. // project paths
  72. String projectPath_;
  73. XMLElement xmlRoot_;
  74. Vector<String> references_;
  75. Vector<String> packages_;
  76. Vector<String> sourceFolders_;
  77. };
  78. class NETSolution : public NETProjectBase
  79. {
  80. OBJECT(NETSolution);
  81. public:
  82. NETSolution(Context* context, NETProjectGen* projectGen);
  83. virtual ~NETSolution();
  84. bool Load(const JSONValue& root);
  85. bool Generate();
  86. const String& GetOutputPath() { return outputPath_; }
  87. private:
  88. void GenerateSolution(const String& slnPath);
  89. String name_;
  90. String outputPath_;
  91. String solutionGUID_;
  92. };
  93. class NETProjectGen : public Object
  94. {
  95. OBJECT(NETProjectGen);
  96. public:
  97. NETProjectGen(Context* context);
  98. virtual ~NETProjectGen();
  99. const String& GetScriptPlatform() { return scriptPlatform_; }
  100. NETSolution* GetSolution() { return solution_; }
  101. const Vector<SharedPtr<NETCSProject>>& GetCSProjects() { return projects_; }
  102. NETCSProject* GetCSProjectByName(const String& name);
  103. bool GetCSProjectDependencies(NETCSProject * source, PODVector<NETCSProject*>& depends) const;
  104. void SetScriptPlatform(const String& platform) { scriptPlatform_ = platform; }
  105. bool Generate();
  106. String GenerateUUID();
  107. bool LoadProject(const JSONValue& root);
  108. bool LoadProject(const String& projectPath);
  109. private:
  110. String scriptPlatform_;
  111. SharedPtr<NETSolution> solution_;
  112. Vector<SharedPtr<NETCSProject>> projects_;
  113. };
  114. }