Skip to content

Commit

Permalink
cmake: pass git revision to wikiheaders.pl to avoid executing git
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Sep 29, 2023
1 parent de1e383 commit 3184fb9
Show file tree
Hide file tree
Showing 7 changed files with 419 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows (MSVC+CMake), os: windows-latest, shell: sh, cmake: '-DSDL3TTF_VENDORED=ON -GNinja', msvc: 1, shared: 1, static: 0 }
- { name: Windows (MSVC+CMake), os: windows-latest, shell: sh, cmake: '-DPerl_ROOT=C:/Strawberry/perl/bin/ -DSDL3TTF_VENDORED=ON -GNinja', msvc: 1, shared: 1, static: 0 }
- { name: Windows (mingw64+CMake), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, shared: 1, static: 0,
cmake: '-DSDL3TTF_VENDORED=OFF -G "Ninja Multi-Config"' }
- { name: Linux, os: ubuntu-20.04, shell: sh, cmake: '-DSDL3TTF_VENDORED=ON -GNinja', shared: 1, static: 0 }
Expand Down Expand Up @@ -43,6 +43,7 @@ jobs:
${{ matrix.platform.msys-env }}-freetype
${{ matrix.platform.msys-env }}-harfbuzz
${{ matrix.platform.msys-env }}-ninja
${{ matrix.platform.msys-env }}-perl
${{ matrix.platform.msys-env }}-pkg-config
${{ matrix.platform.msys-env }}-zlib
- name: Set up SDL
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ project(SDL3_ttf
VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}"
)

include(PrivateSdlFunctions)
include(sdlmanpages)
include("${SDL3_ttf_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake")
include("${SDL3_ttf_SOURCE_DIR}/cmake/PrivateSdlFunctions.cmake")
include("${SDL3_ttf_SOURCE_DIR}/cmake/sdlmanpages.cmake")
sdl_calculate_derived_version_variables(${MAJOR_VERSION} ${MINOR_VERSION} ${MICRO_VERSION})

message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}")
Expand Down Expand Up @@ -334,10 +335,12 @@ if(SDL3TTF_INSTALL)
)

if(SDL3TTF_INSTALL_MAN)
sdl_get_git_revision_hash(SDL3TTF_REVISION)
SDL_generate_manpages(
HEADERS_DIR "${PROJECT_SOURCE_DIR}/include/SDL3_ttf"
SYMBOL "TTF_Init"
WIKIHEADERS_PL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build-scripts/wikiheaders.pl"
REVISION "${SDL3TTF_REVISION}"
)
endif()
endif()
Expand Down
49 changes: 47 additions & 2 deletions build-scripts/wikiheaders.pl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
my $wikipreamble = undef;
my $changeformat = undef;
my $manpath = undef;
my $gitrev = undef;

foreach (@ARGV) {
$warn_about_missing = 1, next if $_ eq '--warn-about-missing';
Expand All @@ -47,6 +48,9 @@
} 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;
Expand Down Expand Up @@ -788,6 +792,45 @@ sub usage {
}
closedir(DH);

delete $wikifuncs{"Undocumented"};

{
my $path = "$wikipath/Undocumented.md";
open(FH, '>', $path) or die("Can't open '$path': $!\n");

print FH "# Undocumented\n\n";

print FH "## Functions defined in the headers, but not in the wiki\n\n";
my $header_only_func = 0;
foreach (sort keys %headerfuncs) {
my $fn = $_;
if (not defined $wikifuncs{$fn}) {
print FH "- [$fn]($fn)\n";
$header_only_func = 1;
}
}
if (!$header_only_func) {
print FH "(none)\n";
}
print FH "\n";

print FH "## Functions defined in the wiki, but not in the headers\n\n";

my $wiki_only_func = 0;
foreach (sort keys %wikifuncs) {
my $fn = $_;
if (not defined $headerfuncs{$fn}) {
print FH "- [$fn]($fn)\n";
$wiki_only_func = 1;
}
}
if (!$wiki_only_func) {
print FH "(none)\n";
}
print FH "\n";

close(FH);
}

if ($warn_about_missing) {
foreach (keys %wikifuncs) {
Expand Down Expand Up @@ -1437,8 +1480,10 @@ sub usage {
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");
Expand Down
Loading

0 comments on commit 3184fb9

Please sign in to comment.