I’m currently exploring SWIG to facilitate wrapping around three C++ header files (file1.h, file2.h, file3.h). I’ve included these header files in my SWIG interface file using the %include
directive.
%include "file1.h"
%include "file2.h"
%include "file3.h"
Now, I want to organize the generated Java classes into different packages, with each package corresponding to one of the header files (file1.h, file2.h, file3.h). I tried using the %module directive along with the package option to achieve this:
%module(package = "a.b.f1") f1_wrap
%include "file1.h"
%module(package = "a.b.f2") f2_wrap
%include "file2.h"
%module(package = "a.b.f3") f3_wrap
%include "file3.h"
However, this approach didn’t seem to work as expected. The generated Java files didn’t include the desired package declaration (package "a.b.fxx")
.
I’ve found that using the -package command-line argument with SWIG works, but it requires splitting the code into three separate SWIG interface files (.i files), which isn’t ideal for my project’s organization.
Is there a way to achieve the desired package organization within a single SWIG interface file (.i file)? Is there an equivalent directive or option within SWIG that allows specifying package names directly within the interface file?