Add rust-version field to solana-program to prevent the accidental use of unsupported platform-tools versions (#32232)

Require the rust-version of solana-program crate to match platform-tools
This commit is contained in:
mvines 2023-06-23 21:48:56 -07:00 committed by GitHub
parent f71cf07181
commit f202ccb033
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -58,6 +58,20 @@ test-stable-sbf)
# SBF solana-sdk legacy compile test
"$cargo_build_sbf" --manifest-path sdk/Cargo.toml
# Ensure the minimum supported "rust-version" matches platform tools to fail
# quickly if users try to build with an older platform tools install
cargo_toml=sdk/program/Cargo.toml
source "scripts/read-cargo-variable.sh"
crate_rust_version=$(readCargoVariable rust-version $cargo_toml)
platform_tools_rust_version=$("$cargo_build_sbf" --version | grep rustc)
platform_tools_rust_version=$(echo "$platform_tools_rust_version" | cut -d\ -f2) # Remove "rustc " prefix from a string like "rustc 1.68.0-dev"
platform_tools_rust_version=$(echo "$platform_tools_rust_version" | cut -d- -f1) # Remove "-dev" suffix from a string like "1.68.0-dev"
if [[ $crate_rust_version != "$platform_tools_rust_version" ]]; then
echo "Error: Update 'rust-version' field in '$cargo_toml' from $crate_rust_version to $platform_tools_rust_version"
exit 1
fi
# SBF C program system tests
_ make -C programs/sbf/c tests
if need_to_upload_test_result; then

View File

@ -9,6 +9,7 @@ repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }
rust-version = "1.68.0" # solana platform-tools rust version
[dependencies]
bincode = { workspace = true }