Skip to content

Commit

Permalink
ext: Fix the build with system libgit2 1.9.0
Browse files Browse the repository at this point in the history
Update version.h parsing regexes for 1.9.0 and fix compilation test by
including git2.h instead of directly including git2/version.h, which is
no longer supported.
  • Loading branch information
Pete Walter committed Jan 15, 2025
1 parent 762fd37 commit 5fee507
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ext/rugged/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ def self.run_cmake(timeout, args)
major = minor = nil

File.readlines(File.join(LIBGIT2_DIR, "include", "git2", "version.h")).each do |line|
if !major && (matches = line.match(/^#define LIBGIT2_VER_MAJOR\s+([0-9]+)$/))
if !major && (matches = line.match(/^#define LIBGIT2_VERSION_MAJOR\s+([0-9]+)$/))
major = matches[1]
next
end

if !minor && (matches = line.match(/^#define LIBGIT2_VER_MINOR\s+([0-9]+)$/))
if !minor && (matches = line.match(/^#define LIBGIT2_VERSION_MINOR\s+([0-9]+)$/))
minor = matches[1]
next
end
Expand All @@ -85,9 +85,9 @@ def self.run_cmake(timeout, args)
end

try_compile(<<-SRC) or abort "libgit2 version is not compatible, expected ~> #{major}.#{minor}.0"
#include <git2/version.h>
#include <git2.h>
#if LIBGIT2_VER_MAJOR != #{major} || LIBGIT2_VER_MINOR != #{minor}
#if LIBGIT2_VERSION_MAJOR != #{major} || LIBGIT2_VERSION_MINOR != #{minor}
#error libgit2 version is not compatible
#endif
SRC
Expand Down

0 comments on commit 5fee507

Please sign in to comment.