* instruby.rb (parse_args): use optparse instead of getopts.
* instruby.rb (DOSISH): embedded path in batch files should not be prefixed by DESTDIR. [ruby-core:02186] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e10564a578
commit
d178414875
@ -1,3 +1,10 @@
|
|||||||
|
Mon Feb 23 09:09:44 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* instruby.rb (parse_args): use optparse instead of getopts.
|
||||||
|
|
||||||
|
* instruby.rb (DOSISH): embedded path in batch files should not be
|
||||||
|
prefixed by DESTDIR. [ruby-core:02186]
|
||||||
|
|
||||||
Sun Feb 22 14:58:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Feb 22 14:58:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/extmk.rb: $extstatic is Array or nil now. [ruby-talk:93383]
|
* ext/extmk.rb: $extstatic is Array or nil now. [ruby-talk:93383]
|
||||||
|
65
instruby.rb
65
instruby.rb
@ -6,27 +6,29 @@ include Config
|
|||||||
$:.unshift File.join(CONFIG["srcdir"], "lib")
|
$:.unshift File.join(CONFIG["srcdir"], "lib")
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'shellwords'
|
require 'shellwords'
|
||||||
require 'getopts'
|
require 'optparse'
|
||||||
|
require 'optparse/shellwords'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
|
|
||||||
File.umask(0)
|
File.umask(0)
|
||||||
|
|
||||||
def parse_args()
|
def parse_args()
|
||||||
getopts('n', 'dest-dir:',
|
$mantype = 'doc'
|
||||||
'make:', 'make-flags:', 'mflags:',
|
$destdir = nil
|
||||||
'mantype:doc')
|
$make = 'make'
|
||||||
|
$mflags = []
|
||||||
$dryrun = $OPT['n']
|
opt = OptionParser.new
|
||||||
$destdir = $OPT['dest-dir'] || ''
|
opt.on('-n') {$dryrun = true}
|
||||||
$make = $OPT['make'] || $make || 'make'
|
opt.on('--dest-dir=DIR') {|dir| $destdir = dir}
|
||||||
$mantype = $OPT['mantype']
|
opt.on('--make=COMMAND') {|make| $make = make}
|
||||||
mflags = ($OPT['make-flags'] || '').strip
|
opt.on('--mantype=MAN') {|man| $mantype = man}
|
||||||
mflags = ($OPT['mflags'] || '').strip if mflags.empty?
|
opt.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v|
|
||||||
|
if arg = v.first
|
||||||
$mflags = Shellwords.shellwords(mflags)
|
|
||||||
if arg = $mflags.first
|
|
||||||
arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
|
arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
|
||||||
end
|
end
|
||||||
|
$mflags.concat(v)
|
||||||
|
end
|
||||||
|
opt.parse! rescue abort [$!.message, opt].join("\n")
|
||||||
|
|
||||||
$make, *rest = Shellwords.shellwords($make)
|
$make, *rest = Shellwords.shellwords($make)
|
||||||
$mflags.unshift(*rest) unless rest.empty?
|
$mflags.unshift(*rest) unless rest.empty?
|
||||||
@ -71,14 +73,9 @@ def makedirs(dirs)
|
|||||||
super(dirs, :mode => 0755, :verbose => true) unless dirs.empty?
|
super(dirs, :mode => 0755, :verbose => true) unless dirs.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def join(dir1, dir2)
|
def with_destdir(dir)
|
||||||
# same scheme as DESTDIR of lib/mkmf.rb
|
dir = dir.sub(/\A\w:/, '') if File::PATH_SEPARATOR == ';'
|
||||||
drive = File::PATH_SEPARATOR == ';' ? /\A\w:/ : /\A/
|
$destdir + dir
|
||||||
if dir1.empty? || dir2.scan(drive).empty?
|
|
||||||
dir1 + dir2
|
|
||||||
else
|
|
||||||
dir1 + $'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
exeext = CONFIG["EXEEXT"]
|
exeext = CONFIG["EXEEXT"]
|
||||||
@ -87,13 +84,13 @@ ruby_install_name = CONFIG["ruby_install_name"]
|
|||||||
rubyw_install_name = CONFIG["rubyw_install_name"]
|
rubyw_install_name = CONFIG["rubyw_install_name"]
|
||||||
|
|
||||||
version = CONFIG["ruby_version"]
|
version = CONFIG["ruby_version"]
|
||||||
bindir = join($destdir, CONFIG["bindir"])
|
bindir = with_destdir(CONFIG["bindir"])
|
||||||
libdir = join($destdir, CONFIG["libdir"])
|
libdir = with_destdir(CONFIG["libdir"])
|
||||||
rubylibdir = join($destdir, CONFIG["rubylibdir"])
|
rubylibdir = with_destdir(CONFIG["rubylibdir"])
|
||||||
archlibdir = join($destdir, CONFIG["archdir"])
|
archlibdir = with_destdir(CONFIG["archdir"])
|
||||||
sitelibdir = join($destdir, CONFIG["sitelibdir"])
|
sitelibdir = with_destdir(CONFIG["sitelibdir"])
|
||||||
sitearchlibdir = join($destdir, CONFIG["sitearchdir"])
|
sitearchlibdir = with_destdir(CONFIG["sitearchdir"])
|
||||||
mandir = File.join(join($destdir, CONFIG["mandir"]), "man")
|
mandir = with_destdir(File.join(CONFIG["mandir"], "man"))
|
||||||
configure_args = Shellwords.shellwords(CONFIG["configure_args"])
|
configure_args = Shellwords.shellwords(CONFIG["configure_args"])
|
||||||
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
|
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
|
||||||
dll = CONFIG["LIBRUBY_SO"]
|
dll = CONFIG["LIBRUBY_SO"]
|
||||||
@ -128,6 +125,9 @@ end
|
|||||||
Dir.chdir CONFIG["srcdir"]
|
Dir.chdir CONFIG["srcdir"]
|
||||||
|
|
||||||
ruby_shebang = File.join(CONFIG["bindir"], ruby_install_name)
|
ruby_shebang = File.join(CONFIG["bindir"], ruby_install_name)
|
||||||
|
if File::ALT_SEPARATOR
|
||||||
|
ruby_bin_dosish = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
||||||
|
end
|
||||||
for src in Dir["bin/*"]
|
for src in Dir["bin/*"]
|
||||||
next unless File.file?(src)
|
next unless File.file?(src)
|
||||||
next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src
|
next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src
|
||||||
@ -152,10 +152,9 @@ for src in Dir["bin/*"]
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
|
if ruby_bin_dosish
|
||||||
ruby_bin_dosish = ruby_bin.gsub(Regexp.compile(File::SEPARATOR), File::ALT_SEPARATOR)
|
batfile = File.join(CONFIG["bindir"], name + ".bat")
|
||||||
batfile = dest + ".bat"
|
open(with_destdir(batfile), "w") { |b|
|
||||||
open(batfile, "w") { |b|
|
|
||||||
b.print <<EOH, shebang, body, <<EOF
|
b.print <<EOH, shebang, body, <<EOF
|
||||||
@echo off
|
@echo off
|
||||||
if "%OS%" == "Windows_NT" goto WinNT
|
if "%OS%" == "Windows_NT" goto WinNT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user