Skip to content

Commit

Permalink
update CImg.h version to 179 to fix leaking file descriptors
Browse files Browse the repository at this point in the history
fix PR#65 => westonplatter#65
  • Loading branch information
ryoga-chan committed Nov 22, 2023
1 parent d8ed3cb commit 2bd0f0e
Show file tree
Hide file tree
Showing 3 changed files with 58,703 additions and 11 deletions.
22 changes: 12 additions & 10 deletions ext/phashion_ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@
if File.exist?("lib")
puts "pHash already built; run 'rake clean' first if you need to rebuild."
else
puts(cmd = "tar xzf #{BUNDLE} 2>&1")
puts(cmd = "tar -xzf #{BUNDLE} 2>&1")
raise "'#{cmd}' failed" unless system(cmd)

puts "patching pHash sources for PNG alpha channel support"
puts(cmd = "patch -d pHash-0.9.6 -p1 < patches/png_alpha.diff")
puts(cmd = "patch -d pHash-0.9.6 -p1 < #{File.join 'patches', 'png_alpha.diff'}")
raise "'#{cmd}' failed" unless system(cmd)

puts "updating config.{guess,sub} to support newer architectures"
FileUtils.cp_f 'patches/config.sub' , BASEDIR
FileUtils.cp_f 'patches/config.guess', BASEDIR
FileUtils.mv File.join('patches', 'config.sub' ), BUNDLE_PATH, force: true
FileUtils.mv File.join('patches', 'config.guess'), BUNDLE_PATH, force: true

puts "updating CImg header version"
FileUtils.mv 'patches/CImg.h', BUNDLE_PATH, force: true

Dir.chdir(BUNDLE_PATH) do
puts(cmd = "env CXXFLAGS='#{$CXXFLAGS}' CFLAGS='#{$CFLAGS}' LDFLAGS='#{$LDFLAGS}' ./configure --prefix=#{BASEDIR} --disable-audio-hash --disable-video-hash --disable-shared --with-pic 2>&1")
Expand All @@ -38,16 +41,15 @@
puts(cmd = "make install || true 2>&1")
raise "'#{cmd}' failed" unless system(cmd)

puts(cmd = "mv CImg.h ../include 2>&1")
raise "'#{cmd}' failed" unless system(cmd)
FileUtils.mv %w{ CImg.h pHash-config.h }, '../include', force: true
end

system("rm -rf #{BUNDLE_PATH}") unless ENV['DEBUG'] or ENV['DEV']
FileUtils.rm_rf BUNDLE_PATH unless ENV['DEBUG'] or ENV['DEV']
end

Dir.chdir("#{BASEDIR}/lib") do
system("cp -f libpHash.a libpHash_gem.a")
system("cp -f libpHash.la libpHash_gem.la")
Dir.chdir('lib') do
FileUtils.mv 'libpHash.a' , 'libpHash_gem.a' , force: true
FileUtils.mv 'libpHash.la', 'libpHash_gem.la', force: true
end # Dir.chdir /lib

$LIBS = " -lpthread -lpHash_gem -lstdc++ -ljpeg -lpng -lm"
Expand Down
Loading

0 comments on commit 2bd0f0e

Please sign in to comment.