Skip to content

Commit d89d1de

Browse files
committed
refactor(layout): Moved cargo timings directory to Layout
1 parent 5f26ace commit d89d1de

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/cargo/core/compiler/build_runner/compilation_files.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
282282
self.layout(unit.kind).incremental()
283283
}
284284

285+
/// Directory where timing output should go.
286+
pub fn timings_dir(&self) -> &Path {
287+
self.host.timings()
288+
}
289+
285290
/// Returns the path for a file in the fingerprint directory.
286291
///
287292
/// The "prefix" should be something to distinguish the file from other

src/cargo/core/compiler/layout.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ pub struct Layout {
132132
build_examples: PathBuf,
133133
/// The directory for rustdoc output: `$root/doc`
134134
doc: PathBuf,
135+
/// The directory for --timings output
136+
timings: PathBuf,
135137
/// The directory for temporary data of integration tests and benches: `$dest/tmp`
136138
tmp: PathBuf,
137139
/// The lockfile for a build (`.cargo-lock`). Will be unlocked when this
@@ -209,6 +211,7 @@ impl Layout {
209211
examples: dest.join("examples"),
210212
build_examples: build_dest.join("examples"),
211213
doc: root.join("doc"),
214+
timings: root.join("cargo-timings"),
212215
tmp: build_root.join("tmp"),
213216
root,
214217
dest,
@@ -268,6 +271,10 @@ impl Layout {
268271
pub fn incremental(&self) -> &Path {
269272
&self.incremental
270273
}
274+
/// Fetch the timings path.
275+
pub fn timings(&self) -> &Path {
276+
&self.timings
277+
}
271278
/// Fetch the fingerprint path.
272279
pub fn fingerprint(&self, pkg_dir: &str) -> PathBuf {
273280
if self.is_new_layout {

src/cargo/core/compiler/timings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl<'gctx> Timings<'gctx> {
441441
) -> CargoResult<()> {
442442
let duration = self.start.elapsed().as_secs_f64();
443443
let timestamp = self.start_str.replace(&['-', ':'][..], "");
444-
let timings_path = build_runner.files().host_root().join("cargo-timings");
444+
let timings_path = build_runner.files().timings_dir();
445445
paths::create_dir_all(&timings_path)?;
446446
let filename = timings_path.join(format!("cargo-timing-{}.html", timestamp));
447447
let mut f = BufWriter::new(paths::create(&filename)?);

0 commit comments

Comments
 (0)