Top Level Namespace

Defined Under Namespace

Modules: Nokogiri, XSD

Constant Summary collapse

PACKAGE_ROOT_DIR =

helpful constants

File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
REQUIRED_LIBXML_VERSION =
"2.9.2"
"2.12.0"
REQUIRED_MINI_PORTILE_VERSION =

keep this version in sync with the one in the gemspec

"~> 2.8.2"
REQUIRED_PKG_CONFIG_VERSION =
"~> 1.1"
OTHER_LIBRARY_VERSIONS =

Keep track of what versions of what libraries we build against

{}
NOKOGIRI_HELP_MESSAGE =
<<~HELP
  USAGE: ruby #{$PROGRAM_NAME} [options]

    Flags that are always valid:

      --use-system-libraries
      --enable-system-libraries
          Use system libraries instead of building and using the packaged libraries.

      --disable-system-libraries
          Use the packaged libraries, and ignore the system libraries. This is the default on most
          platforms, and overrides `--use-system-libraries` and the environment variable
          `NOKOGIRI_USE_SYSTEM_LIBRARIES`.

      --disable-clean
          Do not clean out intermediate files after successful build.

      --prevent-strip
          Take steps to prevent stripping the symbol table and debugging info from the shared
          library, potentially overriding RbConfig's CFLAGS/LDFLAGS/DLDFLAGS.


    Flags only used when using system libraries:

      General:

        --with-opt-dir=DIRECTORY
            Look for headers and libraries in DIRECTORY.

        --with-opt-lib=DIRECTORY
            Look for libraries in DIRECTORY.

        --with-opt-include=DIRECTORY
            Look for headers in DIRECTORY.


      Related to libxml2:

        --with-xml2-dir=DIRECTORY
            Look for xml2 headers and library in DIRECTORY.

        --with-xml2-lib=DIRECTORY
            Look for xml2 library in DIRECTORY.

        --with-xml2-include=DIRECTORY
            Look for xml2 headers in DIRECTORY.

        --with-xml2-source-dir=DIRECTORY
            (dev only) Build libxml2 from the source code in DIRECTORY

        --disable-xml2-legacy
            Do not build libxml2 with zlib, liblzma, or HTTP support. This will become the default
            in a future version of Nokogiri.


      Related to libxslt:

        --with-xslt-dir=DIRECTORY
            Look for xslt headers and library in DIRECTORY.

        --with-xslt-lib=DIRECTORY
            Look for xslt library in DIRECTORY.

        --with-xslt-include=DIRECTORY
            Look for xslt headers in DIRECTORY.

        --with-xslt-source-dir=DIRECTORY
            (dev only) Build libxslt from the source code in DIRECTORY


      Related to libexslt:

        --with-exslt-dir=DIRECTORY
            Look for exslt headers and library in DIRECTORY.

        --with-exslt-lib=DIRECTORY
            Look for exslt library in DIRECTORY.

        --with-exslt-include=DIRECTORY
            Look for exslt headers in DIRECTORY.


      Related to iconv:

        --with-iconv-dir=DIRECTORY
            Look for iconv headers and library in DIRECTORY.

        --with-iconv-lib=DIRECTORY
            Look for iconv library in DIRECTORY.

        --with-iconv-include=DIRECTORY
            Look for iconv headers in DIRECTORY.


      Related to zlib (ignored if `--disable-xml2-legacy` is used):

        --with-zlib-dir=DIRECTORY
            Look for zlib headers and library in DIRECTORY.

        --with-zlib-lib=DIRECTORY
            Look for zlib library in DIRECTORY.

        --with-zlib-include=DIRECTORY
            Look for zlib headers in DIRECTORY.


    Flags only used when building and using the packaged libraries:

      --disable-static
          Do not statically link packaged libraries, instead use shared libraries.

      --enable-cross-build
          Enable cross-build mode. (You probably do not want to set this manually.)


    Environment variables used:

      NOKOGIRI_USE_SYSTEM_LIBRARIES
          Equivalent to `--enable-system-libraries` when set, even if nil or blank.

      AR
          Use this path to invoke the library archiver instead of `RbConfig::CONFIG['AR']`

      CC
          Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`

      CPPFLAGS
          If this string is accepted by the C preprocessor, add it to the flags passed to the C preprocessor

      CFLAGS
          If this string is accepted by the compiler, add it to the flags passed to the compiler

      LD
          Use this path to invoke the linker instead of `RbConfig::CONFIG['LD']`

      LDFLAGS
          If this string is accepted by the linker, add it to the flags passed to the linker

      LIBS
          Add this string to the flags passed to the linker
HELP
LOCAL_PACKAGE_RESPONSE =
Object.new

Instance Method Summary collapse

Instance Method Details

#abort_could_not_find_library(lib) ⇒ Object



327
328
329
330
# File 'ext/nokogiri/extconf.rb', line 327

def abort_could_not_find_library(lib)
  callers = caller(1..2).join("\n")
  abort("-----\n#{callers}\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----")
end

#aix?Boolean

Returns:

  • (Boolean)


208
209
210
# File 'ext/nokogiri/extconf.rb', line 208

def aix?
  RbConfig::CONFIG["target_os"].include?("aix")
end

#chdir_for_build(&block) ⇒ Object



332
333
334
335
336
337
338
# File 'ext/nokogiri/extconf.rb', line 332

def chdir_for_build(&block)
  # When using rake-compiler-dock on Windows, the underlying Virtualbox shared
  # folders don't support symlinks, but libiconv expects it for a build on
  # Linux. We work around this limitation by using the temp dir for cooking.
  build_dir = /mingw|mswin|cygwin/.match?(ENV["RCD_HOST_RUBY_PLATFORM"].to_s) ? "/tmp" : "."
  Dir.chdir(build_dir, &block)
end

#concat_flags(*args) ⇒ Object



224
225
226
# File 'ext/nokogiri/extconf.rb', line 224

def concat_flags(*args)
  args.compact.join(" ")
end

#config_clean?Boolean

utility functions

Returns:

  • (Boolean)


169
170
171
# File 'ext/nokogiri/extconf.rb', line 169

def config_clean?
  enable_config("clean", true)
end

#config_cross_build?Boolean

Returns:

  • (Boolean)


178
179
180
# File 'ext/nokogiri/extconf.rb', line 178

def config_cross_build?
  enable_config("cross-build")
end

#config_static?Boolean

Returns:

  • (Boolean)


173
174
175
176
# File 'ext/nokogiri/extconf.rb', line 173

def config_static?
  default_static = !truffle?
  enable_config("static", default_static)
end

#config_system_libraries?Boolean

Returns:

  • (Boolean)


182
183
184
185
186
# File 'ext/nokogiri/extconf.rb', line 182

def config_system_libraries?
  enable_config("system-libraries", ENV.key?("NOKOGIRI_USE_SYSTEM_LIBRARIES")) do |_, default|
    arg_config("--use-system-libraries", default)
  end
end

#config_with_xml2_legacy?Boolean

Returns:

  • (Boolean)


188
189
190
# File 'ext/nokogiri/extconf.rb', line 188

def config_with_xml2_legacy?
  enable_config("xml2-legacy", true)
end

#copy_packaged_libraries_headers(to_path:, from_recipes:) ⇒ Object



565
566
567
568
569
570
571
# File 'ext/nokogiri/extconf.rb', line 565

def copy_packaged_libraries_headers(to_path:, from_recipes:)
  FileUtils.rm_rf(to_path, secure: true)
  FileUtils.mkdir(to_path)
  from_recipes.each do |recipe|
    FileUtils.cp_r(Dir[File.join(recipe.path, "include/*")], to_path)
  end
end

#darwin?Boolean

Returns:

  • (Boolean)


200
201
202
# File 'ext/nokogiri/extconf.rb', line 200

def darwin?
  RbConfig::CONFIG["target_os"].include?("darwin")
end

#do_cleanObject



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# File 'ext/nokogiri/extconf.rb', line 578

def do_clean
  root = Pathname(PACKAGE_ROOT_DIR)
  pwd  = Pathname(Dir.pwd)

  # Skip if this is a development work tree
  unless (root + ".git").exist?
    message("Cleaning files only used during build.\n")

    # (root + 'tmp') cannot be removed at this stage because
    # nokogiri.so is yet to be copied to lib.

    # clean the ports build directory
    Pathname.glob(pwd.join("tmp", "*", "ports")) do |dir|
      FileUtils.rm_rf(dir, verbose: true)
    end

    if config_static?
      # ports installation can be safely removed if statically linked.
      FileUtils.rm_rf(root + "ports", verbose: true)
    else
      FileUtils.rm_rf(root + "ports" + "archives", verbose: true)
    end
  end

  exit!(0)
end

#do_helpObject



573
574
575
576
# File 'ext/nokogiri/extconf.rb', line 573

def do_help
  print(NOKOGIRI_HELP_MESSAGE)
  exit!(0)
end

#ensure_func(func, headers = nil) ⇒ Object



316
317
318
# File 'ext/nokogiri/extconf.rb', line 316

def ensure_func(func, headers = nil)
  have_func(func, headers) || abort_could_not_find_library(func)
end

#ensure_package_configuration(opt: nil, pc: nil, lib:, func:, headers:) ⇒ Object



311
312
313
314
# File 'ext/nokogiri/extconf.rb', line 311

def ensure_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
  have_package_configuration(opt: opt, pc: pc, lib: lib, func: func, headers: headers) ||
    abort_could_not_find_library(lib)
end

#gnome_sourceObject



242
243
244
245
246
247
248
249
250
251
252
# File 'ext/nokogiri/extconf.rb', line 242

def gnome_source
  # As of 2022-02-20, some mirrors have expired SSL certificates. I'm able to retrieve from my home,
  # but whatever host is resolved on the github actions workers see an expired cert.
  #
  # See https://github.com/sparklemotion/nokogiri/runs/5266206403?check_suite_focus=true
  if ENV["NOKOGIRI_USE_CANONICAL_GNOME_SOURCE"]
    "https://download.gnome.org"
  else
    "https://muug.ca/mirror/gnome" # old reliable
  end
end

#have_libxml_headers?(version = nil) ⇒ Boolean

Returns:

  • (Boolean)


369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'ext/nokogiri/extconf.rb', line 369

def have_libxml_headers?(version = nil)
  source = if version.nil?
    <<~SRC
      #include <libxml/xmlversion.h>
    SRC
  else
    version_int = format("%d%2.2d%2.2d", *version.split("."))
    <<~SRC
      #include <libxml/xmlversion.h>
      #if LIBXML_VERSION < #{version_int}
      #  error libxml2 is older than #{version}
      #endif
    SRC
  end

  try_cpp(source)
end

#have_package_configuration(opt: nil, pc: nil, lib:, func:, headers:) ⇒ Object

set up mkmf to link against the library if we can find it



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'ext/nokogiri/extconf.rb', line 294

def have_package_configuration(opt: nil, pc: nil, lib:, func:, headers:)
  if opt
    dir_config(opt)
    dir_config("opt")
  end

  # see if we have enough path info to do this without trying any harder
  unless ENV.key?("NOKOGIRI_TEST_PKG_CONFIG")
    return true if local_have_library(lib, func, headers)
  end

  try_package_configuration(pc) if pc

  # verify that we can compile and link against the library
  local_have_library(lib, func, headers)
end

#iconv_configure_flagsObject



408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
# File 'ext/nokogiri/extconf.rb', line 408

def iconv_configure_flags
  # give --with-iconv-dir and --with-opt-dir first priority
  ["iconv", "opt"].each do |target|
    config = preserving_globals { dir_config(target) }
    next unless config.any? && try_link_iconv("--with-#{target}-* flags") { dir_config(target) }

    idirs, ldirs = config.map do |dirs|
      Array(dirs).flat_map do |dir|
        dir.split(File::PATH_SEPARATOR)
      end if dirs
    end

    return [
      "--with-iconv=yes",
      *("CPPFLAGS=#{idirs.map { |dir| "-I" + dir }.join(" ")}" if idirs),
      *("LDFLAGS=#{ldirs.map { |dir| "-L" + dir }.join(" ")}" if ldirs),
    ]
  end

  if try_link_iconv
    return ["--with-iconv=yes"]
  end

  config = preserving_globals { pkg_config("libiconv") }
  if config && try_link_iconv("pkg-config libiconv") { pkg_config("libiconv") }
    cflags, ldflags, libs = config

    return [
      "--with-iconv=yes",
      "CPPFLAGS=#{cflags}",
      "LDFLAGS=#{ldflags}",
      "LIBS=#{libs}",
    ]
  end

  abort_could_not_find_library("libiconv")
end

#libflag_to_filename(ldflag) ⇒ Object



362
363
364
365
366
367
# File 'ext/nokogiri/extconf.rb', line 362

def libflag_to_filename(ldflag)
  case ldflag
  when /\A-l(.+)/
    "lib#{Regexp.last_match(1)}.#{$LIBEXT}"
  end
end

#local_have_library(lib, func = nil, headers = nil) ⇒ Object



228
229
230
# File 'ext/nokogiri/extconf.rb', line 228

def local_have_library(lib, func = nil, headers = nil)
  have_library(lib, func, headers) || have_library("lib#{lib}", func, headers)
end

#needs_darwin_linker_hackObject

In ruby 3.2, symbol resolution changed on Darwin, to introduce the ‘-bundle_loader` flag to resolve symbols against the ruby binary.

