diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-31 09:01:59 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-31 09:01:59 +0000 |
commit | 64a36e434d05bfbc88a8b4d0dc22fb3f62006bb5 (patch) | |
tree | a2cfec6fa229be86c9af1f0fbc32d458de9e0437 /tool | |
parent | 8f2683ede5f879c5b1a62aeac90a554cde11e33c (diff) | |
download | ruby-64a36e434d05bfbc88a8b4d0dc22fb3f62006bb5.tar.gz |
rbinstall.rb: trilingual batch files
* tool/rbinstall.rb (bin-comm): trilingual, (sh, cmd, and ruby)
prolog for batch files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rwxr-xr-x | tool/rbinstall.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index 967b4162f3..3cc314111a 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -335,7 +335,8 @@ enable_shared = CONFIG["ENABLE_SHARED"] == 'yes' dll = CONFIG["LIBRUBY_SO", enable_shared] lib = CONFIG["LIBRUBY", true] arc = CONFIG["LIBRUBY_A", true] -load_relative = configure_args.include?("--enable-load-relative") +config_h = File.read(CONFIG["EXTOUT"]+"/include/"+CONFIG["arch"]+"/ruby/config.h") +load_relative = config_h[/^\s*#\s*define\s+LOAD_RELATIVE\s+(\d+)/, 1].to_i.nonzero? install?(:local, :arch, :bin, :'bin-arch') do prepare "binary commands", bindir @@ -466,20 +467,21 @@ install?(:local, :comm, :bin, :'bin-comm') do else trans = proc {|base| base} end + prebatch = ':""||{ ""=> %q<-*- ruby -*-'"\n" + postbatch = PROLOG_SCRIPT ? "};{\n#{PROLOG_SCRIPT.sub(/\A(?:#.*\n)*/, '')}" : '' + postbatch << ">,\n}\n" + postbatch.gsub!(/(?=\n)/, ' #') install_recursive(File.join(srcdir, "bin"), bindir, :maxdepth => 1) do |src, cmd| cmd = cmd.sub(/[^\/]*\z/m) {|n| RbConfig.expand(trans[n])} - shebang = '' - body = '' - open(src, "rb") do |f| - shebang = f.gets - body = f.read + shebang, body = open(src, "rb") do |f| + next f.gets, f.read end shebang or raise "empty file - #{src}" - if PROLOG_SCRIPT + if PROLOG_SCRIPT and !$cmdtype shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")} else - shebang.sub!(/\A\#!.*?ruby\b/) {"#!" + ruby_shebang} + shebang.sub!(/\A(\#!.*?ruby\b)?/) {"#!" + ruby_shebang + ($1 ? "" : "\n")} end shebang.sub!(/\r$/, '') body.gsub!(/\r$/, '') @@ -490,7 +492,7 @@ install?(:local, :comm, :bin, :'bin-comm') do when "exe" stub + shebang + body when "bat" - [<<-"EOH".gsub(/^\s+/, ''), shebang, body, "__END__\n:endofruby\n"].join.gsub(/(?=\n)/, "\r") + (prebatch + <<-"EOH".gsub(/^\s+/, '') << postbatch << shebang << body << "__END__\n:endofruby\n").gsub(/(?=\n)/, "\r") @echo off @if not "%~d0" == "~d0" goto WinNT #{ruby_bin} -x "#{cmd}" %1 %2 %3 %4 %5 %6 %7 %8 %9 @@ -500,7 +502,7 @@ install?(:local, :comm, :bin, :'bin-comm') do @goto endofruby EOH when "cmd" - <<"/EOH" << shebang << body + prebatch + <<"/EOH" << postbatch << shebang << body @"%~dp0#{ruby_install_name}" -x "%~f0" %* @exit /b %ERRORLEVEL% /EOH |