NETProjectGen.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. protected:
  38. SharedPtr<XMLFile> xmlFile_;
  39. WeakPtr<NETProjectGen> projectGen_;
  40. };
  41. class NETCSProject : public NETProjectBase
  42. {
  43. OBJECT(NETCSProject);
  44. public:
  45. NETCSProject(Context* context, NETProjectGen* projectGen);
  46. virtual ~NETCSProject();
  47. bool Load(const JSONValue& root);
  48. const String& GetName() { return name_; }
  49. const String& GetProjectGUID() { return projectGuid_; }
  50. bool Generate();
  51. private:
  52. void CreateCompileItemGroup(XMLElement &projectRoot);
  53. void CreateReferencesItemGroup(XMLElement &projectRoot);
  54. void CreateMainPropertyGroup(XMLElement &projectRoot);
  55. void CreateDebugPropertyGroup(XMLElement &projectRoot);
  56. void CreateReleasePropertyGroup(XMLElement &projectRoot);
  57. void GetAssemblySearchPaths(String& paths);
  58. String name_;
  59. String projectGuid_;
  60. String outputType_;
  61. String rootNamespace_;
  62. String assemblyName_;
  63. String assemblyOutputPath_;
  64. String assemblySearchPaths_;
  65. XMLElement xmlRoot_;
  66. Vector<String> references_;
  67. Vector<String> sourceFolders_;
  68. };
  69. class NETSolution : public NETProjectBase
  70. {
  71. OBJECT(NETSolution);
  72. public:
  73. NETSolution(Context* context, NETProjectGen* projectGen);
  74. virtual ~NETSolution();
  75. bool Load(const JSONValue& root);
  76. bool Generate();
  77. const String& GetOutputPath() { return outputPath_; }
  78. private:
  79. void GenerateXamarinStudio(const String& slnPath);
  80. String name_;
  81. String outputPath_;
  82. };
  83. class NETProjectGen : public Object
  84. {
  85. OBJECT(NETProjectGen);
  86. public:
  87. NETProjectGen(Context* context);
  88. virtual ~NETProjectGen();
  89. const String& GetScriptPlatform() { return scriptPlatform_; }
  90. NETSolution* GetSolution() { return solution_; }
  91. bool GetMonoBuild() { return monoBuild_; }
  92. bool GetGameBuild() { return gameBuild_; }
  93. const Vector<SharedPtr<NETCSProject>>& GetCSProjects() { return projects_; }
  94. void SetScriptPlatform(const String& platform) { scriptPlatform_ = platform; }
  95. bool Generate();
  96. String GenerateUUID();
  97. bool LoadProject(const JSONValue& root, bool gameBuild = false);
  98. bool LoadProject(const String& projectPath, bool gameBuild = false);
  99. private:
  100. String scriptPlatform_;
  101. bool monoBuild_;
  102. bool gameBuild_;
  103. SharedPtr<NETSolution> solution_;
  104. Vector<SharedPtr<NETCSProject>> projects_;
  105. };
  106. }