This makes it challenging to build a single extension that works with both a ruby with ‘–enable-shared` and one with `–disable-shared. To work around that, we choose to add `-flat_namespace` to the link line (later in this file).

The ‘-flat_namespace` line introduces its own behavior change, which is that (similar to on Linux), any symbols in the extension that are exported may now be resolved by shared libraries loaded by the Ruby process. Specifically, that means that libxml2 and libxslt, which are statically linked into the nokogiri bundle, will resolve (at runtime) to a system libxml2 loaded by Ruby on Darwin. And it appears that often Ruby on Darwin does indeed load the system libxml2, and that messes with our assumptions about whether we’re running with a patched libxml2 or a vanilla libxml2.

We choose to use ‘-load_hidden` in this case to prevent exporting those symbols from libxml2 and libxslt, which ensures that they will be resolved to the static libraries in the bundle. In other words, when we use `load_hidden`, what happens in the extension stays in the extension.

See github.com/rake-compiler/rake-compiler-dock/issues/87 for more info.

Anyway, this method is the logical bit to tell us when to turn on these workarounds.



627
628
629
630
631
# File 'ext/nokogiri/extconf.rb', line 627

def needs_darwin_linker_hack
  config_cross_build? &&
    darwin? &&
    Gem::Requirement.new("~> 3.2").satisfied_by?(Gem::Version.new(RbConfig::CONFIG["ruby_version"].split("+").first))
