require 'package' class Expat < Package description 'James Clark\'s Expat XML parser library in C.' homepage 'https://github.com/libexpat/libexpat' version '2.6.2' license 'MIT' compatibility 'all' source_url 'https://github.com/libexpat/libexpat.git' git_hashtag "R_#{version.gsub('.', '_')}" binary_compression 'tar.zst' binary_sha256({ aarch64: '05ab05cd431d91d40d7b5d328ecc9eeb16b794585d47e8250d0e7cba463731a7', armv7l: '05ab05cd431d91d40d7b5d328ecc9eeb16b794585d47e8250d0e7cba463731a7', i686: '3595fcfc0f2fa0501a69cb57823fb5a100540725dd519b444389bcfa431187e1', x86_64: 'c3d018812a6434a6e0639be52434a3a45bdab4defd511c12d7c3c65c9434976e' }) depends_on 'glibc' # R def self.build Dir.chdir('expat') do system "mold -run cmake -B builddir #{CREW_CMAKE_OPTIONS} \ -DEXPAT_BUILD_EXAMPLES=OFF \ -DBUILD_SHARED_LIBS=ON \ -Wno-dev \ -G Ninja" system "mold -run #{CREW_NINJA} -C builddir" end end def self.check Dir.chdir('expat') do system "mold -run #{CREW_NINJA} -C builddir test" end end def self.install Dir.chdir('expat') do system "DESTDIR=#{CREW_DEST_DIR} #{CREW_NINJA} -C builddir install" end # Imagemagick7 wants a libtool file from expat. @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 @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 end