SConstruct 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import os
  2. import subprocess
  3. import sysconfig
  4. import numpy as np
  5. arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
  6. common = ''
  7. python_path = sysconfig.get_paths()['include']
  8. cpppath = [
  9. '#',
  10. '#rednose',
  11. '#rednose/examples/generated',
  12. '/usr/lib/include',
  13. python_path,
  14. np.get_include(),
  15. ]
  16. env = Environment(
  17. ENV=os.environ,
  18. CC='clang',
  19. CXX='clang++',
  20. CCFLAGS=[
  21. "-g",
  22. "-fPIC",
  23. "-O2",
  24. "-Werror=implicit-function-declaration",
  25. "-Werror=incompatible-pointer-types",
  26. "-Werror=int-conversion",
  27. "-Werror=return-type",
  28. "-Werror=format-extra-args",
  29. "-Wshadow",
  30. ],
  31. LIBPATH=["#rednose/examples/generated"],
  32. CFLAGS="-std=gnu11",
  33. CXXFLAGS="-std=c++1z",
  34. CPPPATH=cpppath,
  35. REDNOSE_ROOT=Dir("#").abspath,
  36. tools=["default", "cython", "rednose_filter"],
  37. )
  38. # Cython build enviroment
  39. envCython = env.Clone()
  40. envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-shadow", "-Wno-deprecated-declarations"]
  41. envCython["LIBS"] = []
  42. if arch == "Darwin":
  43. envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"]
  44. elif arch == "aarch64":
  45. envCython["LINKFLAGS"] = ["-shared"]
  46. envCython["LIBS"] = [os.path.basename(python_path)]
  47. else:
  48. envCython["LINKFLAGS"] = ["-pthread", "-shared"]
  49. Export('env', 'envCython', 'common')
  50. SConscript(['#rednose/SConscript'])
  51. SConscript(['#examples/SConscript'])