PlatformDetection.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. // Detect BASELIB_PLATFORM_X define.
  3. //
  4. // Note that PLATFORM_X defines in Unity code base may refer to one or more platforms defined by BASELIB_PLATFORM_X
  5. // Platforms here are very loosely defined on the set of available system apis.
  6. // They have closest relation with the platform toolchains defined in Bee.
  7. #if defined(_XBOX_ONE)
  8. #define BASELIB_PLATFORM_XBOXONE 1
  9. #elif defined(__NX__)
  10. #define BASELIB_PLATFORM_SWITCH 1
  11. #elif defined __ORBIS__
  12. #define BASELIB_PLATFORM_PS4 1
  13. #elif defined __PROSPERO__
  14. #define BASELIB_PLATFORM_PS5 1
  15. #elif defined __EMSCRIPTEN__
  16. #define BASELIB_PLATFORM_EMSCRIPTEN 1
  17. #elif defined __wasi__
  18. #define BASELIB_PLATFORM_WASI 1
  19. #elif defined(__APPLE__)
  20. #include <TargetConditionals.h>
  21. #if !defined(TARGET_OS_XR)
  22. #define TARGET_OS_XR 0
  23. #endif
  24. // TODO: Remove when Bratwurst is removed.
  25. #if defined(TARGET_OS_BRATWURST) && TARGET_OS_BRATWURST
  26. #define BASELIB_PLATFORM_BRATWURST 1
  27. #elif TARGET_OS_XR
  28. #define BASELIB_PLATFORM_VISIONOS 1
  29. #elif TARGET_OS_IOS
  30. #define BASELIB_PLATFORM_IOS 1
  31. #elif TARGET_OS_TV
  32. #define BASELIB_PLATFORM_TVOS 1
  33. #elif TARGET_OS_OSX || TARGET_OS_MAC
  34. #define BASELIB_PLATFORM_MACOS 1
  35. #endif
  36. #elif defined(__NetBSD__)
  37. #define BASELIB_PLATFORM_NETBSD 1
  38. #elif defined(linux) || defined(__linux__)
  39. #if defined(GGP)
  40. #define BASELIB_PLATFORM_STADIA 1
  41. #elif defined(ANDROID) || defined(__ANDROID__)
  42. #define BASELIB_PLATFORM_ANDROID 1
  43. #elif defined(EMBEDDED_LINUX)
  44. #define BASELIB_PLATFORM_EMBEDDED_LINUX 1
  45. #else
  46. #define BASELIB_PLATFORM_LINUX 1
  47. #endif
  48. #elif defined(_WIN32) || defined(__WIN32__)
  49. #include <winapifamily.h>
  50. #if (defined(WINAPI_FAMILY_GAMES) && (WINAPI_FAMILY == WINAPI_FAMILY_GAMES))
  51. #define BASELIB_PLATFORM_WINDOWSGAMES 1
  52. #elif WINAPI_FAMILY == WINAPI_FAMILY_APP
  53. #define BASELIB_PLATFORM_WINRT 1
  54. #else
  55. #define BASELIB_PLATFORM_WINDOWS 1
  56. #endif
  57. #elif defined(__QNX__)
  58. #define BASELIB_PLATFORM_QNX 1
  59. #endif