Skip to content

Commit

Permalink
Cleanup warnings, fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl committed Apr 21, 2023
1 parent 464d3d8 commit 12b7941
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
21 changes: 14 additions & 7 deletions lib/ain-cpp-imports/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,34 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let pkg_name = env::var("CARGO_PKG_NAME")?;
let manifest_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);

let cpp_src_path = &manifest_path.parent()
let cpp_src_path = &manifest_path
.parent()
.and_then(|x| x.parent())
.and_then(|x| Some(x.join("src")));
.map(|x| x.join("src"));

let cpp_src_path = match cpp_src_path.as_ref() {
Some(r) => Ok(r),
None => Err("path err")
None => Err("path err"),
}?;

let ffi_rs_src_path = &manifest_path.join("src/bridge.rs");
let ffi_exports_h_path = &cpp_src_path.join("ffi/ffiexports.h");

cxx_build::bridge(ffi_rs_src_path)
.include(&cpp_src_path)
.include(cpp_src_path)
.cpp_link_stdlib("stdc++")
.flag_if_supported("-std=c++17")
.flag_if_supported("-Wno-unused-parameter")
.compile(pkg_name.as_str());

println!("cargo:rerun-if-changed={}", ffi_rs_src_path.to_string_lossy());
println!("cargo:rerun-if-changed={}", &ffi_exports_h_path.to_string_lossy());
println!(
"cargo:rerun-if-changed={}",
ffi_rs_src_path.to_string_lossy()
);
println!(
"cargo:rerun-if-changed={}",
&ffi_exports_h_path.to_string_lossy()
);

Ok(())
}
2 changes: 1 addition & 1 deletion lib/ain-cpp-imports/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ pub mod ffi {
fn getAccounts() -> Vec<String>;
fn getDatadir() -> String;
}
}
}
25 changes: 16 additions & 9 deletions lib/ain-cpp-imports/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use std::error::Error;

#[cfg(not(any(test, bench, example, doc)))]
Expand All @@ -11,11 +10,21 @@ use bridge::ffi;
#[allow(non_snake_case)]
mod ffi {
const UNIMPL_MSG: &'static str = "This cannot be used on a test path";
pub fn getChainId() -> u64 { unimplemented!("{}", UNIMPL_MSG) }
pub fn isMining() -> bool { unimplemented!("{}", UNIMPL_MSG) }
pub fn publishEthTransaction(_data: Vec<u8>) -> bool { unimplemented!("{}", UNIMPL_MSG) }
pub fn getAccounts() -> Vec<String> { unimplemented!("{}", UNIMPL_MSG) }
pub fn getDatadir() -> String { unimplemented!("{}", UNIMPL_MSG) }
pub fn getChainId() -> u64 {
unimplemented!("{}", UNIMPL_MSG)
}
pub fn isMining() -> bool {
unimplemented!("{}", UNIMPL_MSG)
}
pub fn publishEthTransaction(_data: Vec<u8>) -> bool {
unimplemented!("{}", UNIMPL_MSG)
}
pub fn getAccounts() -> Vec<String> {
unimplemented!("{}", UNIMPL_MSG)
}
pub fn getDatadir() -> String {
unimplemented!("{}", UNIMPL_MSG)
}
}

pub fn get_chain_id() -> Result<u64, Box<dyn Error>> {
Expand Down Expand Up @@ -44,6 +53,4 @@ pub fn get_datadir() -> Result<String, Box<dyn Error>> {
}

#[cfg(test)]
mod tests {

}
mod tests {}
1 change: 0 additions & 1 deletion lib/ain-grpc/src/gen/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,4 +1260,3 @@ pub struct EthSyncingResult {
#[prost(message, optional, tag = "2")]
pub sync_info: ::core::option::Option<EthSyncingInfo>,
}

0 comments on commit 12b7941

Please sign in to comment.