diff --git a/tool/make-snapshot b/tool/make-snapshot index 89aad4b932..10bcd86be5 100755 --- a/tool/make-snapshot +++ b/tool/make-snapshot @@ -285,6 +285,14 @@ def package(vcs, rev, destdir, tmp = nil) open("#{v}/revision.h", "wb") {|f| f.puts "#define RUBY_REVISION #{revision}"} version ||= (versionhdr = IO.read("#{v}/version.h"))[RUBY_VERSION_PATTERN, 1] + version ||= + begin + include_ruby_versionhdr = IO.read("#{v}/include/ruby/version.h") + api_major_version = include_ruby_versionhdr[/^\#define\s+RUBY_API_VERSION_MAJOR\s+([\d.]+)/, 1] + api_minor_version = include_ruby_versionhdr[/^\#define\s+RUBY_API_VERSION_MINOR\s+([\d.]+)/, 1] + version_teeny = versionhdr[/^\#define\s+RUBY_VERSION_TEENY\s+(\d+)/, 1] + [api_major_version, api_minor_version, version_teeny].join('.') + end version or return if patchlevel unless tag.empty? @@ -384,6 +392,9 @@ def package(vcs, rev, destdir, tmp = nil) "BASERUBY"=>baseruby, "PWD"=>Dir.pwd, "ruby_version"=>version, + "MAJOR"=>api_major_version, + "MINOR"=>api_minor_version, + "TEENY"=>version_teeny, } status.scan(/^s([%,])@([A-Za-z_][A-Za-z_0-9]*)@\1(.*?)\1g$/) do vars[$2] ||= $3 diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb index 74736540cd..edfdda203b 100755 --- a/tool/mkconfig.rb +++ b/tool/mkconfig.rb @@ -201,6 +201,12 @@ IO.foreach(File.join(srcdir, "version.h")) do |l| break if versions.size == 4 next end + m = /^\s*#\s*define\s+RUBY_VERSION_(\w+)\s+(-?\d+)/.match(l) + if m + versions[m[1]] = m[2] + break if versions.size == 4 + next + end m = /^\s*#\s*define\s+RUBY_VERSION\s+\W?([.\d]+)/.match(l) if m versions['MAJOR'], versions['MINOR'], versions['TEENY'] = m[1].split('.') @@ -208,6 +214,16 @@ IO.foreach(File.join(srcdir, "version.h")) do |l| next end end +if versions.size != 4 + IO.foreach(File.join(srcdir, "include/ruby/version.h")) do |l| + m = /^\s*#\s*define\s+RUBY_API_VERSION_(\w+)\s+(-?\d+)/.match(l) + if m + versions[m[1]] ||= m[2] + break if versions.size == 4 + next + end + end +end %w[MAJOR MINOR TEENY PATCHLEVEL].each do |v| print " CONFIG[#{v.dump}] = #{(versions[v]||vars[v]).dump}\n" end