-
Notifications
You must be signed in to change notification settings - Fork 0
Borrow build path when emitting manifest #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ use crate::cli::{BuildArgs, Cli, Commands}; | |||||||||||||
| use crate::{ir::BuildGraph, manifest, ninja_gen}; | ||||||||||||||
| use anyhow::{Context, Result}; | ||||||||||||||
| use serde_json; | ||||||||||||||
| use std::borrow::Cow; | ||||||||||||||
| use std::fs; | ||||||||||||||
| use std::io::{self, BufRead, BufReader, Write}; | ||||||||||||||
| use std::path::{Path, PathBuf}; | ||||||||||||||
|
|
@@ -115,17 +116,18 @@ fn handle_build(cli: &Cli, args: &BuildArgs) -> Result<()> { | |||||||||||||
| let targets = BuildTargets::new(&args.targets); | ||||||||||||||
|
|
||||||||||||||
| // Normalise the build file path and keep the temporary file alive for the | ||||||||||||||
| // duration of the Ninja invocation. | ||||||||||||||
| let (build_path, _tmp): (PathBuf, Option<NamedTempFile>) = if let Some(path) = &args.emit { | ||||||||||||||
| // duration of the Ninja invocation. Borrow the emitted path when provided | ||||||||||||||
| // to avoid unnecessary allocation. | ||||||||||||||
|
Comment on lines
+118
to
+120
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Correct the comment: path canonicalization happens in Avoid misleading readers about where normalisation occurs; keep the focus on lifetimes and borrowing. - // Normalize the build file path and keep the temporary file alive for the
- // duration of the Ninja invocation. Borrow the emitted path when provided
- // to avoid unnecessary allocation.
+ // Keep the temporary build file alive for the duration of the Ninja
+ // invocation. Borrow the emitted path when provided to avoid unnecessary
+ // allocation; run_ninja canonicalizes the path.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| let (build_path, _tmp): (Cow<Path>, Option<NamedTempFile>) = if let Some(path) = &args.emit { | ||||||||||||||
| write_ninja_file(path, &ninja)?; | ||||||||||||||
| (path.clone(), None) | ||||||||||||||
| (Cow::Borrowed(path.as_path()), None) | ||||||||||||||
| } else { | ||||||||||||||
| let tmp = create_temp_ninja_file(&ninja)?; | ||||||||||||||
| (tmp.path().to_path_buf(), Some(tmp)) | ||||||||||||||
| (Cow::Owned(tmp.path().to_path_buf()), Some(tmp)) | ||||||||||||||
| }; | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| let program = resolve_ninja_program(); | ||||||||||||||
| run_ninja(program.as_path(), cli, &build_path, &targets)?; | ||||||||||||||
| run_ninja(program.as_path(), cli, build_path.as_ref(), &targets)?; | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Pass If you adopt the - run_ninja(program.as_path(), cli, build_path.as_ref(), &targets)?;
+ run_ninja(program.as_path(), cli, build_path, &targets)?;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| Ok(()) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Cow import no longer needed if you simplify to
&PathDrop this import once you replace
Cow<Path>with&Pathas suggested below.- use std::borrow::Cow;🤖 Prompt for AI Agents