Skip to content

Commit eefd71f

Browse files
authored
Merge pull request #1296 from spkenv/pkg-request-with-options
Create a package request with options concept
2 parents 2c3b666 + 8c8a3b3 commit eefd71f

File tree

88 files changed

+2956
-1000
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2956
-1000
lines changed

crates/spk-build/src/build/binary.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ use spk_schema::ident::{
2828
PkgRequest,
2929
PreReleasePolicy,
3030
RangeIdent,
31+
RequestWithOptions,
3132
RequestedBy,
3233
VersionIdent,
3334
};
35+
use spk_schema::spec_ops::ComponentFileMatchMode;
3436
use spk_schema::variant::Override;
3537
use spk_schema::{
3638
BuildIdent,
37-
ComponentFileMatchMode,
39+
ComponentSpec,
3840
ComponentSpecList,
3941
Components,
4042
InputVariant,
@@ -108,6 +110,13 @@ where
108110
) -> std::borrow::Cow<'_, spk_schema::RequirementsList<PinnedRequest>> {
109111
self.resolved_variant.additional_requirements()
110112
}
113+
114+
#[inline]
115+
fn additional_requirements_with_options(
116+
&self,
117+
) -> std::borrow::Cow<'_, spk_schema::RequirementsList<RequestWithOptions>> {
118+
self.resolved_variant.additional_requirements_with_options()
119+
}
111120
}
112121

113122
impl<V1, V2> InputVariant for VariantPair<V1, V2>
@@ -479,7 +488,10 @@ where
479488
self.solver.add_repository(repo);
480489
}
481490

