gazebosim / gz-math

General purpose math library for robot applications.
https://gazebosim.org/libs/math
Apache License 2.0
54 stars 67 forks source link

Move SWIG files to a common folder #233

Open chapulina opened 3 years ago

chapulina commented 3 years ago

With the addition of Python interfaces, we now have partial support for 2 scripting languages: ruby and python. Each language was placed into a separate folder for organization purposes, but this means we're repeating the SWIG .i files across both directories, i.e.:

It would be nice to reduce duplication as much as possible. The strength of SWIG is the multi-language support, so we should strive to write a SWIG file once and get support for multiple languages automatically.

Desired behavior

Have a single SWIG file for each class, which can be reused across all languages.

Alternatives considered

Keep separate files and deal with the extra overhead.

Implementation suggestion

Move the SWIG files to src/swig and update CMake to get them from there.

Additional context

I see that the SWIG files are slightly different between both directories right now. I imagine there must be good reasons to have differences for each language. I haven't dug into this yet, but I'd hope that SWIG would offer a solution for that use case, maybe using conditionals according to the language?

chapulina commented 2 years ago

Since #354, the SWIG files have been removed from the python directory (which uses pybind11 now) and moved to the Ruby directory. So there's no more duplication until we decide to add SWIG wrappers for another language.

scpeters commented 2 years ago

Since #354, the SWIG files have been removed from the python directory (which uses pybind11 now) and moved to the Ruby directory. So there's no more duplication until we decide to add SWIG wrappers for another language.

this seems to be the case on the ign-math6 branch, but there are still multiple .i and _TEST.rb files in the src/ folder on the main branch: