| 
									
										
										
										
											2021-04-20 18:40:24 +02:00
										 |  |  | #!/usr/bin/env python | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Import("env") | 
					
						
							|  |  |  | Import("env_modules") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  | env_raycast = env_modules.Clone() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Thirdparty source files | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | thirdparty_obj = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if env["builtin_embree"]: | 
					
						
							| 
									
										
										
										
											2021-05-20 12:49:33 +02:00
										 |  |  |     thirdparty_dir = "#thirdparty/embree/" | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     embree_src = [ | 
					
						
							|  |  |  |         "common/sys/sysinfo.cpp", | 
					
						
							|  |  |  |         "common/sys/alloc.cpp", | 
					
						
							|  |  |  |         "common/sys/filename.cpp", | 
					
						
							|  |  |  |         "common/sys/library.cpp", | 
					
						
							|  |  |  |         "common/sys/thread.cpp", | 
					
						
							|  |  |  |         "common/sys/string.cpp", | 
					
						
							|  |  |  |         "common/sys/regression.cpp", | 
					
						
							|  |  |  |         "common/sys/mutex.cpp", | 
					
						
							|  |  |  |         "common/sys/condition.cpp", | 
					
						
							|  |  |  |         "common/sys/barrier.cpp", | 
					
						
							|  |  |  |         "common/math/constants.cpp", | 
					
						
							|  |  |  |         "common/simd/sse.cpp", | 
					
						
							|  |  |  |         "common/lexers/stringstream.cpp", | 
					
						
							|  |  |  |         "common/lexers/tokenstream.cpp", | 
					
						
							|  |  |  |         "common/tasking/taskschedulerinternal.cpp", | 
					
						
							|  |  |  |         "kernels/common/device.cpp", | 
					
						
							|  |  |  |         "kernels/common/stat.cpp", | 
					
						
							|  |  |  |         "kernels/common/acceln.cpp", | 
					
						
							|  |  |  |         "kernels/common/accelset.cpp", | 
					
						
							|  |  |  |         "kernels/common/state.cpp", | 
					
						
							|  |  |  |         "kernels/common/rtcore.cpp", | 
					
						
							|  |  |  |         "kernels/common/rtcore_builder.cpp", | 
					
						
							|  |  |  |         "kernels/common/scene.cpp", | 
					
						
							|  |  |  |         "kernels/common/alloc.cpp", | 
					
						
							|  |  |  |         "kernels/common/geometry.cpp", | 
					
						
							|  |  |  |         "kernels/common/scene_triangle_mesh.cpp", | 
					
						
							|  |  |  |         "kernels/geometry/primitive4.cpp", | 
					
						
							|  |  |  |         "kernels/builders/primrefgen.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_statistics.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh4_factory.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh8_factory.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_collider.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_rotate.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_refit.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_builder.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_builder_morton.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_builder_sah.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_builder_sah_spatial.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_builder_sah_mb.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_builder_twolevel.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_intersector1_bvh4.cpp", | 
					
						
							| 
									
										
										
										
											2021-09-13 15:05:21 +02:00
										 |  |  |         "kernels/bvh/bvh_intersector_hybrid4_bvh4.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_intersector_stream_bvh4.cpp", | 
					
						
							|  |  |  |         "kernels/bvh/bvh_intersector_stream_filters.cpp", | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  |     ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     thirdparty_sources = [thirdparty_dir + file for file in embree_src] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     env_raycast.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "include"]) | 
					
						
							| 
									
										
										
										
											2022-09-23 14:49:11 +02:00
										 |  |  |     env_raycast.Append(CPPDEFINES=["EMBREE_TARGET_SSE2", "EMBREE_LOWEST_ISA", "TASKING_INTERNAL"]) | 
					
						
							|  |  |  |     env_raycast.AppendUnique(CPPDEFINES=["NDEBUG"])  # No assert() even in debug builds. | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if not env.msvc: | 
					
						
							| 
									
										
										
										
											2022-11-25 14:48:29 +01:00
										 |  |  |         if env["arch"] in ["x86_64", "x86_32"]: | 
					
						
							| 
									
										
										
										
											2022-12-15 13:38:27 +01:00
										 |  |  |             env_raycast.Append(CCFLAGS=["-msse2", "-mxsave"]) | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if env["platform"] == "windows": | 
					
						
							| 
									
										
										
										
											2022-12-15 13:38:27 +01:00
										 |  |  |             env_raycast.Append(CCFLAGS=["-mstackrealign"]) | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 18:40:24 +02:00
										 |  |  |     if env["platform"] == "windows": | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  |         if env.msvc: | 
					
						
							|  |  |  |             env.Append(LINKFLAGS=["psapi.lib"]) | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             env.Append(LIBS=["psapi"]) | 
					
						
							| 
									
										
										
										
											2021-04-20 18:40:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-28 16:43:09 +02:00
										 |  |  |     if env.msvc:  # Disable bogus warning about intentional struct padding. | 
					
						
							|  |  |  |         env_raycast.Append(CCFLAGS=["/wd4324"]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  |     env_thirdparty = env_raycast.Clone() | 
					
						
							| 
									
										
										
										
											2021-09-28 11:59:56 +02:00
										 |  |  |     env_thirdparty.force_optimization_on_debug() | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  |     env_thirdparty.disable_warnings() | 
					
						
							|  |  |  |     env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources) | 
					
						
							| 
									
										
										
										
											2021-05-20 12:49:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-25 14:48:29 +01:00
										 |  |  |     if env["arch"] != "x86_64" or env.msvc: | 
					
						
							| 
									
										
										
										
											2021-05-20 12:49:33 +02:00
										 |  |  |         # Embree needs those, it will automatically use SSE2NEON in ARM | 
					
						
							|  |  |  |         env_thirdparty.Append(CPPDEFINES=["__SSE2__", "__SSE__"]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-25 14:48:29 +01:00
										 |  |  |     if env["platform"] == "web": | 
					
						
							| 
									
										
										
										
											2022-12-15 13:38:27 +01:00
										 |  |  |         env_thirdparty.Append(CXXFLAGS=["-msimd128"]) | 
					
						
							| 
									
										
										
										
											2022-11-25 14:48:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-30 01:53:19 +02:00
										 |  |  |     if not env.msvc: | 
					
						
							| 
									
										
										
										
											2022-12-15 13:38:27 +01:00
										 |  |  |         # Flags synced with upstream gnu.cmake. | 
					
						
							| 
									
										
										
										
											2022-12-26 20:31:25 +00:00
										 |  |  |         if env["arch"] == "arm64" and env["platform"] == "linuxbsd" and not env["use_llvm"]: | 
					
						
							| 
									
										
										
										
											2022-12-15 13:38:27 +01:00
										 |  |  |             env_thirdparty.Append(CXXFLAGS=["-flax-vector-conversions"]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-30 01:53:19 +02:00
										 |  |  |         env_thirdparty.Append( | 
					
						
							| 
									
										
										
										
											2022-12-15 13:38:27 +01:00
										 |  |  |             CXXFLAGS=[ | 
					
						
							| 
									
										
										
										
											2021-09-30 01:53:19 +02:00
										 |  |  |                 "-fno-strict-overflow", | 
					
						
							|  |  |  |                 "-fno-delete-null-pointer-checks", | 
					
						
							|  |  |  |                 "-fwrapv", | 
					
						
							|  |  |  |                 "-fsigned-char", | 
					
						
							|  |  |  |                 "-fno-strict-aliasing", | 
					
						
							|  |  |  |                 "-fno-tree-vectorize", | 
					
						
							|  |  |  |                 "-fvisibility=hidden", | 
					
						
							|  |  |  |                 "-fvisibility-inlines-hidden", | 
					
						
							|  |  |  |             ] | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  |     env.modules_sources += thirdparty_obj | 
					
						
							| 
									
										
										
										
											2021-04-20 18:40:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  | # Godot source files | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module_obj = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | env_raycast.add_source_files(module_obj, "*.cpp") | 
					
						
							|  |  |  | env.modules_sources += module_obj | 
					
						
							| 
									
										
										
										
											2021-04-20 18:40:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-04 12:06:54 +02:00
										 |  |  | # Needed to force rebuilding the module files when the thirdparty library is updated. | 
					
						
							|  |  |  | env.Depends(module_obj, thirdparty_obj) |