CCPlatformConfig.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2017 Chukong Technologies
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef __BASE_CC_PLATFORM_CONFIG_H__
  23. #define __BASE_CC_PLATFORM_CONFIG_H__
  24. /// @cond DO_NOT_SHOW
  25. /**
  26. Config of cocos2d-x project, per target platform.
  27. THIS FILE MUST NOT INCLUDE ANY OTHER FILE
  28. */
  29. //////////////////////////////////////////////////////////////////////////
  30. // pre configure
  31. //////////////////////////////////////////////////////////////////////////
  32. // define supported target platform macro which CC uses.
  33. #define CC_PLATFORM_UNKNOWN 0
  34. #define CC_PLATFORM_IOS 1
  35. #define CC_PLATFORM_ANDROID 2
  36. #define CC_PLATFORM_WIN32 3
  37. #define CC_PLATFORM_MARMALADE 4
  38. #define CC_PLATFORM_LINUX 5
  39. #define CC_PLATFORM_BADA 6
  40. #define CC_PLATFORM_BLACKBERRY 7
  41. #define CC_PLATFORM_MAC 8
  42. #define CC_PLATFORM_NACL 9
  43. #define CC_PLATFORM_EMSCRIPTEN 10
  44. #define CC_PLATFORM_TIZEN 11
  45. #define CC_PLATFORM_QT5 12
  46. #define CC_PLATFORM_WINRT 13
  47. // Determine target platform by compile environment macro.
  48. #define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
  49. // Apple: Mac and iOS
  50. #if defined(__APPLE__) && !defined(ANDROID) // exclude android for binding generator.
  51. #include <TargetConditionals.h>
  52. #if TARGET_OS_IPHONE // TARGET_OS_IPHONE includes TARGET_OS_IOS TARGET_OS_TV and TARGET_OS_WATCH. see TargetConditionals.h
  53. #undef CC_TARGET_PLATFORM
  54. #define CC_TARGET_PLATFORM CC_PLATFORM_IOS
  55. #elif TARGET_OS_MAC
  56. #undef CC_TARGET_PLATFORM
  57. #define CC_TARGET_PLATFORM CC_PLATFORM_MAC
  58. #endif
  59. #endif
  60. // android
  61. #if defined(ANDROID)
  62. #undef CC_TARGET_PLATFORM
  63. #define CC_TARGET_PLATFORM CC_PLATFORM_ANDROID
  64. #endif
  65. // win32
  66. #if defined(_WIN32) && defined(_WINDOWS)
  67. #undef CC_TARGET_PLATFORM
  68. #define CC_TARGET_PLATFORM CC_PLATFORM_WIN32
  69. #endif
  70. // linux
  71. #if defined(LINUX) && !defined(__APPLE__)
  72. #undef CC_TARGET_PLATFORM
  73. #define CC_TARGET_PLATFORM CC_PLATFORM_LINUX
  74. #endif
  75. // marmalade
  76. #if defined(MARMALADE)
  77. #undef CC_TARGET_PLATFORM
  78. #define CC_TARGET_PLATFORM CC_PLATFORM_MARMALADE
  79. #endif
  80. // bada
  81. #if defined(SHP)
  82. #undef CC_TARGET_PLATFORM
  83. #define CC_TARGET_PLATFORM CC_PLATFORM_BADA
  84. #endif
  85. // qnx
  86. #if defined(__QNX__)
  87. #undef CC_TARGET_PLATFORM
  88. #define CC_TARGET_PLATFORM CC_PLATFORM_BLACKBERRY
  89. #endif
  90. // native client
  91. #if defined(__native_client__)
  92. #undef CC_TARGET_PLATFORM
  93. #define CC_TARGET_PLATFORM CC_PLATFORM_NACL
  94. #endif
  95. // Emscripten
  96. #if defined(EMSCRIPTEN)
  97. #undef CC_TARGET_PLATFORM
  98. #define CC_TARGET_PLATFORM CC_PLATFORM_EMSCRIPTEN
  99. #endif
  100. // tizen
  101. #if defined(TIZEN)
  102. #undef CC_TARGET_PLATFORM
  103. #define CC_TARGET_PLATFORM CC_PLATFORM_TIZEN
  104. #endif
  105. // qt5
  106. #if defined(CC_TARGET_QT5)
  107. #undef CC_TARGET_PLATFORM
  108. #define CC_TARGET_PLATFORM CC_PLATFORM_QT5
  109. #endif
  110. // WinRT (Windows 8.1 Store/Phone App)
  111. #if defined(WINRT)
  112. #undef CC_TARGET_PLATFORM
  113. #define CC_TARGET_PLATFORM CC_PLATFORM_WINRT
  114. #endif
  115. //////////////////////////////////////////////////////////////////////////
  116. // post configure
  117. //////////////////////////////////////////////////////////////////////////
  118. // check user set platform
  119. #if ! CC_TARGET_PLATFORM
  120. #error "Cannot recognize the target platform; are you targeting an unsupported platform?"
  121. #endif
  122. #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
  123. #ifndef __MINGW32__
  124. #pragma warning (disable:4127)
  125. #endif
  126. #endif // CC_PLATFORM_WIN32
  127. #if ((CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN))
  128. #define CC_PLATFORM_MOBILE
  129. #else
  130. #define CC_PLATFORM_PC
  131. #endif
  132. /// @endcond
  133. #endif // __BASE_CC_PLATFORM_CONFIG_H__