diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-05 20:11:50 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-07 09:11:08 -0500 |
| commit | 2a8c7509d4d4f30d9f468f33b26aad1fc4295156 (patch) | |
| tree | 0bfd351335320b0796edb5b7be62f7d32db8f029 | |
| parent | 88fb06a1f331926bccb448acdb52966fd1ec8a92 (diff) | |
| download | rust-2a8c7509d4d4f30d9f468f33b26aad1fc4295156.tar.gz rust-2a8c7509d4d4f30d9f468f33b26aad1fc4295156.zip | |
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.
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | src/bootstrap/Cargo.toml | 12 | ||||
| -rw-r--r-- | src/bootstrap/dist.rs | 25 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 20 | ||||
| -rw-r--r-- | src/doc/man/rustc.1 | 2 | ||||
| -rw-r--r-- | src/doc/man/rustdoc.1 | 2 |
6 files changed, 16 insertions, 46 deletions
diff --git a/Cargo.lock b/Cargo.lock index 208ce841759..81f34c457a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -236,7 +236,6 @@ dependencies = [ "pretty_assertions", "serde", "serde_json", - "time", "toml", "winapi", ] diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index b68b2163f87..bdb6084220d 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -44,14 +44,22 @@ libc = "0.2" serde = { version = "1.0.8", features = ["derive"] } serde_json = "1.0.2" toml = "0.5" -time = "0.1" ignore = "0.4.10" opener = "0.5" once_cell = "1.7.2" [target.'cfg(windows)'.dependencies.winapi] version = "0.3" -features = ["fileapi", "ioapiset", "jobapi2", "handleapi", "winioctl", "psapi", "impl-default"] +features = [ + "fileapi", + "ioapiset", + "jobapi2", + "handleapi", + "winioctl", + "psapi", + "impl-default", + "timezoneapi", +] [dev-dependencies] pretty_assertions = "0.6" diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 66b63cd1278..472ee3fb014 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -24,7 +24,6 @@ use crate::tarball::{GeneratedTarball, OverlayKind, Tarball}; use crate::tool::{self, Tool}; use crate::util::{exe, is_dylib, timeit}; use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS}; -use time::{self, Timespec}; pub fn pkgname(builder: &Builder<'_>, component: &str) -> String { format!("{}-{}", component, builder.rust_package_vers()) @@ -422,33 +421,15 @@ impl Step for Rustc { let man_src = builder.src.join("src/doc/man"); let man_dst = image.join("share/man/man1"); - // Reproducible builds: If SOURCE_DATE_EPOCH is set, use that as the time. - let time = env::var("SOURCE_DATE_EPOCH") - .map(|timestamp| { - let epoch = timestamp - .parse() - .map_err(|err| format!("could not parse SOURCE_DATE_EPOCH: {}", err)) - .unwrap(); - - time::at(Timespec::new(epoch, 0)) - }) - .unwrap_or_else(|_| time::now()); - - let month_year = t!(time::strftime("%B %Y", &time)); // don't use our `bootstrap::util::{copy, cp_r}`, because those try // to hardlink, and we don't want to edit the source templates for file_entry in builder.read_dir(&man_src) { let page_src = file_entry.path(); let page_dst = man_dst.join(file_entry.file_name()); + let src_text = t!(std::fs::read_to_string(&page_src)); + let new_text = src_text.replace("<INSERT VERSION HERE>", &builder.version); + t!(std::fs::write(&page_dst, &new_text)); t!(fs::copy(&page_src, &page_dst)); - // template in month/year and version number - builder.replace_in_file( - &page_dst, - &[ - ("<INSERT DATE HERE>", &month_year), - ("<INSERT VERSION HERE>", &builder.version), - ], - ); } // Debugger scripts diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index e5f84d417bf..b2ae57438ef 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -106,8 +106,7 @@ use std::cell::{Cell, RefCell}; use std::collections::{HashMap, HashSet}; use std::env; -use std::fs::{self, File, OpenOptions}; -use std::io::{Read, Seek, SeekFrom, Write}; +use std::fs::{self, File}; use std::path::{Path, PathBuf}; use std::process::{self, Command}; use std::str; @@ -1335,23 +1334,6 @@ impl Build { } } - /// Search-and-replaces within a file. (Not maximally efficiently: allocates a - /// new string for each replacement.) - pub fn replace_in_file(&self, path: &Path, replacements: &[(&str, &str)]) { - if self.config.dry_run { - return; - } - let mut contents = String::new(); - let mut file = t!(OpenOptions::new().read(true).write(true).open(path)); - t!(file.read_to_string(&mut contents)); - for &(target, replacement) in replacements { - contents = contents.replace(target, replacement); - } - t!(file.seek(SeekFrom::Start(0))); - t!(file.set_len(0)); - t!(file.write_all(contents.as_bytes())); - } - /// Copies the `src` directory recursively to `dst`. Both are assumed to exist /// when this function is called. pub fn cp_r(&self, src: &Path, dst: &Path) { diff --git a/src/doc/man/rustc.1 b/src/doc/man/rustc.1 index 3788e3c864e..4e7170806d4 100644 --- a/src/doc/man/rustc.1 +++ b/src/doc/man/rustc.1 @@ -1,4 +1,4 @@ -.TH RUSTC "1" "<INSERT DATE HERE>" "rustc <INSERT VERSION HERE>" "User Commands" +.TH RUSTC "1" "April 2019" "rustc <INSERT VERSION HERE>" "User Commands" .SH NAME rustc \- The Rust compiler .SH SYNOPSIS diff --git a/src/doc/man/rustdoc.1 b/src/doc/man/rustdoc.1 index d7f78e8f6f4..e6185347972 100644 --- a/src/doc/man/rustdoc.1 +++ b/src/doc/man/rustdoc.1 @@ -1,4 +1,4 @@ -.TH RUSTDOC "1" "<INSERT DATE HERE>" "rustdoc <INSERT VERSION HERE>" "User Commands" +.TH RUSTDOC "1" "July 2018" "rustdoc <INSERT VERSION HERE>" "User Commands" .SH NAME rustdoc \- generate documentation from Rust source code .SH SYNOPSIS |
