BuildMac.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  2. // Please see LICENSE.md in repository root for license information
  3. // https://github.com/AtomicGameEngine/AtomicGameEngine
  4. #include <Atomic/IO/FileSystem.h>
  5. #include "../ToolSystem.h"
  6. #include "../ToolEnvironment.h"
  7. #include "../Project/Project.h"
  8. #include "BuildMac.h"
  9. #include "BuildSystem.h"
  10. namespace ToolCore
  11. {
  12. BuildMac::BuildMac(Context * context, Project *project) : BuildBase(context, project)
  13. {
  14. }
  15. BuildMac::~BuildMac()
  16. {
  17. }
  18. void BuildMac::Initialize()
  19. {
  20. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  21. Project* project = tsystem->GetProject();
  22. Vector<String> defaultResourcePaths;
  23. GetDefaultResourcePaths(defaultResourcePaths);
  24. String projectResources = project->GetResourcePath();
  25. for (unsigned i = 0; i < defaultResourcePaths.Size(); i++)
  26. {
  27. AddResourceDir(defaultResourcePaths[i]);
  28. }
  29. // TODO: smart filtering of cache
  30. AddResourceDir(project->GetProjectPath() + "Cache/");
  31. AddResourceDir(projectResources);
  32. BuildResourceEntries();
  33. }
  34. void BuildMac::Build(const String& buildPath)
  35. {
  36. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  37. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  38. buildPath_ = AddTrailingSlash(buildPath) + GetBuildSubfolder();
  39. Initialize();
  40. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  41. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  42. if (fileSystem->DirExists(buildPath_))
  43. fileSystem->RemoveDir(buildPath_, true);
  44. String appSrcPath = tenv->GetPlayerAppFolder();
  45. fileSystem->CreateDir(buildPath_);
  46. buildPath_ += "/AtomicPlayer.app";
  47. fileSystem->CreateDir(buildPath_);
  48. fileSystem->CreateDir(buildPath_ + "/Contents");
  49. fileSystem->CreateDir(buildPath_ + "/Contents/MacOS");
  50. fileSystem->CreateDir(buildPath_ + "/Contents/Resources");
  51. String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources.pak";
  52. GenerateResourcePackage(resourcePackagePath);
  53. fileSystem->Copy(appSrcPath + "/Contents/Resources/Atomic.icns", buildPath_ + "/Contents/Resources/Atomic.icns");
  54. fileSystem->Copy(appSrcPath + "/Contents/Info.plist", buildPath_ + "/Contents/Info.plist");
  55. fileSystem->Copy(appSrcPath + "/Contents/MacOS/AtomicPlayer", buildPath_ + "/Contents/MacOS/AtomicPlayer");
  56. #ifdef ATOMIC_PLATFORM_OSX
  57. Vector<String> args;
  58. args.Push("+x");
  59. args.Push(buildPath_ + "/Contents/MacOS/AtomicPlayer");
  60. fileSystem->SystemRun("chmod", args);
  61. #endif
  62. buildPath_ = buildPath + "/Mac-Build";
  63. buildSystem->BuildComplete(PLATFORMID_MAC, buildPath_);
  64. }
  65. }