From f08400a07a966fba8d56c496669868f927781aba Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 10 Nov 2023 17:21:33 +0900 Subject: [PATCH] [ruby/io-console] Define IO::ConsoleMode::VERSION from gemspec https://github.com/ruby/io-console/commit/ebdbebf461 --- ext/io/console/console.c | 1 + ext/io/console/extconf.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/ext/io/console/console.c b/ext/io/console/console.c index f4257446c8..61b6e76327 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -1672,6 +1672,7 @@ InitVM_console(void) { /* :stopdoc: */ cConmode = rb_define_class_under(rb_cIO, "ConsoleMode", rb_cObject); + rb_define_const(cConmode, "VERSION", rb_str_new_cstr(STRINGIZE(IO_CONSOLE_VERSION))); rb_define_alloc_func(cConmode, conmode_alloc); rb_undef_method(cConmode, "initialize"); rb_define_method(cConmode, "initialize_copy", conmode_init_copy, 1); diff --git a/ext/io/console/extconf.rb b/ext/io/console/extconf.rb index a72403c7f9..aa0b6c6cfb 100644 --- a/ext/io/console/extconf.rb +++ b/ext/io/console/extconf.rb @@ -1,6 +1,11 @@ # frozen_string_literal: false require 'mkmf' +version = ["../../..", "."].find do |dir| + break File.read(File.join(__dir__, dir, "io-console.gemspec"))[/^_VERSION\s*=\s*"(.*?)"/, 1] +rescue +end + have_func("rb_io_path") have_func("rb_io_descriptor") have_func("rb_io_get_write_io") @@ -35,6 +40,7 @@ when true elsif have_func("rb_scheduler_timeout") # 3.0 have_func("rb_io_wait") end + $defs << "-D""IO_CONSOLE_VERSION=#{version}" create_makefile("io/console") {|conf| conf << "\n""VK_HEADER = #{vk_header}\n" }