BuildMac.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 "License/AELicenseSystem.h"
  10. #include "BuildMac.h"
  11. #include "BuildSystem.h"
  12. namespace AtomicEditor
  13. {
  14. BuildMac::BuildMac(Context * context) : BuildBase(context)
  15. {
  16. }
  17. BuildMac::~BuildMac()
  18. {
  19. }
  20. void BuildMac::Initialize()
  21. {
  22. Editor* editor = GetSubsystem<Editor>();
  23. Project* project = editor->GetProject();
  24. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  25. #ifdef ATOMIC_PLATFORM_WINDOWS
  26. String bundleResources = fileSystem->GetProgramDir();
  27. #else
  28. String bundleResources = fileSystem->GetAppBundleResourceFolder();
  29. #endif
  30. String projectResources = project->GetResourcePath();
  31. String coreDataFolder = bundleResources + "CoreData/";
  32. AddResourceDir(coreDataFolder);
  33. AddResourceDir(projectResources);
  34. BuildResourceEntries();
  35. }
  36. void BuildMac::Build(const String& buildPath)
  37. {
  38. buildPath_ = buildPath + "/Mac-Build";
  39. Initialize();
  40. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  41. // BEGIN LICENSE MANAGEMENT
  42. LicenseSystem *licenseSystem = GetSubsystem<LicenseSystem>();
  43. if (licenseSystem->IsStandardLicense())
  44. {
  45. if (containsMDL_)
  46. {
  47. buildSystem->BuildComplete(AE_PLATFORM_MAC, buildPath_, false, true);
  48. return;
  49. }
  50. }
  51. // END LICENSE MANAGEMENT
  52. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  53. if (fileSystem->DirExists(buildPath_))
  54. fileSystem->RemoveDir(buildPath_, true);
  55. #ifdef ATOMIC_PLATFORM_WINDOWS
  56. String buildSourceDir = fileSystem->GetProgramDir();
  57. #else
  58. String buildSourceDir = fileSystem->GetAppBundleResourceFolder();
  59. #endif
  60. buildSourceDir += "Deployment/MacOS/AtomicPlayer.app";
  61. fileSystem->CreateDir(buildPath_);
  62. buildPath_ += "/AtomicPlayer.app";
  63. fileSystem->CreateDir(buildPath_);
  64. fileSystem->CreateDir(buildPath_ + "/Contents");
  65. fileSystem->CreateDir(buildPath_ + "/Contents/MacOS");
  66. fileSystem->CreateDir(buildPath_ + "/Contents/Resources");
  67. String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources.pak";
  68. GenerateResourcePackage(resourcePackagePath);
  69. fileSystem->Copy(buildSourceDir + "/Contents/Resources/Atomic.icns", buildPath_ + "/Contents/Resources/Atomic.icns");
  70. fileSystem->Copy(buildSourceDir + "/Contents/Info.plist", buildPath_ + "/Contents/Info.plist");
  71. fileSystem->Copy(buildSourceDir + "/Contents/MacOS/AtomicPlayer", buildPath_ + "/Contents/MacOS/AtomicPlayer");
  72. #ifdef ATOMIC_PLATFORM_OSX
  73. Vector<String> args;
  74. args.Push("+x");
  75. args.Push(buildPath_ + "/Contents/MacOS/AtomicPlayer");
  76. fileSystem->SystemRun("chmod", args);
  77. #endif
  78. buildPath_ = buildPath + "/Mac-Build";
  79. buildSystem->BuildComplete(AE_PLATFORM_MAC, buildPath_);
  80. }
  81. }