BuildBase.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #pragma once
  8. #include <Atomic/Core/Object.h>
  9. #include "BuildTypes.h"
  10. #include "../Platform/Platform.h"
  11. using namespace Atomic;
  12. namespace ToolCore
  13. {
  14. class ResourcePackager;
  15. class Project;
  16. class BuildBase : public Object
  17. {
  18. OBJECT(BuildBase);
  19. public:
  20. BuildBase(Context* context, Project* project, PlatformID platform);
  21. virtual ~BuildBase();
  22. virtual void Build(const String& buildPath) = 0;
  23. // some platforms may want to do their own packaging of resources
  24. virtual bool UseResourcePackager() { return true; }
  25. virtual String GetBuildSubfolder() = 0;
  26. // add in search order, first added is first searched
  27. // will warn on name conflicts
  28. void AddResourceDir(const String& dir);
  29. void BuildLog(const String& message, bool sendEvent = true);
  30. void BuildWarn(const String& warning, bool sendEvent = true);
  31. void BuildError(const String& error, bool sendEvent = true);
  32. /// Fail the current build
  33. void FailBuild(const String& message);
  34. /// Converts subprocess output event to a buildoutput event
  35. void HandleSubprocessOutputEvent(StringHash eventType, VariantMap& eventData);
  36. protected:
  37. bool BuildClean(const String& path);
  38. bool BuildRemoveDirectory(const String& path);
  39. bool BuildCreateDirectory(const String& path);
  40. bool BuildCopyFile(const String& srcFileName, const String& destFileName);
  41. void GenerateResourcePackage(const String& resourcePackagePath);
  42. void BuildResourceEntries();
  43. void GetDefaultResourcePaths(Vector<String>& paths);
  44. String GetSettingsDirectory();
  45. String buildPath_;
  46. PODVector<BuildResourceEntry*> resourceEntries_;
  47. bool containsMDL_;
  48. bool buildFailed_;
  49. private:
  50. PlatformID platformID_;
  51. Vector<String> buildLog_;
  52. Vector<String> buildWarnings_;
  53. Vector<String> buildErrors_;
  54. void ScanResourceDirectory(const String& resourceDir);
  55. SharedPtr<Project> project_;
  56. SharedPtr<ResourcePackager> resourcePackager_;
  57. Vector<String> resourceDirs_;
  58. };
  59. }