1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Auto-generate the release date on version.h from git CommitDate (#6382)

* Auto-generate the release date on version.h

from git CommitDate

* Generate revision.h on mswin
This commit is contained in:
Takashi Kokubun 2022-09-17 21:16:06 +09:00 committed by GitHub
parent ca4cbe59ed
commit 38a7a13ac6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-09-17 21:16:27 +09:00
Merged-By: k0kubun <takashikkbn@gmail.com>
7 changed files with 37 additions and 16 deletions

View file

@ -1214,7 +1214,7 @@ $(BUILTIN_RB_INCS): $(top_srcdir)/tool/mk_builtin_loader.rb
$(srcdir)/revision.h:
$(srcdir)/revision.h$(gnumake:yes=-nongnumake):
$(Q)$(RM) $(@F)
$(Q)$(NULLCMD) > $@ || $(NULLCMD) > $(@F)
$(NULLCMD) > $(@F)
revision.tmp::
$(Q) $(NULLCMD) > $@
@ -8275,6 +8275,7 @@ load.$(OBJEXT): {$(VPATH)}vm_core.h
load.$(OBJEXT): {$(VPATH)}vm_opts.h
loadpath.$(OBJEXT): $(hdrdir)/ruby/ruby.h
loadpath.$(OBJEXT): $(hdrdir)/ruby/version.h
loadpath.$(OBJEXT): $(top_srcdir)/revision.h
loadpath.$(OBJEXT): $(top_srcdir)/version.h
loadpath.$(OBJEXT): {$(VPATH)}assert.h
loadpath.$(OBJEXT): {$(VPATH)}backward/2/assume.h

View file

@ -66,7 +66,13 @@ OptionParser.new {|opts|
new_vcs["."]
end
}
exit unless vcs
unless vcs
# Output only release_date when .git is missing
if @output == :revision_h
puts VCS.release_date(Time.now - 10) # same as make-snapshot
end
exit
end
@output =
case @output
@ -76,7 +82,7 @@ exit unless vcs
}
when :revision_h
Proc.new {|last, changed, modified, branch, title|
vcs.revision_header(last, modified, branch, title, limit: @limit)
vcs.revision_header(last, modified, modified, branch, title, limit: @limit)
}
when :doxygen
Proc.new {|last, changed|

View file

@ -95,6 +95,15 @@ class VCS
opts
end
def self.release_date(time)
t = time.utc
[
t.strftime('#define RUBY_RELEASE_YEAR %Y'),
t.strftime('#define RUBY_RELEASE_MONTH %-m'),
t.strftime('#define RUBY_RELEASE_DAY %-d'),
]
end
attr_reader :srcdir
def initialize(path)
@ -204,7 +213,8 @@ class VCS
revision_handler(rev).short_revision(rev)
end
def revision_header(last, modified = nil, branch = nil, title = nil, limit: 20)
# make-snapshot generates only release_date whereas file2lastrev generates both release_date and release_datetime
def revision_header(last, release_date, release_datetime = nil, branch = nil, title = nil, limit: 20)
short = short_revision(last)
if /[^\x00-\x7f]/ =~ title and title.respond_to?(:force_encoding)
title = title.dup.force_encoding("US-ASCII")
@ -225,10 +235,11 @@ class VCS
title = title.dump.sub(/\\#/, '#')
code << "#define RUBY_LAST_COMMIT_TITLE #{title}"
end
if modified
t = modified.utc
if release_datetime
t = release_datetime.utc
code << t.strftime('#define RUBY_RELEASE_DATETIME "%FT%TZ"')
end
code += VCS.release_date(release_date)
code
end
@ -386,7 +397,10 @@ class VCS
end
class GIT < self
register(".git") {|path, dir| File.exist?(File.join(path, dir))}
register(".git") do |path, dir|
File.exist?(File.join(path, dir)) &&
(`#{COMMAND} -v` rescue false) # make sure git command exists
end
COMMAND = ENV["GIT"] || 'git'
def cmd_args(cmds, srcdir = nil)

View file

@ -347,7 +347,7 @@ def package(vcs, rev, destdir, tmp = nil)
end
File.open("#{v}/revision.h", "wb") {|f|
f.puts vcs.revision_header(revision)
f.puts vcs.revision_header(revision, modified)
}
version ||= (versionhdr = IO.read("#{v}/version.h"))[RUBY_VERSION_PATTERN, 1]
version ||=

View file

@ -13,13 +13,12 @@
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL -1
#define RUBY_RELEASE_YEAR 2022
#define RUBY_RELEASE_MONTH 9
#define RUBY_RELEASE_DAY 17
#include "ruby/version.h"
#include "ruby/internal/abi.h"
#ifndef RUBY_REVISION
#include "revision.h"
#ifndef TOKEN_PASTE
#define TOKEN_PASTE(x,y) x##y
#endif
@ -38,6 +37,8 @@
#define RUBY_RELEASE_DAY_STR STRINGIZE(RUBY_RELEASE_DAY)
#endif
#endif
#ifdef RUBY_ABI_VERSION
# define RUBY_ABI_VERSION_SUFFIX "+"STRINGIZE(RUBY_ABI_VERSION)
#else
@ -61,8 +62,4 @@
#define RUBY_PATCHLEVEL_STR ""
#endif
#ifndef RUBY_REVISION
# include "revision.h"
#endif
#endif /* RUBY_TOPLEVEL_VERSION_H */

View file

@ -1244,6 +1244,8 @@ $(RCFILES): $(RBCONFIG) $(srcdir)/revision.h $(srcdir)/win32/resource.rb
-so_name=$(RUBY_SO_NAME) \
. $(icondirs) $(win_srcdir)
$(srcdir)/revision.h: $(REVISION_H)
update-benchmark-driver:
$(GIT) clone https://github.com/benchmark-driver/benchmark-driver $(srcdir)/benchmark/benchmark-driver || \
$(GIT) -C $(srcdir)/benchmark/benchmark-driver pull origin master

View file

@ -89,6 +89,7 @@ if exist %dest% (
)
)
for %%I in (%1) do echo %%~I updated
del /f %dest%
copy %src% %dest% > nul
del %src%