Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit f8f51c1

Browse files
authored
FFI compatible token interface (#48)
1 parent 63cf718 commit f8f51c1

File tree

9 files changed

+1382
-19
lines changed

9 files changed

+1382
-19
lines changed

ci/token.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set -e
99
./do.sh build token
1010
./do.sh doc token
1111
./do.sh test token
12+
cc token/inc/token.h -o token/target/token.gch
1213
)
1314

1415
(

token/Cargo.lock

Lines changed: 197 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

token/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ edition = "2018"
1313
[dependencies]
1414
num-derive = "0.2"
1515
num-traits = "0.2"
16+
remove_dir_all = "=0.5.0"
1617
solana-sdk = { version = "=1.2.0", default-features = false, features=["program"] }
1718
solana-sdk-bpf-test = { path = "../bin/bpf-sdk/rust/test", default-features = false }
1819
thiserror = "1.0"
1920

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

24+
[build-dependencies]
25+
cbindgen = "0.14"
26+
2327
[lib]
2428
name = "spl_token"
2529
crate-type = ["cdylib", "lib"]

token/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
extern crate cbindgen;
2+
3+
use std::env;
4+
5+
fn main() {
6+
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
7+
cbindgen::generate(&crate_dir)
8+
.unwrap()
9+
.write_to_file("inc/token.h");
10+
}

token/cbindgen.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language = "C"
2+
header = "/* Autogenerated SPL Token program C Bindings */"
3+
pragma_once = true
4+
cpp_compat = true
5+
line_length = 80
6+
tab_width = 4
7+
style = "both"
8+
9+
[export]
10+
prefix = "Token"
11+
include = ["Instruction", "State"]
12+
13+
[parse]
14+
parse_deps = true
15+
include = ["solana-sdk"]

0 commit comments

Comments
 (0)