diff --git a/CMakeLists.txt b/CMakeLists.txt index c97a3989b..c9108712d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3360,6 +3360,7 @@ if(NOT SDL_DISABLE_INSTALL) SDL_generate_manpages( SYMBOL "SDL_Init" WIKIHEADERS_PL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build-scripts/wikiheaders.pl" + REVISION "${SDL_REVISION}" ) if(TARGET SDL3-javadoc) set(SDL_INSTALL_JAVADOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/javadoc" CACHE PATH "Path where to install SDL3 javadoc") diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl index bb09faa8c..a2792a865 100755 --- a/build-scripts/wikiheaders.pl +++ b/build-scripts/wikiheaders.pl @@ -31,6 +31,7 @@ my $optionsfname = undef; my $wikipreamble = undef; my $changeformat = undef; my $manpath = undef; +my $gitrev = undef; foreach (@ARGV) { $warn_about_missing = 1, next if $_ eq '--warn-about-missing'; @@ -47,6 +48,9 @@ foreach (@ARGV) { } elsif (/\A--manpath=(.*)\Z/) { $manpath = $1; next; + } elsif (/\A--rev=(.*)\Z/) { + $gitrev = $1; + next; } $srcpath = $_, next if not defined $srcpath; $wikipath = $_, next if not defined $wikipath; @@ -1437,8 +1441,10 @@ if ($copy_direction == 1) { # --copy-to-headers close(FH); } - my $gitrev = `cd "$srcpath" ; git rev-list HEAD~..`; - chomp($gitrev); + if (!$gitrev) { + $gitrev = `cd "$srcpath" ; git rev-list HEAD~..`; + chomp($gitrev); + } # !!! FIXME open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n"); diff --git a/cmake/sdlmanpages.cmake b/cmake/sdlmanpages.cmake index 0049de1f9..cc706dd70 100644 --- a/cmake/sdlmanpages.cmake +++ b/cmake/sdlmanpages.cmake @@ -2,7 +2,9 @@ include(CMakeParseArguments) include(GNUInstallDirs) function(SDL_generate_manpages) - cmake_parse_arguments(ARG "" "RESULT_VARIABLE;NAME;BUILD_DOCDIR;HEADERS_DIR;SOURCE_DIR;SYMBOL;OPTION_FILE;WIKIHEADERS_PL_PATH" "" ${ARGN}) + cmake_parse_arguments(ARG "" "RESULT_VARIABLE;NAME;BUILD_DOCDIR;HEADERS_DIR;SOURCE_DIR;SYMBOL;OPTION_FILE;WIKIHEADERS_PL_PATH;REVISION" "" ${ARGN}) + + set(wikiheaders_extra_args) if(NOT ARG_NAME) set(ARG_NAME "${PROJECT_NAME}") @@ -25,6 +27,10 @@ function(SDL_generate_manpages) message(FATAL_ERROR "Missing required SYMBOL argument") endif() + if(ARG_REVISION) + list(APPEND wikiheaders_extra_args "--rev=${ARG_REVISION}") + endif() + if(NOT ARG_BUILD_DOCDIR) set(ARG_BUILD_DOCDIR "${CMAKE_CURRENT_BINARY_DIR}/docs") endif() @@ -40,13 +46,13 @@ function(SDL_generate_manpages) add_custom_command( OUTPUT "${BUILD_WIKIDIR}/${ARG_SYMBOL}.md" COMMAND "${CMAKE_COMMAND}" -E make_directory "${BUILD_WIKIDIR}" - COMMAND "${PERL_EXECUTABLE}" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_SOURCE_DIR}" "${BUILD_WIKIDIR}" "--options=${ARG_OPTION_FILE}" --copy-to-wiki + COMMAND "${PERL_EXECUTABLE}" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_SOURCE_DIR}" "${BUILD_WIKIDIR}" "--options=${ARG_OPTION_FILE}" --copy-to-wiki ${wikiheaders_extra_args} DEPENDS ${HEADER_FILES} "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_OPTION_FILE}" COMMENT "Generating ${ARG_NAME} wiki markdown files" ) add_custom_command( OUTPUT "${BUILD_MANDIR}/man3/${ARG_SYMBOL}.3" - COMMAND "${PERL_EXECUTABLE}" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_SOURCE_DIR}" "${BUILD_WIKIDIR}" "--options=${ARG_OPTION_FILE}" "--manpath=${BUILD_MANDIR}" --copy-to-manpages + COMMAND "${PERL_EXECUTABLE}" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_SOURCE_DIR}" "${BUILD_WIKIDIR}" "--options=${ARG_OPTION_FILE}" "--manpath=${BUILD_MANDIR}" --copy-to-manpages ${wikiheaders_extra_args} DEPENDS "${BUILD_WIKIDIR}/${ARG_SYMBOL}.md" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_OPTION_FILE}" COMMENT "Generating ${ARG_NAME} man pages" )