SCsub 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. env_sdl = env.Clone()
  5. # Thirdparty source files
  6. thirdparty_obj = []
  7. if env["builtin_sdl"]:
  8. thirdparty_dir = "#thirdparty/sdl/"
  9. # Use our own SDL_build_config_private.h.
  10. env_sdl.Prepend(CPPDEFINES=["SDL_PLATFORM_PRIVATE"])
  11. # Common sources.
  12. env_sdl.Prepend(
  13. CPPPATH=[
  14. thirdparty_dir,
  15. thirdparty_dir + "include",
  16. thirdparty_dir + "include/build_config",
  17. ".", # SDL_build_config_private.h
  18. ]
  19. )
  20. thirdparty_sources = [
  21. "SDL.c",
  22. "SDL_assert.c",
  23. "SDL_error.c",
  24. "SDL_guid.c",
  25. "SDL_hashtable.c",
  26. "SDL_hints.c",
  27. "SDL_list.c",
  28. "SDL_log.c",
  29. "SDL_properties.c",
  30. "SDL_utils.c",
  31. "atomic/SDL_atomic.c",
  32. "atomic/SDL_spinlock.c",
  33. "events/SDL_events.c",
  34. "events/SDL_eventwatch.c",
  35. "haptic/SDL_haptic.c",
  36. "io/SDL_iostream.c",
  37. "joystick/SDL_gamepad.c",
  38. "joystick/SDL_joystick.c",
  39. "joystick/SDL_steam_virtual_gamepad.c",
  40. "joystick/controller_type.c",
  41. "libm/e_atan2.c",
  42. "libm/e_exp.c",
  43. "libm/e_fmod.c",
  44. "libm/e_log.c",
  45. "libm/e_log10.c",
  46. "libm/e_pow.c",
  47. "libm/e_rem_pio2.c",
  48. "libm/e_sqrt.c",
  49. "libm/k_cos.c",
  50. "libm/k_rem_pio2.c",
  51. "libm/k_sin.c",
  52. "libm/k_tan.c",
  53. "libm/s_atan.c",
  54. "libm/s_copysign.c",
  55. "libm/s_cos.c",
  56. "libm/s_fabs.c",
  57. "libm/s_floor.c",
  58. "libm/s_isinf.c",
  59. "libm/s_isinff.c",
  60. "libm/s_isnan.c",
  61. "libm/s_isnanf.c",
  62. "libm/s_modf.c",
  63. "libm/s_scalbn.c",
  64. "libm/s_sin.c",
  65. "libm/s_tan.c",
  66. "sensor/SDL_sensor.c",
  67. "sensor/dummy/SDL_dummysensor.c",
  68. "stdlib/SDL_crc16.c",
  69. "stdlib/SDL_crc32.c",
  70. "stdlib/SDL_getenv.c",
  71. "stdlib/SDL_iconv.c",
  72. "stdlib/SDL_malloc.c",
  73. "stdlib/SDL_memcpy.c",
  74. "stdlib/SDL_memmove.c",
  75. "stdlib/SDL_memset.c",
  76. "stdlib/SDL_mslibc.c",
  77. "stdlib/SDL_murmur3.c",
  78. "stdlib/SDL_qsort.c",
  79. "stdlib/SDL_random.c",
  80. "stdlib/SDL_stdlib.c",
  81. "stdlib/SDL_string.c",
  82. "stdlib/SDL_strtokr.c",
  83. "thread/SDL_thread.c",
  84. "thread/generic/SDL_syscond.c",
  85. "thread/generic/SDL_sysrwlock.c",
  86. "thread/generic/SDL_systhread.c",
  87. "timer/SDL_timer.c",
  88. ]
  89. # HIDAPI
  90. thirdparty_sources += [
  91. "hidapi/SDL_hidapi.c",
  92. "joystick/hidapi/SDL_hidapi_combined.c",
  93. "joystick/hidapi/SDL_hidapi_gamecube.c",
  94. "joystick/hidapi/SDL_hidapijoystick.c",
  95. "joystick/hidapi/SDL_hidapi_luna.c",
  96. "joystick/hidapi/SDL_hidapi_ps3.c",
  97. "joystick/hidapi/SDL_hidapi_ps4.c",
  98. "joystick/hidapi/SDL_hidapi_ps5.c",
  99. "joystick/hidapi/SDL_hidapi_rumble.c",
  100. "joystick/hidapi/SDL_hidapi_shield.c",
  101. "joystick/hidapi/SDL_hidapi_stadia.c",
  102. "joystick/hidapi/SDL_hidapi_steam.c",
  103. "joystick/hidapi/SDL_hidapi_steamdeck.c",
  104. "joystick/hidapi/SDL_hidapi_steam_hori.c",
  105. "joystick/hidapi/SDL_hidapi_switch.c",
  106. "joystick/hidapi/SDL_hidapi_wii.c",
  107. "joystick/hidapi/SDL_hidapi_xbox360.c",
  108. "joystick/hidapi/SDL_hidapi_xbox360w.c",
  109. "joystick/hidapi/SDL_hidapi_xboxone.c",
  110. ]
  111. # Platform specific sources.
  112. if env["platform"] == "linuxbsd":
  113. # TODO: Check support for BSD systems.
  114. env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_LINUX"])
  115. thirdparty_sources += [
  116. "core/linux/SDL_dbus.c",
  117. "core/linux/SDL_evdev.c",
  118. "core/linux/SDL_evdev_capabilities.c",
  119. "core/linux/SDL_evdev_kbd.c",
  120. "core/linux/SDL_fcitx.c",
  121. "core/linux/SDL_ibus.c",
  122. "core/linux/SDL_ime.c",
  123. "core/linux/SDL_system_theme.c",
  124. "core/linux/SDL_threadprio.c",
  125. "core/linux/SDL_udev.c",
  126. "core/unix/SDL_appid.c",
  127. "core/unix/SDL_poll.c",
  128. "haptic/linux/SDL_syshaptic.c",
  129. "joystick/linux/SDL_sysjoystick.c",
  130. "loadso/dlopen/SDL_sysloadso.c",
  131. "thread/pthread/SDL_syscond.c",
  132. "thread/pthread/SDL_sysmutex.c",
  133. "thread/pthread/SDL_sysrwlock.c",
  134. "thread/pthread/SDL_syssem.c",
  135. "thread/pthread/SDL_systhread.c",
  136. "thread/pthread/SDL_systls.c",
  137. "timer/unix/SDL_systimer.c",
  138. ]
  139. elif env["platform"] == "macos":
  140. env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_MACOS"])
  141. thirdparty_sources += [
  142. "core/unix/SDL_appid.c",
  143. "core/unix/SDL_poll.c",
  144. "haptic/darwin/SDL_syshaptic.c",
  145. "joystick/darwin/SDL_iokitjoystick.c",
  146. "joystick/apple/SDL_mfijoystick.m",
  147. "thread/pthread/SDL_syscond.c",
  148. "thread/pthread/SDL_sysmutex.c",
  149. "thread/pthread/SDL_sysrwlock.c",
  150. "thread/pthread/SDL_syssem.c",
  151. "thread/pthread/SDL_systhread.c",
  152. "thread/pthread/SDL_systls.c",
  153. "timer/unix/SDL_systimer.c",
  154. ]
  155. elif env["platform"] == "windows":
  156. env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_WINDOWS"])
  157. thirdparty_sources += [
  158. "core/windows/SDL_gameinput.c",
  159. "core/windows/SDL_hid.c",
  160. "core/windows/SDL_immdevice.c",
  161. "core/windows/SDL_windows.c",
  162. "core/windows/SDL_xinput.c",
  163. "core/windows/pch.c",
  164. "haptic/windows/SDL_dinputhaptic.c",
  165. "haptic/windows/SDL_windowshaptic.c",
  166. "joystick/windows/SDL_dinputjoystick.c",
  167. "joystick/windows/SDL_rawinputjoystick.c",
  168. "joystick/windows/SDL_windows_gaming_input.c",
  169. "joystick/windows/SDL_windowsjoystick.c",
  170. "joystick/windows/SDL_xinputjoystick.c",
  171. "thread/windows/SDL_syscond_cv.c",
  172. "thread/windows/SDL_sysmutex.c",
  173. "thread/windows/SDL_sysrwlock_srw.c",
  174. "thread/windows/SDL_syssem.c",
  175. "thread/windows/SDL_systhread.c",
  176. "thread/windows/SDL_systls.c",
  177. "timer/windows/SDL_systimer.c",
  178. ]
  179. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  180. env_thirdparty = env_sdl.Clone()
  181. env_thirdparty.disable_warnings()
  182. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  183. env.drivers_sources += thirdparty_obj
  184. # Godot source files
  185. driver_obj = []
  186. env_sdl.add_source_files(driver_obj, "*.cpp")
  187. env.drivers_sources += driver_obj
  188. # Needed to force rebuilding the driver files when the thirdparty library is updated.
  189. env.Depends(driver_obj, thirdparty_obj)