BuildMac.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #include <Atomic/IO/FileSystem.h>
  8. #include "../ToolSystem.h"
  9. #include "../ToolEnvironment.h"
  10. #include "../Project/Project.h"
  11. #include "BuildEvents.h"
  12. #include "BuildSystem.h"
  13. #include "BuildMac.h"
  14. namespace ToolCore
  15. {
  16. BuildMac::BuildMac(Context * context, Project *project) : BuildBase(context, project, PLATFORMID_MAC)
  17. {
  18. }
  19. BuildMac::~BuildMac()
  20. {
  21. }
  22. void BuildMac::Initialize()
  23. {
  24. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  25. Project* project = tsystem->GetProject();
  26. Vector<String> defaultResourcePaths;
  27. GetDefaultResourcePaths(defaultResourcePaths);
  28. String projectResources = project->GetResourcePath();
  29. for (unsigned i = 0; i < defaultResourcePaths.Size(); i++)
  30. {
  31. AddResourceDir(defaultResourcePaths[i]);
  32. }
  33. // TODO: smart filtering of cache
  34. AddResourceDir(project->GetProjectPath() + "Cache/");
  35. AddResourceDir(projectResources);
  36. BuildResourceEntries();
  37. }
  38. void BuildMac::Build(const String& buildPath)
  39. {
  40. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  41. buildPath_ = AddTrailingSlash(buildPath) + GetBuildSubfolder();
  42. VariantMap buildOutput;
  43. buildOutput[BuildOutput::P_TEXT] = "\n\n<color #D4FB79>Starting Mac Deployment</color>\n\n";
  44. SendEvent(E_BUILDOUTPUT, buildOutput);
  45. Initialize();
  46. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  47. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  48. if (fileSystem->DirExists(buildPath_))
  49. fileSystem->RemoveDir(buildPath_, true);
  50. String appSrcPath = tenv->GetPlayerAppFolder();
  51. fileSystem->CreateDir(buildPath_);
  52. buildPath_ += "/AtomicPlayer.app";
  53. fileSystem->CreateDir(buildPath_);
  54. fileSystem->CreateDir(buildPath_ + "/Contents");
  55. fileSystem->CreateDir(buildPath_ + "/Contents/MacOS");
  56. fileSystem->CreateDir(buildPath_ + "/Contents/Resources");
  57. String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources.pak";
  58. GenerateResourcePackage(resourcePackagePath);
  59. fileSystem->Copy(appSrcPath + "/Contents/Resources/Atomic.icns", buildPath_ + "/Contents/Resources/Atomic.icns");
  60. fileSystem->Copy(appSrcPath + "/Contents/Info.plist", buildPath_ + "/Contents/Info.plist");
  61. fileSystem->Copy(appSrcPath + "/Contents/MacOS/AtomicPlayer", buildPath_ + "/Contents/MacOS/AtomicPlayer");
  62. #ifdef ATOMIC_PLATFORM_OSX
  63. Vector<String> args;
  64. args.Push("+x");
  65. args.Push(buildPath_ + "/Contents/MacOS/AtomicPlayer");
  66. fileSystem->SystemRun("chmod", args);
  67. #endif
  68. buildOutput[BuildOutput::P_TEXT] = "\n\n<color #D4FB79>Mac Deployment Complete</color>\n\n";
  69. SendEvent(E_BUILDOUTPUT, buildOutput);
  70. buildPath_ = buildPath + "/Mac-Build";
  71. buildSystem->BuildComplete(PLATFORMID_MAC, buildPath_);
  72. }
  73. }