BuildMac.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 "../Project/Project.h"
  7. #include "BuildMac.h"
  8. #include "BuildSystem.h"
  9. namespace ToolCore
  10. {
  11. BuildMac::BuildMac(Context * context, Project *project) : BuildBase(context, project)
  12. {
  13. }
  14. BuildMac::~BuildMac()
  15. {
  16. }
  17. void BuildMac::Initialize()
  18. {
  19. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  20. Project* project = tsystem->GetProject();
  21. Vector<String> defaultResourcePaths;
  22. GetDefaultResourcePaths(defaultResourcePaths);
  23. String projectResources = project->GetResourcePath();
  24. for (unsigned i = 0; i < defaultResourcePaths.Size(); i++)
  25. {
  26. AddResourceDir(defaultResourcePaths[i]);
  27. }
  28. AddResourceDir(projectResources);
  29. BuildResourceEntries();
  30. }
  31. void BuildMac::Build(const String& buildPath)
  32. {
  33. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  34. buildPath_ = AddTrailingSlash(buildPath) + GetBuildSubfolder();
  35. Initialize();
  36. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  37. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  38. if (fileSystem->DirExists(buildPath_))
  39. fileSystem->RemoveDir(buildPath_, true);
  40. String dataPath = tsystem->GetDataPath();
  41. String appSrcPath = dataPath + "Deployment/MacOS/AtomicPlayer.app";
  42. fileSystem->CreateDir(buildPath_);
  43. buildPath_ += "/AtomicPlayer.app";
  44. fileSystem->CreateDir(buildPath_);
  45. fileSystem->CreateDir(buildPath_ + "/Contents");
  46. fileSystem->CreateDir(buildPath_ + "/Contents/MacOS");
  47. fileSystem->CreateDir(buildPath_ + "/Contents/Resources");
  48. String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources.pak";
  49. GenerateResourcePackage(resourcePackagePath);
  50. fileSystem->Copy(appSrcPath + "/Contents/Resources/Atomic.icns", buildPath_ + "/Contents/Resources/Atomic.icns");
  51. fileSystem->Copy(appSrcPath + "/Contents/Info.plist", buildPath_ + "/Contents/Info.plist");
  52. fileSystem->Copy(appSrcPath + "/Contents/MacOS/AtomicPlayer", buildPath_ + "/Contents/MacOS/AtomicPlayer");
  53. #ifdef ATOMIC_PLATFORM_OSX
  54. Vector<String> args;
  55. args.Push("+x");
  56. args.Push(buildPath_ + "/Contents/MacOS/AtomicPlayer");
  57. fileSystem->SystemRun("chmod", args);
  58. #endif
  59. buildPath_ = buildPath + "/Mac-Build";
  60. buildSystem->BuildComplete(PLATFORMID_MAC, buildPath_);
  61. }
  62. }