import libtbx.load_env
import os, sys

Import("env_base", "env_etc")

env_etc.simtbx_dist = libtbx.env.dist_path("simtbx")
env_etc.simtbx_include = os.path.dirname(env_etc.simtbx_dist)
env_etc.simtbx_common_includes = [
  env_etc.libtbx_include,
  env_etc.scitbx_include,
  env_etc.simtbx_include,
  env_etc.boost_adaptbx_include,
  env_etc.boost_include,
  os.path.dirname(libtbx.env.find_in_repositories(
    relative_path="tbxx", optional=False)),
  env_etc.dxtbx_include,
]

if not env_etc.no_boost_python:
  Import("env_no_includes_boost_python_ext")
  env_simtbx = env_no_includes_boost_python_ext.Clone()

  env_etc.include_registry.append(
    env=env_simtbx,
    paths=env_etc.simtbx_common_includes + [env_etc.python_include])
  env_simtbx.Append(LIBS=env_etc.libm +
    ["scitbx_boost_python",
     env_etc.boost_python_lib,
     "cctbx"])
  env_etc.enable_more_warnings(env=env_simtbx)
  env_simtbx.SConscript("nanoBragg/SConscript",exports={ 'env' : env_simtbx })
  if libtbx.env.build_options.enable_cxx11 and sys.platform != 'win32':
      env_simtbx.SConscript("diffBragg/SConscript", exports="env_simtbx")
  env_simtbx.SConscript("gpu/SConscript",exports={ 'env' : env_simtbx })
  env_simtbx.SConscript("pixel/SConscript",exports={ 'env' : env_simtbx })

  # only build kokkos on linux and if kokkos is enabled
  if sys.platform.startswith('linux') and env_etc.enable_kokkos:
    env_simtbx.SConscript("kokkos/SConscript",exports={ 'env' : env_simtbx })
