Skip to content

Commit

Permalink
chore: add defines
Browse files Browse the repository at this point in the history
  • Loading branch information
soralit committed Dec 26, 2024
1 parent d9b3125 commit 878a1ad
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 12 deletions.
22 changes: 11 additions & 11 deletions rust/rust_c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,23 @@ test_cmd = []
debug-memory = ["multi-coins"]

multi-coins = [
"bitcoin",
"ethereum",
"solana",
"aptos",
"near",
"cosmos",
"arweave",
"bch",
"bitcoin",
"cardano",
"cosmos",
"dash",
"ethereum",
"ltc",
"near",
"solana",
"stellar",
"sui",
"ton",
"tron",
"xrp",
"arweave",
"stellar",
"ton",
"zcash",
"ltc",
"dash",
"bch",
]

btc-only = ["bitcoin"]
Expand Down
35 changes: 35 additions & 0 deletions rust/rust_c/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,41 @@ fn main() {
#[cfg(feature = "debug-btc-only")]
"debug-btc-only",
];
config.after_includes = config.after_includes.map(|mut v| {
#[cfg(feature = "aptos")]
v.push_str("#define FEATURE_APTOS\n");
#[cfg(feature = "arweave")]
v.push_str("#define FEATURE_ARWEAVE\n");
#[cfg(feature = "bch")]
v.push_str("#define FEATURE_BCH\n");
#[cfg(feature = "bitcoin")]
v.push_str("#define FEATURE_BITCOIN\n");
#[cfg(feature = "cardano")]
v.push_str("#define FEATURE_CARDANO\n");
#[cfg(feature = "cosmos")]
v.push_str("#define FEATURE_COSMOS\n");
#[cfg(feature = "dash")]
v.push_str("#define FEATURE_DASH\n");
#[cfg(feature = "ethereum")]
v.push_str("#define FEATURE_ETHEREUM\n");
#[cfg(feature = "ltc")]
v.push_str("#define FEATURE_LTC\n");
#[cfg(feature = "near")]
v.push_str("#define FEATURE_NEAR\n");
#[cfg(feature = "solana")]
v.push_str("#define FEATURE_SOLANA\n");
#[cfg(feature = "stellar")]
v.push_str("#define FEATURE_STELLAR\n");
#[cfg(feature = "ton")]
v.push_str("#define FEATURE_TON\n");
#[cfg(feature = "tron")]
v.push_str("#define FEATURE_TRON\n");
#[cfg(feature = "xrp")]
v.push_str("#define FEATURE_XRP\n");
#[cfg(feature = "zcash")]
v.push_str("#define FEATURE_ZCASH\n");
v
});
assert!(!features.is_empty(), "No build variant enabled");
assert!(
features.len() == 1,
Expand Down
6 changes: 5 additions & 1 deletion rust/rust_c/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
include_guard = "_LIBRUST_C_H"

after_includes = "#define BUILD_MULTI_COINS\n#define SIMPLERESPONSE_C_CHAR_MAX_LEN 2048\n#define ADDRESS_MAX_LEN 256\n#define PATH_ITEM_MAX_LEN 32"
after_includes = "#define BUILD_MULTI_COINS\n#define SIMPLERESPONSE_C_CHAR_MAX_LEN 2048\n#define ADDRESS_MAX_LEN 256\n#define PATH_ITEM_MAX_LEN 32\n"

language = "C"

[defines]
"feature = multi-coins" = "BUILD_MULTI_COINS"

"feature = aptos" = "FEATURE_APTOS"
"feature = arweave" = "FEATURE_ARWEAVE"
"feature = bch" = "FEATURE_BCH"
"feature = bitcoin" = "FEATURE_BITCOIN"
"feature = cardano" = "FEATURE_CARDANO"
"feature = cosmos" = "FEATURE_COSMOS"
"feature = dash" = "FEATURE_DASH"
"feature = ethereum" = "FEATURE_ETHEREUM"
"feature = ltc" = "FEATURE_LTC"
"feature = near" = "FEATURE_NEAR"
"feature = solana" = "FEATURE_SOLANA"
"feature = stellar" = "FEATURE_STELLAR"
Expand Down

0 comments on commit 878a1ad

Please sign in to comment.