Import('qt_env')

env = qt_env.Clone()

env.EnableQtModules('Core', 'Gui')

env.AppendUnique(CPPDEFINES = 'PYTHONRUNNER_LIBRARY')

# suppress a few warnings caused by boost vs vc++ paranoia
# NB HAVE_ROUND causes a warning because it's defined in pythonrunner.cpp
env.AppendUnique(CPPDEFINES = [
    '_SCL_SECURE_NO_WARNINGS',
    'HAVE_ROUND'
])

#  QMAKE_CXXFLAGS += /Zi
#  QMAKE_LFLAGS += /DEBUG

env.RequireLibraries('uibase')

# AppendUnique appears not to work with QT4
env['CPPPATH'] += [
    '${BOOSTPATH}',
    '${PYTHONPATH}\\include',
]

env.AppendUnique(LIBS = [
    'python27',  # Could be done better
])

env.AppendUnique(LIBPATH = [
    '${PYTHONPATH}/libs',  # Could be done better
])

# We have to 'persuade' moc to generate certain other targets and inject them
# into the list of cpps
targets = env.AddExtraMoc(env.Glob('*.h'))

# pythontoolwrapper doesnt compile and isn't in the project file
cpp_files = [
    x for x in Glob('*.cpp') if x.name != 'pythontoolwrapper.cpp'
]

lib = env.SharedLibrary('pythonRunner', cpp_files + targets)

env.InstallModule(lib, 'plugins/data')

# However...
# we do need boost-python and pythonvv.dll and pythonvv.zip (though the last
# isn't needed to just bring up the module)
#env.Pseudo('install')
#env.Depends('install',
#            (env.Install('${INSTALL_PATH}', 'pyCfg.py'),
#             env.Install(os.path.join('${INSTALL_PATH}', 'data'),
#                         ( ui, rc, 'settings.json' )),
#             ))

res = env['QT_USED_MODULES']
Return('res')
