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

delete mk_builtin_binary.rb

To generate what is necessary via generic_erb.rb instead.
This commit is contained in:
卜部昌平 2020-05-05 18:00:59 +09:00
parent 191cfcc407
commit 4fca592e8c
Notes: git 2020-05-10 16:51:41 +09:00
3 changed files with 33 additions and 46 deletions

View file

@ -1121,8 +1121,9 @@ preludes: {$(srcdir)}golf_prelude.c
$(ECHO) making $@
$(Q) $(BASERUBY) $(tooldir)/mk_builtin_loader.rb $<
builtin_binary.inc: $(PREP) $(BUILTIN_RB_SRCS) $(tooldir)/mk_builtin_binary.rb
$(Q) $(MINIRUBY) $(tooldir)/mk_builtin_binary.rb --cross=$(CROSS_COMPILING)
builtin_binary.inc: $(PREP) $(BUILTIN_RB_SRCS) $(srcdir)/template/builtin_binary.inc.tmpl
$(Q) $(MINIRUBY) $(tooldir)/generic_erb.rb -c -o $@ \
$(srcdir)/template/builtin_binary.inc.tmpl -- --cross=$(CROSS_COMPILING)
$(BUILTIN_RB_INCS): $(top_srcdir)/tool/mk_builtin_loader.rb

View file

@ -0,0 +1,30 @@
// -*- c -*-
% ary = RubyVM.enum_for(:each_builtin).to_a
// DO NOT MODIFY THIS FILE DIRECTLY.
// auto-generated file by tool/generic_erb.rb
// with template/builtin_binary.inc.tmpl
% unless ARGV.include?('--corss=yes')
% ary.each{|feature, iseq|
static const unsigned char <%= feature %>_bin[] = {
% iseq \
% . to_binary \
% . each_byte \
% . map(&:ord) \
% . map{ '0x%02x' % _1 } \
% . each_slice(12) {|a|
<%= a.join(', ') %>,
% }
};
% }
static const struct builtin_binary builtin_binary[] = {
% ary.each{|feature, |
{ <%= feature.dump %>, <%= feature %>_bin, sizeof(<%= feature %>_bin), },
% }
{ NULL, },<%# dummy entry %>
};
#define BUILTIN_BINARY_SIZE <%= ary.size %>
STATIC_ASSERT(n_builtin, numberof(builtin_binary) == BUILTIN_BINARY_SIZE + 1);
% end

View file

@ -1,44 +0,0 @@
#
# make builtin_binary.inc file.
#
def dump_bin iseq
bin = iseq.to_binary
bin.each_byte.with_index{|b, index|
print "\n " if (index%20) == 0
print " 0x#{'%02x' % b.ord},"
}
print "\n"
end
$stdout = open('builtin_binary.inc', 'wb')
puts <<H
// -*- c -*-
// DO NOT MODIFY THIS FILE DIRECTLY.
// auto-generated file by #{File.basename(__FILE__)}
H
if ARGV.include?('--cross=yes')
# do nothing
else
ary = []
RubyVM::each_builtin{|feature, iseq|
ary << [feature, iseq]
}
ary.each{|feature, iseq|
print "\n""static const unsigned char #{feature}_bin[] = {"
dump_bin(iseq)
puts "};"
}
print "\n""static const struct builtin_binary builtin_binary[] = {\n"
ary.each{|feature, iseq|
puts " {#{feature.dump}, #{feature}_bin, sizeof(#{feature}_bin)},"
}
puts " {NULL}," # dummy sentry
puts "};"
puts "#define BUILTIN_BINARY_SIZE #{ary.size}"
end