From 9568d5bb737eb468e87fd43f21404e2def101e30 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 12 Aug 2024 19:58:32 +0200 Subject: Display Git revision in docs generated from releases (#499) - makesrcdist: store Git revision in a file in the tarball - CMake/resources.cmake: get git revision either from Git or file and store it as CMake cache variable 'FLTK_GIT_REVISION' for reference - documentation/*: get git revision from git or file - fluid/documentation/*: get git revision from git or file --- documentation/CMakeLists.txt | 27 +++------------------------ documentation/Makefile | 22 ++++++++++++++++++---- documentation/generated.dox.in | 4 ++-- documentation/src/fltk-title.tex.in | 2 +- 4 files changed, 24 insertions(+), 31 deletions(-) (limited to 'documentation') diff --git a/documentation/CMakeLists.txt b/documentation/CMakeLists.txt index cf9699449..150771a0d 100644 --- a/documentation/CMakeLists.txt +++ b/documentation/CMakeLists.txt @@ -1,7 +1,7 @@ # # CMakeLists.txt to build docs for the FLTK project using CMake (www.cmake.org) # -# Copyright 1998-2023 by Bill Spitzak and others. +# Copyright 1998-2024 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 @@ -16,7 +16,6 @@ set(DOCS) set(GENERATE_DOCS FALSE) -set(GIT_REVISION "") set(YEAR "") set(CURRENT_DATE "") @@ -49,28 +48,8 @@ if(GENERATE_DOCS) OUTPUT_STRIP_TRAILING_WHITESPACE ) - # find git revision - - # FIXME: This must also work with tarballs where git is not available. - # For now we just ignore errors and set GIT_REVISION = "unknown". - # In the future tarball/zip generation should create a file - # that contains the git revision. - - execute_process(COMMAND - git rev-parse --short=10 HEAD - OUTPUT_VARIABLE GIT_REVISION - OUTPUT_STRIP_TRAILING_WHITESPACE - WORKING_DIRECTORY ${FLTK_SOURCE_DIR} - ERROR_QUIET - ) - - # set to "'unknown'" if git is not available - if(GIT_REVISION STREQUAL "") - set(GIT_REVISION "'unknown'") - endif() - # Find "short" doxygen version if it was built from Git - # Note: this is still needed in CMake 3.12.0 but later CMake versions + # Note: this is still needed in CMake 3.15 but later CMake versions # (notably 3.25) remove the Git revision in 'DOXYGEN_VERSION'. # Todo: Find the "first good" CMake version and remove this redundant # code once we require this as our minimal version and replace the @@ -98,7 +77,7 @@ if(GENERATE_DOCS) if(0) # debug fl_debug_var(YEAR) fl_debug_var(CURRENT_DATE) - fl_debug_var(GIT_REVISION) + fl_debug_var(FLTK_GIT_REVISION) fl_debug_var(DOXYGEN_FOUND) fl_debug_var(DOXYGEN_EXECUTABLE) fl_debug_var(DOXYGEN_VERSION) diff --git a/documentation/Makefile b/documentation/Makefile index a93345980..972c1b791 100644 --- a/documentation/Makefile +++ b/documentation/Makefile @@ -55,6 +55,17 @@ MANPAGES = $(SRC_DOCDIR)/fltk.$(CAT3EXT) $(SRC_DOCDIR)/fltk-config.$(CAT1EXT) \ $(SRC_DOCDIR)/checkers.$(CAT6EXT) $(SRC_DOCDIR)/sudoku.$(CAT6EXT) \ $(SRC_DOCDIR)/fltk-options.$(CAT1EXT) +# Get FLTK's Git Revision either from Git /or/ from fltk_git_rev.dat (Issue #499) +# +# Note: this may fail (return "unknown") if the sources were downloaded +# from GitHub as a "release" (zip) archive. This is not supported. + +# Test/debug only: should be commented out unless used (see: debug_git_rev) +# GIT_REV_FROM_GIT := "$$(git rev-parse HEAD 2>/dev/null)" +# GIT_REV_FROM_FILE := "$$(cat ../fltk_git_rev.dat 2>/dev/null)" + +FLTK_GIT_REVISION := "`( (git rev-parse HEAD || cat ../fltk_git_rev.dat;) || echo 'unknown'; ) 2>/dev/null`" + all: $(MANPAGES) # Use `make docs' to create all docs for distribution files. @@ -67,6 +78,11 @@ docs: all html pdf alldocs: docs dist: docs +debug_git_rev: + # echo "GIT_REV_FROM_GIT = $(GIT_REV_FROM_GIT)" + # echo "GIT_REV_FROM_FILE = $(GIT_REV_FROM_FILE)" + echo "FLTK_GIT_REVISION = $(FLTK_GIT_REVISION)" + clean: $(RM) Doxyfile Doxybook $(RM) copyright.dox generated.dox @@ -203,8 +219,7 @@ refman.pdf: $(HTMLFILES) Doxybook src/fltk-book.tex src/fltk-title.tex: src/fltk-title.tex.in echo "Generating $@ ..." - GIT_REVISION=`git rev-parse --short=10 HEAD`; \ - sed -e"s/@GIT_REVISION@/$$GIT_REVISION/g" \ + sed -e"s/@FLTK_GIT_REVISION@/$(FLTK_GIT_REVISION)/g" \ < $< > $@ src/fltk-book.tex.in: src/fltk-title.tex @@ -223,10 +238,9 @@ src/fltk-book.tex: src/fltk-book.tex.in generated.dox: generated.dox.in echo "Generating $@ ..." CURRENT_DATE=`date "+%b %d, %Y"`; \ - GIT_REVISION=`git rev-parse --short=10 HEAD`; \ DOXYGEN_VERSION_SHORT=`"$(DOXYDOC)" --version|cut -f1 -d' '`; \ sed -e"s/@CURRENT_DATE@/$$CURRENT_DATE/g" \ - -e"s/@GIT_REVISION@/$$GIT_REVISION/g" \ + -e"s/@FLTK_GIT_REVISION@/$(FLTK_GIT_REVISION)/g" \ -e"s/@DOXYGEN_VERSION_SHORT@/$$DOXYGEN_VERSION_SHORT/g" \ < $< > $@ diff --git a/documentation/generated.dox.in b/documentation/generated.dox.in index 9ab6987e0..75f8dfc1e 100644 --- a/documentation/generated.dox.in +++ b/documentation/generated.dox.in @@ -1,6 +1,6 @@
Generated on @CURRENT_DATE@ - from Git revision @GIT_REVISION@ - by Doxygen @DOXYGEN_VERSION_SHORT@ + from Git revision '@FLTK_GIT_REVISION@' + by Doxygen version '@DOXYGEN_VERSION_SHORT@' diff --git a/documentation/src/fltk-title.tex.in b/documentation/src/fltk-title.tex.in index c4c7c1813..8a5e2dee2 100644 --- a/documentation/src/fltk-title.tex.in +++ b/documentation/src/fltk-title.tex.in @@ -27,7 +27,7 @@ provided this copyright and permission notice are preserved.}\\ \vspace*{0.5cm} \today{}\\ \vspace*{0.5cm} -{\small Git revision @GIT_REVISION@}\\ +{\small Git revision '@FLTK_GIT_REVISION@'}\\ \end{center} \end{titlepage} % -- cgit v1.2.3