import numpy as np
import os
from SCons.Script import Clean

Import('env')

# make sure numpy headers are available
env.AppendUnique(CPPPATH=[np.get_include()])

# configure the boost_python library, which may have different extensions
if not (GetOption('clean') or env.GetOption('help')):
    SConscript('SConscript.configure')

if env['PLATFORM'] == 'win32':
    if env['profile']:
        print("Warning: Windows profiling is not enabled; skipping /Gh")
else:
    if env['profile']:
        env.AppendUnique(CCFLAGS='-pg')
        env.AppendUnique(LINKFLAGS='-pg')

# python extension module
module_nodes = env.SharedLibrary(
    '_pyobjcryst',
    Glob('*.cpp'),
    SHLIBPREFIX='',
    SHLIBSUFFIX = '.pyd' if env['PLATFORM']=='win32' else '.so')

ext_module = module_nodes[0]
installed = env.Install(Dir('#/src/pyobjcryst'), ext_module)

# run `scons develop` to install the extension in development mode
dev = Alias('dev', installed)
AlwaysBuild(dev)


# run `scons test` to run the tests
env['ENV']['PYTHONPATH'] = Dir('#').abspath + os.sep + 'src'
test = env.Alias(
    'test',
    ['dev'],
    Action('pytest')
)
AlwaysBuild(test)

# default targets:
Default(module_nodes)

# clean up the build artifacts
Clean(module_nodes, installed)

# vim: ft=python
