FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: Batch wrappers generation  (Read 1781 times)

srdan

  • Newbie
  • Posts: 2
    • View Profile
Batch wrappers generation
« on: August 21, 2013, 03:24:05 pm »

Hi!

I'm wondering that, do you have any public batch file for generating the (python) wrappers?
I'm trying to generate java wrappers. It would be nice, if i could keep the package structure, and automatize the wrapper generating.

Thanks for your help
Logged

helios

  • Developer
  • Jr. Member
  • *
  • Posts: 61
    • View Profile
Re: Batch wrappers generation
« Reply #1 on: August 22, 2013, 11:44:31 am »

Hi srdan,
we use SWIG for wrapper generating. If you take a look at our sources you'll see beside .cpp and .h the .i files. These are used by SWIG to create the wrappers.
I've not tried it yet but SWIG have already support for java. http://www.swig.org/Doc1.3/Java.html

Please keep us up to date :)
Logged

srdan

  • Newbie
  • Posts: 2
    • View Profile
Re: Batch wrappers generation
« Reply #2 on: August 23, 2013, 09:00:19 am »

Hello helios,

thank you for your answer.
I went through your wiki pages, so i know that you are using SWIG, thats why I try to generate the java wrappers :)

My question is about a (public) script, which you use to generate the python wrappers from the .i headers. As i see eg the build_engine.bat, maybe you have a generate_python_wrappers.bat, so I don't need to write my own.  ;D

But maybe i can start from this:
https://github.com/FellowTraveler/Open-Transactions/blob/master/swig/buildwrappers.bat

thanks
Logged

vtchill

  • Developer
  • Full Member
  • *
  • Posts: 206
    • View Profile
Re: Batch wrappers generation
« Reply #3 on: August 23, 2013, 02:41:40 pm »

Hey srdan and welcome to the fife community.

The generation of the swig wrappers is built into the SCons build system. The SCons build script can optionally only build the swig wrappers if you tell it to.

So if you don't want to rebuild all of FIFE and just want to generate the SWIG wrappers you would do this:
command line: scons fife-swig

On windows there is also a file update_swig_wrappers.bat which does exactly this.

However this command only generates python bindings as that is all FIFE officially supports.

If you want to attempt generating bindings in another language you will need to look here:
https://github.com/fifengine/fifengine/blob/master/engine/SConscript#L253

Here is the code:
Code: [Select]
pythonext = env.PythonExtensions(target = [os.path.join('swigwrappers', 'python' ,'fife_wrap.cc'),
   os.path.join('swigwrappers', 'python' ,'fife_wrap.h'),
   os.path.join('python', 'fife', 'fife.py')],
   source = os.path.join('swigwrappers', 'python' ,'fife.i'),
   SWIGFLAGS=['-python','-c++','-w511', '-w473', '-w404'],
   SWIGPATH='core',
   SWIGOUTDIR=Dir('#/engine/python/fife').srcnode().path)

The important parts are the swig flags that are being passed and the files fife.i. You could try taking this code and changing -python to -java and maybe a couple other changes to see if you can get the correct swig call to generate java bindings.
Logged