NETProjectSystem.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. using namespace Atomic;
  25. namespace ToolCore
  26. {
  27. class Project;
  28. class Subprocess;
  29. class NETBuild;
  30. // AtomicProject.dll state (this shouldn't be in resources too)
  31. enum NETProjectState
  32. {
  33. NETPROJECT_CLEAN,
  34. NETPROJECT_DIRTY,
  35. NETPROJECT_ERROR
  36. };
  37. class NETProjectSystem : public Object
  38. {
  39. ATOMIC_OBJECT(NETProjectSystem, Object)
  40. public:
  41. NETProjectSystem(Context* context);
  42. virtual ~NETProjectSystem();
  43. bool GetIDEAvailable() const { return idePath_.Length() != 0; }
  44. /// Returns true if there is a solution available for the loaded project (true = managed app)
  45. bool GetSolutionAvailable() const { return solutionPath_.Length() != 0; }
  46. const String& GetSolutionPath() const { return solutionPath_; }
  47. NETBuild* BuildAtomicProject();
  48. /// Open the solution, if opening a source file, better to call OpenSourceFile as will launch VS instance with source file loaded
  49. /// otherwise, no guarantee where source file will load when multiple VS instances running
  50. void OpenSolution();
  51. void OpenSourceFile(const String& sourceFilePath);
  52. bool GenerateSolution();
  53. bool GenerateResourcePak();
  54. /// Get whether the project assembly is dirty and needs to be rebuilt
  55. bool GetProjectAssemblyDirty();
  56. private:
  57. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  58. void HandleNETBuildResult(StringHash eventType, VariantMap& eventData);
  59. void HandleFileChanged(StringHash eventType, VariantMap& eventData);
  60. void HandleResourceAdded(StringHash eventType, VariantMap& eventData);
  61. void HandleResourceRemoved(StringHash eventType, VariantMap& eventData);
  62. void HandleAssetRenamed(StringHash eventType, VariantMap& eventData);
  63. void HandleAssetMoved(StringHash eventType, VariantMap& eventData);
  64. void HandleAssetNew(StringHash eventType, VariantMap& eventData);
  65. void HandleAssetScanBegin(StringHash eventType, VariantMap& eventData);
  66. void HandleAssetScanEnd(StringHash eventType, VariantMap& eventData);
  67. void HandleProjectLoaded(StringHash eventType, VariantMap& eventData);
  68. void HandleProjectUnloaded(StringHash eventType, VariantMap& eventData);
  69. void Clear();
  70. void Initialize();
  71. /// Checks the status of the project assembly, including if sources files are newer, missing, etc
  72. void CheckProjectAssembly();
  73. String idePath_;
  74. String projectPath_;
  75. String solutionPath_;
  76. String projectAssemblyPath_;
  77. float quietPeriod_;
  78. bool solutionDirty_;
  79. bool projectAssemblyDirty_;
  80. // Visual Studio subprocess
  81. WeakPtr<Subprocess> ideSubprocess_;
  82. };
  83. /// Copies the core Atomic NET assemblies to a specified folder
  84. bool AtomicNETCopyAssemblies(Context* context, const String& dstFolder);
  85. }