cc-args

Crates.iocc-args
lib.rscc-args
version0.2.0
sourcesrc
created_at2022-06-11 22:41:05.345424
updated_at2024-01-20 18:57:42.015435
descriptionThe clue between pkg-config and bindgen, cc
homepagehttps://github.com/shurizzle/cc-args
repositoryhttps://github.com/shurizzle/cc-args
max_upload_size
id604245
size15,860
shurizzle (shurizzle)

documentation

https://docs.rs/cc-args

README

cc-args

crate.io rustdocs

tl;dr

bindgen::Builder::merge_cc_args(&self, &pkg_config::Library)

This crate exports CcArgs and MergeCcArgs.

CcArgs

It provides link_paths, include_paths, framework_paths, frameworks, libs, ld_args and defines.

MergeCcArgs

It provides the method merge_cc_args that accept a CcArgs implementation.

Features
  • pkg_config implements CcArgs for pkg_config::Library
  • cc implements MergeCcArgs for cc::Build
  • bindgen implements MergeCcArgs for bindgen::Builder

Example

build.rs

use std::path::PathBuf;

use cc_args::{bindgen, pkg_config, MergeCcArgs};

fn main() {
    let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
    println!("cargo:rerun-if-changed=wrapper.h");
    bindgen::Builder::default()
        .merge_cc_args(&pkg_config::probe_library("libzstd").unwrap())
        .header("wrapper.h")
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        .generate()
        .unwrap()
        .write_to_file(out_path.join("bindings.rs"))
        .unwrap();
}
Commit count: 1

cargo fmt