Skip to content

Commit

Permalink
use source from cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Nov 30, 2024
1 parent 5f888f1 commit 4b8ea71
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub async fn run_build(
output.build_or_fetch_cache(tool_configuration).await?
} else {
output
.fetch_sources(None, tool_configuration)
.fetch_sources(tool_configuration)
.await
.into_diagnostic()?
};
Expand Down
24 changes: 16 additions & 8 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ use crate::{
env_vars,
metadata::{build_reindexed_channels, Output},
packaging::{contains_prefix_binary, contains_prefix_text, content_type, Files},
recipe::parser::{Dependency, Requirements, Source},
recipe::parser::{Dependency, Requirements},
render::resolved_dependencies::{
install_environments, resolve_dependencies, FinalizedDependencies,
},
source::copy_dir::{copy_file, create_symlink, CopyDir, CopyOptions},
source::{
copy_dir::{copy_file, create_symlink, CopyDir, CopyOptions},
fetch_sources,
},
};

/// Error type for cache key generation
Expand Down Expand Up @@ -186,7 +189,7 @@ impl Output {
Ok(cache) => {
tracing::info!("Restoring cache from {:?}", cache_dir);
self = self
.fetch_sources(Some(cache.sources.clone()), tool_configuration)
.fetch_sources(tool_configuration)
.await
.into_diagnostic()?;
return self.restore_cache(cache, cache_dir).await;
Expand All @@ -200,10 +203,16 @@ impl Output {
}
}

self = self
.fetch_sources(None, tool_configuration)
.await
.into_diagnostic()?;
// fetch the sources for the `cache` section
// TODO store them as finalized?!
fetch_sources(
&cache.source,
&self.build_configuration.directories,
&self.system_tools,
tool_configuration,
)
.await
.into_diagnostic()?;

let target_platform = self.build_configuration.target_platform;
let mut env_vars = env_vars::vars(&self, "BUILD");
Expand Down Expand Up @@ -296,7 +305,6 @@ impl Output {
prefix_files: copied_files,
work_dir_files: work_dir_files.copied_paths().to_vec(),
prefix: self.prefix().to_path_buf(),
sources: self.recipe.source.clone(),
};

let cache_file = cache_dir.join("cache.json");
Expand Down
14 changes: 1 addition & 13 deletions src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ impl Output {
/// Fetches the sources for the given output and returns a new output with the finalized sources attached
pub async fn fetch_sources(
self,
already_fetched: Option<Vec<Source>>,
tool_configuration: &tool_configuration::Configuration,
) -> Result<Self, SourceError> {
let span = tracing::info_span!("Fetching source code");
Expand All @@ -300,19 +299,8 @@ impl Output {

Ok(self)
} else {
let sources_to_fetch = if let Some(already_fetched) = already_fetched {
self.recipe
.sources()
.iter()
.filter(|&s| !already_fetched.iter().any(|fetched| fetched == s))
.cloned()
.collect()
} else {
self.recipe.sources().to_vec()
};

let rendered_sources = fetch_sources(
&sources_to_fetch,
&self.recipe.sources(),

Check failure on line 303 in src/source/mod.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

[clippy] reported by reviewdog 🐶 error: this expression creates a reference which is immediately dereferenced by the compiler --> src/source/mod.rs:303:17 | 303 | &self.recipe.sources(), | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.recipe.sources()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` Raw Output: src/source/mod.rs:303:17:e:error: this expression creates a reference which is immediately dereferenced by the compiler --> src/source/mod.rs:303:17 | 303 | &self.recipe.sources(), | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.recipe.sources()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` __END__

Check failure on line 303 in src/source/mod.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

[clippy] reported by reviewdog 🐶 error: this expression creates a reference which is immediately dereferenced by the compiler --> src/source/mod.rs:303:17 | 303 | &self.recipe.sources(), | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.recipe.sources()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` Raw Output: src/source/mod.rs:303:17:e:error: this expression creates a reference which is immediately dereferenced by the compiler --> src/source/mod.rs:303:17 | 303 | &self.recipe.sources(), | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.recipe.sources()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` __END__

Check failure on line 303 in src/source/mod.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

[clippy] reported by reviewdog 🐶 error: this expression creates a reference which is immediately dereferenced by the compiler --> src/source/mod.rs:303:17 | 303 | &self.recipe.sources(), | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.recipe.sources()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` Raw Output: src/source/mod.rs:303:17:e:error: this expression creates a reference which is immediately dereferenced by the compiler --> src/source/mod.rs:303:17 | 303 | &self.recipe.sources(), | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.recipe.sources()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` __END__

Check failure on line 303 in src/source/mod.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

[clippy] reported by reviewdog 🐶 error: this expression creates a reference which is immediately dereferenced by the compiler --> src/source/mod.rs:303:17 | 303 | &self.recipe.sources(), | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.recipe.sources()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` Raw Output: src/source/mod.rs:303:17:e:error: this expression creates a reference which is immediately dereferenced by the compiler --> src/source/mod.rs:303:17 | 303 | &self.recipe.sources(), | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `self.recipe.sources()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `-D clippy::needless-borrow` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` __END__
&self.build_configuration.directories,
&self.system_tools,
tool_configuration,
Expand Down

0 comments on commit 4b8ea71

Please sign in to comment.