The build system setup consists of five declarations in Meson. It should be doable in four, but Rust is a bit special. Ignoring the boilerplate the core business logic looks like this:
rustlib = static_library('func', 'func.rs')
py3_mod.extension_module('polysnake',
'polysnake.c',
'func.cpp',
'ffunc.f90',
link_with : rustlib,
dependencies : py3_dep)
The code is available on Github.
Compiling and running.
Compiling is done using the default Meson commands:meson build
ninja -C build
Once built the main script can be run with this command:
PYTHONPATH=build ./main.py
The script just calls into the module and prints the string it returns. The output looks like this:
Combining many languages is simple.
This line is created in C.
This line is created in FORTRAN.
This line is created in C++.
This line is created in Rust.
No comments:
Post a Comment