meson-next

Crates.iomeson-next
lib.rsmeson-next
version1.2.3
sourcesrc
created_at2022-11-24 20:06:30.620985
updated_at2024-06-11 13:29:22.936223
descriptionA build dependency crate for running Meson to build a native library
homepage
repositoryhttps://github.com/ThatNerdUKnow/meson-rs
max_upload_size
id722374
size6,715
Brandon Piña (ThatNerdUKnow)

documentation

https://docs.rs/meson-next/latest/meson_next

README

Rust meson-next crate

A build dependency crate for running Meson to build a native library.

This crate is a simple wrapper that invokes the system's meson binary.

Ensure you have both meson and ninja installed. Refer to Meson's manual for specific install instructions for your OS.

This crate is a fork of meson 1.0 by dovee, which is abandoned.

Build Example

.
├── build.rs
├── Cargo.toml
├── clib
│   ├── meson.build
│   ├── squid.h
│   └── squid.c
└── src
    └── lib.rs

build.rs:

extern crate meson_next as meson;
use std::env;
use std::path::PathBuf;

fn main() {
    let build_path = PathBuf::from(env::var("OUT_DIR").unwrap());
    build_path.join("build");
    let build_path = build_path.to_str().unwrap();

    let mut options = HashMap::new();
    options.insert("key", "value");

    let config = meson::Config::new().options(options);

    println!("cargo:rustc-link-lib=squid");
    println!("cargo:rustc-link-search=native={}", build_path);
    meson::build("clib", build_path, config);
}

Cargo.toml:

# ...

[build-dependencies]
meson-next = "1"

meson.build:

project('squid', 'c')
shared_library('squid', 'squid.c')
Commit count: 21

cargo fmt