forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cargo-build-sbf: Use
metadata.solana.tools-version
in Cargo.toml (#…
…2914) * cargo-build-sbf: Use `solana.tools-version` in Cargo.toml #### Problem It's possible to specify the version of the platform-tools version using the `--tools-version`, but most people aren't aware of the different versions of the compiler, or that they can use the flag. #### Summary of changes Allow `cargo-build-sbf` to read from the metadata section of a package or workspace Cargo.toml. The concept is similar to `rust-toolchain.toml`, where cargo finds the right version of Rust. For cargo-build-sbf, it can read: ```toml [package.metadata.solana] tools-version = "v1.43" ``` Or ```toml [workspace.metadata.solana] tools-version = "v1.43" ``` To go with this change, since I often forget leading "v" in the version string, the version parsing now allows for omitting the leading "v", so you can specify `--tools-version 1.43`. * Relax leading "v" * Add CHANGELOG entry * Special-case default run * Add tests * ci: Fix parsing platform tools version
- Loading branch information
Showing
9 changed files
with
163 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
sdk/cargo-build-sbf/tests/crates/package-metadata/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "package-metadata" | ||
version = "2.1.0" | ||
description = "Solana SBF test program with tools version in package metadata" | ||
authors = ["Anza Maintainers <[email protected]>"] | ||
repository = "https://github.com/anza-xyz/agave" | ||
license = "Apache-2.0" | ||
homepage = "https://anza.xyz" | ||
edition = "2021" | ||
publish = false | ||
|
||
[package.metadata.solana] | ||
tools-version = "v1.43" | ||
|
||
[dependencies] | ||
solana-program = { path = "../../../../program", version = "=2.1.0" } | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[workspace] |
12 changes: 12 additions & 0 deletions
12
sdk/cargo-build-sbf/tests/crates/package-metadata/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//! Example Rust-based SBF noop program | ||
|
||
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey}; | ||
|
||
solana_program::entrypoint!(process_instruction); | ||
fn process_instruction( | ||
_program_id: &Pubkey, | ||
_accounts: &[AccountInfo], | ||
_instruction_data: &[u8], | ||
) -> ProgramResult { | ||
Ok(()) | ||
} |
21 changes: 21 additions & 0 deletions
21
sdk/cargo-build-sbf/tests/crates/workspace-metadata/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "workspace-metadata" | ||
version = "2.1.0" | ||
description = "Solana SBF test program with tools version in workspace metadata" | ||
authors = ["Anza Maintainers <[email protected]>"] | ||
repository = "https://github.com/anza-xyz/agave" | ||
license = "Apache-2.0" | ||
homepage = "https://anza.xyz" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
solana-program = { path = "../../../../program", version = "=2.1.0" } | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[workspace] | ||
|
||
[workspace.metadata.solana] | ||
tools-version = "v1.43" |
12 changes: 12 additions & 0 deletions
12
sdk/cargo-build-sbf/tests/crates/workspace-metadata/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//! Example Rust-based SBF noop program | ||
|
||
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey}; | ||
|
||
solana_program::entrypoint!(process_instruction); | ||
fn process_instruction( | ||
_program_id: &Pubkey, | ||
_accounts: &[AccountInfo], | ||
_instruction_data: &[u8], | ||
) -> ProgramResult { | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters