-
Notifications
You must be signed in to change notification settings - Fork 52
Language Hooks : C# SWIG Bindings
#Introduction
BioGears now supports C# Language hooks through the use of SWIG Bindings Generator. (http://www.swig.org/). This page details how to build SWIG Bindings on Windows based platforms. The initial procedure will be the same on all platforms, but you will need to ensure you have a C# compiler and runtime environment supported by CMAKE to build the resulting project
CMAKE controls the building of SWING bindings through the use of
Name | Note |
---|---|
Biogears_BUILD_SWIG_BINDINGS | Turns on detection of SWIG and language support |
Biogears_BUILD_SWIG_CSHARP_BINDINGS | When SWIG is found and CHARP development environment exist this will be true and bindings automatically built. |
We plan to add support for RUST and Python using our existing SWIG Template files. Some work is needed to make sure that no CSHARP specific directives are applied to the other languages, but as support for other languages grow additional CMake flags will allow you to enable and disable the binding outputs of each language.
The Simplified Wrapper and Interface Generator (SWIG) is an open source project that provides a cross language interface code generator for a multitude of languages based off a SWIG template language. SWIG templates reference C/C++ files directly reducing the amount of code maintenance needed to keep bindings update and eliminating the need to write boiler plate code when providing cross language hooks. The BioGears team can not thank the SWIG team enough for this project please check it out.
You can obtain SWIG as source or binaries in a number of ways http://www.swig.org/download.html. BioGears currently requires a version of the 4.X line to support all features. As CMake has native support for generating SWIG bindings the implementation of our bindings is fairly straight forward provided CMake can detect the requirements for the target language and the SWIG code generator.
#Example installation on Ubuntu 20.04
sudo apt install swig
#Example installation on MacOS using Brew
brew install swig
#For Windows simply download the pre built binaries and extract SWIG.exe and Libs in a bin directly CMAKE Can find.
http://www.swig.org/download.html
These instructions assume you have already built BioGears and would like to enable SWIG bindings for the first time. If you do not know how to build BioGears please refer to our build instruction pages for your OS.