BuildBase.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 "BuildTypes.h"
  25. #include "../Platform/Platform.h"
  26. using namespace Atomic;
  27. namespace ToolCore
  28. {
  29. class ResourcePackager;
  30. class Project;
  31. class BuildBase : public Object
  32. {
  33. OBJECT(BuildBase);
  34. public:
  35. BuildBase(Context* context, Project* project, PlatformID platform);
  36. virtual ~BuildBase();
  37. virtual void Build(const String& buildPath) = 0;
  38. // some platforms may want to do their own packaging of resources
  39. virtual bool UseResourcePackager() { return true; }
  40. virtual String GetBuildSubfolder() = 0;
  41. // add in search order, first added is first searched
  42. // will warn on name conflicts
  43. void AddResourceDir(const String& dir);
  44. void AddProjectResourceDir(const String& dir);
  45. void BuildLog(const String& message, bool sendEvent = true);
  46. void BuildWarn(const String& warning, bool sendEvent = true);
  47. void BuildError(const String& error, bool sendEvent = true);
  48. /// Fail the current build
  49. void FailBuild(const String& message);
  50. /// Converts subprocess output event to a buildoutput event
  51. void HandleSubprocessOutputEvent(StringHash eventType, VariantMap& eventData);
  52. /// Asset build tag used by the assetbuildconfig.json file to identify the assets to that should be include
  53. /// in the build. If no tag is specified, then all resources are included.
  54. void SetAssetBuildTag(const String assetBuildTag) { assetBuildTag_ = assetBuildTag; }
  55. protected:
  56. bool BuildClean(const String& path);
  57. bool BuildRemoveDirectory(const String& path);
  58. bool BuildCreateDirectory(const String& path);
  59. bool BuildCopyFile(const String& srcFileName, const String& destFileName);
  60. virtual bool CheckIncludeResourceFile(const String& resourceDir, const String& fileName);
  61. void GenerateResourcePackage(const String& resourcePackagePath);
  62. void BuildDefaultResourceEntries();
  63. void BuildProjectResourceEntries();
  64. void AddToResourcePackager(const String& filename, const String& resourceDir);
  65. void GetDefaultResourcePaths(Vector<String>& paths);
  66. String GetSettingsDirectory();
  67. String buildPath_;
  68. PODVector<BuildResourceEntry*> resourceEntries_;
  69. bool containsMDL_;
  70. bool buildFailed_;
  71. // EGS: I think I added this for the assetBuildConfiguraton file
  72. String assetBuildTag_;
  73. private:
  74. void BuildFilteredProjectResourceEntries();
  75. void BuildAllProjectResourceEntries();
  76. PlatformID platformID_;
  77. Vector<String> buildLog_;
  78. Vector<String> buildWarnings_;
  79. Vector<String> buildErrors_;
  80. void ScanResourceDirectory(const String& resourceDir);
  81. SharedPtr<Project> project_;
  82. SharedPtr<ResourcePackager> resourcePackager_;
  83. Vector<String> resourceDirs_;
  84. Vector<String> projectResourceDir_;
  85. void ReadAssetBuildConfig();
  86. };
  87. }