482-
let build_requirements = self.recipe.get_build_requirements(variant)?.into_owned();
491+
let build_requirements = self
492+
.recipe
493+
.get_build_requirements_with_options(variant)?
494+
.into_owned();
483495
for request in build_requirements.iter().cloned() {
484496
self.solver.add_request(request);
485497
}
@@ -805,7 +817,7 @@ where
805817
fn split_manifest_by_component(
806818
pkg: &BuildIdent,
807819
manifest: &spfs::tracking::Manifest,
808-
components: &ComponentSpecList<PinnedRequest>,
820+
components: &ComponentSpecList<ComponentSpec>,
809821
) -> Result<HashMap<Component, spfs::tracking::Manifest>> {
810822
let mut seen = HashSet::new();
811823
let mut manifests = HashMap::with_capacity(components.len());

crates/spk-build/src/build/binary_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use spk_schema::{
1717
Components,
1818
FromYaml,
1919
OptionMap,
20+
OptionValues,
2021
Package,
2122
Recipe,
2223
SpecRecipe,

crates/spk-build/src/validation/alter_existing_files_test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ async fn test_validate_build_changeset_modified() {
3030
},
3131
setup: BuildSetupReport {
3232
environment: Solution::default(),
33-
variant: package.build.variants.first().cloned().unwrap_or_default(),
33+
variant: package
34+
.build()
35+
.variants
36+
.first()
37+
.cloned()
38+
.unwrap_or_default(),
3439
environment_filesystem: Manifest::new(
3540
spfs::tracking::Entry::empty_dir_with_open_perms_with_data(package.ident().clone()),
3641
),

crates/spk-build/src/validation/collect_all_files_test.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ async fn test_validate_build_changeset_collected() {
1515
let mut package = v0::PackageSpec::new("test-pkg/1.0.0/3I42H3S6".parse().unwrap());
1616
// the default components are added and collect all files,
1717
// so we remove them to ensure nothing is collected
18-
let _ = package.install.components.drain(..);
18+
package.install_mut(|install| {
19+
install.components.drain(..);
20+
});
1921
let report = BuildReport {
2022
output: BuildOutputReport {
2123
collected_changes: vec![spfs::tracking::Diff {
@@ -27,7 +29,7 @@ async fn test_validate_build_changeset_collected() {
2729
),
2830
}],
2931
components: package
30-
.install
32+
.install()
3133
.components
3234
.iter()
3335
.map(|c| {
@@ -46,7 +48,12 @@ async fn test_validate_build_changeset_collected() {
4648
},
4749
setup: BuildSetupReport {
4850
environment: Solution::default(),
49-
variant: package.build.variants.first().cloned().unwrap_or_default(),
51+
variant: package
52+
.build()
53+
.variants
54+
.first()
55+
.cloned()
56+
.unwrap_or_default(),
5057
environment_filesystem: Manifest::new(
5158
spfs::tracking::Entry::empty_dir_with_open_perms_with_data(package.ident().clone()),
5259
),

crates/spk-build/src/validation/collect_existing_files_test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ async fn test_validate_build_changeset_collect_existing() {
4141
},
4242
setup: BuildSetupReport {
4343
environment: Solution::default(),
44-
variant: package.build.variants.first().cloned().unwrap_or_default(),
44+
variant: package
45+
.build()
46+
.variants
47+
.first()
48+
.cloned()
49+
.unwrap_or_default(),
4550
environment_filesystem,
4651
package,
4752
},

crates/spk-build/src/validation/empty_package_test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ async fn test_validate_build_changeset_nothing() {
1616
let report = BuildReport {
1717
setup: BuildSetupReport {
1818
environment: Solution::default(),
19-
variant: package.build.variants.first().cloned().unwrap_or_default(),
19+
variant: package
20+
.build()
21+
.variants
22+
.first()
23+
.cloned()
24+
.unwrap_or_default(),
2025
environment_filesystem: Manifest::new(
2126
spfs::tracking::Entry::empty_dir_with_open_perms_with_data(package.ident().clone()),
2227
),

crates/spk-build/src/validation/inherit_requirements_test.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::sync::Arc;
77
use spfs::tracking::Manifest;
88
use spk_schema::foundation::fixtures::*;
99
use spk_schema::foundation::option_map;
10-
use spk_schema::ident::PkgRequest;
10+
use spk_schema::ident::PkgRequestWithOptions;
1111
use spk_schema::validation::ValidationMatcher;
1212
use spk_schema::{Package, PinnableRequest, ValidationRule, spec};
1313
use spk_solve::{RequestedBy, Solution};
@@ -39,7 +39,10 @@ async fn test_build_package_downstream_build_requests() {
3939

4040
let mut environment = Solution::default();
4141
environment.add(
42-
PkgRequest::from_ident(base_spec.ident().to_any_ident(), RequestedBy::DoesNotMatter),
42+
PkgRequestWithOptions::from_ident(
43+
base_spec.ident().to_any_ident(),
44+
RequestedBy::DoesNotMatter,
45+
),
4346
base_spec.clone(),
4447
spk_solve::PackageSource::SpkInternalTest,
4548
);
@@ -107,7 +110,10 @@ async fn test_build_package_downstream_runtime_request() {
107110

108111
let mut environment = Solution::default();
109112
environment.add(
110-
PkgRequest::from_ident(base_spec.ident().to_any_ident(), RequestedBy::DoesNotMatter),
113+
PkgRequestWithOptions::from_ident(
114+
base_spec.ident().to_any_ident(),
115+
RequestedBy::DoesNotMatter,
116+
),
111117
base_spec.clone(),
112118
spk_solve::PackageSource::SpkInternalTest,
113119
);

crates/spk-build/src/validation/long_var_description_test.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::sync::Arc;
66

77
use spfs::tracking::Manifest;
88
use spk_schema::foundation::option_map;
9-
use spk_schema::ident::PkgRequest;
9+
use spk_schema::ident::PkgRequestWithOptions;
1010
use spk_schema::validation::ValidationMatcher;
1111
use spk_schema::{Package, ValidationRule, spec};
1212
use spk_solve::{RequestedBy, Solution};
@@ -30,7 +30,10 @@ async fn test_for_description_over_limit() {
3030

3131
let mut environment = Solution::default();
3232
environment.add(
33-
PkgRequest::from_ident(package.ident().to_any_ident(), RequestedBy::DoesNotMatter),
33+
PkgRequestWithOptions::from_ident(
34+
package.ident().to_any_ident(),
35+
RequestedBy::DoesNotMatter,
36+
),
3437
package.clone(),
3538
spk_solve::PackageSource::SpkInternalTest,
3639
);

crates/spk-build/src/validation/recursive_build_test.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rstest::rstest;
88
use spfs::tracking::Manifest;
99
use spk_schema::foundation::fixtures::*;
1010
use spk_schema::foundation::option_map;
11-
use spk_schema::ident::PkgRequest;
11+
use spk_schema::ident::PkgRequestWithOptions;
1212
use spk_schema::validation::ValidationMatcher;
1313
use spk_schema::{Package, ValidationRule, spec};
1414
use spk_solve::{RequestedBy, Solution};
@@ -36,7 +36,10 @@ async fn test_build_with_circular_dependency() {
3636

3737
let mut environment = Solution::default();
3838
environment.add(
39-
PkgRequest::from_ident(old_build.ident().to_any_ident(), RequestedBy::DoesNotMatter),
39+
PkgRequestWithOptions::from_ident(
40+
old_build.ident().to_any_ident(),
41+
RequestedBy::DoesNotMatter,
42+
),
4043
old_build.clone(),
4144
spk_solve::PackageSource::SpkInternalTest,
4245
);

crates/spk-build/src/validation/strong_inheritance_var_desc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl super::Validator for StrongInheritanceVarDescriptionValidator {
3232
for opt in setup.package.get_build_options().iter() {
3333
match opt {
3434
Opt::Pkg(_) => continue,
35-
Opt::Var(v) => match v.inheritance {
35+
Opt::Var(v) => match v.inheritance() {
3636
Inheritance::Weak => continue,
3737
_ => {
3838
let mut outcome = Outcome {

0 commit comments

Comments
 (0)