ProjectBuilderWorker_linux.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <ProjectUtils.h>
  11. #include <QDir>
  12. #include <QString>
  13. namespace O3DE::ProjectManager
  14. {
  15. AZ::Outcome<QStringList, QString> ProjectBuilderWorker::ConstructCmakeGenerateProjectArguments(const QString& thirdPartyPath) const
  16. {
  17. // Attempt to use the Ninja build system if it is installed (described in the o3de documentation) if possible,
  18. // otherwise default to the the default for Linux (Unix Makefiles)
  19. auto whichNinjaResult = ProjectUtils::ExecuteCommandResult("which", QStringList{"ninja"});
  20. QString cmakeGenerator = (whichNinjaResult.IsSuccess()) ? "Ninja Multi-Config" : "Unix Makefiles";
  21. bool compileProfileOnBuild = (whichNinjaResult.IsSuccess());
  22. QString targetBuildPath = QDir(m_projectInfo.m_path).filePath(ProjectBuildPathPostfix);
  23. QStringList generateProjectArgs = QStringList{ProjectCMakeCommand,
  24. "-B", ProjectBuildPathPostfix,
  25. "-S", ".",
  26. QString("-G%1").arg(cmakeGenerator),
  27. QString("-DLY_3RDPARTY_PATH=").append(thirdPartyPath)};
  28. if (!compileProfileOnBuild)
  29. {
  30. generateProjectArgs.append("-DCMAKE_BUILD_TYPE=profile");
  31. }
  32. return AZ::Success(generateProjectArgs);
  33. }
  34. AZ::Outcome<QStringList, QString> ProjectBuilderWorker::ConstructCmakeBuildCommandArguments() const
  35. {
  36. auto whichNinjaResult = ProjectUtils::ExecuteCommandResult("which", QStringList{"ninja"});
  37. bool compileProfileOnBuild = (whichNinjaResult.IsSuccess());
  38. const QString gameLauncherTargetName = m_projectInfo.m_projectName + ".GameLauncher";
  39. const QString serverLauncherTargetName = m_projectInfo.m_projectName + ".ServerLauncher";
  40. const QString unifiedLauncherTargetName = m_projectInfo.m_projectName + ".UnifiedLauncher";
  41. QStringList buildProjectArgs = QStringList{ProjectCMakeCommand,
  42. "--build", ProjectBuildPathPostfix,
  43. "--target", gameLauncherTargetName, serverLauncherTargetName, unifiedLauncherTargetName, ProjectCMakeBuildTargetEditor};
  44. if (compileProfileOnBuild)
  45. {
  46. buildProjectArgs.append(QStringList{"--config","profile"});
  47. }
  48. return AZ::Success(buildProjectArgs);
  49. }
  50. AZ::Outcome<QStringList, QString> ProjectBuilderWorker::ConstructKillProcessCommandArguments(const QString& pidToKill) const
  51. {
  52. return AZ::Success(QStringList{"kill", "-9", pidToKill});
  53. }
  54. } // namespace O3DE::ProjectManager