Skip to content

Commit 12a1e4a

Browse files
committed
extra
1 parent bf74b7a commit 12a1e4a

File tree

7 files changed

+46
-46
lines changed

7 files changed

+46
-46
lines changed

src/cache.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
packaging::{Files, contains_prefix_binary, contains_prefix_text, rewrite_prefix_in_file},
1717
recipe::{
1818
Jinja,
19-
parser::{Dependency, Requirements, Source},
19+
parser::{CacheOutput, CacheRequirements, Dependency, Requirements, RunExports, Source},
2020
},
2121
render::resolved_dependencies::{
2222
FinalizedDependencies, RunExportsDownload, install_environments, resolve_dependencies,
@@ -26,6 +26,7 @@ use crate::{
2626
fetch_sources,
2727
patch::apply_patch_custom,
2828
},
29+
tool_configuration::Configuration,
2930
};
3031

3132
/// Check if a file contains the prefix and determine if it's binary or text
@@ -103,7 +104,7 @@ pub struct Cache {
103104

104105
/// The run exports declared by the cache at build time (rendered form is computed later)
105106
#[serde(default)]
106-
pub run_exports: crate::recipe::parser::RunExports,
107+
pub run_exports: RunExports,
107108

108109
/// Files (relative to prefix/work_dir) that contain the old prefix string and
109110
/// should be rewritten when restoring to a different location.
@@ -131,20 +132,17 @@ impl Output {
131132
pub fn cache_key_for(
132133
&self,
133134
cache_name: &str,
134-
cache_reqs: &crate::recipe::parser::CacheRequirements,
135+
cache_reqs: &CacheRequirements,
135136
) -> Result<String, CacheKeyError> {
136137
let requirement_names: HashSet<_> = cache_reqs
137138
.build
138139
.iter()
139140
.chain(cache_reqs.host.iter())
140141
.filter_map(|dep| match dep {
141-
crate::recipe::parser::Dependency::Spec(spec)
142-
if spec.version.is_none() && spec.build.is_none() =>
143-
{
144-
spec.name
145-
.as_ref()
146-
.map(|name| name.as_normalized().to_string())
147-
}
142+
Dependency::Spec(spec) if spec.version.is_none() && spec.build.is_none() => spec
143+
.name
144+
.as_ref()
145+
.map(|name| name.as_normalized().to_string()),
148146
_ => None,
149147
})
150148
.chain(
@@ -349,8 +347,8 @@ impl Output {
349347
/// Build or fetch a specific cache output
350348
pub async fn build_or_fetch_cache_output(
351349
mut self,
352-
cache_output: &crate::recipe::parser::CacheOutput,
353-
tool_configuration: &crate::tool_configuration::Configuration,
350+
cache_output: &CacheOutput,
351+
tool_configuration: &Configuration,
354352
) -> Result<Self, miette::Error> {
355353
let cache_name = cache_output.name.as_normalized();
356354
let cache_key = self
@@ -410,12 +408,12 @@ impl Output {
410408
.into_diagnostic()?;
411409

412410
// Convert CacheRequirements to Requirements
413-
let requirements = crate::recipe::parser::Requirements {
411+
let requirements = Requirements {
414412
build: cache_output.requirements.build.clone(),
415413
host: cache_output.requirements.host.clone(),
416414
run: Vec::new(),
417415
run_constraints: Vec::new(),
418-
run_exports: crate::recipe::parser::RunExports::default(),
416+
run_exports: RunExports::default(),
419417
ignore_run_exports: cache_output.ignore_run_exports.clone().unwrap_or_default(),
420418
};
421419

@@ -564,7 +562,7 @@ impl Output {
564562
/// Note: this modifies the output in place
565563
pub(crate) async fn build_or_fetch_cache(
566564
self,
567-
tool_configuration: &crate::tool_configuration::Configuration,
565+
tool_configuration: &Configuration,
568566
) -> Result<Self, miette::Error> {
569567
if let Some(synthetic_cache) = self.recipe.synthetic_cache_output() {
570568
// Convert to synthetic cache output
@@ -579,7 +577,7 @@ impl Output {
579577
#[allow(dead_code)]
580578
async fn build_or_fetch_cache_legacy(
581579
mut self,
582-
tool_configuration: &crate::tool_configuration::Configuration,
580+
tool_configuration: &Configuration,
583581
) -> Result<Self, miette::Error> {
584582
if let Some(cache) = self.recipe.cache.clone() {
585583
// if we don't have a cache, we need to run the cache build with our current
@@ -741,7 +739,7 @@ impl Output {
741739
work_dir_files: work_dir_files.copied_paths().to_vec(),
742740
prefix: self.prefix().to_path_buf(),
743741
work_dir: self.build_configuration.directories.work_dir.clone(),
744-
run_exports: crate::recipe::parser::RunExports::default(),
742+
run_exports: RunExports::default(),
745743
files_with_prefix,
746744
binary_files_with_prefix,
747745
files_with_work_dir: Vec::new(),

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ use rattler_conda_types::{
6767
use rattler_config::config::build::PackageFormatAndCompression;
6868
use rattler_solve::SolveStrategy;
6969
use rattler_virtual_packages::VirtualPackageOverrides;
70+
use recipe::parser::output::resolve_cache_inheritance_with_caches;
7071
use recipe::parser::{Dependency, Recipe, TestType, find_outputs_from_src};
7172
use recipe::variable::Variable;
7273
use render::resolved_dependencies::RunExportsDownload;
@@ -233,7 +234,7 @@ pub async fn get_build_output(
233234
});
234235

235236
let jinja = recipe::Jinja::new(selector_config.clone());
236-
recipe::parser::output::resolve_cache_inheritance_with_caches(
237+
resolve_cache_inheritance_with_caches(
237238
outputs,
238239
has_toplevel_cache,
239240
selector_config.experimental,

src/packaging/metadata.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use content_inspector::ContentType;
1414
use fs_err as fs;
1515
use fs_err::File;
1616
use itertools::Itertools;
17+
use memchr::memmem;
1718
use rattler_conda_types::{
1819
ChannelUrl, NoArchType, Platform,
1920
package::{
@@ -60,7 +61,7 @@ pub fn contains_prefix_binary(file_path: &Path, prefix: &Path) -> Result<bool, P
6061
let data = unsafe { memmap2::Mmap::map(&file) }?;
6162

6263
// Check if the content contains the prefix bytes with memchr
63-
let contains_prefix = memchr::memmem::find_iter(data.as_ref(), &prefix_bytes)
64+
let contains_prefix = memmem::find_iter(data.as_ref(), &prefix_bytes)
6465
.next()
6566
.is_some();
6667

@@ -83,7 +84,7 @@ pub fn contains_prefix_text(
8384
// Check if the content contains the prefix with memchr
8485
let prefix_string = prefix.to_string_lossy().to_string();
8586
let mut detected_prefix = None;
86-
if memchr::memmem::find_iter(mmap.as_ref(), &prefix_string)
87+
if memmem::find_iter(mmap.as_ref(), &prefix_string)
8788
.next()
8889
.is_some()
8990
{
@@ -99,7 +100,7 @@ pub fn contains_prefix_text(
99100
// to something meaningful in unix either way
100101
let forward_slash: Cow<'_, str> = to_forward_slash_lossy(prefix);
101102

102-
if memchr::memmem::find_iter(mmap.as_ref(), forward_slash.deref())
103+
if memmem::find_iter(mmap.as_ref(), forward_slash.deref())
103104
.next()
104105
.is_some()
105106
{
@@ -186,7 +187,7 @@ fn rewrite_binary_prefix(
186187
let mut mmap = unsafe { memmap2::MmapOptions::new().map_mut(&file) }?;
187188

188189
let mut search_start = 0;
189-
while let Some(found) = memchr::memmem::find(&mmap[search_start..], old_prefix_bytes) {
190+
while let Some(found) = memmem::find(&mmap[search_start..], old_prefix_bytes) {
190191
let pos = search_start + found;
191192
mmap[pos..pos + new_prefix_bytes.len()].copy_from_slice(new_prefix_bytes);
192193
let padding_range = pos + new_prefix_bytes.len()..pos + old_prefix_bytes.len();

src/recipe/parser/cache_output.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
use crate::{
1111
_partialerror,
1212
recipe::{
13-
custom_yaml::{HasSpan, RenderedMappingNode, RenderedNode, TryConvertNode},
13+
custom_yaml::{
14+
HasSpan, RenderedMappingNode, RenderedNode, RenderedScalarNode, TryConvertNode,
15+
},
1416
error::{ErrorKind, PartialParsingError},
1517
parser::{
1618
StandardTryConvert, build::VariantKeyUsage, invalid_field_error, missing_field_error,
@@ -377,7 +379,7 @@ fn parse_cache_requirements(
377379
}
378380

379381
// For compatibility with Vec<CacheOutput> parsing
380-
impl TryConvertNode<CacheOutput> for crate::recipe::custom_yaml::RenderedScalarNode {
382+
impl TryConvertNode<CacheOutput> for RenderedScalarNode {
381383
fn try_convert(&self, _name: &str) -> Result<CacheOutput, Vec<PartialParsingError>> {
382384
Err(vec![_partialerror!(
383385
*self.span(),

src/recipe/parser/output.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::collections::{HashMap, HashSet};
1010
use crate::{
1111
_partialerror,
1212
recipe::{
13-
ParsingError, Render,
13+
Jinja, ParsingError, Render,
1414
custom_yaml::{HasSpan, Node, RenderedNode, TryConvertNode, parse_yaml},
1515
error::{ErrorKind, PartialParsingError},
1616
},
@@ -29,14 +29,8 @@ use super::{
2929
};
3030

3131
/// Result type for resolve_cache_inheritance_with_caches function
32-
type CacheInheritanceResult = Result<
33-
(
34-
Vec<Node>,
35-
Vec<crate::recipe::parser::CacheOutput>,
36-
std::collections::HashMap<String, Vec<String>>,
37-
),
38-
ParsingError<&'static str>,
39-
>;
32+
type CacheInheritanceResult =
33+
Result<(Vec<Node>, Vec<CacheOutput>, HashMap<String, Vec<String>>), ParsingError<&'static str>>;
4034

4135
// Extract inherit information
4236
fn inherit_name_from(node: &Node) -> Option<String> {
@@ -517,7 +511,7 @@ fn detect_cache_inheritance_cycles(
517511
/// Parse a cache output from a Node using proper TryConvertNode
518512
fn parse_cache_output_from_node(
519513
output: &Node,
520-
) -> Result<Option<crate::recipe::parser::CacheOutput>, ParsingError<&'static str>> {
514+
) -> Result<Option<CacheOutput>, ParsingError<&'static str>> {
521515
// Convert Node to RenderedNode to use TryConvertNode
522516
// For now, we'll use a simplified approach since we don't have jinja context here
523517
// In a full implementation, we would need to render the node first
@@ -565,8 +559,8 @@ fn parse_cache_output_from_node(
565559
/// Parse inheritance relationships from outputs
566560
fn parse_inheritance_relationships(
567561
outputs: &[Node],
568-
) -> Result<std::collections::HashMap<String, Vec<String>>, ParsingError<&'static str>> {
569-
let mut relationships = std::collections::HashMap::new();
562+
) -> Result<HashMap<String, Vec<String>>, ParsingError<&'static str>> {
563+
let mut relationships = HashMap::new();
570564

571565
for output in outputs {
572566
let Some(mapping) = output.as_mapping() else {
@@ -623,8 +617,8 @@ fn parse_inheritance_relationships(
623617
/// Parse cache outputs using proper TryConvertNode with jinja context
624618
fn parse_cache_outputs_with_context(
625619
outputs: &[Node],
626-
jinja: &crate::recipe::Jinja,
627-
) -> Result<Vec<crate::recipe::parser::CacheOutput>, ParsingError<&'static str>> {
620+
jinja: &Jinja,
621+
) -> Result<Vec<CacheOutput>, ParsingError<&'static str>> {
628622
use super::output_parser::OutputType;
629623
let mut cache_outputs = Vec::new();
630624

@@ -747,10 +741,10 @@ fn topological_sort(inheritance: &HashMap<String, Vec<String>>) -> Vec<String> {
747741

748742
/// Apply cache-to-cache inheritance to the cache outputs
749743
fn apply_cache_to_cache_inheritance(
750-
cache_outputs: Vec<crate::recipe::parser::CacheOutput>,
744+
cache_outputs: Vec<CacheOutput>,
751745
cache_inheritance_relationships: HashMap<String, Vec<String>>,
752-
) -> Vec<crate::recipe::parser::CacheOutput> {
753-
let mut cache_map: HashMap<String, crate::recipe::parser::CacheOutput> = cache_outputs
746+
) -> Vec<CacheOutput> {
747+
let mut cache_map: HashMap<String, CacheOutput> = cache_outputs
754748
.into_iter()
755749
.map(|cache| (cache.name.as_normalized().to_string(), cache))
756750
.collect();
@@ -816,7 +810,7 @@ pub fn resolve_cache_inheritance_with_caches(
816810
outputs: Vec<Node>,
817811
has_toplevel_cache: bool,
818812
experimental_enabled: bool,
819-
jinja: &crate::recipe::Jinja,
813+
jinja: &Jinja,
820814
) -> CacheInheritanceResult {
821815
if !experimental_enabled {
822816
for output in &outputs {

src/recipe/parser/output_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
1212

1313
use super::cache_output::CacheOutput;
1414
use super::common_output::InheritSpec;
15-
use super::{About, Build, OutputPackage, Requirements, Source, TestType};
15+
use super::{About, Build, OutputPackage, Requirements, Source, TestType, build::VariantKeyUsage};
1616

1717
fn duplicate_field_error(field: &str, span: Span) -> PartialParsingError {
1818
_partialerror!(
@@ -216,7 +216,7 @@ impl Output {
216216
}
217217

218218
// Deep merge compatible build fields from cache (script is intentionally excluded)
219-
let variant_is_default = |v: &super::build::VariantKeyUsage| {
219+
let variant_is_default = |v: &VariantKeyUsage| {
220220
v.use_keys.is_empty() && v.ignore_keys.is_empty() && v.down_prioritize_variant.is_none()
221221
};
222222
if variant_is_default(&self.build.variant) && !variant_is_default(&cache.build.variant) {

src/types/build_output.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ use std::{
1818
use crate::{
1919
NormalizedKey,
2020
console_utils::github_integration_enabled,
21-
recipe::{Recipe, parser::Source, variable::Variable},
21+
recipe::{
22+
Recipe,
23+
parser::{CacheOutput, Source},
24+
variable::Variable,
25+
},
2226
render::resolved_dependencies::FinalizedDependencies,
2327
system_tools::SystemTools,
2428
types::{BuildConfiguration, BuildSummary, PlatformWithVirtualPackages},
@@ -58,7 +62,7 @@ pub struct BuildOutput {
5862

5963
/// Cache outputs that need to be built before this package output
6064
#[serde(skip_serializing_if = "Vec::is_empty", default)]
61-
pub cache_outputs_to_build: Vec<crate::recipe::parser::CacheOutput>,
65+
pub cache_outputs_to_build: Vec<CacheOutput>,
6266

6367
/// Summary of the build
6468
#[serde(skip)]

0 commit comments

Comments
 (0)