SCsub 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. "timer/SDL_timer.c",
  85. ]
  86. # HIDAPI
  87. thirdparty_sources += [
  88. "hidapi/SDL_hidapi.c",
  89. "joystick/hidapi/SDL_hidapi_combined.c",
  90. "joystick/hidapi/SDL_hidapi_gamecube.c",
  91. "joystick/hidapi/SDL_hidapijoystick.c",
  92. "joystick/hidapi/SDL_hidapi_luna.c",
  93. "joystick/hidapi/SDL_hidapi_ps3.c",
  94. "joystick/hidapi/SDL_hidapi_ps4.c",
  95. "joystick/hidapi/SDL_hidapi_ps5.c",
  96. "joystick/hidapi/SDL_hidapi_rumble.c",
  97. "joystick/hidapi/SDL_hidapi_shield.c",
  98. "joystick/hidapi/SDL_hidapi_stadia.c",
  99. "joystick/hidapi/SDL_hidapi_steam.c",
  100. "joystick/hidapi/SDL_hidapi_steamdeck.c",
  101. "joystick/hidapi/SDL_hidapi_steam_hori.c",
  102. "joystick/hidapi/SDL_hidapi_switch.c",
  103. "joystick/hidapi/SDL_hidapi_wii.c",
  104. "joystick/hidapi/SDL_hidapi_xbox360.c",
  105. "joystick/hidapi/SDL_hidapi_xbox360w.c",
  106. "joystick/hidapi/SDL_hidapi_xboxone.c",
  107. ]
  108. # Platform specific sources.
  109. if env["platform"] == "linuxbsd":
  110. # TODO: Check support for BSD systems.
  111. env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_LINUX"])
  112. thirdparty_sources += [
  113. "core/linux/SDL_dbus.c",
  114. "core/linux/SDL_evdev.c",
  115. "core/linux/SDL_evdev_capabilities.c",
  116. "core/linux/SDL_evdev_kbd.c",
  117. "core/linux/SDL_threadprio.c",
  118. "core/linux/SDL_udev.c",
  119. "core/unix/SDL_appid.c",
  120. "core/unix/SDL_poll.c",
  121. "haptic/linux/SDL_syshaptic.c",
  122. "joystick/linux/SDL_sysjoystick.c",
  123. "loadso/dlopen/SDL_sysloadso.c",
  124. "thread/pthread/SDL_syscond.c",
  125. "thread/pthread/SDL_sysmutex.c",
  126. "thread/pthread/SDL_sysrwlock.c",
  127. "thread/pthread/SDL_syssem.c",
  128. "thread/pthread/SDL_systhread.c",
  129. "thread/pthread/SDL_systls.c",
  130. "timer/unix/SDL_systimer.c",
  131. ]
  132. env_sdl.Prepend(CPPPATH=[thirdparty_dir + "core/linux"])
  133. elif env["platform"] == "macos":
  134. env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_MACOS"])
  135. thirdparty_sources += [
  136. "core/unix/SDL_appid.c",
  137. "core/unix/SDL_poll.c",
  138. "haptic/darwin/SDL_syshaptic.c",
  139. "joystick/darwin/SDL_iokitjoystick.c",
  140. "joystick/apple/SDL_mfijoystick.m",
  141. "thread/pthread/SDL_syscond.c",
  142. "thread/pthread/SDL_sysmutex.c",
  143. "thread/pthread/SDL_sysrwlock.c",
  144. "thread/pthread/SDL_syssem.c",
  145. "thread/pthread/SDL_systhread.c",
  146. "thread/pthread/SDL_systls.c",
  147. "timer/unix/SDL_systimer.c",
  148. ]
  149. elif env["platform"] == "windows":
  150. env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_WINDOWS"])
  151. thirdparty_sources += [
  152. "core/windows/SDL_gameinput.c",
  153. "core/windows/SDL_hid.c",
  154. "core/windows/SDL_immdevice.c",
  155. "core/windows/SDL_windows.c",
  156. "core/windows/SDL_xinput.c",
  157. "core/windows/pch.c",
  158. "haptic/windows/SDL_dinputhaptic.c",
  159. "haptic/windows/SDL_windowshaptic.c",
  160. "joystick/windows/SDL_dinputjoystick.c",
  161. "joystick/windows/SDL_rawinputjoystick.c",
  162. "joystick/windows/SDL_windows_gaming_input.c",
  163. "joystick/windows/SDL_windowsjoystick.c",
  164. "joystick/windows/SDL_xinputjoystick.c",
  165. "thread/generic/SDL_syscond.c",
  166. "thread/generic/SDL_sysrwlock.c",
  167. "sensor/windows/SDL_windowssensor.c",
  168. "thread/windows/SDL_syscond_cv.c",
  169. "thread/windows/SDL_sysmutex.c",
  170. "thread/windows/SDL_sysrwlock_srw.c",
  171. "thread/windows/SDL_syssem.c",
  172. "thread/windows/SDL_systhread.c",
  173. "thread/windows/SDL_systls.c",
  174. "timer/windows/SDL_systimer.c",
  175. ]
  176. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  177. env_thirdparty = env_sdl.Clone()
  178. env_thirdparty.disable_warnings()
  179. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  180. env.drivers_sources += thirdparty_obj
  181. # Godot source files
  182. driver_obj = []
  183. env_sdl.add_source_files(driver_obj, "*.cpp")
  184. env.drivers_sources += driver_obj
  185. # Needed to force rebuilding the driver files when the thirdparty library is updated.
  186. env.Depends(driver_obj, thirdparty_obj)