Skip to content
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

Autogenerate the manpages with the current date. #35438

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions man/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rustc.1
rustdoc.1
1 change: 0 additions & 1 deletion man/rustc.1 → man/rustc.1.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.TH RUSTC "1" "August 2016" "rustc 1.12.0" "User Commands"
.SH NAME
rustc \- The Rust compiler
.SH SYNOPSIS
Expand Down
1 change: 0 additions & 1 deletion man/rustdoc.1 → man/rustdoc.1.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.TH RUSTDOC "1" "August 2016" "rustdoc 1.12.0" "User Commands"
.SH NAME
rustdoc \- generate documentation from Rust source code
.SH SYNOPSIS
Expand Down
1 change: 1 addition & 0 deletions mk/clean.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ clean-misc:
$(Q)rm -Rf rust-stage0-*.tar.bz2 $(PKG_NAME)-*.tar.gz $(PKG_NAME)-*.exe
$(Q)rm -Rf dist/*
$(Q)rm -Rf doc
$(Q)git clean -xdf man/

define CLEAN_GENERIC

Expand Down
10 changes: 9 additions & 1 deletion mk/docs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ ifdef CFG_DISABLE_DOCS
COMPILER_DOC_TARGETS :=
endif

docs: $(DOC_TARGETS)
docs: $(DOC_TARGETS) doc-man
doc: docs
compiler-docs: $(COMPILER_DOC_TARGETS)

Expand Down Expand Up @@ -227,3 +227,11 @@ doc/error-index.html: $(ERR_IDX_GEN_EXE) $(CSREQ$(2)_T_$(CFG_BUILD)_H_$(CFG_BUIL
doc/error-index.md: $(ERR_IDX_GEN_EXE) $(CSREQ$(2)_T_$(CFG_BUILD)_H_$(CFG_BUILD)) | doc/
$(Q)$(call E, error_index_generator: $@)
$(Q)$(ERR_IDX_GEN_MD)

doc-man:
cd man && \
echo '.TH RUSTC "1" "$(shell LANG=C date "+%B %Y")" "rustc $(CFG_RELEASE_NUM)" "User Commands"' > rustc.1 && \
cat rustc.1.in >> rustc.1
cd man && \
echo '.TH RUSTDOC "1" "$(shell LANG=C date "+%B %Y")" "rustdoc $(CFG_RELEASE_NUM)" "User Commands"' > rustdoc.1 && \
cat rustdoc.1.in >> rustdoc.1
21 changes: 21 additions & 0 deletions src/bootstrap/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 68 additions & 1 deletion src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,28 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {

// Man pages
t!(fs::create_dir_all(image.join("share/man/man1")));
cp_r(&build.src.join("man"), &image.join("share/man/man1"));
//cp_r(&build.src.join("man"), &image.join("share/man/man1"));
let now_string = calc_now_string();
println!("Searchable 98hnandsf9ifnesd");
for man_page_source in t!(build.src.join("man").read_dir()).map(|e| t!(e)) {
let os_filename = man_page_source.file_name();

if let Some(filename) = os_filename.to_str() {

// Match all source files
if filename.ends_with(".1.in") {
let header =
format!(r##".TH RUSTC "1" "{now_string}" "rustc 1.12.0" "User Commands""##
, now_string=now_string);

println!("build: {:?}\nheader: {:?}", build.release, header);
}
// Match all generated files
if filename.ends_with(".1") {
// FIXME copy them
}
}
}

// Debugger scripts
debugger_scripts(build, &image, host);
Expand All @@ -225,6 +246,52 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {
cp("LICENSE-MIT");
cp("README.md");
}

fn calc_now_string() -> String {
use std::time::*;

let now = SystemTime::now();
let now = now.duration_since(UNIX_EPOCH).unwrap();
let secs = now.as_secs();

let years = secs / (60 * 60 * 24 * 365);

let year_secs = 60 * 60 * 24 * 365; // n seconds per year
let years_secs = years * year_secs; // seconds all past years used up

let this_years_secs = secs - years_secs;

let january : u64 = 60*60*24* 31;
let february : u64 = january + (60f64*60f64*24f64* 28.25) as u64;
let march : u64 = february + 60*60*24* 31;
let april : u64 = march + 60*60*24* 30;
let may : u64 = april + 60*60*24* 31;
let june : u64 = may + 60*60*24* 30;
let july : u64 = june + 60*60*24* 31;
let august : u64 = july + 60*60*24* 31;
let september : u64 = august + 60*60*24* 30;
let october : u64 = september + 60*60*24* 31;
let november : u64 = october + 60*60*24* 30;

let month =
if this_years_secs < january { "January" } else
if this_years_secs < february { "February" } else
if this_years_secs < march { "March" } else
if this_years_secs < april { "April" } else
if this_years_secs < may { "May" } else
if this_years_secs < june { "June" } else
if this_years_secs < july { "July" } else
if this_years_secs < august { "August" } else
if this_years_secs < september { "September" } else
if this_years_secs < october { "October" } else
if this_years_secs < november { "November" } else
{ "December" }
;

let year = years + 1970;

format!("{} {}", month, year)
}
}

/// Copies debugger scripts for `host` into the `sysroot` specified.
Expand Down