Skip to content

Controlling where to look for files - make distcheck and VPATH builds, finding config.h and other includes #2930

Open
@ghenry

Description

@ghenry

Intro

SentryPeer is being extended using Rust as a lib. This Rust lib also uses SentryPeer via a C lib it generates, hence the use of cbindgen and bindgen in the same build.rs. This is all driven by autotools.

Input C/C++ Header

https://github.com/SentryPeer/SentryPeer/blob/main/sentrypeer_rust/wrapper.h

/* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only  */
/* Copyright (c) 2021 - 2024 Gavin Henry <[email protected]> */
/* 
   _____            _              _____
  / ____|          | |            |  __ \
 | (___   ___ _ __ | |_ _ __ _   _| |__) |__  ___ _ __
  \___ \ / _ \ '_ \| __| '__| | | |  ___/ _ \/ _ \ '__|
  ____) |  __/ | | | |_| |  | |_| | |  |  __/  __/ |
 |_____/ \___|_| |_|\__|_|   \__, |_|   \___|\___|_|
                              __/ |
                             |___/
*/

#include "../src/conf.h"
#include "../src/sip_message_event.h"
#include "../src/sip_daemon.h"

Bindgen Invocation

https://github.com/SentryPeer/SentryPeer/blob/main/sentrypeer_rust/build.rs

    // The bindgen::Builder is the main entry point
    // to bindgen, and lets you build up options for
    // the resulting bindings.
    let bindings = bindgen::Builder::default()
        // The input header we would like to generate
        // bindings for.
        .header("wrapper.h")
        // Pick the functions we want to generate bindings for
        .allowlist_function("sentrypeer_config_new|sentrypeer_config_destroy")
        .allowlist_function("sip_message_event_new|sip_message_event_destroy")
        .allowlist_function("sip_log_event")
        // Tell cargo to invalidate the built crate whenever any of the
        // included header files changed.
        .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
        // Finish the builder and generate the bindings.
        .generate()
        // Unwrap the Result and panic on failure.
        .expect("Unable to generate bindings");

    // Write the bindings to the $OUT_DIR/bindings.rs file.
    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
    bindings
        .write_to_file(out_path.join("bindings.rs"))
        .expect("Couldn't write bindings.rs, so can't use SentryPeer C lib!");

What options do I have for setting where we look for files?

Output

  --- stderr
  src_dir: ../..
  ./../src/conf.h:21:10: fatal error: '../config.h' file not found
  thread 'main' panicked at build.rs:60:10:
  Unable to generate bindings: ClangDiagnostic("./../src/conf.h:21:10: fatal error: '../config.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
make[2]: *** [Makefile:2850: /home/ghenry/src/sentrypeer/sentrypeer-4.0.0/_build/sub/sentrypeer_rust/target/release/libsentrypeer_rust.a] Error 101
make[2]: Leaving directory '/home/ghenry/src/sentrypeer/sentrypeer-4.0.0/_build/sub'
make[1]: *** [Makefile:942: all] Error 2
make[1]: Leaving directory '/home/ghenry/src/sentrypeer/sentrypeer-4.0.0/_build/sub'

I'm passing in SRC_DIR from my makefile here:

https://github.com/SentryPeer/SentryPeer/blob/main/Makefile.am#L273

This is all to try and get make distcheck to work for VPATH

Maybe I just can't. make dist and running all the usual works:

./configure
make
make check
make install

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions