mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Introduce --basedir to insns2vm.rb
and leverage that to preserve the directory structure under tool/ruby_vm/views
This commit is contained in:
parent
12023c833f
commit
a988fe0b3e
5 changed files with 18 additions and 8 deletions
|
@ -505,9 +505,9 @@ clean-local::
|
||||||
-$(Q) $(RMDIRS) $(MJIT_HEADER_INSTALL_DIR) $(MJIT_HEADER_BUILD_DIR) $(TIMESTAMPDIR) 2> $(NULL) || $(NULLCMD)
|
-$(Q) $(RMDIRS) $(MJIT_HEADER_INSTALL_DIR) $(MJIT_HEADER_BUILD_DIR) $(TIMESTAMPDIR) 2> $(NULL) || $(NULLCMD)
|
||||||
|
|
||||||
main: $(srcdir)/lib/mjit/instruction.rb
|
main: $(srcdir)/lib/mjit/instruction.rb
|
||||||
$(srcdir)/lib/mjit/instruction.rb: $(tooldir)/ruby_vm/views/instruction.rb.erb $(srcdir)/insns.def
|
$(srcdir)/lib/mjit/instruction.rb: $(tooldir)/ruby_vm/views/lib/mjit/instruction.rb.erb $(srcdir)/insns.def
|
||||||
$(ECHO) generating $@
|
$(ECHO) generating $@
|
||||||
$(Q) $(BASERUBY) -Ku $(tooldir)/insns2vm.rb $(INSNS2VMOPT) $@
|
$(Q) $(BASERUBY) -Ku $(tooldir)/insns2vm.rb --basedir="$(srcdir)" $(INSNS2VMOPT) $@
|
||||||
|
|
||||||
# DTrace static library hacks described here:
|
# DTrace static library hacks described here:
|
||||||
# https://marc.info/?l=opensolaris-dtrace-discuss&m=114761203110734&w=4
|
# https://marc.info/?l=opensolaris-dtrace-discuss&m=114761203110734&w=4
|
||||||
|
|
|
@ -16,10 +16,11 @@ require_relative '../models/typemap'
|
||||||
require_relative '../loaders/vm_opts_h'
|
require_relative '../loaders/vm_opts_h'
|
||||||
|
|
||||||
class ApplicationController
|
class ApplicationController
|
||||||
def generate i, destdir
|
def generate i, destdir, basedir
|
||||||
path = Pathname.new i
|
path = Pathname.new i
|
||||||
dst = destdir ? Pathname.new(destdir).join(i) : Pathname.new(i)
|
dst = destdir ? Pathname.new(destdir).join(i) : Pathname.new(i)
|
||||||
dumper = RubyVM::Dumper.new dst
|
base = basedir ? Pathname.new(basedir) : Pathname.pwd
|
||||||
|
dumper = RubyVM::Dumper.new dst, base.expand_path
|
||||||
return [path, dumper]
|
return [path, dumper]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,7 @@ class RubyVM::Dumper
|
||||||
path = Pathname.new(__FILE__)
|
path = Pathname.new(__FILE__)
|
||||||
path = (path.relative_path_from(Pathname.pwd) rescue path).dirname
|
path = (path.relative_path_from(Pathname.pwd) rescue path).dirname
|
||||||
path += '../views'
|
path += '../views'
|
||||||
path += File.basename(spec)
|
path += Pathname.pwd.join(spec).to_s.sub("#{@base}/", '')
|
||||||
src = path.read mode: 'rt:utf-8:utf-8'
|
src = path.read mode: 'rt:utf-8:utf-8'
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
raise "don't know how to generate #{path}"
|
raise "don't know how to generate #{path}"
|
||||||
|
@ -85,10 +85,11 @@ class RubyVM::Dumper
|
||||||
. join
|
. join
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize dst
|
def initialize dst, base
|
||||||
@erb = {}
|
@erb = {}
|
||||||
@empty = new_binding
|
@empty = new_binding
|
||||||
@file = cstr dst.to_path
|
@file = cstr dst.to_path
|
||||||
|
@base = base
|
||||||
end
|
end
|
||||||
|
|
||||||
def render partial, opts = { :locals => {} }
|
def render partial, opts = { :locals => {} }
|
||||||
|
|
|
@ -15,10 +15,10 @@ require_relative '../controllers/application_controller.rb'
|
||||||
|
|
||||||
module RubyVM::Insns2VM
|
module RubyVM::Insns2VM
|
||||||
def self.router argv
|
def self.router argv
|
||||||
options = { destdir: nil }
|
options = { destdir: nil, basedir: nil }
|
||||||
targets = generate_parser(options).parse argv
|
targets = generate_parser(options).parse argv
|
||||||
return targets.map do |i|
|
return targets.map do |i|
|
||||||
next ApplicationController.new.generate i, options[:destdir]
|
next ApplicationController.new.generate i, options[:destdir], options[:basedir]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,6 +84,14 @@ module RubyVM::Insns2VM
|
||||||
options[:destdir] = dir
|
options[:destdir] = dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
this.on "--basedir=DIR", <<-'begin' do |dir|
|
||||||
|
Change the base directory from the current working directory
|
||||||
|
to the given path. Used for searching the source template.
|
||||||
|
begin
|
||||||
|
raise "directory was not found in '#{dir}'" unless Dir.exist?(dir)
|
||||||
|
options[:basedir] = dir
|
||||||
|
end
|
||||||
|
|
||||||
this.on "-V", "--[no-]verbose", <<-'end'
|
this.on "-V", "--[no-]verbose", <<-'end'
|
||||||
Please let us ignore this and be modest.
|
Please let us ignore this and be modest.
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue