solana/sdk/Cargo.toml

84 lines
2.5 KiB
TOML
Raw Normal View History

[package]
name = "solana-sdk"
2020-10-07 20:20:42 -07:00
version = "1.5.0"
description = "Solana SDK"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana"
2018-12-13 21:14:37 -08:00
homepage = "https://solana.com/"
license = "Apache-2.0"
2018-12-14 20:39:10 -08:00
edition = "2018"
[features]
# On-chain program specific dependencies
program = []
2020-10-19 10:17:29 -07:00
# Everything includes functionality that is not compatible or needed for on-chain programs
default = [
2020-10-19 10:17:29 -07:00
"everything"
]
everything = [
"assert_matches",
"byteorder",
2020-02-24 14:55:08 -08:00
"chrono",
"generic-array",
"memmap",
"rand",
2019-09-20 13:21:12 -07:00
"rand_chacha",
"serde_json",
2019-11-07 17:08:10 -08:00
"ed25519-dalek",
"solana-logger",
"solana-crate-features",
"libsecp256k1",
"sha3",
"digest",
]
[dependencies]
assert_matches = { version = "1.3.0", optional = true }
bincode = "1.3.1"
bs58 = "0.3.1"
bv = { version = "0.11.1", features = ["serde"] }
byteorder = { version = "1.3.4", optional = true }
2020-02-24 14:55:08 -08:00
chrono = { version = "0.4", optional = true }
curve25519-dalek = { version = "2.1.0", optional = true }
generic-array = { version = "0.14.3", default-features = false, features = ["serde", "more_lengths"], optional = true }
hex = "0.4.2"
hmac = "0.7.0"
itertools = { version = "0.9.0" }
lazy_static = "1.4.0"
log = { version = "0.4.8" }
memmap = { version = "0.7.0", optional = true }
num-derive = { version = "0.3" }
num-traits = { version = "0.2" }
pbkdf2 = { version = "0.3.0", default-features = false }
2020-04-27 09:33:33 -07:00
rand = { version = "0.7.0", optional = true }
rand_chacha = { version = "0.2.2", optional = true }
serde = "1.0.112"
serde_bytes = "0.11"
serde_derive = "1.0.103"
serde_json = { version = "1.0.56", optional = true }
sha2 = "0.8.2"
thiserror = "1.0"
2020-07-23 16:23:51 -07:00
ed25519-dalek = { version = "=1.0.0-pre.4", optional = true }
2020-10-07 20:20:42 -07:00
solana-crate-features = { path = "../crate-features", version = "1.5.0", optional = true }
solana-logger = { path = "../logger", version = "1.5.0", optional = true }
solana-frozen-abi = { path = "../frozen-abi", version = "1.5.0" }
solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "1.5.0" }
2020-10-07 20:20:42 -07:00
solana-sdk-macro = { path = "macro", version = "1.5.0" }
Fix hygiene issues in `declare_program!` and `declare_loader!` The `declare_program!` and `declare_loader!` macros both expand to new macro definitions (based on the `$name` argument). These 'inner' macros make use of the special `$crate` metavariable to access items in the crate where the 'inner' macros is defined. However, this only works due to a bug in rustc. When a macro is expanded, all `$crate` tokens in its output are 'marked' as being resolved in the defining crate of that macro. An inner macro (including the body of its arms) is 'just' another set of tokens that appears in the body of the outer macro, so any `$crate` identifiers used there are resolved relative to the 'outer' macro. For example, consider the following code: ```rust macro_rules! outer { () => { macro_rules! inner { () => { $crate::Foo } } } } ``` The path `$crate::Foo` will be resolved relative to the crate that defines `outer`, **not** the crate which defines `inner`. However, rustc currently loses this extra resolution information (referred to as 'hygiene' information) when a crate is serialized. In the above example, this means that the macro `inner` (which gets defined in whatever crate invokes `outer!`) will behave differently depending on which crate it is invoked from: When `inner` is invoked from the same crate in which it is defined, the hygiene information will still be available, which will cause `$crate::Foo` to be resolved in the crate which defines 'outer'. When `inner` is invoked from a different crate, it will be loaded from the metadata of the crate which defines 'inner'. Since the hygiene information is currently lost, rust will 'forget' that `$crate::Foo` is supposed to be resolved in the context of 'outer'. Instead, it will be resolved relative to the crate which defines 'inner', which can cause incorrect code to compile. This bug will soon be fixed in rust (see https://github.com/rust-lang/rust/pull/72121), which will break `declare_program!` and `declare_loader!`. Fortunately, it's possible to obtain the desired behavior (`$crate` resolving in the context of the 'inner' macro) by use of a procedural macro. This commit adds a `respan!` proc-macro to the `sdk/macro` crate. Using the newly-stabilized (on Nightly) `Span::resolved_at` method, the `$crate` identifier can be made to be resolved in the context of the proper crate. Since `Span::resolved_at` is only stable on the latest nightly, referencing it on an earlier version of Rust will cause a compilation error. This requires the `rustversion` crate to be used, which allows conditionally compiling code epending on the Rust compiler version in use. Since this method is already stabilized in the latest nightly, there will never be a situation where the hygiene bug is fixed (e.g. https://github.com/rust-lang/rust/pull/72121) is merged but we are unable to call `Span::resolved_at`.
2020-06-19 22:42:11 -07:00
rustversion = "1.0.3"
libsecp256k1 = { version = "0.3.5", optional = true }
sha3 = { version = "0.9.1", optional = true }
digest = { version = "0.9.0", optional = true }
2020-10-19 10:17:29 -07:00
[target.'cfg(not(target_arch = "bpf"))'.dependencies]
curve25519-dalek = { version = "2.1.0" }
[dev-dependencies]
curve25519-dalek = "2.1.0"
tiny-bip39 = "0.7.0"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[build-dependencies]
rustc_version = "0.2"