-
Notifications
You must be signed in to change notification settings - Fork 2
/
cargo-build-sbf.patch
129 lines (125 loc) · 4.68 KB
/
cargo-build-sbf.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
diff --git a/sdk/cargo-build-sbf/src/main.rs b/sdk/cargo-build-sbf/src/main.rs
index 1a9e4e1b62..3cb0f2af4f 100644
--- a/sdk/cargo-build-sbf/src/main.rs
+++ b/sdk/cargo-build-sbf/src/main.rs
@@ -4,7 +4,6 @@ use {
itertools::Itertools,
log::*,
regex::Regex,
- solana_download_utils::download_file,
solana_sdk::signature::{write_keypair_file, Keypair},
std::{
borrow::Cow,
@@ -233,95 +232,12 @@ fn make_platform_tools_path_for_version(package: &str, version: &str) -> PathBuf
// Check whether a package is installed and install it if missing.
fn install_if_missing(
- config: &Config,
- package: &str,
- url: &str,
- download_file_name: &str,
- target_path: &Path,
+ _config: &Config,
+ _package: &str,
+ _url: &str,
+ _download_file_name: &str,
+ _target_path: &Path,
) -> Result<(), String> {
- if config.force_tools_install {
- if target_path.is_dir() {
- debug!("Remove directory {:?}", target_path);
- fs::remove_dir_all(target_path).map_err(|err| err.to_string())?;
- }
- let source_base = config.sbf_sdk.join("dependencies");
- if source_base.exists() {
- let source_path = source_base.join(package);
- if source_path.exists() {
- debug!("Remove file {:?}", source_path);
- fs::remove_file(source_path).map_err(|err| err.to_string())?;
- }
- }
- }
- // Check whether the target path is an empty directory. This can
- // happen if package download failed on previous run of
- // cargo-build-sbf. Remove the target_path directory in this
- // case.
- if target_path.is_dir()
- && target_path
- .read_dir()
- .map_err(|err| err.to_string())?
- .next()
- .is_none()
- {
- debug!("Remove directory {:?}", target_path);
- fs::remove_dir(target_path).map_err(|err| err.to_string())?;
- }
-
- // Check whether the package is already in ~/.cache/solana.
- // Download it and place in the proper location if not found.
- if !target_path.is_dir()
- && !target_path
- .symlink_metadata()
- .map(|metadata| metadata.file_type().is_symlink())
- .unwrap_or(false)
- {
- if target_path.exists() {
- debug!("Remove file {:?}", target_path);
- fs::remove_file(target_path).map_err(|err| err.to_string())?;
- }
- fs::create_dir_all(target_path).map_err(|err| err.to_string())?;
- let mut url = String::from(url);
- url.push('/');
- url.push_str(config.platform_tools_version);
- url.push('/');
- url.push_str(download_file_name);
- let download_file_path = target_path.join(download_file_name);
- if download_file_path.exists() {
- fs::remove_file(&download_file_path).map_err(|err| err.to_string())?;
- }
- download_file(url.as_str(), &download_file_path, true, &mut None)?;
- let zip = File::open(&download_file_path).map_err(|err| err.to_string())?;
- let tar = BzDecoder::new(BufReader::new(zip));
- let mut archive = Archive::new(tar);
- archive.unpack(target_path).map_err(|err| err.to_string())?;
- fs::remove_file(download_file_path).map_err(|err| err.to_string())?;
- }
- // Make a symbolic link source_path -> target_path in the
- // sdk/sbf/dependencies directory if no valid link found.
- let source_base = config.sbf_sdk.join("dependencies");
- if !source_base.exists() {
- fs::create_dir_all(&source_base).map_err(|err| err.to_string())?;
- }
- let source_path = source_base.join(package);
- // Check whether the correct symbolic link exists.
- let invalid_link = if let Ok(link_target) = source_path.read_link() {
- if link_target.ne(target_path) {
- fs::remove_file(&source_path).map_err(|err| err.to_string())?;
- true
- } else {
- false
- }
- } else {
- true
- };
- if invalid_link {
- #[cfg(unix)]
- std::os::unix::fs::symlink(target_path, source_path).map_err(|err| err.to_string())?;
- #[cfg(windows)]
- std::os::windows::fs::symlink_dir(target_path, source_path)
- .map_err(|err| err.to_string())?;
- }
Ok(())
}
@@ -634,7 +550,6 @@ fn build_solana_package(
error!("Failed to install platform-tools: {}", err);
exit(1);
});
- link_solana_toolchain(config);
let llvm_bin = config
.sbf_sdk
@@ -692,7 +607,6 @@ fn build_solana_package(
let cargo_build = PathBuf::from("cargo");
let mut cargo_build_args = vec![
- "+solana",
"build",
"--release",
"--target",