Use CMake's built-in timestamp formatting (#1242)
* Use CMake's built-in timestamp formatting. It notably honors SOURCE_DATE_EPOCH if set, making for reproducible output. For even better reproducibility, use UTC. (Unlike the date command's output, the result is already always in English.) Extend this approach to the book, introducing appropriately formatted PDF_DATE and TODAY variables for its PDF metadata and title page respectively and making make_pdf configurable. Under the traditional build system, don't attempt to handle SOURCE_DATE_EPOCH because date's portable interface is too limited, just supply PDF_DATE and TODAY values corresponding to the current date (and time zone) and use the C (English) locale for month names and abbreviations. * Fix missing parts and a syntax error in documentation/Makefile - documentation/Makefile: - add make_pdf to target 'clean' - add make_pdf to dependencies of 'refman.pdf' - add missing quotes to `date` command - documentation/.gitignore: add make_pdf --------- Co-authored-by: Albrecht Schlosser <albrechts.fltk@online.de>
This commit is contained in:
parent
838b7b98ea
commit
6b8409fc6c
1
documentation/.gitignore
vendored
1
documentation/.gitignore
vendored
@ -27,6 +27,7 @@ fluid.z
|
|||||||
generated.dox
|
generated.dox
|
||||||
html
|
html
|
||||||
latex
|
latex
|
||||||
|
make_pdf
|
||||||
sudoku.0
|
sudoku.0
|
||||||
sudoku.6
|
sudoku.6
|
||||||
sudoku.z
|
sudoku.z
|
||||||
|
|||||||
@ -37,16 +37,12 @@ if(GENERATE_DOCS)
|
|||||||
|
|
||||||
# create required variables
|
# create required variables
|
||||||
|
|
||||||
execute_process(COMMAND date "+%Y"
|
string(TIMESTAMP YEAR "%Y" UTC)
|
||||||
OUTPUT_VARIABLE YEAR
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
|
|
||||||
# note: current locale is used for abbreviated month
|
# note: current locale is used for abbreviated month
|
||||||
execute_process(COMMAND date "+%b %d, %Y"
|
string(TIMESTAMP CURRENT_DATE "%b %d, %Y" UTC)
|
||||||
OUTPUT_VARIABLE CURRENT_DATE
|
string(TIMESTAMP PDF_DATE "D:%Y%m%d%H%M%SZ" UTC)
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
string(TIMESTAMP TODAY "%B %d, %Y" UTC)
|
||||||
)
|
string(REPLACE " 0" " " TODAY "${TODAY}")
|
||||||
|
|
||||||
# Find "short" doxygen version if it was built from Git
|
# Find "short" doxygen version if it was built from Git
|
||||||
# Note: this is still needed in CMake 3.15 but later CMake versions
|
# Note: this is still needed in CMake 3.15 but later CMake versions
|
||||||
@ -77,6 +73,8 @@ if(GENERATE_DOCS)
|
|||||||
if(0) # debug
|
if(0) # debug
|
||||||
fl_debug_var(YEAR)
|
fl_debug_var(YEAR)
|
||||||
fl_debug_var(CURRENT_DATE)
|
fl_debug_var(CURRENT_DATE)
|
||||||
|
fl_debug_var(PDF_DATE)
|
||||||
|
fl_debug_var(TODAY)
|
||||||
fl_debug_var(FLTK_GIT_REVISION)
|
fl_debug_var(FLTK_GIT_REVISION)
|
||||||
fl_debug_var(DOXYGEN_FOUND)
|
fl_debug_var(DOXYGEN_FOUND)
|
||||||
fl_debug_var(DOXYGEN_EXECUTABLE)
|
fl_debug_var(DOXYGEN_EXECUTABLE)
|
||||||
@ -179,7 +177,7 @@ if(FLTK_BUILD_PDF_DOCS)
|
|||||||
COMMENT "Converting ${DOXYFILE} to doxygen version ${DOXYGEN_VERSION_SHORT}" VERBATIM
|
COMMENT "Converting ${DOXYFILE} to doxygen version ${DOXYGEN_VERSION_SHORT}" VERBATIM
|
||||||
)
|
)
|
||||||
|
|
||||||
# generate LaTeX title fltk-title.tex
|
# generate LaTeX title fltk-title.tex and make_pdf script
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/fltk-title.tex.in
|
${CMAKE_CURRENT_SOURCE_DIR}/src/fltk-title.tex.in
|
||||||
@ -187,6 +185,12 @@ if(FLTK_BUILD_PDF_DOCS)
|
|||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/make_pdf.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/make_pdf
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
# generate fltk.pdf
|
# generate fltk.pdf
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
@ -196,7 +200,7 @@ if(FLTK_BUILD_PDF_DOCS)
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex
|
${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex
|
${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex
|
||||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
|
||||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make_pdf
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/make_pdf
|
||||||
COMMAND cp -f latex/refman.pdf fltk.pdf
|
COMMAND cp -f latex/refman.pdf fltk.pdf
|
||||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex
|
${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex
|
||||||
|
|||||||
@ -85,7 +85,7 @@ debug_git_rev:
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) Doxyfile Doxybook
|
$(RM) Doxyfile Doxybook
|
||||||
$(RM) copyright.dox generated.dox
|
$(RM) copyright.dox generated.dox make_pdf
|
||||||
$(RM) fltk.pdf refman.pdf src/fltk-title.tex src/fltk-book.tex.in src/fltk-book.tex
|
$(RM) fltk.pdf refman.pdf src/fltk-title.tex src/fltk-book.tex.in src/fltk-book.tex
|
||||||
$(RMDIR) html latex
|
$(RMDIR) html latex
|
||||||
$(RM) *~ *.bck *.bak *.log
|
$(RM) *~ *.bck *.bak *.log
|
||||||
@ -211,15 +211,24 @@ html: $(HTMLFILES) Doxyfile
|
|||||||
pdf: refman.pdf
|
pdf: refman.pdf
|
||||||
cp -f latex/refman.pdf fltk.pdf
|
cp -f latex/refman.pdf fltk.pdf
|
||||||
|
|
||||||
refman.pdf: $(HTMLFILES) Doxybook src/fltk-book.tex
|
refman.pdf: $(HTMLFILES) Doxybook src/fltk-book.tex make_pdf
|
||||||
-$(RMDIR) latex
|
-$(RMDIR) latex
|
||||||
echo "Generating PDF documentation ..."
|
echo "Generating PDF documentation ..."
|
||||||
"$(DOXYDOC)" Doxybook
|
"$(DOXYDOC)" Doxybook
|
||||||
./make_pdf
|
./make_pdf
|
||||||
|
|
||||||
|
make_pdf: make_pdf.in
|
||||||
|
echo "Generating $@ ..."
|
||||||
|
PDF_DATE=`date +D:%Y%m%d%H%M%S`; \
|
||||||
|
sed -e"s/@PDF_DATE@/$$PDF_DATE/g" \
|
||||||
|
< $< > $@
|
||||||
|
chmod +x $@
|
||||||
|
|
||||||
src/fltk-title.tex: src/fltk-title.tex.in
|
src/fltk-title.tex: src/fltk-title.tex.in
|
||||||
echo "Generating $@ ..."
|
echo "Generating $@ ..."
|
||||||
|
TODAY=`LC_ALL=C date '+%B %e, %Y'`; \
|
||||||
sed -e"s/@FLTK_GIT_REVISION@/$(FLTK_GIT_REVISION)/g" \
|
sed -e"s/@FLTK_GIT_REVISION@/$(FLTK_GIT_REVISION)/g" \
|
||||||
|
-e"s/@TODAY@/$$TODAY/g" \
|
||||||
< $< > $@
|
< $< > $@
|
||||||
|
|
||||||
src/fltk-book.tex.in: src/fltk-title.tex
|
src/fltk-book.tex.in: src/fltk-title.tex
|
||||||
@ -237,7 +246,7 @@ src/fltk-book.tex: src/fltk-book.tex.in
|
|||||||
|
|
||||||
generated.dox: generated.dox.in
|
generated.dox: generated.dox.in
|
||||||
echo "Generating $@ ..."
|
echo "Generating $@ ..."
|
||||||
CURRENT_DATE=`date "+%b %d, %Y"`; \
|
CURRENT_DATE=`LC_ALL=C date "+%b %d, %Y"`; \
|
||||||
DOXYGEN_VERSION_SHORT=`"$(DOXYDOC)" --version|cut -f1 -d' '`; \
|
DOXYGEN_VERSION_SHORT=`"$(DOXYDOC)" --version|cut -f1 -d' '`; \
|
||||||
sed -e"s/@CURRENT_DATE@/$$CURRENT_DATE/g" \
|
sed -e"s/@CURRENT_DATE@/$$CURRENT_DATE/g" \
|
||||||
-e"s/@FLTK_GIT_REVISION@/$(FLTK_GIT_REVISION)/g" \
|
-e"s/@FLTK_GIT_REVISION@/$(FLTK_GIT_REVISION)/g" \
|
||||||
|
|||||||
@ -26,10 +26,15 @@
|
|||||||
#
|
#
|
||||||
# Used in: Makefile and CMakeLists.txt
|
# Used in: Makefile and CMakeLists.txt
|
||||||
|
|
||||||
|
run_pdflatex() {
|
||||||
|
pdflatex --interaction=nonstopmode \
|
||||||
|
"\pdfinfo{/CreationDate(@PDF_DATE@)/ModDate(@PDF_DATE@)}\input{refman.tex}"
|
||||||
|
}
|
||||||
|
|
||||||
( cd latex
|
( cd latex
|
||||||
pdflatex --interaction=nonstopmode refman.tex
|
run_pdflatex
|
||||||
makeindex refman.idx
|
makeindex refman.idx
|
||||||
pdflatex --interaction=nonstopmode refman.tex
|
run_pdflatex
|
||||||
latex_count=5
|
latex_count=5
|
||||||
while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log \
|
while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log \
|
||||||
&& [ $latex_count -gt 0 ]
|
&& [ $latex_count -gt 0 ]
|
||||||
@ -25,7 +25,7 @@ provided this copyright and permission notice are preserved.}\\
|
|||||||
\vspace*{1.5cm}
|
\vspace*{1.5cm}
|
||||||
{\large Generated by Doxygen @DOXY_VERSION@}\\
|
{\large Generated by Doxygen @DOXY_VERSION@}\\
|
||||||
\vspace*{0.5cm}
|
\vspace*{0.5cm}
|
||||||
\today{}\\
|
@TODAY@\\
|
||||||
\vspace*{0.5cm}
|
\vspace*{0.5cm}
|
||||||
{\small Git revision @FLTK_GIT_REVISION@}\\
|
{\small Git revision @FLTK_GIT_REVISION@}\\
|
||||||
\end{center}
|
\end{center}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user