Files
chromebrew/packages/libpng.rb
Maximilian Downey Twiss f6dc1d8d4e Derive binary_url in package.rb (#7082)
* Add binary_compression value to each package

* Remove binary_url values and arrays

* Handle packages with empty binary_sha256 arrays (either missing binaries or not compiled by us)
2024-01-25 11:03:31 -05:00

99 lines
3.0 KiB
Ruby

require 'package'
class Libpng < Package
description 'libpng is the official PNG reference library.'
homepage 'http://libpng.org/pub/png/libpng.html'
version '1.6.39'
license 'libpng2'
compatibility 'all'
source_url 'https://git.code.sf.net/p/libpng/code.git'
git_hashtag "v#{version}"
binary_compression 'tar.zst'
binary_sha256({
aarch64: '54bea8afba78bd2388704137d49b5151a9d0f8dcaafacff02436ec510e2ae627',
armv7l: '54bea8afba78bd2388704137d49b5151a9d0f8dcaafacff02436ec510e2ae627',
i686: 'd4516093258bc90eecb4cc4bfd16cd5540a6e056806df37b43695b8b9137982a',
x86_64: '6f7c139fc86ec24c0dce766b43a940441a0ab4b29f685f1110adcf03bad5d5d9'
})
depends_on 'zlibpkg'
depends_on 'glibc' # R
def self.build
system "cmake \
-B builddir -G Ninja \
#{CREW_CMAKE_OPTIONS.gsub('-mfpu=vfpv3-d16', '-mfpu=neon-fp16')} \
-DPNG_STATIC=OFF \
-Wno-dev"
system "#{CREW_NINJA} -C builddir"
end
def self.install
system "DESTDIR=#{CREW_DEST_DIR} #{CREW_NINJA} -C builddir install"
# Imagemagick wants a libtool file.
@libname = name.to_s.start_with?('lib') ? name.downcase : "lib#{name.downcase}"
@libnames = Dir["#{CREW_DEST_LIB_PREFIX}/#{@libname}.so*"]
@libnames = Dir["#{CREW_DEST_LIB_PREFIX}/#{@libname}-*.so*"] if @libnames.empty?
@libnames.each do |s|
s.gsub!("#{CREW_DEST_LIB_PREFIX}/", '')
end
@dlname = @libnames.grep(/.so./).first
@dlname = @libnames.grep(/.so/).first if @dlname.nil?
@libname = @dlname.gsub(/.so.\d+/, '')
@longest_libname = @libnames.max_by(&:length)
@libvars = @longest_libname.rpartition('.so.')[2].split('.')
@libtool_file = <<~LIBTOOLEOF
# #{@libname}.la - a libtool library file
# Generated by libtool (GNU libtool) (Created by Chromebrew)
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='#{@dlname}'
# Names of this library.
library_names='#{@libnames.reverse.join(' ')}'
# The name of the static archive.
old_library='#{@libname}.a'
# Linker flags that cannot go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=''
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for #{name}.
current=#{@libvars[1]}
age=#{@libvars[1]}
revision=#{@libvars[2]}
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='#{CREW_LIB_PREFIX}'
LIBTOOLEOF
File.write("#{CREW_DEST_LIB_PREFIX}/#{@libname}.la", @libtool_file)
end
def self.postinstall
return unless File.exist?("#{CREW_PREFIX}/bin/gdk-pixbuf-query-loaders")
system 'gdk-pixbuf-query-loaders',
'--update-cache'
end
end