wikiheaders.pl: add --rev= option to pass revision string

This way, git is not required anymore to calculate the git revision
main
Anonymous Maarten 2023-09-04 18:56:00 +02:00
parent 233789b0d1
commit e85206ffd8
3 changed files with 18 additions and 5 deletions

View File

@ -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")

View File

@ -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");

View File

@ -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"
)