BuildBase.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. friend class AndroidProjectGenerator;
  35. public:
  36. BuildBase(Context* context, Project* project, PlatformID platform);
  37. virtual ~BuildBase();
  38. virtual void Build(const String& buildPath) = 0;
  39. // some platforms may want to do their own packaging of resources
  40. virtual bool UseResourcePackager() { return true; }
  41. virtual String GetBuildSubfolder() = 0;
  42. // add in search order, first added is first searched
  43. // will warn on name conflicts
  44. void AddResourceDir(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. protected:
  53. bool BuildClean(const String& path);
  54. bool BuildRemoveDirectory(const String& path);
  55. bool BuildCreateDirectory(const String& path);
  56. bool BuildCopyFile(const String& srcFileName, const String& destFileName);
  57. bool BuildCopyDir(const String& srcDir, const String& destDir);
  58. virtual bool CheckIncludeResourceFile(const String& resourceDir, const String& fileName);
  59. void GenerateResourcePackage(const String& resourcePackagePath);
  60. void BuildResourceEntries();
  61. void GetDefaultResourcePaths(Vector<String>& paths);
  62. String GetSettingsDirectory();
  63. String buildPath_;
  64. PODVector<BuildResourceEntry*> resourceEntries_;
  65. bool containsMDL_;
  66. bool buildFailed_;
  67. private:
  68. PlatformID platformID_;
  69. Vector<String> buildLog_;
  70. Vector<String> buildWarnings_;
  71. Vector<String> buildErrors_;
  72. void ScanResourceDirectory(const String& resourceDir);
  73. SharedPtr<Project> project_;
  74. SharedPtr<ResourcePackager> resourcePackager_;
  75. Vector<String> resourceDirs_;
  76. };
  77. }