SCsub 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_util.cpp",
  11. "spirv_cross.cpp",
  12. "spirv_parser.cpp",
  13. "spirv_msl.cpp",
  14. "spirv_reflect.cpp",
  15. "spirv_glsl.cpp",
  16. "spirv_cross_parsed_ir.cpp",
  17. ]
  18. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  19. env_metal.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"])
  20. # Must enable exceptions for SPIRV-Cross; otherwise, it will abort the process on errors.
  21. if "-fno-exceptions" in env_metal["CXXFLAGS"]:
  22. env_metal["CXXFLAGS"].remove("-fno-exceptions")
  23. env_metal.Append(CXXFLAGS=["-fexceptions"])
  24. env_thirdparty = env_metal.Clone()
  25. env_thirdparty.disable_warnings()
  26. env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
  27. env_metal.drivers_sources += thirdparty_obj
  28. # Enable C++20 for the Objective-C++ Metal code, which uses C++20 concepts.
  29. if "-std=gnu++17" in env_metal["CXXFLAGS"]:
  30. env_metal["CXXFLAGS"].remove("-std=gnu++17")
  31. env_metal.Append(CXXFLAGS=["-std=c++20"])
  32. # Driver source files
  33. driver_obj = []
  34. env_metal.add_source_files(driver_obj, "*.mm")
  35. env.drivers_sources += driver_obj
  36. # Needed to force rebuilding the driver files when the thirdparty library is updated.
  37. env.Depends(driver_obj, thirdparty_obj)