Code Monkey home page Code Monkey logo

Comments (5)

alexcrichton avatar alexcrichton commented on July 16, 2024

Hm I'm not sure I quite follow unfortunately? Is the idea that you want something like include paths from pkg-config but lib paths from a custom location?

from pkg-config-rs.

grossws avatar grossws commented on July 16, 2024

In first place I want to write build.rs using pkg-config crate API with support of 2 additional cases:

  • for systems which has no pkg-config binary (e.g. MacOSX and Windows);
  • for libs which have no lib<name>.pc.

So build.rs will be something like

fn main() {
    let lib = pkg_config::Config::new()
        .probe("smbclient")
        .expect("libsmbclient not found");

    // bindgen staff
    let header = find_header(&lib).unwrap().to_str().unwrap().to_string();
    let bindings = bindgen::Builer::default().header(header)
        // bindgen config
        .generate()
        .expect("failed to generate bindings");
    // write bindings to file
}

instead of

fn main() {
    let inc_path_name = "SMBCLIENT_INCLUDE_PATH";
    let lib_path_name = "SMBCLIENT_LIBRARY_PATH";
    let header = match (env::var(inc_path_name), env::var(lib_path_name)) {
        (Ok(inc_path), Ok(lib_path)) => {
            println!("cargo:rustc-link-lib=smbclient");
            println!("cargo:rustc-link-search=native={}", lib_path);
            let mut path = PathBuf::from(inc_path);
            path.push("libsmbclient.h");
            path.to_str().unwrap().to_string()
        }
        (Ok(_), Err(_)) | (Err(_), Ok(_)) =>
            panic!("Either both {} and {} should be set or none of them", inc_path_name, lib_path_name),
        (Err(_), Err(_)) => {
            let lib = pkg_config::Config::new()
                .probe("smbclient")
                .expect("libsmbclient not found");
            find_header(&lib).unwrap().to_str().unwrap().to_string()
        }
    };

    // bindgen staff
    let bindings = bindgen::Builer::default().header(header)
        // bindgen config
        .generate()
        .expect("failed to generate bindings");
    // write bindings to file
}

from pkg-config-rs.

alexcrichton avatar alexcrichton commented on July 16, 2024

Ah ok I see, but I think that's beyond the scope of the pkg-config crate? That sounds like an external helper crate, though, which may internally use pkg-config.

from pkg-config-rs.

grossws avatar grossws commented on July 16, 2024

I thought it but it seems to me as duplication. It will still have something like Library struct with almost same fields, it will have overlapping env vars (in functional sence) for static linking, similar logic for emitting cargo:rustc-* etc.

Of course, if it seems out of scope for pkg-build to you, I could write a wrapper.

from pkg-config-rs.

alexcrichton avatar alexcrichton commented on July 16, 2024

Sure yeah there may be some duplication, but not too much in theory, right? The wrapper like you're indicating may also not want to have all the fields that pkg-config returns.

from pkg-config-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.