end

#nix?Boolean

Returns:

  • (Boolean)


216
217
218
# File 'ext/nokogiri/extconf.rb', line 216

def nix?
  ENV.key?("NIX_CC")
end

#Nokogiri(*args, &block) ⇒ Object

Parse a document contained in args. Nokogiri will try to guess what type of document you are attempting to parse. For more information, see Nokogiri.parse

To specify the type of document, use Nokogiri.XML, Nokogiri.HTML4, or Nokogiri.HTML5.



108
109
110
111
112
113
114
# File 'lib/nokogiri.rb', line 108

def Nokogiri(*args, &block)
  if block
    Nokogiri::HTML4::Builder.new(&block).doc.root
  else
    Nokogiri.parse(*args)
  end
end

#openbsd?Boolean

Returns:

  • (Boolean)


204
205
206
# File 'ext/nokogiri/extconf.rb', line 204

def openbsd?
  RbConfig::CONFIG["target_os"].include?("openbsd")
end

#preserving_globalsObject



320
321
322
323
324
325
# File 'ext/nokogiri/extconf.rb', line 320

def preserving_globals
  values = [$arg_config, $INCFLAGS, $CFLAGS, $CPPFLAGS, $LDFLAGS, $DLDFLAGS, $LIBPATH, $libs].map(&:dup)
  yield
