Skip to content

Commit 4ba3120

Browse files
authored
Rollup merge of rust-lang#93685 - Mark-Simulacrum:drop-time, r=pietroalbini
Drop time dependency from bootstrap This was only used for the inclusion of 'current' dates into our manpages, but it is not clear that this is practically necessary. The manpage is essentially never updated, and so we can likely afford to keep a manual date in these files. It also seems possible to just omit it, but that may cause other tools trouble, so avoid doing that for now. This is largely done to reduce bootstrap complexity; the time crate is not particularly small and in rust-lang#92480 would have started pulling in num-threads, which does runtime thread count detection. I would prefer to avoid that, so filing this to just drop the nearly unused dependency entirely. r? `@pietroalbini`
2 parents 32df274 + 2f23624 commit 4ba3120

File tree

6 files changed

+6
-45
lines changed

6 files changed

+6
-45
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ dependencies = [
236236
"pretty_assertions",
237237
"serde",
238238
"serde_json",
239-
"time",
240239
"toml",
241240
"winapi",
242241
]

src/bootstrap/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ libc = "0.2"
4444
serde = { version = "1.0.8", features = ["derive"] }
4545
serde_json = "1.0.2"
4646
toml = "0.5"
47-
time = "0.1"
4847
ignore = "0.4.10"
4948
opener = "0.5"
5049
once_cell = "1.7.2"

src/bootstrap/dist.rs

+3-22
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use crate::tarball::{GeneratedTarball, OverlayKind, Tarball};
2424
use crate::tool::{self, Tool};
2525
use crate::util::{exe, is_dylib, timeit};
2626
use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
27-
use time::{self, Timespec};
2827

2928
pub fn pkgname(builder: &Builder<'_>, component: &str) -> String {
3029
format!("{}-{}", component, builder.rust_package_vers())
@@ -422,33 +421,15 @@ impl Step for Rustc {
422421
let man_src = builder.src.join("src/doc/man");
423422
let man_dst = image.join("share/man/man1");
424423

425-
// Reproducible builds: If SOURCE_DATE_EPOCH is set, use that as the time.
426-
let time = env::var("SOURCE_DATE_EPOCH")
427-
.map(|timestamp| {
428-
let epoch = timestamp
429-
.parse()
430-
.map_err(|err| format!("could not parse SOURCE_DATE_EPOCH: {}", err))
431-
.unwrap();
432-
433-
time::at(Timespec::new(epoch, 0))
434-
})
435-
.unwrap_or_else(|_| time::now());
436-
437-
let month_year = t!(time::strftime("%B %Y", &time));
438424
// don't use our `bootstrap::util::{copy, cp_r}`, because those try
439425
// to hardlink, and we don't want to edit the source templates
440426
for file_entry in builder.read_dir(&man_src) {
441427
let page_src = file_entry.path();
442428
let page_dst = man_dst.join(file_entry.file_name());
429+
let src_text = t!(std::fs::read_to_string(&page_src));
430+
let new_text = src_text.replace("<INSERT VERSION HERE>", &builder.version);
431+
t!(std::fs::write(&page_dst, &new_text));
443432
t!(fs::copy(&page_src, &page_dst));
444-
// template in month/year and version number
445-
builder.replace_in_file(
446-
&page_dst,
447-
&[
448-
("<INSERT DATE HERE>", &month_year),
449-
("<INSERT VERSION HERE>", &builder.version),
450-
],
451-
);
452433
}
453434

454435
// Debugger scripts

src/bootstrap/lib.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@
106106
use std::cell::{Cell, RefCell};
107107
use std::collections::{HashMap, HashSet};
108108
use std::env;
109-
use std::fs::{self, File, OpenOptions};
110-
use std::io::{Read, Seek, SeekFrom, Write};
109+
use std::fs::{self, File};
111110
use std::path::{Path, PathBuf};
112111
use std::process::{self, Command};
113112
use std::str;
@@ -1335,23 +1334,6 @@ impl Build {
13351334
}
13361335
}
13371336

1338-
/// Search-and-replaces within a file. (Not maximally efficiently: allocates a
1339-
/// new string for each replacement.)
1340-
pub fn replace_in_file(&self, path: &Path, replacements: &[(&str, &str)]) {
1341-
if self.config.dry_run {
1342-
return;
1343-
}
1344-
let mut contents = String::new();
1345-
let mut file = t!(OpenOptions::new().read(true).write(true).open(path));
1346-
t!(file.read_to_string(&mut contents));
1347-
for &(target, replacement) in replacements {
1348-
contents = contents.replace(target, replacement);
1349-
}
1350-
t!(file.seek(SeekFrom::Start(0)));
1351-
t!(file.set_len(0));
1352-
t!(file.write_all(contents.as_bytes()));
1353-
}
1354-
13551337
/// Copies the `src` directory recursively to `dst`. Both are assumed to exist
13561338
/// when this function is called.
13571339
pub fn cp_r(&self, src: &Path, dst: &Path) {

src/doc/man/rustc.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH RUSTC "1" "<INSERT DATE HERE>" "rustc <INSERT VERSION HERE>" "User Commands"
1+
.TH RUSTC "1" "April 2019" "rustc <INSERT VERSION HERE>" "User Commands"
22
.SH NAME
33
rustc \- The Rust compiler
44
.SH SYNOPSIS

src/doc/man/rustdoc.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH RUSTDOC "1" "<INSERT DATE HERE>" "rustdoc <INSERT VERSION HERE>" "User Commands"
1+
.TH RUSTDOC "1" "July 2018" "rustdoc <INSERT VERSION HERE>" "User Commands"
22
.SH NAME
33
rustdoc \- generate documentation from Rust source code
44
.SH SYNOPSIS

0 commit comments

Comments
 (0)