Skip to content

Commit

Permalink
FFI compatible token interface (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored Jun 26, 2020
1 parent 63cf718 commit f8f51c1
Show file tree
Hide file tree
Showing 9 changed files with 1,382 additions and 19 deletions.
1 change: 1 addition & 0 deletions ci/token.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set -e
./do.sh build token
./do.sh doc token
./do.sh test token
cc token/inc/token.h -o token/target/token.gch
)

(
Expand Down
199 changes: 197 additions & 2 deletions token/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ edition = "2018"
[dependencies]
num-derive = "0.2"
num-traits = "0.2"
remove_dir_all = "=0.5.0"
solana-sdk = { version = "=1.2.0", default-features = false, features=["program"] }
solana-sdk-bpf-test = { path = "../bin/bpf-sdk/rust/test", default-features = false }
thiserror = "1.0"

[dev-dependencies]
rand = { version = "0.7.0"}

[build-dependencies]
cbindgen = "0.14"

[lib]
name = "spl_token"
crate-type = ["cdylib", "lib"]
10 changes: 10 additions & 0 deletions token/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extern crate cbindgen;

use std::env;

fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::generate(&crate_dir)
.unwrap()
.write_to_file("inc/token.h");
}
15 changes: 15 additions & 0 deletions token/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language = "C"
header = "/* Autogenerated SPL Token program C Bindings */"
pragma_once = true
cpp_compat = true
line_length = 80
tab_width = 4
style = "both"

[export]
prefix = "Token"
include = ["Instruction", "State"]

[parse]
parse_deps = true
include = ["solana-sdk"]
Loading

0 comments on commit f8f51c1

Please sign in to comment.