|
3 | 3 | // https://github.com/spkenv/spk |
4 | 4 |
|
5 | 5 | use std::borrow::Cow; |
6 | | -use std::str::FromStr; |
7 | 6 |
|
8 | 7 | use serde::{Deserialize, Serialize}; |
9 | 8 | use spk_schema_foundation::IsDefault; |
10 | 9 | use spk_schema_foundation::ident::{AsVersionIdent, BuildIdent, VersionIdent}; |
11 | 10 | use spk_schema_foundation::ident_build::EmbeddedSource; |
12 | | -use spk_schema_foundation::version::{IncompatibleReason, VarOptionProblem}; |
13 | 11 |
|
14 | 12 | use super::TestSpec; |
15 | 13 | use crate::foundation::ident_build::Build; |
16 | 14 | use crate::foundation::name::PkgName; |
17 | 15 | use crate::foundation::spec_ops::prelude::*; |
18 | 16 | use crate::foundation::version::{Compat, Compatibility, Version}; |
19 | | -use crate::ident::{PkgRequest, Satisfy, VarRequest, is_false}; |
| 17 | +use crate::ident::{PkgRequest, Satisfy, is_false}; |
20 | 18 | use crate::metadata::Meta; |
21 | 19 | use crate::v0::{ |
22 | 20 | EmbeddedBuildSpec, |
@@ -151,95 +149,6 @@ impl Satisfy<PkgRequest> for EmbeddedPackageSpec { |
151 | 149 | } |
152 | 150 | } |
153 | 151 |
|
154 | | -impl Satisfy<VarRequest> for EmbeddedPackageSpec |
155 | | -where |
156 | | - Self: Named, |
157 | | -{ |
158 | | - fn check_satisfies_request(&self, var_request: &VarRequest) -> Compatibility { |
159 | | - let opt_required = var_request.var.namespace() == Some(self.name()); |
160 | | - let mut opt: Option<&Opt> = None; |
161 | | - let request_name = &var_request.var; |
162 | | - for o in self.build.options.iter() { |
163 | | - if request_name == o.full_name() { |
164 | | - opt = Some(o); |
165 | | - break; |
166 | | - } |
167 | | - if request_name == &o.full_name().with_namespace(self.name()) { |
168 | | - opt = Some(o); |
169 | | - break; |
170 | | - } |
171 | | - } |
172 | | - |
173 | | - match opt { |
174 | | - None => { |
175 | | - if opt_required { |
176 | | - return Compatibility::Incompatible(IncompatibleReason::VarOptionMissing( |
177 | | - var_request.var.clone(), |
178 | | - )); |
179 | | - } |
180 | | - Compatibility::Compatible |
181 | | - } |
182 | | - Some(Opt::Pkg(opt)) => opt.validate(var_request.value.as_pinned()), |
183 | | - Some(Opt::Var(opt)) => { |
184 | | - let request_value = var_request.value.as_pinned(); |
185 | | - let exact = opt.get_value(request_value); |
186 | | - if exact.as_deref() == request_value { |
187 | | - return Compatibility::Compatible; |
188 | | - } |
189 | | - |
190 | | - // For values that aren't exact matches, if the option specifies |
191 | | - // a compat rule, try treating the values as version numbers |
192 | | - // and see if they satisfy the rule. |
193 | | - if let Some(compat) = &opt.compat { |
194 | | - let base_version = exact.clone(); |
195 | | - let Ok(base_version) = Version::from_str(&base_version.unwrap_or_default()) |
196 | | - else { |
197 | | - return Compatibility::Incompatible(IncompatibleReason::VarOptionMismatch( |
198 | | - VarOptionProblem::IncompatibleBuildOptionInvalidVersion { |
199 | | - var_request: var_request.var.clone(), |
200 | | - base: exact.unwrap_or_default(), |
201 | | - request_value: request_value.unwrap_or_default().to_string(), |
202 | | - }, |
203 | | - )); |
204 | | - }; |
205 | | - |
206 | | - let Ok(request_version) = Version::from_str(request_value.unwrap_or_default()) |
207 | | - else { |
208 | | - return Compatibility::Incompatible(IncompatibleReason::VarOptionMismatch( |
209 | | - VarOptionProblem::IncompatibleBuildOptionInvalidVersion { |
210 | | - var_request: var_request.var.clone(), |
211 | | - base: exact.unwrap_or_default(), |
212 | | - request_value: request_value.unwrap_or_default().to_string(), |
213 | | - }, |
214 | | - )); |
215 | | - }; |
216 | | - |
217 | | - let result = compat.is_binary_compatible(&base_version, &request_version); |
218 | | - if let Compatibility::Incompatible(incompatible) = result { |
219 | | - return Compatibility::Incompatible(IncompatibleReason::VarOptionMismatch( |
220 | | - VarOptionProblem::IncompatibleBuildOptionWithContext { |
221 | | - var_request: var_request.var.clone(), |
222 | | - exact: exact.unwrap_or_else(|| "None".to_string()), |
223 | | - request_value: request_value.unwrap_or_default().to_string(), |
224 | | - context: Box::new(incompatible), |
225 | | - }, |
226 | | - )); |
227 | | - } |
228 | | - return result; |
229 | | - } |
230 | | - |
231 | | - Compatibility::Incompatible(IncompatibleReason::VarOptionMismatch( |
232 | | - VarOptionProblem::IncompatibleBuildOption { |
233 | | - var_request: var_request.var.clone(), |
234 | | - exact: exact.unwrap_or_else(|| "None".to_string()), |
235 | | - request_value: request_value.unwrap_or_default().to_string(), |
236 | | - }, |
237 | | - )) |
238 | | - } |
239 | | - } |
240 | | - } |
241 | | -} |
242 | | - |
243 | 152 | impl From<EmbeddedRecipeSpec> for EmbeddedPackageSpec { |
244 | 153 | fn from(recipe: EmbeddedRecipeSpec) -> Self { |
245 | 154 | Self { |
|
0 commit comments