Skip to content

Commit

Permalink
Version C header (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored Jul 8, 2020
1 parent 6c10d91 commit f083260
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
40 changes: 39 additions & 1 deletion token/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,45 @@ use std::env;

fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::generate(&crate_dir)
let config = cbindgen::Config {
header: Some("/* Autogenerated SPL Token program C Bindings */".to_string()),
after_includes: Some(format!(
"{}{}{}",
format!(
"\n#define TOKEN_MAJOR_VERSION {}",
env!("CARGO_PKG_VERSION_MAJOR")
),
format!(
"\n#define TOKEN_MINOR_VERSION {}",
env!("CARGO_PKG_VERSION_MINOR")
),
format!(
"\n#define TOKEN_PATCH_VERSION {}",
env!("CARGO_PKG_VERSION_PATCH")
)
)),
language: cbindgen::Language::C,
line_length: 80,
style: cbindgen::Style::Both,
tab_width: 4,
cpp_compat: true,
pragma_once: true,
export: cbindgen::ExportConfig {
prefix: Some("Token_".to_string()),
include: vec!["TokenInstruction".to_string(), "State".to_string()],
..cbindgen::ExportConfig::default()
},
parse: cbindgen::ParseConfig {
parse_deps: true,
include: Some(vec!["solana-sdk".to_string()]),
..cbindgen::ParseConfig::default()
},
..cbindgen::Config::default()
};
cbindgen::Builder::new()
.with_crate(crate_dir)
.with_config(config)
.generate()
.unwrap()
.write_to_file("inc/token.h");
}
4 changes: 4 additions & 0 deletions token/inc/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <stdint.h>
#include <stdlib.h>

#define TOKEN_MAJOR_VERSION 0
#define TOKEN_MINOR_VERSION 1
#define TOKEN_PATCH_VERSION 0

/**
* Maximum number of multisignature signers (max N)
*/
Expand Down

0 comments on commit f083260

Please sign in to comment.