BuildBase.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. protected:
  52. bool BuildClean(const String& path);
  53. bool BuildRemoveDirectory(const String& path);
  54. bool BuildCreateDirectory(const String& path);
  55. bool BuildCopyFile(const String& srcFileName, const String& destFileName);
  56. virtual bool CheckIncludeResourceFile(const String& resourceDir, const String& fileName);
  57. void GenerateResourcePackage(const String& resourcePackagePath);
  58. void BuildResourceEntries();
  59. void GetDefaultResourcePaths(Vector<String>& paths);
  60. String GetSettingsDirectory();
  61. String buildPath_;
  62. PODVector<BuildResourceEntry*> resourceEntries_;
  63. bool containsMDL_;
  64. bool buildFailed_;
  65. private:
  66. PlatformID platformID_;
  67. Vector<String> buildLog_;
  68. Vector<String> buildWarnings_;
  69. Vector<String> buildErrors_;
  70. void ScanResourceDirectory(const String& resourceDir);
  71. SharedPtr<Project> project_;
  72. SharedPtr<ResourcePackager> resourcePackager_;
  73. Vector<String> resourceDirs_;
  74. };
  75. }