Format, clippy, and start the docs

pull/3/head
Bradlee Speice 2019-09-19 23:06:37 -04:00
parent e43c035aed
commit 6018b12670
3 changed files with 25 additions and 13 deletions

View File

@ -1,12 +1,12 @@
use cmake::Config;
use std::env;
use std::path::{Path, PathBuf};
use std::fs::canonicalize;
use std::path::{Path, PathBuf};
pub enum LinkType {
Dynamic,
Static
Static,
}
impl LinkType {
@ -21,14 +21,14 @@ impl LinkType {
fn link_lib(&self) -> &'static str {
match self {
LinkType::Dynamic => "dylib=",
LinkType::Static => "static="
LinkType::Static => "static=",
}
}
fn target_name(&self) -> &'static str {
match self {
LinkType::Dynamic => "aeron_driver",
LinkType::Static => "aeron_driver_static"
LinkType::Static => "aeron_driver_static",
}
}
}
@ -42,11 +42,18 @@ pub fn main() {
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
let link_type = LinkType::detect();
println!("cargo:rustc-link-lib={}{}", link_type.link_lib(), link_type.target_name());
println!(
"cargo:rustc-link-lib={}{}",
link_type.link_lib(),
link_type.target_name()
);
let lib_dir = Config::new(&aeron_path)
.build_target(link_type.target_name())
.build();
println!("cargo:rustc-link-search=native={}", lib_dir.join("build/lib").display());
println!(
"cargo:rustc-link-search=native={}",
lib_dir.join("build/lib").display()
);
println!("cargo:include={}", header_path.display());
let bindings = bindgen::Builder::default()
@ -58,4 +65,4 @@ pub fn main() {
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}
}

View File

@ -1,7 +1,7 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(clippy::all)]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[cfg(test)]

View File

@ -1,8 +1,13 @@
//! Aeron client for Rust
#![deny(missing_docs)]
/// Retrieve the C library version in (major, minor, patch) format
pub fn aeron_version() -> (u32, u32, u32) {
unsafe {(
aeron_driver_sys::aeron_version_major() as u32,
aeron_driver_sys::aeron_version_minor() as u32,
aeron_driver_sys::aeron_version_patch() as u32,
)}
unsafe {
(
aeron_driver_sys::aeron_version_major() as u32,
aeron_driver_sys::aeron_version_minor() as u32,
aeron_driver_sys::aeron_version_patch() as u32,
)
}
}