__init__.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. OS and devices are detected and set as constants when ly_test_tools.__init__() completes.
  6. """
  7. import logging
  8. import sys
  9. import platform
  10. logger = logging.getLogger(__name__)
  11. # Supported platforms
  12. ALL_PLATFORM_OPTIONS = ['android', 'ios', 'linux', 'mac', 'windows']
  13. ALL_LAUNCHER_OPTIONS = [
  14. 'android', 'base', 'linux', 'mac', 'windows', 'windows_editor', 'windows_dedicated', 'windows_atom_tools']
  15. ANDROID = False
  16. IOS = False # Not implemented - see SPEC-2505
  17. LINUX = sys.platform.startswith('linux')
  18. MAC = sys.platform.startswith('darwin')
  19. WINDOWS = sys.platform.startswith('win')
  20. # Detect available platforms
  21. HOST_OS_PLATFORM = 'unknown'
  22. HOST_OS_EDITOR = 'unknown'
  23. HOST_OS_DEDICATED_SERVER = 'unknown'
  24. HOST_OS_ATOM_TOOLS = 'unknown'
  25. LAUNCHERS = {}
  26. for launcher_option in ALL_LAUNCHER_OPTIONS:
  27. LAUNCHERS[launcher_option] = None
  28. from ly_test_tools.launchers.platforms.base import Launcher
  29. LAUNCHERS['base'] = Launcher
  30. if WINDOWS:
  31. HOST_OS_PLATFORM = 'windows'
  32. HOST_OS_EDITOR = 'windows_editor'
  33. HOST_OS_DEDICATED_SERVER = 'windows_dedicated'
  34. HOST_OS_ATOM_TOOLS = 'windows_atom_tools'
  35. import ly_test_tools.mobile.android
  36. from ly_test_tools.launchers import (
  37. AndroidLauncher, WinLauncher, DedicatedWinLauncher, WinEditor, WinAtomToolsLauncher)
  38. ANDROID = ly_test_tools.mobile.android.can_run_android()
  39. LAUNCHERS['windows'] = WinLauncher
  40. LAUNCHERS['windows_editor'] = WinEditor
  41. LAUNCHERS['windows_dedicated'] = DedicatedWinLauncher
  42. LAUNCHERS['windows_atom_tools'] = WinAtomToolsLauncher
  43. LAUNCHERS['android'] = AndroidLauncher
  44. elif MAC:
  45. ARM64 = platform.machine() == 'arm64'
  46. HOST_OS_PLATFORM = 'mac'
  47. HOST_OS_EDITOR = NotImplementedError('LyTestTools does not yet support Mac editor')
  48. HOST_OS_DEDICATED_SERVER = NotImplementedError('LyTestTools does not yet support Mac dedicated server')
  49. HOST_OS_ATOM_TOOLS = NotImplementedError('LyTestTools does not yet support Mac Atom Tools executables')
  50. from ly_test_tools.launchers import MacLauncher
  51. LAUNCHERS['mac'] = MacLauncher
  52. elif LINUX:
  53. ARM64 = platform.machine() == 'aarch64'
  54. HOST_OS_PLATFORM = 'linux'
  55. HOST_OS_EDITOR = 'linux_editor'
  56. HOST_OS_DEDICATED_SERVER = 'linux_dedicated'
  57. HOST_OS_ATOM_TOOLS = 'linux_atom_tools'
  58. from ly_test_tools.launchers.platforms.linux.launcher import (
  59. LinuxLauncher, LinuxEditor, DedicatedLinuxLauncher, LinuxAtomToolsLauncher)
  60. LAUNCHERS['linux'] = LinuxLauncher
  61. LAUNCHERS['linux_editor'] = LinuxEditor
  62. LAUNCHERS['linux_dedicated'] = DedicatedLinuxLauncher
  63. LAUNCHERS['linux_atom_tools'] = LinuxAtomToolsLauncher
  64. else:
  65. ARM64 = False
  66. logger.warning(f'WARNING: LyTestTools only supports Windows, Mac, and Linux. '
  67. f'Unexpectedly detected HOST_OS_PLATFORM: "{HOST_OS_PLATFORM}".')