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:
Nobuyoshi Nakada 2019-11-26 19:08:56 +09:00
parent 8b20829396
commit 7db719c516
No known key found for this signature in database
GPG Key ID: 4BC7D6DF58D8DF60

View File

@ -57,12 +57,18 @@ end
def mk_builtin_header file
base = File.basename(file, '.rb')
ofile = "#{base}.rbinc"
ofile = "#{file}inc"
# bs = { func_name => argc }
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 "// DO NOT MODIFY THIS FILE DIRECTLY."
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 "}"
}
ensure
f.close
end
end
ARGV.each{|file|