Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby32/share/ruby
File: mkmf.rb
# -*- coding: us-ascii -*-
[0] Fix | Delete
# frozen-string-literal: false
[1] Fix | Delete
# module to create Makefile for extension modules
[2] Fix | Delete
# invoke like: ruby -r mkmf extconf.rb
[3] Fix | Delete
[4] Fix | Delete
require 'rbconfig'
[5] Fix | Delete
require 'fileutils'
[6] Fix | Delete
require 'shellwords'
[7] Fix | Delete
[8] Fix | Delete
class String # :nodoc:
[9] Fix | Delete
# Wraps a string in escaped quotes if it contains whitespace.
[10] Fix | Delete
def quote
[11] Fix | Delete
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
[12] Fix | Delete
end
[13] Fix | Delete
[14] Fix | Delete
# Escape whitespaces for Makefile.
[15] Fix | Delete
def unspace
[16] Fix | Delete
gsub(/\s/, '\\\\\\&')
[17] Fix | Delete
end
[18] Fix | Delete
[19] Fix | Delete
# Generates a string used as cpp macro name.
[20] Fix | Delete
def tr_cpp
[21] Fix | Delete
strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
[22] Fix | Delete
end
[23] Fix | Delete
[24] Fix | Delete
def funcall_style
[25] Fix | Delete
/\)\z/ =~ self ? dup : "#{self}()"
[26] Fix | Delete
end
[27] Fix | Delete
[28] Fix | Delete
def sans_arguments
[29] Fix | Delete
self[/\A[^()]+/]
[30] Fix | Delete
end
[31] Fix | Delete
end
[32] Fix | Delete
[33] Fix | Delete
class Array # :nodoc:
[34] Fix | Delete
# Wraps all strings in escaped quotes if they contain whitespace.
[35] Fix | Delete
def quote
[36] Fix | Delete
map {|s| s.quote}
[37] Fix | Delete
end
[38] Fix | Delete
end
[39] Fix | Delete
[40] Fix | Delete
##
[41] Fix | Delete
# mkmf.rb is used by Ruby C extensions to generate a Makefile which will
[42] Fix | Delete
# correctly compile and link the C extension to Ruby and a third-party
[43] Fix | Delete
# library.
[44] Fix | Delete
module MakeMakefile
[45] Fix | Delete
#### defer until this module become global-state free.
[46] Fix | Delete
# def self.extended(obj)
[47] Fix | Delete
# obj.init_mkmf
[48] Fix | Delete
# super
[49] Fix | Delete
# end
[50] Fix | Delete
#
[51] Fix | Delete
# def initialize(*args, rbconfig: RbConfig, **rest)
[52] Fix | Delete
# init_mkmf(rbconfig::MAKEFILE_CONFIG, rbconfig::CONFIG)
[53] Fix | Delete
# super(*args, **rest)
[54] Fix | Delete
# end
[55] Fix | Delete
[56] Fix | Delete
##
[57] Fix | Delete
# The makefile configuration using the defaults from when Ruby was built.
[58] Fix | Delete
[59] Fix | Delete
CONFIG = RbConfig::MAKEFILE_CONFIG
[60] Fix | Delete
ORIG_LIBPATH = ENV['LIB']
[61] Fix | Delete
[62] Fix | Delete
##
[63] Fix | Delete
# Extensions for files compiled with a C compiler
[64] Fix | Delete
[65] Fix | Delete
C_EXT = %w[c m]
[66] Fix | Delete
[67] Fix | Delete
##
[68] Fix | Delete
# Extensions for files compiled with a C++ compiler
[69] Fix | Delete
[70] Fix | Delete
CXX_EXT = %w[cc mm cxx cpp]
[71] Fix | Delete
unless File.exist?(File.join(*File.split(__FILE__).tap {|d, b| b.swapcase}))
[72] Fix | Delete
CXX_EXT.concat(%w[C])
[73] Fix | Delete
end
[74] Fix | Delete
[75] Fix | Delete
##
[76] Fix | Delete
# Extensions for source files
[77] Fix | Delete
[78] Fix | Delete
SRC_EXT = C_EXT + CXX_EXT
[79] Fix | Delete
[80] Fix | Delete
##
[81] Fix | Delete
# Extensions for header files
[82] Fix | Delete
[83] Fix | Delete
HDR_EXT = %w[h hpp]
[84] Fix | Delete
$static = nil
[85] Fix | Delete
$config_h = '$(arch_hdrdir)/ruby/config.h'
[86] Fix | Delete
$default_static = $static
[87] Fix | Delete
[88] Fix | Delete
unless defined? $configure_args
[89] Fix | Delete
$configure_args = {}
[90] Fix | Delete
args = CONFIG["configure_args"]
[91] Fix | Delete
if ENV["CONFIGURE_ARGS"]
[92] Fix | Delete
args << " " << ENV["CONFIGURE_ARGS"]
[93] Fix | Delete
end
[94] Fix | Delete
for arg in Shellwords::shellwords(args)
[95] Fix | Delete
arg, val = arg.split('=', 2)
[96] Fix | Delete
next unless arg
[97] Fix | Delete
arg.tr!('_', '-')
[98] Fix | Delete
if arg.sub!(/^(?!--)/, '--')
[99] Fix | Delete
val or next
[100] Fix | Delete
arg.downcase!
[101] Fix | Delete
end
[102] Fix | Delete
next if /^--(?:top|topsrc|src|cur)dir$/ =~ arg
[103] Fix | Delete
$configure_args[arg] = val || true
[104] Fix | Delete
end
[105] Fix | Delete
for arg in ARGV
[106] Fix | Delete
arg, val = arg.split('=', 2)
[107] Fix | Delete
next unless arg
[108] Fix | Delete
arg.tr!('_', '-')
[109] Fix | Delete
if arg.sub!(/^(?!--)/, '--')
[110] Fix | Delete
val or next
[111] Fix | Delete
arg.downcase!
[112] Fix | Delete
end
[113] Fix | Delete
$configure_args[arg] = val || true
[114] Fix | Delete
end
[115] Fix | Delete
end
[116] Fix | Delete
[117] Fix | Delete
$libdir = CONFIG["libdir"]
[118] Fix | Delete
$rubylibdir = CONFIG["rubylibdir"]
[119] Fix | Delete
$archdir = CONFIG["archdir"]
[120] Fix | Delete
$sitedir = CONFIG["sitedir"]
[121] Fix | Delete
$sitelibdir = CONFIG["sitelibdir"]
[122] Fix | Delete
$sitearchdir = CONFIG["sitearchdir"]
[123] Fix | Delete
$vendordir = CONFIG["vendordir"]
[124] Fix | Delete
$vendorlibdir = CONFIG["vendorlibdir"]
[125] Fix | Delete
$vendorarchdir = CONFIG["vendorarchdir"]
[126] Fix | Delete
[127] Fix | Delete
$mswin = /mswin/ =~ RUBY_PLATFORM
[128] Fix | Delete
$mingw = /mingw/ =~ RUBY_PLATFORM
[129] Fix | Delete
$cygwin = /cygwin/ =~ RUBY_PLATFORM
[130] Fix | Delete
$netbsd = /netbsd/ =~ RUBY_PLATFORM
[131] Fix | Delete
$haiku = /haiku/ =~ RUBY_PLATFORM
[132] Fix | Delete
$solaris = /solaris/ =~ RUBY_PLATFORM
[133] Fix | Delete
$universal = /universal/ =~ RUBY_PLATFORM
[134] Fix | Delete
$dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/)
[135] Fix | Delete
[136] Fix | Delete
# :stopdoc:
[137] Fix | Delete
[138] Fix | Delete
def config_string(key, config = CONFIG)
[139] Fix | Delete
s = config[key] and !s.empty? and block_given? ? yield(s) : s
[140] Fix | Delete
end
[141] Fix | Delete
module_function :config_string
[142] Fix | Delete
[143] Fix | Delete
def dir_re(dir)
[144] Fix | Delete
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
[145] Fix | Delete
end
[146] Fix | Delete
module_function :dir_re
[147] Fix | Delete
[148] Fix | Delete
def relative_from(path, base)
[149] Fix | Delete
dir = File.join(path, "")
[150] Fix | Delete
if File.expand_path(dir) == File.expand_path(dir, base)
[151] Fix | Delete
path
[152] Fix | Delete
else
[153] Fix | Delete
File.join(base, path)
[154] Fix | Delete
end
[155] Fix | Delete
end
[156] Fix | Delete
[157] Fix | Delete
INSTALL_DIRS = [
[158] Fix | Delete
[dir_re('commondir'), "$(RUBYCOMMONDIR)"],
[159] Fix | Delete
[dir_re('sitedir'), "$(RUBYCOMMONDIR)"],
[160] Fix | Delete
[dir_re('vendordir'), "$(RUBYCOMMONDIR)"],
[161] Fix | Delete
[dir_re('rubylibdir'), "$(RUBYLIBDIR)"],
[162] Fix | Delete
[dir_re('archdir'), "$(RUBYARCHDIR)"],
[163] Fix | Delete
[dir_re('sitelibdir'), "$(RUBYLIBDIR)"],
[164] Fix | Delete
[dir_re('vendorlibdir'), "$(RUBYLIBDIR)"],
[165] Fix | Delete
[dir_re('sitearchdir'), "$(RUBYARCHDIR)"],
[166] Fix | Delete
[dir_re('vendorarchdir'), "$(RUBYARCHDIR)"],
[167] Fix | Delete
[dir_re('rubyhdrdir'), "$(RUBYHDRDIR)"],
[168] Fix | Delete
[dir_re('sitehdrdir'), "$(SITEHDRDIR)"],
[169] Fix | Delete
[dir_re('vendorhdrdir'), "$(VENDORHDRDIR)"],
[170] Fix | Delete
[dir_re('bindir'), "$(BINDIR)"],
[171] Fix | Delete
]
[172] Fix | Delete
[173] Fix | Delete
def install_dirs(target_prefix = nil)
[174] Fix | Delete
if $extout and $extmk
[175] Fix | Delete
dirs = [
[176] Fix | Delete
['BINDIR', '$(extout)/bin'],
[177] Fix | Delete
['RUBYCOMMONDIR', '$(extout)/common'],
[178] Fix | Delete
['RUBYLIBDIR', '$(RUBYCOMMONDIR)$(target_prefix)'],
[179] Fix | Delete
['RUBYARCHDIR', '$(extout)/$(arch)$(target_prefix)'],
[180] Fix | Delete
['HDRDIR', '$(extout)/include/ruby$(target_prefix)'],
[181] Fix | Delete
['ARCHHDRDIR', '$(extout)/include/$(arch)/ruby$(target_prefix)'],
[182] Fix | Delete
['extout', "#$extout"],
[183] Fix | Delete
['extout_prefix', "#$extout_prefix"],
[184] Fix | Delete
]
[185] Fix | Delete
elsif $extmk
[186] Fix | Delete
dirs = [
[187] Fix | Delete
['BINDIR', '$(bindir)'],
[188] Fix | Delete
['RUBYCOMMONDIR', '$(rubylibdir)'],
[189] Fix | Delete
['RUBYLIBDIR', '$(rubylibdir)$(target_prefix)'],
[190] Fix | Delete
['RUBYARCHDIR', '$(archdir)$(target_prefix)'],
[191] Fix | Delete
['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
[192] Fix | Delete
['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
[193] Fix | Delete
]
[194] Fix | Delete
elsif $configure_args.has_key?('--vendor')
[195] Fix | Delete
dirs = [
[196] Fix | Delete
['BINDIR', '$(bindir)'],
[197] Fix | Delete
['RUBYCOMMONDIR', '$(vendordir)$(target_prefix)'],
[198] Fix | Delete
['RUBYLIBDIR', '$(vendorlibdir)$(target_prefix)'],
[199] Fix | Delete
['RUBYARCHDIR', '$(vendorarchdir)$(target_prefix)'],
[200] Fix | Delete
['HDRDIR', '$(vendorhdrdir)$(target_prefix)'],
[201] Fix | Delete
['ARCHHDRDIR', '$(vendorarchhdrdir)$(target_prefix)'],
[202] Fix | Delete
]
[203] Fix | Delete
else
[204] Fix | Delete
dirs = [
[205] Fix | Delete
['BINDIR', '$(bindir)'],
[206] Fix | Delete
['RUBYCOMMONDIR', '$(sitedir)$(target_prefix)'],
[207] Fix | Delete
['RUBYLIBDIR', '$(sitelibdir)$(target_prefix)'],
[208] Fix | Delete
['RUBYARCHDIR', '$(sitearchdir)$(target_prefix)'],
[209] Fix | Delete
['HDRDIR', '$(sitehdrdir)$(target_prefix)'],
[210] Fix | Delete
['ARCHHDRDIR', '$(sitearchhdrdir)$(target_prefix)'],
[211] Fix | Delete
]
[212] Fix | Delete
end
[213] Fix | Delete
dirs << ['target_prefix', (target_prefix ? "/#{target_prefix}" : "")]
[214] Fix | Delete
dirs
[215] Fix | Delete
end
[216] Fix | Delete
[217] Fix | Delete
def map_dir(dir, map = nil)
[218] Fix | Delete
map ||= INSTALL_DIRS
[219] Fix | Delete
map.inject(dir) {|d, (orig, new)| d.gsub(orig, new)}
[220] Fix | Delete
end
[221] Fix | Delete
[222] Fix | Delete
topdir = File.dirname(File.dirname(__FILE__))
[223] Fix | Delete
path = File.expand_path($0)
[224] Fix | Delete
until (dir = File.dirname(path)) == path
[225] Fix | Delete
if File.identical?(dir, topdir)
[226] Fix | Delete
$extmk = true if %r"\A(?:ext|enc|tool|test)\z" =~ File.basename(path)
[227] Fix | Delete
break
[228] Fix | Delete
end
[229] Fix | Delete
path = dir
[230] Fix | Delete
end
[231] Fix | Delete
$extmk ||= false
[232] Fix | Delete
if not $extmk and File.exist?(($hdrdir = RbConfig::CONFIG["rubyhdrdir"]) + "/ruby/ruby.h")
[233] Fix | Delete
$topdir = $hdrdir
[234] Fix | Delete
$top_srcdir = $hdrdir
[235] Fix | Delete
$arch_hdrdir = RbConfig::CONFIG["rubyarchhdrdir"]
[236] Fix | Delete
elsif File.exist?(($hdrdir = ($top_srcdir ||= topdir) + "/include") + "/ruby.h")
[237] Fix | Delete
$topdir ||= RbConfig::CONFIG["topdir"]
[238] Fix | Delete
$arch_hdrdir = "$(extout)/include/$(arch)"
[239] Fix | Delete
else
[240] Fix | Delete
abort <<MESSAGE
[241] Fix | Delete
mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h
[242] Fix | Delete
[243] Fix | Delete
You might have to install separate package for the ruby development
[244] Fix | Delete
environment, ruby-dev or ruby-devel for example.
[245] Fix | Delete
MESSAGE
[246] Fix | Delete
end
[247] Fix | Delete
[248] Fix | Delete
CONFTEST = "conftest".freeze
[249] Fix | Delete
CONFTEST_C = "#{CONFTEST}.c"
[250] Fix | Delete
[251] Fix | Delete
OUTFLAG = CONFIG['OUTFLAG']
[252] Fix | Delete
COUTFLAG = CONFIG['COUTFLAG']
[253] Fix | Delete
CSRCFLAG = CONFIG['CSRCFLAG']
[254] Fix | Delete
CPPOUTFILE = config_string('CPPOUTFILE') {|str| str.sub(/\bconftest\b/, CONFTEST)}
[255] Fix | Delete
[256] Fix | Delete
def rm_f(*files)
[257] Fix | Delete
opt = (Hash === files.last ? [files.pop] : [])
[258] Fix | Delete
FileUtils.rm_f(Dir[*files.flatten], *opt)
[259] Fix | Delete
end
[260] Fix | Delete
module_function :rm_f
[261] Fix | Delete
[262] Fix | Delete
def rm_rf(*files)
[263] Fix | Delete
opt = (Hash === files.last ? [files.pop] : [])
[264] Fix | Delete
FileUtils.rm_rf(Dir[*files.flatten], *opt)
[265] Fix | Delete
end
[266] Fix | Delete
module_function :rm_rf
[267] Fix | Delete
[268] Fix | Delete
# Returns time stamp of the +target+ file if it exists and is newer than or
[269] Fix | Delete
# equal to all of +times+.
[270] Fix | Delete
def modified?(target, times)
[271] Fix | Delete
(t = File.mtime(target)) rescue return nil
[272] Fix | Delete
Array === times or times = [times]
[273] Fix | Delete
t if times.all? {|n| n <= t}
[274] Fix | Delete
end
[275] Fix | Delete
[276] Fix | Delete
def split_libs(*strs)
[277] Fix | Delete
sep = $mswin ? /\s+/ : /\s+(?=-|\z)/
[278] Fix | Delete
strs.flat_map {|s| s.lstrip.split(sep)}
[279] Fix | Delete
end
[280] Fix | Delete
[281] Fix | Delete
def merge_libs(*libs)
[282] Fix | Delete
libs.inject([]) do |x, y|
[283] Fix | Delete
y = y.inject([]) {|ary, e| ary.last == e ? ary : ary << e}
[284] Fix | Delete
y.each_with_index do |v, yi|
[285] Fix | Delete
if xi = x.rindex(v)
[286] Fix | Delete
x[(xi+1)..-1] = merge_libs(y[(yi+1)..-1], x[(xi+1)..-1])
[287] Fix | Delete
x[xi, 0] = y[0...yi]
[288] Fix | Delete
break
[289] Fix | Delete
end
[290] Fix | Delete
end and x.concat(y)
[291] Fix | Delete
x
[292] Fix | Delete
end
[293] Fix | Delete
end
[294] Fix | Delete
[295] Fix | Delete
# This is a custom logging module. It generates an mkmf.log file when you
[296] Fix | Delete
# run your extconf.rb script. This can be useful for debugging unexpected
[297] Fix | Delete
# failures.
[298] Fix | Delete
#
[299] Fix | Delete
# This module and its associated methods are meant for internal use only.
[300] Fix | Delete
#
[301] Fix | Delete
module Logging
[302] Fix | Delete
@log = nil
[303] Fix | Delete
@logfile = 'mkmf.log'
[304] Fix | Delete
@orgerr = $stderr.dup
[305] Fix | Delete
@orgout = $stdout.dup
[306] Fix | Delete
@postpone = 0
[307] Fix | Delete
@quiet = $extmk
[308] Fix | Delete
[309] Fix | Delete
def self::log_open
[310] Fix | Delete
@log ||= File::open(@logfile, 'wb')
[311] Fix | Delete
@log.sync = true
[312] Fix | Delete
end
[313] Fix | Delete
[314] Fix | Delete
def self::log_opened?
[315] Fix | Delete
@log and not @log.closed?
[316] Fix | Delete
end
[317] Fix | Delete
[318] Fix | Delete
def self::open
[319] Fix | Delete
log_open
[320] Fix | Delete
$stderr.reopen(@log)
[321] Fix | Delete
$stdout.reopen(@log)
[322] Fix | Delete
yield
[323] Fix | Delete
ensure
[324] Fix | Delete
$stderr.reopen(@orgerr)
[325] Fix | Delete
$stdout.reopen(@orgout)
[326] Fix | Delete
end
[327] Fix | Delete
[328] Fix | Delete
def self::message(*s)
[329] Fix | Delete
log_open
[330] Fix | Delete
@log.printf(*s)
[331] Fix | Delete
end
[332] Fix | Delete
[333] Fix | Delete
def self::logfile file
[334] Fix | Delete
@logfile = file
[335] Fix | Delete
log_close
[336] Fix | Delete
end
[337] Fix | Delete
[338] Fix | Delete
def self::log_close
[339] Fix | Delete
if @log and not @log.closed?
[340] Fix | Delete
@log.flush
[341] Fix | Delete
@log.close
[342] Fix | Delete
@log = nil
[343] Fix | Delete
end
[344] Fix | Delete
end
[345] Fix | Delete
[346] Fix | Delete
def self::postpone
[347] Fix | Delete
tmplog = "mkmftmp#{@postpone += 1}.log"
[348] Fix | Delete
open do
[349] Fix | Delete
log, *save = @log, @logfile, @orgout, @orgerr
[350] Fix | Delete
@log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
[351] Fix | Delete
begin
[352] Fix | Delete
log.print(open {yield @log})
[353] Fix | Delete
ensure
[354] Fix | Delete
@log.close if @log and not @log.closed?
[355] Fix | Delete
File::open(tmplog) {|t| FileUtils.copy_stream(t, log)} if File.exist?(tmplog)
[356] Fix | Delete
@log, @logfile, @orgout, @orgerr = log, *save
[357] Fix | Delete
@postpone -= 1
[358] Fix | Delete
MakeMakefile.rm_f tmplog
[359] Fix | Delete
end
[360] Fix | Delete
end
[361] Fix | Delete
end
[362] Fix | Delete
[363] Fix | Delete
class << self
[364] Fix | Delete
attr_accessor :quiet
[365] Fix | Delete
end
[366] Fix | Delete
end
[367] Fix | Delete
[368] Fix | Delete
def libpath_env
[369] Fix | Delete
# used only if native compiling
[370] Fix | Delete
if libpathenv = config_string("LIBPATHENV")
[371] Fix | Delete
pathenv = ENV[libpathenv]
[372] Fix | Delete
libpath = RbConfig.expand($DEFLIBPATH.join(File::PATH_SEPARATOR))
[373] Fix | Delete
{libpathenv => [libpath, pathenv].compact.join(File::PATH_SEPARATOR)}
[374] Fix | Delete
else
[375] Fix | Delete
{}
[376] Fix | Delete
end
[377] Fix | Delete
end
[378] Fix | Delete
[379] Fix | Delete
def expand_command(commands, envs = libpath_env)
[380] Fix | Delete
varpat = /\$\((\w+)\)|\$\{(\w+)\}/
[381] Fix | Delete
vars = nil
[382] Fix | Delete
expand = proc do |command|
[383] Fix | Delete
case command
[384] Fix | Delete
when Array
[385] Fix | Delete
command.map(&expand)
[386] Fix | Delete
when String
[387] Fix | Delete
if varpat =~ command
[388] Fix | Delete
vars ||= Hash.new {|h, k| h[k] = ENV[k]}
[389] Fix | Delete
command = command.dup
[390] Fix | Delete
nil while command.gsub!(varpat) {vars[$1||$2]}
[391] Fix | Delete
end
[392] Fix | Delete
command
[393] Fix | Delete
else
[394] Fix | Delete
command
[395] Fix | Delete
end
[396] Fix | Delete
end
[397] Fix | Delete
if Array === commands
[398] Fix | Delete
env, *commands = commands if Hash === commands.first
[399] Fix | Delete
envs.merge!(env) if env
[400] Fix | Delete
end
[401] Fix | Delete
return envs, expand[commands]
[402] Fix | Delete
end
[403] Fix | Delete
[404] Fix | Delete
def env_quote(envs)
[405] Fix | Delete
envs.map {|e, v| "#{e}=#{v.quote}"}
[406] Fix | Delete
end
[407] Fix | Delete
[408] Fix | Delete
def xsystem command, opts = nil
[409] Fix | Delete
env, command = expand_command(command)
[410] Fix | Delete
Logging::open do
[411] Fix | Delete
puts [env_quote(env), command.quote].join(' ')
[412] Fix | Delete
if opts and opts[:werror]
[413] Fix | Delete
result = nil
[414] Fix | Delete
Logging.postpone do |log|
[415] Fix | Delete
output = IO.popen(env, command, &:read)
[416] Fix | Delete
result = ($?.success? and File.zero?(log.path))
[417] Fix | Delete
output
[418] Fix | Delete
end
[419] Fix | Delete
result
[420] Fix | Delete
else
[421] Fix | Delete
system(env, *command)
[422] Fix | Delete
end
[423] Fix | Delete
end
[424] Fix | Delete
end
[425] Fix | Delete
[426] Fix | Delete
def xpopen command, *mode, &block
[427] Fix | Delete
env, commands = expand_command(command)
[428] Fix | Delete
command = [env_quote(env), command].join(' ')
[429] Fix | Delete
Logging::open do
[430] Fix | Delete
case mode[0]
[431] Fix | Delete
when nil, Hash, /^r/
[432] Fix | Delete
puts "#{command} |"
[433] Fix | Delete
else
[434] Fix | Delete
puts "| #{command}"
[435] Fix | Delete
end
[436] Fix | Delete
IO.popen(env, commands, *mode, &block)
[437] Fix | Delete
end
[438] Fix | Delete
end
[439] Fix | Delete
[440] Fix | Delete
def log_src(src, heading="checked program was")
[441] Fix | Delete
src = src.split(/^/)
[442] Fix | Delete
fmt = "%#{src.size.to_s.size}d: %s"
[443] Fix | Delete
Logging::message <<"EOM"
[444] Fix | Delete
#{heading}:
[445] Fix | Delete
/* begin */
[446] Fix | Delete
EOM
[447] Fix | Delete
src.each_with_index {|line, no| Logging::message fmt, no+1, line}
[448] Fix | Delete
Logging::message <<"EOM"
[449] Fix | Delete
/* end */
[450] Fix | Delete
[451] Fix | Delete
EOM
[452] Fix | Delete
end
[453] Fix | Delete
[454] Fix | Delete
def conftest_source
[455] Fix | Delete
CONFTEST_C
[456] Fix | Delete
end
[457] Fix | Delete
[458] Fix | Delete
def create_tmpsrc(src)
[459] Fix | Delete
src = "#{COMMON_HEADERS}\n#{src}"
[460] Fix | Delete
src = yield(src) if block_given?
[461] Fix | Delete
src.gsub!(/[ \t]+$/, '')
[462] Fix | Delete
src.gsub!(/\A\n+|^\n+$/, '')
[463] Fix | Delete
src.sub!(/[^\n]\z/, "\\&\n")
[464] Fix | Delete
count = 0
[465] Fix | Delete
begin
[466] Fix | Delete
File.open(conftest_source, "wb") do |cfile|
[467] Fix | Delete
cfile.print src
[468] Fix | Delete
end
[469] Fix | Delete
rescue Errno::EACCES
[470] Fix | Delete
if (count += 1) < 5
[471] Fix | Delete
sleep 0.2
[472] Fix | Delete
retry
[473] Fix | Delete
end
[474] Fix | Delete
end
[475] Fix | Delete
src
[476] Fix | Delete
end
[477] Fix | Delete
[478] Fix | Delete
def have_devel?
[479] Fix | Delete
unless defined? $have_devel
[480] Fix | Delete
$have_devel = true
[481] Fix | Delete
$have_devel = try_link(MAIN_DOES_NOTHING)
[482] Fix | Delete
end
[483] Fix | Delete
$have_devel
[484] Fix | Delete
end
[485] Fix | Delete
[486] Fix | Delete
def try_do(src, command, *opts, &b)
[487] Fix | Delete
unless have_devel?
[488] Fix | Delete
raise <<MSG
[489] Fix | Delete
The compiler failed to generate an executable file.
[490] Fix | Delete
You have to install development tools first.
[491] Fix | Delete
MSG
[492] Fix | Delete
end
[493] Fix | Delete
begin
[494] Fix | Delete
src = create_tmpsrc(src, &b)
[495] Fix | Delete
xsystem(command, *opts)
[496] Fix | Delete
ensure
[497] Fix | Delete
log_src(src)
[498] Fix | Delete
end
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function