Skip to content

Commit

Permalink
cmake: pass git reversion 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 92d8320 commit 199a824
Show file tree
Hide file tree
Showing 7 changed files with 412 additions and 9 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), os: windows-latest, shell: sh, vendored: true, cmake: '-GNinja', msvc: 1, shared: 1, static: 0 }
- { name: Windows (MSVC), os: windows-latest, shell: sh, vendored: true, cmake: '-DPerl_ROOT=C:/Strawberry/perl/bin/ -GNinja', msvc: 1, shared: 1, static: 0 }
- { name: Windows (mingw64), os: windows-latest, shell: 'msys2 {0}', vendored: false, msystem: mingw64, msys-env: mingw-w64-x86_64, shared: 1, static: 0,
cmake: '-DSDL3IMAGE_BACKEND_STB=OFF -DSDL3IMAGE_BACKEND_WIC=OFF -DSDL3IMAGE_AVIF=ON -G "Ninja Multi-Config"' }
- { name: Linux, os: ubuntu-latest, shell: sh, vendored: false, cmake: '-GNinja', shared: 1, static: 0, nojxl: true }
Expand All @@ -38,6 +38,7 @@ jobs:
${{ matrix.platform.msys-env }}-cmake
${{ matrix.platform.msys-env }}-gcc
${{ matrix.platform.msys-env }}-ninja
${{ matrix.platform.msys-env }}-perl
${{ matrix.platform.msys-env }}-pkg-config
${{ matrix.platform.msys-env }}-nasm
${{ matrix.platform.msys-env }}-libavif
Expand Down
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ project(SDL3_image
VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}"
)

include(PrivateSdlFunctions)
include(sdlmanpages)
include("${SDL3_image_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake" )
include("${SDL3_image_SOURCE_DIR}/cmake/PrivateSdlFunctions.cmake" )
include("${SDL3_image_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 @@ -804,7 +805,7 @@ if(SDL3IMAGE_INSTALL)
else()
set(SDL3IMAGE_INSTALL_CMAKEDIR_ROOT_DEFAULT "${CMAKE_INSTALL_LIBDIR}/cmake")
endif()
set(SDL3IMAGE_INSTALL_CMAKEDIR_ROOT "${SDL3IMAGE_INSTALL_CMAKEDIR_ROOT_DEFAULT}" CACHE STRING "Root folder where to install SDL3Config.cmake related files (SDL3 subfolder for MSVC projects)")
set(SDL3IMAGE_INSTALL_CMAKEDIR_ROOT "${SDL3IMAGE_INSTALL_CMAKEDIR_ROOT_DEFAULT}" CACHE STRING "Root folder where to install SDL3_imageConfig.cmake related files (SDL3_image subfolder for MSVC projects)")
set(SDLIMAGE_PKGCONFIG_INSTALLDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

if(WIN32 AND NOT MINGW)
Expand Down Expand Up @@ -854,10 +855,12 @@ if(SDL3IMAGE_INSTALL)
)

if(SDL3IMAGE_INSTALL_MAN)
sdl_get_git_revision_hash(SDL3IMAGE_REVISION)
SDL_generate_manpages(
HEADERS_DIR "${PROJECT_SOURCE_DIR}/include/SDL3_image"
SYMBOL "IMG_Init"
WIKIHEADERS_PL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build-scripts/wikiheaders.pl"
REVISION "${SDL3IMAGE_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 199a824

Please sign in to comment.