BuildWindows.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #include <Atomic/Core/StringUtils.h>
  8. #include <Atomic/IO/FileSystem.h>
  9. #include "../ToolSystem.h"
  10. #include "../ToolEnvironment.h"
  11. #include "../Project/Project.h"
  12. #include "BuildWindows.h"
  13. #include "BuildSystem.h"
  14. namespace ToolCore
  15. {
  16. BuildWindows::BuildWindows(Context * context, Project *project) : BuildBase(context, project, PLATFORMID_WINDOWS)
  17. {
  18. }
  19. BuildWindows::~BuildWindows()
  20. {
  21. }
  22. void BuildWindows::Initialize()
  23. {
  24. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  25. Project* project = tsystem->GetProject();
  26. Vector<String> defaultResourcePaths;
  27. GetDefaultResourcePaths(defaultResourcePaths);
  28. String projectResources = project->GetResourcePath();
  29. for (unsigned i = 0; i < defaultResourcePaths.Size(); i++)
  30. {
  31. AddResourceDir(defaultResourcePaths[i]);
  32. }
  33. // TODO: smart filtering of cache
  34. AddResourceDir(project->GetProjectPath() + "Cache/");
  35. AddResourceDir(projectResources);
  36. BuildResourceEntries();
  37. }
  38. void BuildWindows::BuildAtomicNET()
  39. {
  40. // AtomicNET
  41. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  42. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  43. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  44. Project* project = tsystem->GetProject();
  45. String projectResources = project->GetResourcePath();
  46. String assembliesPath = projectResources + "Assemblies/";
  47. // if no assemblies path, no need to install AtomicNET
  48. if (!fileSystem->DirExists(assembliesPath))
  49. return;
  50. Vector<String> results;
  51. fileSystem->ScanDir(results, assembliesPath, "*.dll", SCAN_FILES, true);
  52. // if no assembiles in Assemblies path, no need to install AtomicNET
  53. if (!results.Size())
  54. return;
  55. fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources/AtomicNET");
  56. fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources/AtomicNET/Atomic");
  57. fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources/AtomicNET/Atomic/Assemblies");
  58. fileSystem->CopyDir(tenv->GetNETCoreCLRAbsPath(), buildPath_ + "/AtomicPlayer_Resources/AtomicNET/CoreCLR");
  59. fileSystem->CopyDir(tenv->GetNETTPAPaths(), buildPath_ + "/AtomicPlayer_Resources/AtomicNET/Atomic/TPA");
  60. // Atomic Assemblies
  61. const String& assemblyLoadPaths = tenv->GetNETAssemblyLoadPaths();
  62. Vector<String> paths = assemblyLoadPaths.Split(';');
  63. for (unsigned i = 0; i < paths.Size(); i++)
  64. {
  65. Vector<String> loadResults;
  66. fileSystem->ScanDir(loadResults, paths[i], "*.dll", SCAN_FILES, true);
  67. for (unsigned j = 0; j < loadResults.Size(); j++)
  68. {
  69. String pathName, fileName, ext;
  70. SplitPath(loadResults[j], pathName, fileName, ext);
  71. if (fileName != "AtomicNETEngine")
  72. continue;
  73. fileSystem->Copy(paths[i] + "/" + loadResults[j], ToString("%s/AtomicPlayer_Resources/AtomicNET/Atomic/Assemblies/%s.dll", buildPath_.CString(), fileName.CString()));
  74. }
  75. }
  76. // Project assemblied
  77. for (unsigned i = 0; i < results.Size(); i++)
  78. {
  79. String pathName, fileName, ext;
  80. SplitPath(results[i], pathName, fileName, ext);
  81. fileSystem->Copy(assembliesPath + results[i], ToString("%s/AtomicPlayer_Resources/AtomicNET/Atomic/Assemblies/%s.dll", buildPath_.CString(), fileName.CString()));
  82. }
  83. }
  84. void BuildWindows::Build(const String& buildPath)
  85. {
  86. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  87. buildPath_ = AddTrailingSlash(buildPath) + GetBuildSubfolder();
  88. Initialize();
  89. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  90. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  91. if (fileSystem->DirExists(buildPath_))
  92. fileSystem->RemoveDir(buildPath_, true);
  93. String rootSourceDir = tenv->GetRootSourceDir();
  94. String playerBinary = tenv->GetPlayerBinary();
  95. String d3d9dll = GetPath(playerBinary) + "/D3DCompiler_47.dll";
  96. fileSystem->CreateDir(buildPath_);
  97. fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources");
  98. String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources.pak";
  99. GenerateResourcePackage(resourcePackagePath);
  100. fileSystem->Copy(playerBinary, buildPath_ + "/AtomicPlayer.exe");
  101. fileSystem->Copy(d3d9dll, buildPath_ + "/D3DCompiler_47.dll");
  102. BuildAtomicNET();
  103. buildSystem->BuildComplete(PLATFORMID_WINDOWS, buildPath_);
  104. }
  105. }