SCsub 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/usr/bin/env python
  2. Import("env")
  3. Import("env_modules")
  4. env_raycast = env_modules.Clone()
  5. # Thirdparty source files
  6. thirdparty_obj = []
  7. if env["builtin_embree"]:
  8. thirdparty_dir = "#thirdparty/embree/"
  9. embree_src = [
  10. "common/sys/sysinfo.cpp",
  11. "common/sys/alloc.cpp",
  12. "common/sys/filename.cpp",
  13. "common/sys/library.cpp",
  14. "common/sys/thread.cpp",
  15. "common/sys/string.cpp",
  16. "common/sys/regression.cpp",
  17. "common/sys/mutex.cpp",
  18. "common/sys/condition.cpp",
  19. "common/sys/barrier.cpp",
  20. "common/math/constants.cpp",
  21. "common/simd/sse.cpp",
  22. "common/lexers/stringstream.cpp",
  23. "common/lexers/tokenstream.cpp",
  24. "common/tasking/taskschedulerinternal.cpp",
  25. "kernels/common/device.cpp",
  26. "kernels/common/stat.cpp",
  27. "kernels/common/acceln.cpp",
  28. "kernels/common/accelset.cpp",
  29. "kernels/common/state.cpp",
  30. "kernels/common/rtcore.cpp",
  31. "kernels/common/rtcore_builder.cpp",
  32. "kernels/common/scene.cpp",
  33. "kernels/common/alloc.cpp",
  34. "kernels/common/geometry.cpp",
  35. "kernels/common/scene_triangle_mesh.cpp",
  36. "kernels/geometry/primitive4.cpp",
  37. "kernels/builders/primrefgen.cpp",
  38. "kernels/bvh/bvh.cpp",
  39. "kernels/bvh/bvh_statistics.cpp",
  40. "kernels/bvh/bvh4_factory.cpp",
  41. "kernels/bvh/bvh8_factory.cpp",
  42. "kernels/bvh/bvh_collider.cpp",
  43. "kernels/bvh/bvh_rotate.cpp",
  44. "kernels/bvh/bvh_refit.cpp",
  45. "kernels/bvh/bvh_builder.cpp",
  46. "kernels/bvh/bvh_builder_morton.cpp",
  47. "kernels/bvh/bvh_builder_sah.cpp",
  48. "kernels/bvh/bvh_builder_sah_spatial.cpp",
  49. "kernels/bvh/bvh_builder_sah_mb.cpp",
  50. "kernels/bvh/bvh_builder_twolevel.cpp",
  51. "kernels/bvh/bvh_intersector1_bvh4.cpp",
  52. "kernels/bvh/bvh_intersector_hybrid4_bvh4.cpp",
  53. "kernels/bvh/bvh_intersector_stream_bvh4.cpp",
  54. "kernels/bvh/bvh_intersector_stream_filters.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", "x86_64"]:
  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. env_thirdparty = env_raycast.Clone()
  71. env_thirdparty.force_optimization_on_debug()
  72. env_thirdparty.disable_warnings()
  73. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  74. if not env["arch"] in ["x86", "x86_64"] or env.msvc:
  75. # Embree needs those, it will automatically use SSE2NEON in ARM
  76. env_thirdparty.Append(CPPDEFINES=["__SSE2__", "__SSE__"])
  77. if not env.msvc:
  78. # Flags synced with upstream gnu.cmake.
  79. if env["arch"] == "arm64" and env["platform"] == "x11" and not env["use_llvm"]:
  80. env_thirdparty.Append(CXXFLAGS=["-flax-vector-conversions"])
  81. env_thirdparty.Append(
  82. CXXFLAGS=[
  83. "-fno-strict-overflow",
  84. "-fno-delete-null-pointer-checks",
  85. "-fwrapv",
  86. "-fsigned-char",
  87. "-fno-strict-aliasing",
  88. "-fno-tree-vectorize",
  89. "-fvisibility=hidden",
  90. "-fvisibility-inlines-hidden",
  91. ]
  92. )
  93. env.modules_sources += thirdparty_obj
  94. # Godot source files
  95. module_obj = []
  96. env_raycast.add_source_files(module_obj, "*.cpp")
  97. env.modules_sources += module_obj
  98. # Needed to force rebuilding the module files when the thirdparty library is updated.
  99. env.Depends(module_obj, thirdparty_obj)