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

Make docs reproducibility more robust #3951

Closed
wants to merge 2 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.v linguist-language=Verilog
/.gitcommit export-subst
/.gitepoch export-subst
1 change: 1 addition & 0 deletions .gitepoch
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$Format:%ct$
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,7 @@ endif

YOSYS_VER := 0.33+0

# Note: We arrange for .gitcommit to contain the (short) commit hash in
# tarballs generated with git-archive(1) using .gitattributes. The git repo
# will have this file in its unexpanded form tough, in which case we fall
# back to calling git directly.
TARBALL_GIT_REV := $(shell cat $(YOSYS_SRC)/.gitcommit)
ifeq ($(TARBALL_GIT_REV),$$Format:%h$$)
GIT_REV := $(shell GIT_DIR=$(YOSYS_SRC)/.git git rev-parse --short=9 HEAD || echo UNKNOWN)
else
GIT_REV := $(TARBALL_GIT_REV)
endif
include git.mk #< sets $(GIT_REV)

OBJS = kernel/version_$(GIT_REV).o

Expand Down
5 changes: 5 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) sou
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

# Reproducibility
include ../git.mk #< sets $(GIT_EPOCH)
export FORCE_SOURCE_DATE ?= 1
export SOURCE_DATE_EPOCH ?= $(GIT_EPOCH)

.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
Expand Down
8 changes: 6 additions & 2 deletions docs/images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ dots: $(DOT_PDF)
tex: $(TEX_PDF)
svg: $(SVG_OUTPUT)

include ../../git.mk #< sets $(GIT_EPOCH)
export FORCE_SOURCE_DATE ?= 1
export SOURCE_DATE_EPOCH ?= $(GIT_EPOCH)

011/%.pdf: $(DOT_LOC)/%.dot
faketime -f '2022-01-01 00:00:00 x0,001' dot -Tpdf -o $@ $<
dot -Tpdf -o $@ $<

011/%.pdf: 011/%.tex
cd 011 && faketime -f '2022-01-01 00:00:00 x0,001' pdflatex $(<F) --interaction=nonstopmode
cd 011 && pdflatex $(<F) --interaction=nonstopmode

%.pdf: %.tex
pdflatex $< --interaction=nonstopmode
Expand Down
16 changes: 16 additions & 0 deletions git.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
GIT_METADATA_DIR := $(dir $(lastword $(MAKEFILE_LIST)))

# Note: We arrange for .gitcommit to contain the (short) commit hash in
# tarballs generated with git-archive(1) using .gitattributes. The git repo
# will have this file in its unexpanded form tough, in which case we fall
# back to calling git directly.

TARBALL_GIT_REV := $(shell cat $(GIT_METADATA_DIR)/.gitcommit)
ifeq ($(TARBALL_GIT_REV),$$Format:%h$$)
GIT_REV := $(shell GIT_DIR=$(GIT_METADATA_DIR)/.git git rev-parse --short=9 HEAD || echo UNKNOWN)
GIT_EPOCH = $(shell GIT_DIR=$(GIT_METADATA_DIR)/.git git show --format=%ct -q || echo 1640991600)
#^ 1640991600 == 2022-01-01 00:00:00
else
GIT_REV := $(TARBALL_GIT_REV)
GIT_EPOCH = $(shell cat $(GIT_METADATA_DIR)/.gitepoch)
endif