ensure
  $arg_config, $INCFLAGS, $CFLAGS, $CPPFLAGS, $LDFLAGS, $DLDFLAGS, $LIBPATH, $libs = values
end

#process_recipe(name, version, static_p, cross_p, cacheable_p = true) ⇒ Object



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'ext/nokogiri/extconf.rb', line 446

def process_recipe(name, version, static_p, cross_p, cacheable_p = true)
  require "rubygems"
  gem("mini_portile2", REQUIRED_MINI_PORTILE_VERSION) # gemspec is not respected at install time
  require "mini_portile2"
  message("Using mini_portile version #{MiniPortile::VERSION}\n")

  unless ["libxml2", "libxslt"].include?(name)
    OTHER_LIBRARY_VERSIONS[name] = version
  end

  MiniPortile.new(name, version).tap do |recipe|
    def recipe.port_path
      "#{@target}/#{RUBY_PLATFORM}/#{@name}/#{@version}"
    end

    # We use 'host' to set compiler prefix for cross-compiling. Prefer host_alias over host. And
    # prefer i686 (what external dev tools use) to i386 (what ruby's configure.ac emits).
    recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
    recipe.host = recipe.host.gsub("i386", "i686")

    recipe.target = File.join(PACKAGE_ROOT_DIR, "ports") if cacheable_p
    recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}"

    yield recipe

    env = Hash.new do |hash, key|
      hash[key] = (ENV[key]).to_s
    end

    recipe.configure_options.flatten!

    recipe.configure_options.delete_if do |option|
      case option
      when /\A(\w+)=(.*)\z/
        env[Regexp.last_match(1)] = if env.key?(Regexp.last_match(1))
          concat_flags(env[Regexp.last_match(1)], Regexp.last_match(2))
        else
          Regexp.last_match(2)
        end
        true
      else
        false
      end
    end

    if static_p
      recipe.configure_options += [
        "--disable-shared",
        "--enable-static",
      ]
      env["CFLAGS"] = concat_flags(env["CFLAGS"], "-fPIC")
    else
      recipe.configure_options += [
        "--enable-shared",
        "--disable-static",
      ]
    end

    if cross_p
      recipe.configure_options += [
        "--target=#{recipe.host}",
        "--host=#{recipe.host}",
      ]
    end

    if RbConfig::CONFIG["target_cpu"] == "universal"
      ["CFLAGS", "LDFLAGS"].each do |key|
        unless env[key].include?("-arch")
          env[key] = concat_flags(env[key], RbConfig::CONFIG["ARCH_FLAG"])
        end
      end
    end

    recipe.configure_options += env.map do |key, value|
      "#{key}=#{value.strip}"
    end

    checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{RUBY_PLATFORM}.installed"
    if File.exist?(checkpoint) && !recipe.source_directory
      message("Building Nokogiri with a packaged version of #{name}-#{version}.\n")
    else
      message(<<~EOM)
        ---------- IMPORTANT NOTICE ----------
        Building Nokogiri with a packaged version of #{name}-#{version}.
        Configuration options: #{recipe.configure_options.shelljoin}
      EOM

      unless recipe.patch_files.empty?
        message("The following patches are being applied:\n")

        recipe.patch_files.each do |patch|
          message(format("  - %s\n", File.basename(patch)))
        end
      end

      message(<<~EOM) if name != "libgumbo"

        The Nokogiri maintainers intend to provide timely security updates, but if
        this is a concern for you and want to use your OS/distro system library
        instead, then abort this installation process and install nokogiri as
        instructed at:

          https://nokogiri.org/tutorials/installing_nokogiri.html#installing-using-standard-system-libraries

      EOM

      message(<<~EOM) if name == "libxml2"
        Note, however, that nokogiri cannot guarantee compatibility with every
        version of libxml2 that may be provided by OS/package vendors.

      EOM

      chdir_for_build { recipe.cook }
      FileUtils.touch(checkpoint)
    end
    recipe.activate
  end
end

#sh_export_path(path) ⇒ Object



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'ext/nokogiri/extconf.rb', line 340

def sh_export_path(path)
  # because libxslt 1.1.29 configure.in uses AC_PATH_TOOL which treats ":"
  # as a $PATH separator, we need to convert windows paths from
  #
  #   C:/path/to/foo
  #
  # to
  #
  #   /C/path/to/foo
  #
  # which is sh-compatible, in order to find things properly during
  # configuration
  return path unless windows?

  match = Regexp.new("^([A-Z]):(/.*)").match(path)
  if match && match.length == 3
    return File.join("/", match[1], match[2])
  end

  path
end

#solaris?Boolean

Returns:

  • (Boolean)


196
197
198
# File 'ext/nokogiri/extconf.rb', line 196

def solaris?
  RbConfig::CONFIG["target_os"].include?("solaris")
end

#truffle?Boolean

Returns:

  • (Boolean)


220
221
222
# File 'ext/nokogiri/extconf.rb', line 220

def truffle?
  RUBY_ENGINE == "truffleruby"
end


387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'ext/nokogiri/extconf.rb', line 387

def try_link_iconv(using = nil)
  checking_for(using ? "iconv using #{using}" : "iconv") do
    ["", "-liconv"].any? do |opt|
      preserving_globals do
        yield if block_given?

        try_link(<<~SRC, opt)
          #include <stdlib.h>
          #include <iconv.h>
          int main(void)
          {
              iconv_t cd = iconv_open("", "");
              iconv(cd, NULL, NULL, NULL, NULL);
              return EXIT_SUCCESS;
          }
        SRC
      end
    end
  end
