Debian Codegraph @

SConscript

raw
1 import libtbx.load_env
2 import os
3 import platform
4 from libtbx.env_config import get_boost_library_with_python_version
5 from pathlib import Path
6
7 Import("env_etc")
8
9 env_etc.dials_dist = os.path.join(libtbx.env.dist_path("dials"), "src", "dials")
10 env_etc.dials_include = os.path.dirname(env_etc.dials_dist)
11 if not env_etc.no_boost_python and hasattr(env_etc, "boost_adaptbx_include"):
12 Import("env_no_includes_boost_python_ext")
13 env = env_no_includes_boost_python_ext.Clone()
14 env_etc.enable_more_warnings(env=env)
15
16 system_includes = [x for x in env_etc.conda_cpppath if x] if libtbx.env.build_options.use_conda else []
17 system_includes.append(str(Path(env_etc.scitbx_dist).parent))
18 env.Append(CXXFLAGS=[f"-isystem{x}" for x in system_includes])
19 env.Append(SHCXXFLAGS=[f"-isystem{x}" for x in system_includes])
20
21 include_paths = [
22 env_etc.libtbx_include,
23 env_etc.scitbx_include,
24 env_etc.cctbx_include,
25 env_etc.ccp4io_include,
26 env_etc.rstbx_include,
27 env_etc.boost_include,
28 env_etc.boost_adaptbx_include,
29 env_etc.python_include,
30 env_etc.dxtbx_include,
31 env_etc.dials_include,
32 ]
33
34 # Handle cctbx bootstrap builds that pull a fixed msgpack version into modules/
35 msgpack = Path(libtbx.env.dist_path("dials")).parent / "msgpack-3.1.1" / "include"
36 if msgpack.is_dir():
37 include_paths.append(str(msgpack))
38
39 if libtbx.env.build_options.use_conda:
40 boost_python = get_boost_library_with_python_version(
41 "boost_python", env_etc.conda_libpath
42 )
43 env.Append(LIBPATH=env_etc.conda_libpath)
44 include_paths.extend(env_etc.conda_cpppath)
45 else:
46 boost_python = "boost_python"
47 env_etc.include_registry.append(env=env, paths=include_paths)
48 env.Append(
49 LIBS=env_etc.libm
50 + ["scitbx_boost_python", boost_python, "boost_thread", "cctbx"],
51 )
52
53 # Fix the build environment so that it doesn't break on modern C++
54 for path in list(env["CPPPATH"]):
55 if "msvc9.0_include" in path:
56 env["CPPPATH"].remove(path)
57
58 # Fix compilation errors on windows, caused by function redefinition
59 # See: https://github.com/boostorg/system/issues/32#issuecomment-462912013
60 if env_etc.compiler == "win32_cl":
61 env.Append(CPPDEFINES="HAVE_SNPRINTF")
62
63 env.SConscript("src/dials/model/SConscript", exports={"env": env})
64 env.SConscript("src/dials/array_family/SConscript", exports={"env": env})
65 env.SConscript("src/dials/algorithms/SConscript", exports={"env": env})
66 env.SConscript("src/dials/pychef/SConscript", exports={"env": env})
67 env.SConscript("src/dials/viewer/SConscript", exports={"env": env})
68 # env.SConscript('src/dials/nexus/SConscript', exports={ 'env' : env })
69 env.SConscript("src/dials/util/SConscript", exports={"env": env})
70
71 autocomplete_scons = os.path.join(
72 libtbx.env.under_build(os.path.join("dials", "autocomplete")), "SConscript"
73 )
74 if not any(platform.win32_ver()) and os.path.isfile(autocomplete_scons):
75 env.SConscript(autocomplete_scons, exports={"env": env})
76
77 #
78 # NOTE: This must go at the bottom. The LIBS are replaced with an empty
79 # list. This is done because errors occur when building the tests if it
80 # isn't done. Replacing the libs afterwards still results in those errors.
81 #
82 env.SConscript("tests/SConscript", exports={"env": env})