BuildMac.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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* tools = GetSubsystem<ToolSystem>();
  20. Project* project = tools->GetProject();
  21. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  22. #ifdef ATOMIC_PLATFORM_WINDOWS
  23. String bundleResources = fileSystem->GetProgramDir();
  24. #else
  25. String bundleResources = fileSystem->GetAppBundleResourceFolder();
  26. #endif
  27. String projectResources = project->GetResourcePath();
  28. String coreDataFolder = bundleResources + "CoreData/";
  29. AddResourceDir(coreDataFolder);
  30. AddResourceDir(projectResources);
  31. BuildResourceEntries();
  32. }
  33. void BuildMac::Build(const String& buildPath)
  34. {
  35. buildPath_ = buildPath + "/Mac-Build";
  36. Initialize();
  37. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  38. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  39. if (fileSystem->DirExists(buildPath_))
  40. fileSystem->RemoveDir(buildPath_, true);
  41. #ifdef ATOMIC_PLATFORM_WINDOWS
  42. String buildSourceDir = fileSystem->GetProgramDir();
  43. #else
  44. String buildSourceDir = fileSystem->GetAppBundleResourceFolder();
  45. #endif
  46. buildSourceDir += "Deployment/MacOS/AtomicPlayer.app";
  47. fileSystem->CreateDir(buildPath_);
  48. buildPath_ += "/AtomicPlayer.app";
  49. fileSystem->CreateDir(buildPath_);
  50. fileSystem->CreateDir(buildPath_ + "/Contents");
  51. fileSystem->CreateDir(buildPath_ + "/Contents/MacOS");
  52. fileSystem->CreateDir(buildPath_ + "/Contents/Resources");
  53. String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources.pak";
  54. GenerateResourcePackage(resourcePackagePath);
  55. fileSystem->Copy(buildSourceDir + "/Contents/Resources/Atomic.icns", buildPath_ + "/Contents/Resources/Atomic.icns");
  56. fileSystem->Copy(buildSourceDir + "/Contents/Info.plist", buildPath_ + "/Contents/Info.plist");
  57. fileSystem->Copy(buildSourceDir + "/Contents/MacOS/AtomicPlayer", buildPath_ + "/Contents/MacOS/AtomicPlayer");
  58. #ifdef ATOMIC_PLATFORM_OSX
  59. Vector<String> args;
  60. args.Push("+x");
  61. args.Push(buildPath_ + "/Contents/MacOS/AtomicPlayer");
  62. fileSystem->SystemRun("chmod", args);
  63. #endif
  64. buildPath_ = buildPath + "/Mac-Build";
  65. buildSystem->BuildComplete(PLATFORMID_MAC, buildPath_);
  66. }
  67. }