Skip to content

Commit b4d1c77

Browse files
v3.0: Add --install-only command for cargo-build-sbf (backport of #8461) (#8643)
* Add --install-only command for `cargo-build-sbf` (#8461) * Add --install-only command * Update platform-tools-sdk/cargo-build-sbf/src/toolchain.rs Co-authored-by: Jon C <[email protected]> --------- Co-authored-by: Jon C <[email protected]> (cherry picked from commit 83c02c7) # Conflicts: # Cargo.lock # platform-tools-sdk/cargo-build-sbf/Cargo.toml * Resolve conflicts --------- Co-authored-by: Lucas Ste <[email protected]> Co-authored-by: Lucas <[email protected]>
1 parent c77b827 commit b4d1c77

File tree

5 files changed

+224
-61
lines changed

5 files changed

+224
-61
lines changed

Cargo.lock

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform-tools-sdk/cargo-build-sbf/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ clap = { version = "3.1.5", features = ["cargo", "env"] }
2323
itertools = { workspace = true }
2424
log = { workspace = true, features = ["std"] }
2525
regex = { workspace = true }
26-
reqwest = { workspace = true, features = ["blocking", "rustls-tls"] }
26+
reqwest = { workspace = true, features = ["blocking", "rustls-tls", "rustls-tls-native-roots", "json" ] }
2727
semver = { workspace = true }
28-
solana-file-download = "=3.0.0"
28+
serde = { workspace = true }
29+
solana-file-download = "=3.1.0"
2930
solana-keypair = "=3.0.0"
3031
solana-logger = "=3.0.0"
3132
tar = { workspace = true }

platform-tools-sdk/cargo-build-sbf/src/main.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ use {
66
crate::{
77
post_processing::post_process,
88
toolchain::{
9-
corrupted_toolchain, generate_toolchain_name, get_base_rust_version, install_tools,
10-
rust_target_triple, DEFAULT_PLATFORM_TOOLS_VERSION,
9+
corrupted_toolchain, generate_toolchain_name, get_base_rust_version,
10+
install_and_link_tools, install_tools, rust_target_triple,
11+
validate_platform_tools_version, DEFAULT_PLATFORM_TOOLS_VERSION,
1112
},
1213
utils::spawn,
1314
},
@@ -48,6 +49,7 @@ pub struct Config<'a> {
4849
arch: &'a str,
4950
optimize_size: bool,
5051
lto: bool,
52+
install_only: bool,
5153
}
5254

5355
impl Default for Config<'_> {
@@ -81,6 +83,7 @@ impl Default for Config<'_> {
8183
arch: "v0",
8284
optimize_size: false,
8385
lto: false,
86+
install_only: false,
8487
}
8588
}
8689
}
@@ -139,7 +142,7 @@ fn prepare_environment(
139142
exit(1);
140143
});
141144

142-
install_tools(config, package, metadata)
145+
install_and_link_tools(config, package, metadata)
143146
}
144147

145148
fn invoke_cargo(config: &Config, validated_toolchain_version: String) {
@@ -436,6 +439,17 @@ fn main() {
436439
.conflicts_with("skip_tools_install")
437440
.help("Download and install platform-tools even when existing tools are located"),
438441
)
442+
.arg(
443+
Arg::new("install_only")
444+
.long("install-only")
445+
.takes_value(false)
446+
.conflicts_with("skip_tools_install")
447+
.help(
448+
"Download and install platform-tools, without building a program. May be used \
449+
together with `--force-tools-install` to override an existing installation. \
450+
To choose a specific version, use `--install-only --tools-version v1.51`",
451+
),
452+
)
439453
.arg(
440454
Arg::new("skip_tools_install")
441455
.long("skip-tools-install")
@@ -615,12 +629,25 @@ fn main() {
615629
arch: matches.value_of("arch").unwrap(),
616630
optimize_size: matches.is_present("optimize_size"),
617631
lto: matches.is_present("lto"),
632+
install_only: matches.is_present("install_only"),
618633
};
619634
let manifest_path: Option<PathBuf> = matches.value_of_t("manifest_path").ok();
620635
if config.verbose {
621636
debug!("{config:?}");
622637
debug!("manifest_path: {manifest_path:?}");
623638
}
639+
640+
if config.install_only {
641+
let platform_tools_version = validate_platform_tools_version(
642+
config
643+
.platform_tools_version
644+
.unwrap_or(DEFAULT_PLATFORM_TOOLS_VERSION),
645+
DEFAULT_PLATFORM_TOOLS_VERSION,
646+
);
647+
install_tools(&config, &platform_tools_version, true);
648+
return;
649+
}
650+
624651
build_solana(config, manifest_path);
625652
}
626653

0 commit comments

Comments
 (0)