enso/docs/infrastructure/rust.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.2 KiB
Markdown
Raw Normal View History

2020-08-14 12:10:52 +03:00
---
layout: developer-doc
title: Rust
category: infrastructure
2020-08-28 14:03:09 +03:00
tags: [infrastructure, build, rust]
order: 4
2020-08-14 12:10:52 +03:00
---
# Rust
The Rust project is built using Cargo which manages dependencies between the
projects as well as external dependencies and allows for incremental
compilation. The build configuration is defined in
[`Cargo.toml`](../../Cargo.toml).
<!-- MarkdownTOC levels="2,3" autolink="true" -->
- [Shared Libraries](#shared-libraries)
<!-- /MarkdownTOC -->
# Java Native Interface
Although the entry point of the Enso project is a Java archive, it can still
make use of native libraries built in Rust trough the JVM foreign function
interface (FFI) named
[Java Native Interface](https://en.wikipedia.org/wiki/Java_Native_Interface)
(JNI).
In order to generate a shared library, the `Cargo.toml` needs to enable
compilation into a dynamic system library:
```
crate-type = ["cdylib"]
```
Invoking `cargo build` will then output the library into `target/rust/debug`
with the extension `.so` on Linux, `.dll` on Windows and `.dylib` on macOS.
Then, to be able to load the library by `System.loadLibrary("lib_name")`, the
Java application should be started with the option
2020-08-14 12:10:52 +03:00
`-Djava.library.path=path/to/lib_folder`.