PlatformDetection.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_VISION)
  22. #define TARGET_OS_VISION 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_VISION
  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(__OHOS__)
  44. #define BASELIB_PLATFORM_OPENHARMONY 1
  45. #elif defined(EMBEDDED_LINUX)
  46. #define BASELIB_PLATFORM_EMBEDDED_LINUX 1
  47. #elif defined(ARM_LINUX)
  48. #define BASELIB_PLATFORM_ARM_LINUX 1
  49. #else
  50. #define BASELIB_PLATFORM_LINUX 1
  51. #endif
  52. #elif defined(_WIN32) || defined(__WIN32__)
  53. #include <winapifamily.h>
  54. #if (defined(WINAPI_FAMILY_GAMES) && (WINAPI_FAMILY == WINAPI_FAMILY_GAMES))
  55. #define BASELIB_PLATFORM_WINDOWSGAMES 1
  56. #elif WINAPI_FAMILY == WINAPI_FAMILY_APP
  57. #define BASELIB_PLATFORM_WINRT 1
  58. #else
  59. #define BASELIB_PLATFORM_WINDOWS 1
  60. #endif
  61. #elif defined(__QNX__)
  62. #define BASELIB_PLATFORM_QNX 1
  63. #endif