SCsub 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. Import("env_modules")
  5. env_raycast = env_modules.Clone()
  6. # Thirdparty source files
  7. thirdparty_obj = []
  8. if env["builtin_embree"]:
  9. thirdparty_dir = "#thirdparty/embree/"
  10. embree_src = [
  11. "common/sys/sysinfo.cpp",
  12. "common/sys/alloc.cpp",
  13. "common/sys/estring.cpp",
  14. "common/sys/filename.cpp",
  15. "common/sys/library.cpp",
  16. "common/sys/thread.cpp",
  17. "common/sys/regression.cpp",
  18. "common/sys/mutex.cpp",
  19. "common/sys/condition.cpp",
  20. "common/sys/barrier.cpp",
  21. "common/math/constants.cpp",
  22. "common/simd/sse.cpp",
  23. "common/lexers/stringstream.cpp",
  24. "common/lexers/tokenstream.cpp",
  25. "common/tasking/taskschedulerinternal.cpp",
  26. "kernels/common/device.cpp",
  27. "kernels/common/stat.cpp",
  28. "kernels/common/acceln.cpp",
  29. "kernels/common/accelset.cpp",
  30. "kernels/common/state.cpp",
  31. "kernels/common/rtcore.cpp",
  32. "kernels/common/rtcore_builder.cpp",
  33. "kernels/common/scene.cpp",
  34. "kernels/common/scene_verify.cpp",
  35. "kernels/common/alloc.cpp",
  36. "kernels/common/geometry.cpp",
  37. "kernels/common/scene_triangle_mesh.cpp",
  38. "kernels/geometry/primitive4.cpp",
  39. "kernels/builders/primrefgen.cpp",
  40. "kernels/bvh/bvh.cpp",
  41. "kernels/bvh/bvh_statistics.cpp",
  42. "kernels/bvh/bvh4_factory.cpp",
  43. "kernels/bvh/bvh8_factory.cpp",
  44. "kernels/bvh/bvh_collider.cpp",
  45. "kernels/bvh/bvh_rotate.cpp",
  46. "kernels/bvh/bvh_refit.cpp",
  47. "kernels/bvh/bvh_builder.cpp",
  48. "kernels/bvh/bvh_builder_morton.cpp",
  49. "kernels/bvh/bvh_builder_sah.cpp",
  50. "kernels/bvh/bvh_builder_sah_spatial.cpp",
  51. "kernels/bvh/bvh_builder_sah_mb.cpp",
  52. "kernels/bvh/bvh_builder_twolevel.cpp",
  53. "kernels/bvh/bvh_intersector1_bvh4.cpp",
  54. "kernels/bvh/bvh_intersector_hybrid4_bvh4.cpp",
  55. ]
  56. thirdparty_sources = [thirdparty_dir + file for file in embree_src]
  57. env_raycast.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "include"])
  58. env_raycast.Append(CPPDEFINES=["EMBREE_TARGET_SSE2", "EMBREE_LOWEST_ISA", "TASKING_INTERNAL"])
  59. env_raycast.AppendUnique(CPPDEFINES=["NDEBUG"]) # No assert() even in debug builds.
  60. if not env.msvc:
  61. if env["arch"] in ["x86_64", "x86_32"]:
  62. env_raycast.Append(CCFLAGS=["-msse2", "-mxsave"])
  63. if env["platform"] == "windows":
  64. env_raycast.Append(CCFLAGS=["-mstackrealign"])
  65. if env["platform"] == "windows":
  66. if env.msvc:
  67. env.Append(LINKFLAGS=["psapi.lib"])
  68. else:
  69. env.Append(LIBS=["psapi"])
  70. if env.msvc: # Disable bogus warning about intentional struct padding.
  71. env_raycast.Append(CCFLAGS=["/wd4324"])
  72. env_thirdparty = env_raycast.Clone()
  73. env_thirdparty.force_optimization_on_debug()
  74. env_thirdparty.disable_warnings()
  75. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  76. if env["arch"] != "x86_64" or env.msvc:
  77. # Embree needs those, it will automatically use SSE2NEON in ARM
  78. env_thirdparty.Append(CPPDEFINES=["__SSE2__", "__SSE__"])
  79. if env["platform"] == "web":
  80. env_thirdparty.Append(CXXFLAGS=["-msimd128"])
  81. if not env.msvc:
  82. # Flags synced with upstream gnu.cmake.
  83. if env["arch"] == "arm64" and env["platform"] == "linuxbsd" and not env["use_llvm"]:
  84. env_thirdparty.Append(CXXFLAGS=["-flax-vector-conversions"])
  85. env_thirdparty.Append(
  86. CXXFLAGS=[
  87. "-fno-strict-overflow",
  88. "-fno-delete-null-pointer-checks",
  89. "-fwrapv",
  90. "-fsigned-char",
  91. "-fno-strict-aliasing",
  92. "-fno-tree-vectorize",
  93. "-fvisibility=hidden",
  94. "-fvisibility-inlines-hidden",
  95. ]
  96. )
  97. env.modules_sources += thirdparty_obj
  98. # Godot source files
  99. module_obj = []
  100. env_raycast.add_source_files(module_obj, "*.cpp")
  101. env.modules_sources += module_obj
  102. # Needed to force rebuilding the module files when the thirdparty library is updated.
  103. env.Depends(module_obj, thirdparty_obj)