BuildMac.cpp 3.0 KB

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