-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enable C++ FFI * Rename evm_ffi to ffi_exports * Update Makefile.am
- Loading branch information
Showing
6 changed files
with
42 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
let manifest_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); | ||
let lib_path = &manifest_path | ||
.parent() | ||
.unwrap() | ||
.parent() | ||
.unwrap() | ||
.join("src"); | ||
|
||
cxx_build::bridge("src/lib.rs") | ||
.include(lib_path) | ||
.flag_if_supported("-std=c++17") | ||
.flag_if_supported("-Wno-unused-parameter") | ||
.compile("ain-evm-cpp-ffi"); | ||
|
||
println!( | ||
"cargo:rerun-if-changed={}/lib.rs", | ||
lib_path.to_str().unwrap() | ||
); | ||
println!( | ||
"cargo:rerun-if-changed={}/masternodes/ffi_exports.h", | ||
lib_path.to_str().unwrap() | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
use std::error::Error; | ||
|
||
// #[cxx::bridge] | ||
// mod ffi { | ||
// unsafe extern "C++" { | ||
// include!("masternodes/evm_ffi.h"); | ||
#[cxx::bridge] | ||
mod ffi { | ||
unsafe extern "C++" { | ||
include!("masternodes/ffi_exports.h"); | ||
|
||
// fn getChainId() -> u64; | ||
// fn isMining() -> bool; | ||
// } | ||
// } | ||
fn getChainId() -> u64; | ||
fn isMining() -> bool; | ||
} | ||
} | ||
|
||
pub fn get_chain_id() -> Result<u64, Box<dyn Error>> { | ||
// let chain_id = ffi::getChainId(); | ||
Ok(0) | ||
let chain_id = ffi::getChainId(); | ||
Ok(chain_id) | ||
} | ||
|
||
pub fn is_mining() -> Result<bool, Box<dyn Error>> { | ||
// let is_mining = ffi::isMining(); | ||
Ok(true) | ||
let is_mining = ffi::isMining(); | ||
Ok(is_mining) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.