mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Write rbinc files to the source directory
Update the target file itself of the dependency on this script. Fall back to the current working directory if unwritable.
This commit is contained in:
parent
8b20829396
commit
7db719c516
1 changed files with 11 additions and 3 deletions
|
@ -57,12 +57,18 @@ end
|
||||||
|
|
||||||
def mk_builtin_header file
|
def mk_builtin_header file
|
||||||
base = File.basename(file, '.rb')
|
base = File.basename(file, '.rb')
|
||||||
ofile = "#{base}.rbinc"
|
ofile = "#{file}inc"
|
||||||
|
|
||||||
# bs = { func_name => argc }
|
# bs = { func_name => argc }
|
||||||
collect_builtin(base, RubyVM::InstructionSequence.compile_file(file, false).to_a, bs = {}, inlines = [])
|
collect_builtin(base, RubyVM::InstructionSequence.compile_file(file, false).to_a, bs = {}, inlines = [])
|
||||||
|
|
||||||
open(ofile, 'w'){|f|
|
begin
|
||||||
|
f = open(ofile, 'w')
|
||||||
|
rescue Errno::EACCESS
|
||||||
|
# Fall back to the current directory
|
||||||
|
f = open(File.basename(ofile), 'w')
|
||||||
|
end
|
||||||
|
begin
|
||||||
f.puts "// -*- c -*-"
|
f.puts "// -*- c -*-"
|
||||||
f.puts "// DO NOT MODIFY THIS FILE DIRECTLY."
|
f.puts "// DO NOT MODIFY THIS FILE DIRECTLY."
|
||||||
f.puts "// auto-generated file"
|
f.puts "// auto-generated file"
|
||||||
|
@ -120,7 +126,9 @@ def mk_builtin_header file
|
||||||
f.puts " rb_load_with_builtin_functions(#{base.dump}, #{table});"
|
f.puts " rb_load_with_builtin_functions(#{base.dump}, #{table});"
|
||||||
|
|
||||||
f.puts "}"
|
f.puts "}"
|
||||||
}
|
ensure
|
||||||
|
f.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ARGV.each{|file|
|
ARGV.each{|file|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue