Skip to content

Commit

Permalink
store finalized sources
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Nov 30, 2024
1 parent 4b8ea71 commit 64f7378
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
8 changes: 5 additions & 3 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ impl Output {
}

// fetch the sources for the `cache` section
// TODO store them as finalized?!
fetch_sources(
&cache.source,
let rendered_sources = fetch_sources(
self.finalized_cache_sources
.as_ref()
.unwrap_or(&cache.source),
&self.build_configuration.directories,
&self.system_tools,
tool_configuration,
Expand Down Expand Up @@ -312,6 +313,7 @@ impl Output {

Ok(Output {
finalized_cache_dependencies: Some(finalized_dependencies),
finalized_cache_sources: Some(rendered_sources),
..self
})
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,9 @@ pub async fn get_build_output(
force_colors: args.color_build_log && console::colors_enabled(),
},
finalized_dependencies: None,
finalized_cache_dependencies: None,
finalized_sources: None,
finalized_cache_dependencies: None,
finalized_cache_sources: None,
system_tools: SystemTools::new(),
build_summary: Arc::new(Mutex::new(BuildSummary::default())),
extra_meta: Some(
Expand Down
11 changes: 8 additions & 3 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,18 @@ pub struct Output {
/// dependencies have not been resolved yet. During the `run_build`
/// functions, the dependencies are resolved and this field is filled.
pub finalized_dependencies: Option<FinalizedDependencies>,
/// The finalized dependencies from the cache (if there is a cache
/// instruction)
pub finalized_cache_dependencies: Option<FinalizedDependencies>,
/// The finalized sources for this output. Contain the exact git hashes for
/// the sources that are used to build this output.
pub finalized_sources: Option<Vec<Source>>,

/// The finalized dependencies from the cache (if there is a cache
/// instruction)
#[serde(skip_serializing_if = "Option::is_none")]
pub finalized_cache_dependencies: Option<FinalizedDependencies>,
/// The finalized sources from the cache (if there is a cache instruction)
#[serde(skip_serializing_if = "Option::is_none")]
pub finalized_cache_sources: Option<Vec<Source>>,

/// Summary of the build
#[serde(skip)]
pub build_summary: Arc<Mutex<BuildSummary>>,
Expand Down
38 changes: 14 additions & 24 deletions src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,29 +288,19 @@ impl Output {
let span = tracing::info_span!("Fetching source code");
let _enter = span.enter();

if let Some(finalized_sources) = &self.finalized_sources {
fetch_sources(
finalized_sources,
&self.build_configuration.directories,
&self.system_tools,
tool_configuration,
)
.await?;

Ok(self)
} else {
let rendered_sources = fetch_sources(
&self.recipe.sources(),
&self.build_configuration.directories,
&self.system_tools,
tool_configuration,
)
.await?;

Ok(Output {
finalized_sources: Some(rendered_sources),
..self
})
}
let rendered_sources = fetch_sources(
self.finalized_sources
.as_deref()
.unwrap_or(self.recipe.sources()),
&self.build_configuration.directories,
&self.system_tools,
tool_configuration,
)
.await?;

Ok(Output {
finalized_sources: Some(rendered_sources),
..self
})
}
}

0 comments on commit 64f7378

Please sign in to comment.