BuildBase.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 BuildLog(const String& message, bool sendEvent = true);
  45. void BuildWarn(const String& warning, bool sendEvent = true);
  46. void BuildError(const String& error, bool sendEvent = true);
  47. /// Fail the current build
  48. void FailBuild(const String& message);
  49. /// Converts subprocess output event to a buildoutput event
  50. void HandleSubprocessOutputEvent(StringHash eventType, VariantMap& eventData);
  51. /// Asset build tag used by the assetbuildconfig.json file to identify the assets to that should be include
  52. /// in the build. If no tag is specified, then all resources are included.
  53. void SetAssetBuildTag(const String assetBuildTag) { assetBuildTag_ = assetBuildTag; }
  54. protected:
  55. bool BuildClean(const String& path);
  56. bool BuildRemoveDirectory(const String& path);
  57. bool BuildCreateDirectory(const String& path);
  58. bool BuildCopyFile(const String& srcFileName, const String& destFileName);
  59. void GenerateResourcePackage(const String& resourcePackagePath);
  60. void BuildResourceEntries();
  61. void BuildProjectResourceEntries();
  62. void GetDefaultResourcePaths(Vector<String>& paths);
  63. String GetSettingsDirectory();
  64. String buildPath_;
  65. PODVector<BuildResourceEntry*> resourceEntries_;
  66. bool containsMDL_;
  67. bool buildFailed_;
  68. String assetBuildTag_;
  69. private:
  70. PlatformID platformID_;
  71. Vector<String> buildLog_;
  72. Vector<String> buildWarnings_;
  73. Vector<String> buildErrors_;
  74. void ScanResourceDirectory(const String& resourceDir);
  75. SharedPtr<Project> project_;
  76. SharedPtr<ResourcePackager> resourcePackager_;
  77. Vector<String> resourceDirs_;
  78. void ReadAssetBuildConfig();
  79. };
  80. }