Skip to content

Commit

Permalink
docs: Add a document on using Rust in Meson
Browse files Browse the repository at this point in the history
This is hardly complete, but it's a start.
  • Loading branch information
dcbaker committed Mar 4, 2022
1 parent d447d10 commit eb5fbfc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
56 changes: 56 additions & 0 deletions docs/markdown/Rust.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: Rust
short-description: Working with Rust in Meson
---

# Using Rust with Meson

## Mixing Rust and non-Rust sources

Meson currently does not support creating a single target with Rust and non Rust
sources mixed together, therefore one must compile multiple libraries and link
them.

```meson
rust_lib = static_library(
'rust_lib',
sources : 'lib.rs',
...
)
c_lib = static_library(
'c_lib',
sources : 'lib.c',
link_with : rust_lib,
)
```
This is an implementation detail of Meson, and is subject to change in the future.

## Mixing Generated and Static sources

*Note* This feature was added in 0.60

You can use a "structured source" for this. Structured sources are a dictionary
mapping a string of the directory ('' means root), to a source or list of sources.
When using a structured source all inputs *must* be listed, as Meson may copy
the sources from the source tree to the build tree.

Structured inputs are generally not needed when not using generated sources.

As an implementation detail, Meson will attempt to determine if it needs to copy
files at configure time and will skip copying if it can. Copying is done at
build time (when necessary), to avoid reconfiguring when sources change.

```meson
executable(
'rust_exe',
structured_sources(
'main.rs',
{
'foo' : ['bar.rs', 'foo/lib.rs', generated_rs],
'foo/bar' : [...],
'other' : [...],
}
)
)
```
1 change: 1 addition & 0 deletions docs/sitemap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ index.md
Vala.md
D.md
Cython.md
Rust.md
IDE-integration.md
Custom-build-targets.md
Build-system-converters.md
Expand Down

0 comments on commit eb5fbfc

Please sign in to comment.