ToolEnvironment.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 "ToolPrefs.h"
  25. using namespace Atomic;
  26. namespace ToolCore
  27. {
  28. // the tool environment contains paths for various
  29. // binaries, data paths, example folder, etc
  30. // it is either built from the cli, AtomicEditor, environment variables,
  31. // or a json config file, this avoids needing to symlink folders, etc
  32. class ToolEnvironment : public Object
  33. {
  34. ATOMIC_OBJECT(ToolEnvironment, Object)
  35. public:
  36. ToolEnvironment(Context* context);
  37. virtual ~ToolEnvironment();
  38. bool Initialize(bool cli = false);
  39. /// Root source and build directories for development source tree builds
  40. void SetRootSourceDir(const String& sourceDir);
  41. void SetRootBuildDir(const String& buildDir, bool setBinaryPaths = false);
  42. ToolPrefs* GetToolPrefs() { return toolPrefs_; }
  43. void SaveToolPrefs() { toolPrefs_->Save(); }
  44. void LoadToolPrefs() { toolPrefs_->Load(); }
  45. const String& GetRootSourceDir() { return rootSourceDir_; }
  46. const String& GetRootBuildDir() { return rootBuildDir_; }
  47. /// Binaries
  48. const String& GetEditorBinary() { return editorBinary_; }
  49. const String& GetPlayerBinary() { return playerBinary_; }
  50. const String& GetToolBinary() { return toolBinary_; }
  51. /// Resource directories
  52. const String& GetCoreDataDir() { return resourceCoreDataDir_; }
  53. const String& GetPlayerDataDir() { return resourcePlayerDataDir_; }
  54. const String& GetEditorDataDir() { return resourceEditorDataDir_; }
  55. /// Data directories
  56. const String& GetDeploymentDataDir() { return toolBinary_; }
  57. const String& GetToolDataDir() { return toolDataDir_; }
  58. // Returns true if we running from a command line tool (aka: AtomicTool)
  59. bool GetCLI() { return cli_; }
  60. // AtomicNET
  61. const String& GetAtomicNETRootDir() { return atomicNETRootDir_; }
  62. const String& GetAtomicNETCoreAssemblyDir() { return atomicNETCoreAssemblyDir_; }
  63. const String& GetAtomicNETNuGetBinary() { return atomicNETNuGetBinary_; }
  64. const String& GetMonoExecutableDir() { return monoExecutableDir_; }
  65. // OSX
  66. const String& GetPlayerAppFolder() { return playerAppFolder_; }
  67. // iOS
  68. String GetIOSDeployBinary();
  69. void Dump();
  70. static void SetBootstrapping() { bootstrapping_ = true; }
  71. private:
  72. bool InitFromDistribution();
  73. // Whether we are running from a command line tool, such as AtomicTool
  74. bool cli_;
  75. // root source directory (for development builds)
  76. String rootSourceDir_;
  77. // root build directory (for development builds)
  78. String rootBuildDir_;
  79. // path to the Atomic Editor binary
  80. String editorBinary_;
  81. // path to Atomic player binary used when running content from the editor or cli
  82. String playerBinary_;
  83. // path to Atomic player app (OSX)
  84. String playerAppFolder_;
  85. // path to the AtomicTool command line binary
  86. String toolBinary_;
  87. String toolDataDir_;
  88. // resources
  89. String resourceCoreDataDir_;
  90. String resourcePlayerDataDir_;
  91. String resourceEditorDataDir_;
  92. // deployment
  93. // static deployment data directory
  94. String deploymentDataDir_;
  95. // whether to use individual build folders, or the deployment data dir for binaries
  96. bool useBuildDirs_;
  97. String macBuildDir_;
  98. String windowsBuildDir_;
  99. String linuxBuildDir_;
  100. String androidBuildDir_;
  101. String iosBuildDir_;
  102. String webBuildDir_;
  103. // AtomicNET
  104. String atomicNETRootDir_;
  105. String atomicNETCoreAssemblyDir_;
  106. String atomicNETNuGetBinary_;
  107. String monoExecutableDir_;
  108. SharedPtr<ToolPrefs> toolPrefs_;
  109. static bool bootstrapping_;
  110. };
  111. }