Import('env')
import sys

# For the record: I know that scons supports swig. But it doesn't scan for #include in the generated code.
# 
# I have given up. Scons just can't get the dependencies right with those
# code generators. Let's give scons a "normal" c++ project to dependency-scan.
if env.Execute('swig -o mypaintlib_wrap.cpp -noproxydel -python -c++ mypaintlib.i'):
    Exit(1)
env.Execute('patch < mypaintlib_wrap.patch')
#env.Clean('.', 'mypaintlib_wrap.cc')
#env.Clean('.', 'mypaintlib.py')


# python extension module
src = 'mypaintlib_wrap.cpp'
if sys.platform == "win32": # there 's a better way to do this 
    module = env.LoadableModule('_mypaintlib', Split(src), SHLIBPREFIX="", SHLIBSUFFIX=".pyd")
else:
    module = env.LoadableModule('_mypaintlib', Split(src), SHLIBPREFIX="")

env.Command('strokemap_pb2.py', 'strokemap.proto', 'protoc --python_out=. lib/strokemap.proto')

Return('module')
