Skip to content

corollaries/opensplice-sys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opensplice-sys

This library is a rust binding to the DCPS C API of Adlink's Vortex Opensplice community edition version 6.9.1.181018.
To be able to use this binding you need Vortex Opensplice installed on your machine. Vortex Opensplice can be downloaded from here.

The rust bindings were generated using bindgen.

Current state of opensplice-sys

If you encounter any problems, please create an issue and let me know!

Building opensplice-sys

To be able to build the rust bindings you need to have the Vortex Opensplice Community installed on your machine of choice.
Before building make sure you set the required environment variables by sourcing release.com in the Opensplice installation folder on Linux.

The build script will use the OSPL_HOME environment variable to find the required headers and libraries.
If it cannot find the environment variable the library will not be build.

Generating bindings using bindgen

If you want to generate the bindings yourself replace build.rs with the following piece of code. Note: You will need to add bindgen to the [build-dependencies] in Cargo.toml.

extern crate bindgen;

use std::collections::HashSet;
use std::env;
use std::path::PathBuf;

fn main() {
    let key = "OSPL_HOME";
    let ospl_home = match env::var(key) {
        Ok(val) => val,
        Err(_e) => panic!("OSPL_HOME variable was not set.")
    };

    println!(r"cargo:rustc-link-search={}/lib/", ospl_home);
    println!(r"cargo:include={}/include/dcps/C/SAC", ospl_home);
    println!(r"cargo:rustc-link-lib=dcpssac");

    let bindings = bindgen::Builder::default()
    .header(format!("{}/include/dcps/C/SAC/dds_dcps.h", ospl_home))
    .clang_arg(format!("-I{}/include/dcps/C/SAC/", ospl_home))
    .allowlist_type("DDS_.*")
    .allowlist_var("DDS_.*")
    .allowlist_function("DDS_.*")
    .layout_tests(false)
    .rustfmt_bindings(true)
    .generate()
    .expect("Unable to generate bindings for OpenSplice DDS");

    // 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 OpenSplice DDS bindings to bindings.rs!");
}

Contributing

Help is always appreciated! Submit a PR if you have any improvements for the rust binding to Vortex Opensplice.

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages