summaryrefslogtreecommitdiff
path: root/version.c
diff options
context:
space:
mode:
Diffstat (limited to 'version.c')
-rw-r--r--version.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/version.c b/version.c
index bb6c15fb7a..5547832652 100644
--- a/version.c
+++ b/version.c
@@ -12,6 +12,7 @@
#include "internal/cmdlineopt.h"
#include "internal/parse.h"
#include "internal/gc.h"
+#include "ruby/internal/globals.h"
#include "ruby/ruby.h"
#include "version.h"
#include "vm_core.h"
@@ -24,8 +25,9 @@
#ifdef RUBY_REVISION
# if RUBY_PATCHLEVEL == -1
+# define RUBY_API_VERSION_NAME "master"
# ifndef RUBY_BRANCH_NAME
-# define RUBY_BRANCH_NAME "master"
+# define RUBY_BRANCH_NAME RUBY_API_VERSION_NAME
# endif
# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION
# else
@@ -35,6 +37,9 @@
# define RUBY_REVISION "HEAD"
# define RUBY_REVISION_STR ""
#endif
+#ifndef RUBY_API_VERSION_NAME
+# define RUBY_API_VERSION_NAME RUBY_API_VERSION_STR
+#endif
#if !defined RUBY_RELEASE_DATETIME || RUBY_PATCHLEVEL != -1
# undef RUBY_RELEASE_DATETIME
# define RUBY_RELEASE_DATETIME RUBY_RELEASE_DATE
@@ -44,6 +49,9 @@
#define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
#define MKINT(name) INT2FIX(ruby_##name)
+#define RUBY_API_VERSION_STR \
+ STRINGIZE(RUBY_API_VERSION_MAJOR) "." \
+ STRINGIZE(RUBY_API_VERSION_MINOR)
const int ruby_api_version[] = {
RUBY_API_VERSION_MAJOR,
RUBY_API_VERSION_MINOR,
@@ -66,11 +74,6 @@ const int ruby_api_version[] = {
#else
#define ZJIT_DESCRIPTION " +ZJIT"
#endif
-#if USE_ZJIT
-#define JIT_DESCRIPTION ZJIT_DESCRIPTION
-#else
-#define JIT_DESCRIPTION YJIT_DESCRIPTION
-#endif
#if USE_MODULAR_GC
#define GC_DESCRIPTION " +GC"
#else
@@ -81,6 +84,7 @@ const char ruby_revision[] = RUBY_FULL_REVISION;
const char ruby_release_date[] = RUBY_RELEASE_DATE;
const char ruby_platform[] = RUBY_PLATFORM;
const int ruby_patchlevel = RUBY_PATCHLEVEL;
+const char ruby_api_version_name[] = RUBY_API_VERSION_NAME;
const char ruby_description[] =
"ruby " RUBY_VERSION RUBY_PATCHLEVEL_STR " "
"(" RUBY_RELEASE_DATETIME RUBY_REVISION_STR ") "
@@ -110,6 +114,12 @@ define_ruby_const(VALUE mod, const char *name, VALUE value, bool toplevel)
#define rb_define_const(mod, name, value) \
define_ruby_const(mod, (mod == mRuby ? "RUBY_" name : name), value, (mod == mRuby))
+void
+Init_Ruby_module(void)
+{
+ rb_define_module("Ruby");
+}
+
/*! Defines platform-depended Ruby-level constants */
void
Init_version(void)
@@ -200,6 +210,8 @@ rb_ruby_default_parser_set(ruby_default_parser_enum parser)
static void
define_ruby_description(const char *const jit_opt)
{
+#define JIT_DESCRIPTION YJIT_DESCRIPTION ZJIT_DESCRIPTION
+
static char desc[
sizeof(ruby_description)
+ rb_strlen_lit(JIT_DESCRIPTION)
@@ -241,6 +253,7 @@ define_ruby_description(const char *const jit_opt)
* The full ruby version string, like <tt>ruby -v</tt> prints
*/
rb_define_const(mRuby, "DESCRIPTION", /* MKSTR(description) */ description);
+#undef JIT_DESCRIPTION
}
void
@@ -263,6 +276,15 @@ ruby_set_yjit_description(void)
}
void
+ruby_set_zjit_description(void)
+{
+ VALUE mRuby = rb_path2class("Ruby");
+ rb_const_remove(rb_cObject, rb_intern("RUBY_DESCRIPTION"));
+ rb_const_remove(mRuby, rb_intern("DESCRIPTION"));
+ define_ruby_description(ZJIT_DESCRIPTION);
+}
+
+void
ruby_show_version(void)
{
puts(rb_dynamic_description);