An experimental abstraction over the components required for building rust *-sys
crates with FFI bindings.
See rust-embedded#481 for background discussion and #1 for a meta-issue.
To simplify the construction of *-sys
crates that adequately support multiple target architectures, minimising the burden on crate authors to create and manage complex build.rs
configurations and improving the crate consumer experience by providing consistent support for a set of required features.
- Minimise surprise by providing working defaults for common configurations
- Attempt to use non-interactive discovery mechanisms, provide useful errors, support overrides as required
- Support per-target configuration to pass to underlying build systems
- ie. existing
autotools
may expect a variety of configuration options per-target
- ie. existing
- Support both linking against system libraries and compiling and linking against static or dynamic libraries
- Support cross-platform use
- packages should both work and be cross compilable using at least linux / windows / macos
- Provide cargo-centric mechanisms for configuration (no environmental variables required _by default)
- Support fetching pre-compiled libraries / headers for platforms where this is requried / useful
- Support testing of
*-sys
crates across supported hosts and targets
No more than a rough idea. Check out the issues or add your own!
sys-build
provides a high-level configuration that allows crate authors to declare how a library should be located, compiled, and linked in their build.rs
, along with a set of features that can be re-exported from *-sys
crates to allow higher level crates to choose which of the available mechanisms to use.
- Locating Sources
-
source_dir
enables building from an included directory / submodule -
source_git
enables building from a specified git repository
-
- Locating Libraries
-
use_pkgconfig
enables system library discovery usingpkgconfig
-
use_vcpkg
enable system library discovery -
lib_dir
use default (or provided) library directory -
lib_dl
use a downloaded pre-compiled library
-
- Binding Generation
-
bindgen
enables compile-time binding generation (otherwise included bindings are used)
-
- Linking mechanisms
-
link_static
attempts to statically link the library -
link_dymanic
attempts to dynamically link the libary
-
- Compilation
-
cc
enables compile-time library compilation via thecc
crate (must be paired withsource_dir
orsource_git
) -
make
enables compile-time library compilation viamake
-
cmake
enables compile-time library compilation viacmake
-
autotools
enables compile-time library compilation viaautotools
-