Split monolithic raw crates into sys crates
Creating a crate for bwd-gc highlights the fact that it would be nice to fix 2! The file blocklist is a lost less unmaintainable then the more fine-grained one we had before. Fix #9
This commit is contained in:
parent
485070ffa9
commit
dbb00333b1
51 changed files with 571 additions and 104 deletions
17
nix-bindings-expr-sys/Cargo.toml
Normal file
17
nix-bindings-expr-sys/Cargo.toml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[package]
|
||||
name = "nix-bindings-expr-sys"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
license = "LGPL-2.1"
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
nix-bindings-util-sys = { path = "../nix-bindings-util-sys", version = "0.2.0" }
|
||||
nix-bindings-store-sys = { path = "../nix-bindings-store-sys", version = "0.2.0" }
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.69"
|
||||
pkg-config = "0.3"
|
||||
5
nix-bindings-expr-sys/README.md
Normal file
5
nix-bindings-expr-sys/README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# nix-bindings-expr-sys
|
||||
|
||||
This crate contains generated bindings for the Nix C API (`nix-expr-c`).
|
||||
**You should not have to use this crate directly,** and so you should probably not add it to your dependencies.
|
||||
Instead, use the `nix-bindings-expr` crate, which _should_ be sufficient.
|
||||
42
nix-bindings-expr-sys/build.rs
Normal file
42
nix-bindings-expr-sys/build.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct StripNixPrefix;
|
||||
|
||||
impl bindgen::callbacks::ParseCallbacks for StripNixPrefix {
|
||||
fn item_name(&self, name: &str) -> Option<String> {
|
||||
name.strip_prefix("nix_").map(String::from)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=include/nix-c-expr.h");
|
||||
println!("cargo:rustc-link-lib=nixexprc");
|
||||
|
||||
let mut args = Vec::new();
|
||||
for path in pkg_config::probe_library("nix-expr-c")
|
||||
.unwrap()
|
||||
.include_paths
|
||||
.iter()
|
||||
{
|
||||
args.push(format!("-I{}", path.to_str().unwrap()));
|
||||
}
|
||||
|
||||
let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("include/nix-c-expr.h")
|
||||
.clang_args(args)
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
||||
.parse_callbacks(Box::new(StripNixPrefix))
|
||||
// Blocklist symbols from nix-bindings-util-sys
|
||||
.blocklist_file(".*nix_api_util\\.h")
|
||||
// Blocklist symbols from nix-bindings-store-sys
|
||||
.blocklist_file(".*nix_api_store\\.h")
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
||||
2
nix-bindings-expr-sys/include/nix-c-expr.h
Normal file
2
nix-bindings-expr-sys/include/nix-c-expr.h
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#include <nix_api_expr.h>
|
||||
#include <nix_api_value.h>
|
||||
10
nix-bindings-expr-sys/src/lib.rs
Normal file
10
nix-bindings-expr-sys/src/lib.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(clippy::all)]
|
||||
|
||||
use nix_bindings_store_sys::*;
|
||||
use nix_bindings_util_sys::*;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue