[前][次][番号順一覧][スレッド一覧]

ruby-changes:71536

From: Hiroshi <ko1@a...>
Date: Tue, 29 Mar 2022 19:07:37 +0900 (JST)
Subject: [ruby-changes:71536] 8e2a2ba0f9 (master): Merge psych master

https://git.ruby-lang.org/ruby.git/commit/?id=8e2a2ba0f9

From 8e2a2ba0f98adb5f8b189b963a82cbc0ecea7410 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Tue, 29 Mar 2022 17:45:33 +0900
Subject: Merge psych master

  https://github.com/ruby/psych/commit/c386ecb0c24eeb9693cc4ad3b1f263b2622c4f1e
---
 ext/psych/extconf.rb | 76 +++++++++++++++++++++++++++++-----------------------
 ext/psych/extlibs    |  7 +++++
 2 files changed, 49 insertions(+), 34 deletions(-)
 create mode 100644 ext/psych/extlibs

diff --git a/ext/psych/extconf.rb b/ext/psych/extconf.rb
index 0e4fb86a0b..17c0deee96 100644
--- a/ext/psych/extconf.rb
+++ b/ext/psych/extconf.rb
@@ -1,48 +1,56 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/extconf.rb#L1
 # -*- coding: us-ascii -*-
 # frozen_string_literal: true
 require 'mkmf'
-require 'fileutils'
 
-# :stopdoc:
-
-dir_config 'libyaml'
-
-if enable_config("bundled-libyaml", false) || !pkg_config('yaml-0.1') && !(find_header('yaml.h') && find_library('yaml', 'yaml_get_version'))
-  # Embed libyaml since we could not find it.
+if $mswin or $mingw or $cygwin
+  $CPPFLAGS << " -DYAML_DECLARE_STATIC"
+end
 
-  unless File.exist?("#{$srcdir}/yaml")
-    puts "failed to build psych because no libyaml is available"
-    exit
+yaml_source = with_config("libyaml-source-dir") || enable_config("bundled-libyaml", false)
+if yaml_source == true
+  yaml_source = Dir.glob("#{$srcdir}/yaml{,-*}/").max_by {|n| File.basename(n).scan(/\d+/).map(&:to_i)}
+  unless yaml_source
+    require_relative '../../tool/extlibs.rb'
+    extlibs = ExtLibs.new(cache_dir: File.expand_path("../../tmp/download_cache", $srcdir))
+    unless extlibs.process_under($srcdir)
+      raise "failed to download libyaml source"
+    end
+    yaml_source, = Dir.glob("#{$srcdir}/yaml-*/")
   end
-
-  $VPATH << "$(srcdir)/yaml"
-  $INCFLAGS << " -I$(srcdir)/yaml"
-
-  $srcs = Dir.glob("#{$srcdir}/{,yaml/}*.c").map {|n| File.basename(n)}.sort
-
-  header = 'yaml/yaml.h'
-  header = "{$(VPATH)}#{header}" if $nmake
-  if have_macro("_WIN32")
-    $CPPFLAGS << " -DYAML_DECLARE_STATIC -DHAVE_CONFIG_H"
+elsif yaml_source
+  yaml_source = yaml_source.gsub(/\$\((\w+)\)|\$\{(\w+)\}/) {ENV[$1||$2]}
+end
+if yaml_source
+  yaml_configure = "#{File.expand_path(yaml_source)}/configure"
+  unless File.exist?(yaml_configure)
+    raise "Configure script not found in #{yaml_source.quote}"
   end
 
-  have_header 'dlfcn.h'
-  have_header 'inttypes.h'
-  have_header 'memory.h'
-  have_header 'stdint.h'
-  have_header 'stdlib.h'
-  have_header 'strings.h'
-  have_header 'string.h'
-  have_header 'sys/stat.h'
-  have_header 'sys/types.h'
-  have_header 'unistd.h'
-
-  find_header 'yaml.h'
-  have_header 'config.h'
+  puts("Configuring libyaml source in #{yaml_source.quote}")
+  yaml = "libyaml"
+  Dir.mkdir(yaml) unless File.directory?(yaml)
+  unless system(yaml_configure, "-q",
+                "--enable-#{$enable_shared || !$static ? 'shared' : 'static'}",
+                *(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
+                chdir: yaml)
+    raise "failed to configure libyaml"
+  end
+  Logging.message("libyaml configured\n")
+  inc = yaml_source.start_with?("#$srcdir/") ? "$(srcdir)#{yaml_source[$srcdir.size..-1]}" : yaml_source
+  $INCFLAGS << " -I#{yaml}/include -I#{inc}/include"
+  Logging.message("INCLFAG=#$INCLFAG\n")
+  libyaml = "#{yaml}/src/.libs/libyaml.#$LIBEXT"
+  $LOCAL_LIBS.prepend("$(LIBYAML) ")
+else
+  pkg_config('yaml-0.1')
+  dir_config('libyaml')
+  unless find_header('yaml.h') && find_library('yaml', 'yaml_get_version')
+    raise "libyaml not found"
+  end
 end
 
 create_makefile 'psych' do |mk|
-  mk << "YAML_H = #{header}".strip << "\n"
+  mk << "LIBYAML = #{libyaml}".strip << "\n"
 end
 
 # :startdoc:
diff --git a/ext/psych/extlibs b/ext/psych/extlibs
new file mode 100644
index 0000000000..b4ac02edf7
--- /dev/null
+++ b/ext/psych/extlibs
@@ -0,0 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/extlibs#L1
+ver = 0.2.5
+
+https://github.com/yaml/libyaml/releases/download/$(ver)/yaml-$(ver).tar.gz \
+	rmd160:cc175ed640046722fb7790de828002633407b6b9 \
+	sha256:c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4 \
+	sha512:dadd7d8e0d88b5ebab005e5d521d56d541580198aa497370966b98c904586e642a1cd4f3881094eb57624f218d50db77417bbfd0ffdce50340f011e35e8c4c02 \
+	#
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]