1515REQUIRED_LIBXML_VERSION = "2.6.21"
1616RECOMMENDED_LIBXML_VERSION = "2.9.3"
1717
18- REQUIRED_MINI_PORTILE_VERSION = "~> 2.8.2 " # keep this version in sync with the one in the gemspec
18+ REQUIRED_MINI_PORTILE_VERSION = "2.9.0.rc1 " # keep this version in sync with the one in the gemspec
1919REQUIRED_PKG_CONFIG_VERSION = "~> 1.1"
2020
2121# Keep track of what versions of what libraries we build against
@@ -429,7 +429,6 @@ def process_recipe(name, version, static_p, cross_p, cacheable_p = true)
429429 require "rubygems"
430430 gem ( "mini_portile2" , REQUIRED_MINI_PORTILE_VERSION ) # gemspec is not respected at install time
431431 require "mini_portile2"
432- message ( "Using mini_portile version #{ MiniPortile ::VERSION } \n " )
433432
434433 unless [ "libxml2" , "libxslt" ] . include? ( name )
435434 OTHER_LIBRARY_VERSIONS [ name ] = version
@@ -540,7 +539,6 @@ def recipe.port_path
540539 chdir_for_build { recipe . cook }
541540 FileUtils . touch ( checkpoint )
542541 end
543- recipe . activate
544542 end
545543end
546544
@@ -804,6 +802,15 @@ def configure
804802 end
805803 end
806804
805+ zlib_recipe . mkmf_config ( pkg : "zlib" )
806+ ensure_package_configuration (
807+ opt : "zlib" ,
808+ pc : "zlib" ,
809+ lib : "z" ,
810+ headers : "zlib.h" ,
811+ func : "gzdopen" ,
812+ )
813+
807814 unless nix?
808815 libiconv_recipe = process_recipe (
809816 "libiconv" ,
@@ -829,7 +836,20 @@ def configure
829836 "LDFLAGS=" ,
830837 ]
831838 end
839+
840+ # libiconv does not ship with a pkg-config file
841+ # append_cppflags("-I#{libiconv_recipe.path}/include")
842+ # append_ldflags("-L#{libiconv_recipe.path}/lib")
843+ libiconv_recipe . mkmf_config
844+ ensure_package_configuration (
845+ opt : "iconv" ,
846+ pc : "iconv" ,
847+ lib : "iconv" ,
848+ headers : "iconv.h" ,
849+ func : "iconv_open" ,
850+ )
832851 end
852+
833853 elsif darwin? && !have_header ( "iconv.h" )
834854 abort ( <<~EOM . chomp )
835855 -----
@@ -845,30 +865,6 @@ def configure
845865 EOM
846866 end
847867
848- if zlib_recipe
849- append_cppflags ( "-I#{ zlib_recipe . path } /include" )
850- $LIBPATH = [ "#{ zlib_recipe . path } /lib" ] | $LIBPATH
851- ensure_package_configuration (
852- opt : "zlib" ,
853- pc : "zlib" ,
854- lib : "z" ,
855- headers : "zlib.h" ,
856- func : "gzdopen" ,
857- )
858- end
859-
860- if libiconv_recipe
861- append_cppflags ( "-I#{ libiconv_recipe . path } /include" )
862- $LIBPATH = [ "#{ libiconv_recipe . path } /lib" ] | $LIBPATH
863- ensure_package_configuration (
864- opt : "iconv" ,
865- pc : "iconv" ,
866- lib : "iconv" ,
867- headers : "iconv.h" ,
868- func : "iconv_open" ,
869- )
870- end
871-
872868 libxml2_recipe = process_recipe ( "libxml2" , dependencies [ "libxml2" ] [ "version" ] , static_p , cross_build_p ) do |recipe |
873869 source_dir = arg_config ( "--with-xml2-source-dir" )
874870 if source_dir
@@ -924,6 +920,9 @@ def configure
924920 ]
925921 end
926922
923+ libxml2_recipe . mkmf_config ( pkg : "libxml-2.0" )
924+ ensure_func ( "xmlParseDoc" , "libxml/parser.h" )
925+
927926 libxslt_recipe = process_recipe ( "libxslt" , dependencies [ "libxslt" ] [ "version" ] , static_p , cross_build_p ) do |recipe |
928927 source_dir = arg_config ( "--with-xslt-source-dir" )
929928 if source_dir
@@ -963,72 +962,27 @@ def configure
963962 ]
964963 end
965964
966- append_cppflags ( "-DNOKOGIRI_PACKAGED_LIBRARIES ")
967- append_cppflags ( "-DNOKOGIRI_PRECOMPILED_LIBRARIES" ) if cross_build_p
965+ libxslt_recipe . mkmf_config ( pkg : "libxslt ")
966+ ensure_func ( "xsltParseStylesheetDoc" , "libxslt/xslt.h" )
968967
969- $libs = $libs. shellsplit . tap do |libs |
970- [ libxml2_recipe , libxslt_recipe ] . each do |recipe |
971- libname = recipe . name [ /\A lib(.+)\z / , 1 ]
972- config_basename = "#{ libname } -config"
973- File . join ( recipe . path , "bin" , config_basename ) . tap do |config |
974- # call config scripts explicit with 'sh' for compat with Windows
975- cflags = %x(sh #{ config } --cflags) . strip
976- message ( "#{ config_basename } cflags: #{ cflags } \n " )
977- $CPPFLAGS = concat_flags ( cflags , $CPPFLAGS) # prepend
978-
979- %x(sh #{ config } --libs) . strip . shellsplit . each do |arg |
980- case arg
981- when /\A -L(.+)\z /
982- # Prioritize ports' directories
983- $LIBPATH = if Regexp . last_match ( 1 ) . start_with? ( PACKAGE_ROOT_DIR + "/" )
984- [ Regexp . last_match ( 1 ) ] | $LIBPATH
985- else
986- $LIBPATH | [ Regexp . last_match ( 1 ) ]
987- end
988- when /\A -l./
989- libs . unshift ( arg )
990- else
991- $LDFLAGS << " " << arg . shellescape
992- end
993- end
994- end
968+ libxslt_recipe . mkmf_config ( pkg : "libexslt" )
969+ ensure_func ( "exsltFuncRegister" , "libexslt/exslt.h" )
995970
996- patches_string = recipe . patch_files . map { |path | File . basename ( path ) } . join ( " " )
997- append_cppflags ( %[-DNOKOGIRI_#{ recipe . name . upcase } _PATCHES="\\ "#{ patches_string } \\ ""] )
971+ if windows?
972+ append_cppflags ( "-DLIBXSLT_STATIC -DLIBEXSLT_STATIC" ) # https://gitlab.gnome.org/GNOME/libxslt/-/merge_requests/66
973+ end
998974
999- case libname
1000- when "xml2"
1001- # xslt-config --libs or pkg-config libxslt --libs does not include
1002- # -llzma, so we need to add it manually when linking statically.
1003- if static_p && preserving_globals { local_have_library ( "lzma" ) }
1004- # Add it at the end; GH #988
1005- libs << "-llzma"
1006- end
1007- when "xslt"
1008- # xslt-config does not have a flag to emit options including
1009- # -lexslt, so add it manually.
1010- libs . unshift ( "-lexslt" )
1011- end
1012- end
1013- end . shelljoin
1014-
1015- if static_p
1016- static_archive_ld_flag = needs_darwin_linker_hack ? [ "-load_hidden" ] : [ ]
1017- $libs = $libs. shellsplit . map do |arg |
1018- case arg
1019- when "-lxml2"
1020- static_archive_ld_flag + [ File . join ( libxml2_recipe . path , "lib" , libflag_to_filename ( arg ) ) ]
1021- when "-lxslt" , "-lexslt"
1022- static_archive_ld_flag + [ File . join ( libxslt_recipe . path , "lib" , libflag_to_filename ( arg ) ) ]
1023- else
1024- arg
1025- end
1026- end . flatten . shelljoin
975+ # Nokogiri::VERSION_INFO metadata
976+ append_cppflags ( "-DNOKOGIRI_PACKAGED_LIBRARIES" )
977+ append_cppflags ( "-DNOKOGIRI_PRECOMPILED_LIBRARIES" ) if cross_build_p
978+ [ libxml2_recipe , libxslt_recipe ] . each do |recipe |
979+ patches_string = recipe . patch_files . map { |path | File . basename ( path ) } . join ( " " )
980+ append_cppflags ( %[-DNOKOGIRI_#{ recipe . name . upcase } _PATCHES="\\ "#{ patches_string } \\ ""] )
1027981 end
1028982
1029- ensure_func ( "xmlParseDoc" , "libxml/parser.h" )
1030- ensure_func ( "xsltParseStylesheetDoc" , "libxslt/xslt.h" )
1031- ensure_func ( "exsltFuncRegister" , "libexslt/exslt.h" )
983+ # if static_p
984+ # static_archive_ld_flag = needs_darwin_linker_hack ? ["-load_hidden"] : []
985+ # end
1032986end
1033987
1034988libgumbo_recipe = process_recipe ( "libgumbo" , "1.0.0-nokogiri" , static_p , cross_build_p , false ) do |recipe |
0 commit comments