From: Luigi Ballabio Date: 2002-01-16T20:52:10+09:00 Subject: Re: Swig Ruby documentation mods. At 11:09 AM 1/16/02 +0000, Hugh Sasse Staff Elec Eng wrote: >On Wed, 16 Jan 2002, Luigi Ballabio wrote: > > >* if you don't use -module in the swig -ruby command then swig > > > complains. This is probably always correct, but needs mentioning. > > > > Are you sure you are including the %module directive in your .i file? > > I'm not using -module and SWIG doesn't complain. > >I'm not using a .i file -- I'm using the fact that swig -ruby example.c >will generally work, as described elsewhere in the docs. Oh, I see. Then I agree: SWIG is correct in complaining, but this needs mentioning. > > >* It is not clear what should be done about integrating several C > > > functions into the same module. Does this depend on one writing a .i > > > file to connect them together? How? > > > > - I write a file mymodule.i containing: > > > > %module MyModule > > %include somefuncs.i > > %include someotherfuncs.i > > > > - by running SWIG on the latter file, all functions from the two original > > ones will be exported in MyModule. > >Will it produce one "%s_wrap.c" or two? Just one. > > If you want to get fancy, you can compare the modification times of > > MyModule.i and mymodule_wrap.cpp and run swig only when needed > >Yes, that sort of thing would work, but since extconf is supposed to be >used to write a makefile, it seems a bit much to re-implement make >inside it! :-) I see your point. Ok, how about: require 'mkmf' require 'ftools' # create the wrapper file if it doesn't exist yet (i.e., first extconf run) # since it is needed in order to create a correct makefile system('swig -ruby MyModule.i') unless File.exists? "mymodule_wrap.cpp" # create the makefile create_makefile('MyModule') # add the target to the makefile makefile = File.new("Makefile","a") # open in append mode makefile << "\n" makefile << "mymodule_wrap.cpp: MyModule.i\n" makefile << "\tswig -ruby MyModule.i\n" makefile.close # Done. Now the makefile will do the job as expected. Again, I didn't test the above. Bye, Luigi