8000 GitHub - allanma8/bind-builder: Rust build dependency to make building cxx bindings easier! (Forked from my personal account)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000
This repository was archived by the owner on Jun 17, 2024. It is now read-only.
/ bind-builder Public archive
forked from ccamel55/bind-builder

Rust build dependency to make building cxx bindings easier! (Forked from my personal account)

License

Notifications You must be signed in to change notification settings

allanma8/bind-builder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bind-builder

Rust build dependency that helps you build and link native libraries.

Note: this repo is no longer used, please visit the original repo for public updates

Requirements 6DA4

  • cmake must be installed and available in the system path.
  • git if you wish to clone repositories.
  • c/c++ build tools.

Usage

Before you start, make sure that the cmake project you want to build has install targets setup for the libraries you want to link against. See cmake documentation to learn more.

Example

let project = CMakeBuilder::clone(
    "some-repo",
    "git@github.com:user/repo.git",
    "tag"
    )
    .generator("Ninja")
    .build();

let library = LocalLibrary::from(project)
    .link_target("some_library")
    .link_system_target("some_system_library")
    .get();

cxx_build::bridge("src/bindings.rs")
    .cpp(true)
    .static_flag(true)
    .std("c++20")
    .file("src/cpp_crate.cpp")
    .include(Path::new("src"))
    .bind_library(library)
    .compile("rust-cxx-testing");

If you are linking against shared libraries, and building for Linux or MacOS, you will need to explicitly set the @rpath to contain the binaries current directory.

This can be done by adding the following to your final artifact's build.rs:

#[cfg(target_os="macos")]
println!("cargo:rustc-link-arg=-Wl,-rpath,@loader_path");

#[cfg(target_os="linux")]
println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN");

About

Rust build dependency to make building cxx bindings easier! (Forked from my personal account)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%
0