From c98eac9c59a01d69726cd167b1d016d5ac826d99 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Mon, 29 Jun 2020 22:14:13 +0200 Subject: [PATCH] meson: docs: generate docs timestamp Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa Reviewed-by: Neal Gompa --- docs/Makefile.am | 7 ------- docs/meson.build | 4 ++++ scripts/meson-timestamp.py | 13 +++++++++++++ scripts/meson.build | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) create mode 100755 scripts/meson-timestamp.py diff --git a/docs/Makefile.am b/docs/Makefile.am index 1237b4c47c..f54336cf35 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -306,13 +306,6 @@ aclperms.htmlinc: $(top_srcdir)/src/access/viraccessperm.h \ $(top_srcdir)/scripts/genaclperms.py Makefile.am $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(top_srcdir)/scripts/genaclperms.py $< > $@ -timestamp="$(shell if test -n "$$SOURCE_DATE_EPOCH"; \ - then \ - date -u --date="@$$SOURCE_DATE_EPOCH"; \ - else \ - date -u; \ - fi)" - hvsupport.html: hvsupport.html.in hvsupport.html.in: $(top_srcdir)/scripts/hvsupport.py $(api_DATA) \ diff --git a/docs/meson.build b/docs/meson.build index 9bd4e19b3f..7fbd46af7c 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -29,6 +29,10 @@ docs_assets = [ install_data(docs_assets, install_dir: docs_html_dir) +docs_timestamp = run_command( + python3_prog, meson_timestamp_prog.path(), env: runutf8 +).stdout().strip() + docs_api_generated = custom_target( 'generate-api', output: [ diff --git a/scripts/meson-timestamp.py b/scripts/meson-timestamp.py new file mode 100755 index 0000000000..f109cad66e --- /dev/null +++ b/scripts/meson-timestamp.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import os + +from datetime import datetime, timezone + +timestamp = os.environ.get('SOURCE_DATE_EPOCH', None) +timeformat = '%c %Z' + +if timestamp: + print(datetime.fromtimestamp(int(timestamp), tz=timezone.utc).strftime(timeformat)) +else: + print(datetime.now(tz=timezone.utc).strftime(timeformat)) diff --git a/scripts/meson.build b/scripts/meson.build index e1ecda2a0c..d1d069847d 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -23,6 +23,7 @@ scripts = [ 'meson-install-dirs.py', 'meson-install-symlink.py', 'meson-python.sh', + 'meson-timestamp.py', 'mock-noinline.py', 'prohibit-duplicate-header.py', 'test-wrap-argv.py',