BuildMac.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "AtomicEditor.h"
  5. #include <Atomic/IO/FileSystem.h>
  6. #include "../AEEditor.h"
  7. #include "../Project/AEProject.h"
  8. #include "../Project/ProjectUtils.h"
  9. #include "BuildMac.h"
  10. #include "BuildSystem.h"
  11. namespace AtomicEditor
  12. {
  13. BuildMac::BuildMac(Context * context) : BuildBase(context)
  14. {
  15. }
  16. BuildMac::~BuildMac()
  17. {
  18. }
  19. void BuildMac::Initialize()
  20. {
  21. Editor* editor = GetSubsystem<Editor>();
  22. Project* project = editor->GetProject();
  23. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  24. String bundleResources = fileSystem->GetAppBundleResourceFolder();
  25. String projectResources = project->GetResourcePath();
  26. String dataFolder = bundleResources + "Data/";
  27. String coreDataFolder = bundleResources + "CoreData/";
  28. AddResourceDir(coreDataFolder);
  29. AddResourceDir(dataFolder);
  30. AddResourceDir(projectResources);
  31. BuildResourceEntries();
  32. }
  33. void BuildMac::Build(const String& buildPath)
  34. {
  35. buildPath_ = buildPath;
  36. Initialize();
  37. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  38. String buildSourceDir = fileSystem->GetAppBundleResourceFolder();
  39. buildSourceDir += "Deployment/MacOS/AtomicPlayer.app";
  40. fileSystem->CreateDir(buildPath);
  41. fileSystem->CreateDir(buildPath + "/Contents");
  42. fileSystem->CreateDir(buildPath + "/Contents/MacOS");
  43. fileSystem->CreateDir(buildPath + "/Contents/Resources");
  44. String resourcePackagePath = buildPath + "/Contents/Resources/AtomicResources.pak";
  45. GenerateResourcePackage(resourcePackagePath);
  46. fileSystem->Copy(buildSourceDir + "/Contents/Resources/Atomic.icns", buildPath + "/Contents/Resources/Atomic.icns");
  47. fileSystem->Copy(buildSourceDir + "/Contents/Info.plist", buildPath + "/Contents/Info.plist");
  48. fileSystem->Copy(buildSourceDir + "/Contents/MacOS/AtomicPlayer", buildPath + "/Contents/MacOS/AtomicPlayer");
  49. Vector<String> args;
  50. args.Push("+x");
  51. args.Push(buildPath + "/Contents/MacOS/AtomicPlayer");
  52. fileSystem->SystemRun("chmod", args);
  53. ProjectUtils* utils = GetSubsystem<ProjectUtils>();
  54. utils->RevealInFinder(GetPath(buildPath));
  55. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  56. buildSystem->BuildComplete();
  57. }
  58. }