From 678c85027294c0ae5162d02b20a59fde758ac77a Mon Sep 17 00:00:00 2001 From: "Aaron M. Ucko" Date: Sun, 30 Mar 2025 20:56:57 -0400 Subject: 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. --- documentation/CMakeLists.txt | 26 ++++++++++++--------- documentation/make_pdf | 41 --------------------------------- documentation/make_pdf.in | 46 +++++++++++++++++++++++++++++++++++++ documentation/src/fltk-title.tex.in | 2 +- 4 files changed, 62 insertions(+), 53 deletions(-) delete mode 100755 documentation/make_pdf create mode 100755 documentation/make_pdf.in (limited to 'documentation') diff --git a/documentation/CMakeLists.txt b/documentation/CMakeLists.txt index f93d0cba5..6cd1d1462 100644 --- a/documentation/CMakeLists.txt +++ b/documentation/CMakeLists.txt @@ -37,16 +37,12 @@ if(GENERATE_DOCS) # create required variables - execute_process(COMMAND date "+%Y" - OUTPUT_VARIABLE YEAR - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - + string(TIMESTAMP YEAR "%Y" UTC) # note: current locale is used for abbreviated month - execute_process(COMMAND date "+%b %d, %Y" - OUTPUT_VARIABLE CURRENT_DATE - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + string(TIMESTAMP CURRENT_DATE "%b %d, %Y" UTC) + string(TIMESTAMP PDF_DATE "D:%Y%m%d%H%M%SZ" UTC) + string(TIMESTAMP TODAY "%B %d, %Y" UTC) + string(REPLACE " 0" " " TODAY "${TODAY}") # Find "short" doxygen version if it was built from Git # Note: this is still needed in CMake 3.15 but later CMake versions @@ -77,6 +73,8 @@ if(GENERATE_DOCS) if(0) # debug fl_debug_var(YEAR) fl_debug_var(CURRENT_DATE) + fl_debug_var(PDF_DATE) + fl_debug_var(TODAY) fl_debug_var(FLTK_GIT_REVISION) fl_debug_var(DOXYGEN_FOUND) fl_debug_var(DOXYGEN_EXECUTABLE) @@ -179,7 +177,7 @@ if(FLTK_BUILD_PDF_DOCS) 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( ${CMAKE_CURRENT_SOURCE_DIR}/src/fltk-title.tex.in @@ -187,6 +185,12 @@ if(FLTK_BUILD_PDF_DOCS) @ONLY ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/make_pdf.in + ${CMAKE_CURRENT_BINARY_DIR}/make_pdf + @ONLY + ) + # generate fltk.pdf add_custom_command( @@ -196,7 +200,7 @@ if(FLTK_BUILD_PDF_DOCS) ${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex ${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex 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 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE} ${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex diff --git a/documentation/make_pdf b/documentation/make_pdf deleted file mode 100755 index a5487bae4..000000000 --- a/documentation/make_pdf +++ /dev/null @@ -1,41 +0,0 @@ -#! /bin/sh -# -# Makefile helper script for the Fast Light Tool Kit (FLTK) documentation. -# -# Copyright 1998-2020 by Bill Spitzak and others. -# -# This library is free software. Distribution and use rights are outlined in -# the file "COPYING" which should have been included with this file. If this -# file is missing or damaged, see the license at: -# -# https://www.fltk.org/COPYING.php -# -# Please see the following page on how to report bugs and issues: -# -# https://www.fltk.org/bugs.php -# - -# This script generates latex/refman.pdf after doxygen has been executed. -# -# Input: run `doxygen Doxybook' (creates files in subdirectory latex) -# Output: latex/refman.pdf (if successful) -# -# Next step: cp -f latex/refman.pdf fltk.pdf (why is this extra step needed ?) -# -# Working directory: fltk/documentation -# -# Used in: Makefile and CMakeLists.txt - -( cd latex - pdflatex --interaction=nonstopmode refman.tex - makeindex refman.idx - pdflatex --interaction=nonstopmode refman.tex - latex_count=5 - while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log \ - && [ $latex_count -gt 0 ] - do - echo "Rerunning pdflatex ..." - pdflatex --interaction=nonstopmode refman.tex - latex_count=`expr $latex_count - 1` - done - cd ..) > pdfall.log 2>&1 diff --git a/documentation/make_pdf.in b/documentation/make_pdf.in new file mode 100755 index 000000000..c0e5fad8a --- /dev/null +++ b/documentation/make_pdf.in @@ -0,0 +1,46 @@ +#! /bin/sh +# +# Makefile helper script for the Fast Light Tool Kit (FLTK) documentation. +# +# Copyright 1998-2020 by Bill Spitzak and others. +# +# This library is free software. Distribution and use rights are outlined in +# the file "COPYING" which should have been included with this file. If this +# file is missing or damaged, see the license at: +# +# https://www.fltk.org/COPYING.php +# +# Please see the following page on how to report bugs and issues: +# +# https://www.fltk.org/bugs.php +# + +# This script generates latex/refman.pdf after doxygen has been executed. +# +# Input: run `doxygen Doxybook' (creates files in subdirectory latex) +# Output: latex/refman.pdf (if successful) +# +# Next step: cp -f latex/refman.pdf fltk.pdf (why is this extra step needed ?) +# +# Working directory: fltk/documentation +# +# Used in: Makefile and CMakeLists.txt + +run_pdflatex() { + pdflatex --interaction=nonstopmode \ + "\pdfinfo{/CreationDate(@PDF_DATE@)/ModDate(@PDF_DATE@)}\input{refman.tex}" +} + +( cd latex + run_pdflatex + makeindex refman.idx + run_pdflatex + latex_count=5 + while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log \ + && [ $latex_count -gt 0 ] + do + echo "Rerunning pdflatex ..." + pdflatex --interaction=nonstopmode refman.tex + latex_count=`expr $latex_count - 1` + done + cd ..) > pdfall.log 2>&1 diff --git a/documentation/src/fltk-title.tex.in b/documentation/src/fltk-title.tex.in index cc7f853c9..5096461c2 100644 --- a/documentation/src/fltk-title.tex.in +++ b/documentation/src/fltk-title.tex.in @@ -25,7 +25,7 @@ provided this copyright and permission notice are preserved.}\\ \vspace*{1.5cm} {\large Generated by Doxygen @DOXY_VERSION@}\\ \vspace*{0.5cm} -\today{}\\ +@TODAY@\\ \vspace*{0.5cm} {\small Git revision @FLTK_GIT_REVISION@}\\ \end{center} -- cgit v1.2.3