launcher_helper.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. Main launchers module, provides a facade for creating launchers.
  6. """
  7. import logging
  8. import ly_test_tools
  9. import ly_test_tools._internal.managers.workspace as workspace_manager
  10. import ly_test_tools.launchers.platforms.base as base_launcher
  11. # These are the launchers *currently* supported by the test tools. While other launchers exist, they are not supported
  12. # by the test tools.
  13. GAME_LAUNCHERS = ['windows', 'linux', 'android']
  14. SERVER_LAUNCHERS = ['windows_dedicated', 'linux_dedicated']
  15. log = logging.getLogger(__name__)
  16. def create_game_launcher(workspace, launcher_platform=ly_test_tools.HOST_OS_PLATFORM, args=None):
  17. # type: (workspace_manager.AbstractWorkspaceManager, str, list[str]) -> base_launcher.Launcher
  18. """
  19. Create a GameLauncher compatible with the specified workspace, defaulting to a generic one otherwise.
  20. :param workspace: lumberyard workspace to use
  21. :param launcher_platform: the platform to target for a launcher (i.e. 'windows' or 'android')
  22. :param args: List of arguments to pass to the launcher's 'args' argument during construction
  23. :return: Launcher instance
  24. """
  25. if launcher_platform in GAME_LAUNCHERS:
  26. launcher_class = ly_test_tools.LAUNCHERS.get(launcher_platform)
  27. else:
  28. log.warning(f"Using default launcher for '{ly_test_tools.HOST_OS_PLATFORM}' "
  29. f"as no option is available for '{launcher_platform}'")
  30. launcher_class = ly_test_tools.LAUNCHERS.get(ly_test_tools.HOST_OS_PLATFORM)
  31. return launcher_class(workspace, args)
  32. def create_server_launcher(workspace, launcher_platform=ly_test_tools.HOST_OS_PLATFORM, args=None):
  33. # type: (workspace_manager.AbstractWorkspaceManager, str, list[str]) -> base_launcher.Launcher
  34. """
  35. Create a ServerLauncher compatible with the specified workspace, defaulting to a generic one otherwise.
  36. :param workspace: lumberyard workspace to use
  37. :param launcher_platform: the platform to target for a launcher (i.e. 'windows' or 'android')
  38. :param args: List of arguments to pass to the launcher's 'args' argument during construction
  39. :return: Launcher instance
  40. """
  41. if launcher_platform in SERVER_LAUNCHERS:
  42. launcher_class = ly_test_tools.LAUNCHERS.get(launcher_platform)
  43. else:
  44. log.warning(f"Using default dedicated launcher for '{ly_test_tools.HOST_OS_DEDICATED_SERVER}' "
  45. f"as no option is available for '{launcher_platform}'")
  46. launcher_class = ly_test_tools.LAUNCHERS.get(ly_test_tools.HOST_OS_DEDICATED_SERVER)
  47. return launcher_class(workspace, args)
  48. def create_editor(workspace, launcher_platform=ly_test_tools.HOST_OS_EDITOR, args=None):
  49. # type: (workspace_manager.AbstractWorkspaceManager, str, list[str]) -> base_launcher.Launcher
  50. """
  51. Create an Editor compatible with the specified workspace.
  52. Editor is only officially supported on the Windows Platform.
  53. :param workspace: lumberyard workspace to use
  54. :param launcher_platform: the platform to target for a launcher (i.e. 'windows_dedicated' for DedicatedWinLauncher)
  55. :param args: List of arguments to pass to the launcher's 'args' argument during construction
  56. :return: Editor instance
  57. """
  58. launcher_class = ly_test_tools.LAUNCHERS.get(launcher_platform)
  59. if not launcher_class:
  60. log.warning(f"Using default editor launcher for '{ly_test_tools.HOST_OS_EDITOR}' "
  61. f"as no option is available for '{launcher_platform}'")
  62. launcher_class = ly_test_tools.LAUNCHERS.get(ly_test_tools.HOST_OS_EDITOR)
  63. return launcher_class(workspace, args)
  64. def create_atom_tools_launcher(workspace, app_file_name, launcher_platform=ly_test_tools.HOST_OS_ATOM_TOOLS, args=None):
  65. # type: (workspace_manager.AbstractWorkspaceManager, str, str, list[str]) -> base_launcher.Launcher
  66. """
  67. Create an Atom Tools launcher compatible with the specified workspace.
  68. Most Atom Tools executables are only officially supported on the Windows Platform.
  69. :param workspace: lumberyard workspace to use
  70. :param app_file_name: name of the file to look for
  71. :param launcher_platform: the platform to target for a launcher (i.e. 'windows_atom_tools' for WinAtomToolsLauncher)
  72. :param args: List of arguments to pass to the launcher's 'args' argument during construction
  73. :return: Atom Tools application instance
  74. """
  75. launcher_class = ly_test_tools.LAUNCHERS.get(launcher_platform)
  76. if not launcher_class:
  77. log.warning(f"Using default Atom Tools launcher for '{ly_test_tools.HOST_OS_ATOM_TOOLS}' "
  78. f"as no option is available for '{launcher_platform}'")
  79. launcher_class = ly_test_tools.LAUNCHERS.get(ly_test_tools.HOST_OS_ATOM_TOOLS)
  80. return launcher_class(workspace, app_file_name, args)