I am trying to write an SCons script to build lua/embed3 example distributed with swig. Build instructions by makefile as follows:
swig -c++ -lua -external-runtime swigluarun.h
swig -c++ -lua -module example -o example_wrap.cpp example.i
g++ -o embed3 embe开发者_如何学运维d3.cpp example_wrap.cpp example.cpp \
-llua5.1 -I/usr/include/lua5.1
In Scons wiki, it's said that Scons has builtin swig support. Adding '.i' file among sources should do the job, however i am unable to find any detailed description about how can this script can be implemented.
Following script builds lua/simple project under swig examples. However, i am unable to find how to execute first swig directive given in my question. Thanks for reply.
env = Environment()
env.Append( SWIGFLAGS = '-lua' )
env.Append( CPPPATH = '/usr/include/lua5.1' )
env.Append( LIBS = 'lua5.1' )
env.SharedLibrary( target = 'example.so',
source = ['example.c', 'example.i' ], SHLIBPREFIX='' )
Thanks in advance.
Did you try/see this example script:
import distutils.sysconfig
env = Environment(SWIGFLAGS=['-python'],
CPPPATH=[distutils.sysconfig.get_python_inc()],
SHLIBPREFIX="")
env.SharedLibrary('_example.so', ['example.c', 'example.i'])
Some more interesting details are in this blog post.
Thanks to Eli's guidance, this is only way i could find to implement script. Any improvements are welcome.
env = Environment()
swigCmdLine = 'swig -c++ -lua -external-runtime swigluarun.h'
swigDefs = env.Command( 'swigluarun.h', '', swigCmdLine )
env.Depends( 'embed3', swigDefs )
env.Append( SWIGFLAGS = '-c++ -lua' )
env.Append( CPPPATH = '/usr/include/lua5.1' )
env.Append( LIBS = 'lua5.1' )
env.Program( 'embed3', ['embed3.cpp', 'example.cpp', 'example.i' ] )
Note: I am working on Ubuntu 9.10, swig-1.3.36, and scons 1.3.0.
精彩评论