end

#try_package_configuration(pc) ⇒ Object

wrapper around MakeMakefil#pkg_config and the PKGConfig gem



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'ext/nokogiri/extconf.rb', line 260

def try_package_configuration(pc)
  unless ENV.key?("NOKOGIRI_TEST_PKG_CONFIG_GEM")
    # try MakeMakefile#pkg_config, which uses the system utility `pkg-config`.
    return if checking_for("#{pc} using `pkg_config`", LOCAL_PACKAGE_RESPONSE) do
      pkg_config(pc)
    end
  end

  # `pkg-config` probably isn't installed, which appears to be the case for lots of freebsd systems.
  # let's fall back to the pkg-config gem, which knows how to parse .pc files, and wrap it with the
  # same logic as MakeMakefile#pkg_config
  begin
    require "rubygems"
    gem("pkg-config", REQUIRED_PKG_CONFIG_VERSION)
    require "pkg-config"

    checking_for("#{pc} using pkg-config gem version #{PKGConfig::VERSION}", LOCAL_PACKAGE_RESPONSE) do
      if PKGConfig.have_package(pc)
        cflags  = PKGConfig.cflags(pc)
        ldflags = PKGConfig.libs_only_L(pc)
        libs    = PKGConfig.libs_only_l(pc)

        Logging.message("pkg-config gem found package configuration for %s\n", pc)
        Logging.message("cflags: %s\nldflags: %s\nlibs: %s\n\n", cflags, ldflags, libs)

        [cflags, ldflags, libs]
      end
    end
  rescue LoadError
    message("Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n")
  end
end

#unix?Boolean

Returns:

  • (Boolean)


212
213
214
# File 'ext/nokogiri/extconf.rb', line 212

def unix?
  !(windows? || solaris? || darwin?)
end

#windows?Boolean

Returns:

  • (Boolean)


192
193
194
# File 'ext/nokogiri/extconf.rb', line 192

def windows?
  RbConfig::CONFIG["target_os"].match?(/mingw|mswin/)
end

#zlib_source(version_string) ⇒ Object



232
233
234
235
236
237
238
239
240
# File 'ext/nokogiri/extconf.rb', line 232

def zlib_source(version_string)
  # As of 2022-12, I'm starting to see failed downloads often enough from zlib.net that I want to
  # change the default to github.
  if ENV["NOKOGIRI_USE_CANONICAL_ZLIB_SOURCE"]
    "https://zlib.net/fossils/zlib-#{version_string}.tar.gz"
  else
    "https://github.com/madler/zlib/releases/download/v#{version_string}/zlib-#{version_string}.tar.gz"
  end
end