SCsub 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. env_metal = env.Clone()
  5. # Thirdparty source files
  6. thirdparty_obj = []
  7. thirdparty_dir = "#thirdparty/spirv-cross/"
  8. thirdparty_sources = [
  9. "spirv_cfg.cpp",
  10. "spirv_cross.cpp",
  11. "spirv_parser.cpp",
  12. "spirv_msl.cpp",
  13. "spirv_reflect.cpp",
  14. "spirv_glsl.cpp",
  15. "spirv_cross_parsed_ir.cpp",
  16. ]
  17. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  18. env_metal.Prepend(CPPEXTPATH=[thirdparty_dir, thirdparty_dir + "/include"])
  19. # Must enable exceptions for SPIRV-Cross; otherwise, it will abort the process on errors.
  20. if "-fno-exceptions" in env_metal["CXXFLAGS"]:
  21. env_metal["CXXFLAGS"].remove("-fno-exceptions")
  22. env_metal.Append(CXXFLAGS=["-fexceptions"])
  23. env_thirdparty = env_metal.Clone()
  24. env_thirdparty.disable_warnings()
  25. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  26. env_metal.drivers_sources += thirdparty_obj
  27. # Enable C++20 for the Objective-C++ Metal code, which uses C++20 concepts.
  28. if "-std=gnu++17" in env_metal["CXXFLAGS"]:
  29. env_metal["CXXFLAGS"].remove("-std=gnu++17")
  30. env_metal.Append(CXXFLAGS=["-std=c++20"])
  31. # Enable module support
  32. env_metal.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])
  33. # Driver source files
  34. driver_obj = []
  35. env_metal.add_source_files(driver_obj, "*.mm")
  36. env.drivers_sources += driver_obj
  37. # Needed to force rebuilding the driver files when the thirdparty library is updated.
  38. env.Depends(driver_obj, thirdparty_obj)