ProjectBuilderWorker_windows.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <ProjectBuilderWorker.h>
  9. #include <ProjectManagerDefs.h>
  10. #include <QDir>
  11. #include <QString>
  12. namespace O3DE::ProjectManager
  13. {
  14. AZ::Outcome<QStringList, QString> ProjectBuilderWorker::ConstructCmakeGenerateProjectArguments(const QString& thirdPartyPath) const
  15. {
  16. QString targetBuildPath = QDir(m_projectInfo.m_path).filePath(ProjectBuildPathPostfix);
  17. QStringList args = {
  18. ProjectCMakeCommand,
  19. "-B", targetBuildPath,
  20. "-S", m_projectInfo.m_path,
  21. QString("-DLY_3RDPARTY_PATH=").append(thirdPartyPath)
  22. };
  23. if (m_projectInfo.m_isScriptOnly)
  24. {
  25. // Due to the way Visual Studio / MSBuild works, the Visual Studio CMake Generator is unable
  26. // to override the compiler / linker to use in any trivial manner (it would instead require an entire
  27. // visual studio toolchain to be actually installed on the machine).
  28. // It completely ignores the CMAKE_CXX_COMPILER and CMAKE_C_COMPILER variables, among other things.
  29. // We must use something else instead of MSBuild/VS on Windows, because of this.
  30. // The easiest is Ninja. On other platforms, the default generators, for example
  31. // "Unix Makefiles", will actually just do what you tell them to do in regards to fake compilers
  32. // and thus do not need to be overridden.
  33. args.append("-GNinja Multi-Config");
  34. }
  35. return AZ::Success( args );
  36. }
  37. AZ::Outcome<QStringList, QString> ProjectBuilderWorker::ConstructCmakeBuildCommandArguments() const
  38. {
  39. const QString targetBuildPath = QDir(m_projectInfo.m_path).filePath(ProjectBuildPathPostfix);
  40. const QString gameLauncherTargetName = m_projectInfo.m_projectName + ".GameLauncher";
  41. const QString headlessServerLauncherTargetName = m_projectInfo.m_projectName + ".HeadlessServerLauncher";
  42. const QString serverLauncherTargetName = m_projectInfo.m_projectName + ".ServerLauncher";
  43. const QString unifiedLauncherTargetName = m_projectInfo.m_projectName + ".UnifiedLauncher";
  44. return AZ::Success(QStringList{ ProjectCMakeCommand,
  45. "--build", targetBuildPath,
  46. "--config", "profile",
  47. "--target", gameLauncherTargetName, headlessServerLauncherTargetName, serverLauncherTargetName, unifiedLauncherTargetName, ProjectCMakeBuildTargetEditor });
  48. }
  49. AZ::Outcome<QStringList, QString> ProjectBuilderWorker::ConstructKillProcessCommandArguments(const QString& pidToKill) const
  50. {
  51. return AZ::Success(QStringList { "cmd.exe", "/C", "taskkill", "/pid", pidToKill, "/f", "/t" } );
  52. }
  53. } // namespace O3DE::ProjectManager