ruby-changes:58917
From: Nobuyoshi <ko1@a...>
Date: Tue, 26 Nov 2019 21:51:18 +0900 (JST)
Subject: [ruby-changes:58917] 7db719c516 (master): Write rbinc files to the source directory
https://git.ruby-lang.org/ruby.git/commit/?id=7db719c516 From 7db719c51652f0de6cae079c6ce0723dd00a9939 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 26 Nov 2019 19:08:56 +0900 Subject: 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. diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb index efb2d7d..87eb042 100644 --- a/tool/mk_builtin_loader.rb +++ b/tool/mk_builtin_loader.rb @@ -57,12 +57,18 @@ end https://github.com/ruby/ruby/blob/trunk/tool/mk_builtin_loader.rb#L57 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 https://github.com/ruby/ruby/blob/trunk/tool/mk_builtin_loader.rb#L126 f.puts " rb_load_with_builtin_functions(#{base.dump}, #{table});" f.puts "}" - } + ensure + f.close + end end ARGV.each{|file| -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/