ruby-changes:24486
From: nobu <ko1@a...>
Date: Wed, 25 Jul 2012 17:17:56 +0900 (JST)
Subject: [ruby-changes:24486] nobu:r36537 (trunk): mkrunnable.rb: mswin
nobu 2012-07-25 17:17:46 +0900 (Wed, 25 Jul 2012) New Revision: 36537 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36537 Log: mkrunnable.rb: mswin * tool/mkrunnable.rb (ln_safe, ln_dir_safe): separate for mklink command on Windows. Modified files: trunk/tool/mkrunnable.rb Index: tool/mkrunnable.rb =================================================================== --- tool/mkrunnable.rb (revision 36536) +++ tool/mkrunnable.rb (revision 36537) @@ -13,12 +13,31 @@ include FileUtils end +module Mswin + def ln_safe(src, dest, *opt) + cmd = ["mklink", dest.tr("/", "\\"), src.tr("/", "\\")] + cmd[1, 0] = opt + # TODO: use RUNAS or something + puts cmd.join(" ") + end + + def ln_dir_safe(src, dest) + ln_safe(src, dest, "/d") + end +end + def ln_safe(src, dest) link = File.readlink(dest) rescue nil return if link == src ln_sf(src, dest) end +alias ln_dir_safe ln_safe + +if /mingw|mswin/ =~ RUBY_PLATFORM + extend Mswin +end + config = RbConfig::CONFIG extout = ARGV[0] || config["EXTOUT"] version = config["ruby_version"] @@ -41,9 +60,9 @@ libruby.concat(config["LIBRUBY_ALIASES"].split) libruby.each {|lib|ln_safe("../#{lib}", "lib/#{lib}")} if File.expand_path(extout) == extout - ln_safe(extout, "lib/ruby") + ln_dir_safe(extout, "lib/ruby") else - ln_safe(File.join("..", extout), "lib/ruby") + ln_dir_safe(File.join("..", extout), "lib/ruby") cur = "#{extout}/".gsub(/(\A|\/)(?:\.\/)+/, '\1').tr_s('/', '/') nil while cur.sub!(/[^\/]+\/\.\.\//, '') if /(\A|\/)\.\.\// =~ cur @@ -57,6 +76,6 @@ else ln_safe(File.expand_path("rbconfig.rb"), File.join(extout, arch, "rbconfig.rb")) end -ln_safe("common", File.join(extout, version)) -ln_safe(File.join("..", arch), File.join(extout, "common", arch)) -ln_safe(relative_from(File.join(File.dirname(config["srcdir"]), "lib"), ".."), File.join(extout, "vendor_ruby")) +ln_dir_safe("common", File.join(extout, version)) +ln_dir_safe(File.join("..", arch), File.join(extout, "common", arch)) +ln_dir_safe(relative_from(File.join(File.dirname(config["srcdir"]), "lib"), ".."), File.join(extout, "vendor_ruby")) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/