зеркало из https://github.com/github/ruby.git
* common.mk (encs): new target to compile external encodings.
* enc/Makefile.in: became a serb template. * enc/make_encmake.rb: creates enc.mk from enc/Makefile.in using serb. * lib/mkmf.rb (relative_from): moved from ext/extmk.rb. * lib/mkmf.rb ($extmk): true if under to top source directory, not only ext. * lib/mkmf.rb (depend_rules): extracted from create_makefile. * tool/serb.rb (serb): splitted from tool/compile_prelude.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5043ab95ed
Коммит
b2d9f1e9d0
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
Mon Dec 17 17:47:26 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* common.mk (encs): new target to compile external encodings.
|
||||||
|
|
||||||
|
* enc/Makefile.in: became a serb template.
|
||||||
|
|
||||||
|
* enc/make_encmake.rb: creates enc.mk from enc/Makefile.in using serb.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (relative_from): moved from ext/extmk.rb.
|
||||||
|
|
||||||
|
* lib/mkmf.rb ($extmk): true if under to top source directory, not
|
||||||
|
only ext.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (depend_rules): extracted from create_makefile.
|
||||||
|
|
||||||
|
* tool/serb.rb (serb): splitted from tool/compile_prelude.rb.
|
||||||
|
|
||||||
Mon Dec 17 17:32:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Dec 17 17:32:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in (MAKEFILES): removed enc/Makefile.
|
* configure.in (MAKEFILES): removed enc/Makefile.
|
||||||
|
|
|
@ -96,7 +96,7 @@ TESTWORKDIR = testwork
|
||||||
|
|
||||||
BOOTSTRAPRUBY = $(BASERUBY)
|
BOOTSTRAPRUBY = $(BASERUBY)
|
||||||
|
|
||||||
all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
|
all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY) encs
|
||||||
@$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
|
@$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
|
||||||
prog: $(PROGRAM) $(WPROGRAM)
|
prog: $(PROGRAM) $(WPROGRAM)
|
||||||
|
|
||||||
|
@ -339,6 +339,12 @@ $(RBCONFIG): $(srcdir)/mkconfig.rb config.status $(PREP)
|
||||||
-install_name=$(RUBY_INSTALL_NAME) \
|
-install_name=$(RUBY_INSTALL_NAME) \
|
||||||
-so_name=$(RUBY_SO_NAME) rbconfig.rb
|
-so_name=$(RUBY_SO_NAME) rbconfig.rb
|
||||||
|
|
||||||
|
encs: enc.mk
|
||||||
|
$(MAKE) -f enc.mk
|
||||||
|
|
||||||
|
enc.mk: miniruby$(EXEEXT)
|
||||||
|
$(MINIRUBY) $(srcdir)/enc/make_encmake.rb $@
|
||||||
|
|
||||||
.PRECIOUS: $(MKFILES)
|
.PRECIOUS: $(MKFILES)
|
||||||
|
|
||||||
.PHONY: test install install-nodoc install-doc dist
|
.PHONY: test install install-nodoc install-doc dist
|
||||||
|
|
|
@ -4,7 +4,7 @@ arch = @arch@
|
||||||
EXTOUT = @EXTOUT@
|
EXTOUT = @EXTOUT@
|
||||||
hdrdir = $(top_srcdir)/include
|
hdrdir = $(top_srcdir)/include
|
||||||
arch_hdrdir = $(EXTOUT)/include/$(arch)
|
arch_hdrdir = $(EXTOUT)/include/$(arch)
|
||||||
VPATH = $(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(top_srcdir):$(srcdir)
|
VPATH = <% %w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(top_srcdir) $(srcdir)].join("@PATH_SEPARATOR@") %>
|
||||||
ENCSODIR = $(EXTOUT)/$(arch)/enc
|
ENCSODIR = $(EXTOUT)/$(arch)/enc
|
||||||
DLEXT = @DLEXT@
|
DLEXT = @DLEXT@
|
||||||
OBJEXT = @OBJEXT@
|
OBJEXT = @OBJEXT@
|
||||||
|
@ -13,8 +13,8 @@ BUILTIN_ENCS = ascii.c \
|
||||||
euc_jp.c sjis.c \
|
euc_jp.c sjis.c \
|
||||||
unicode.c utf8.c
|
unicode.c utf8.c
|
||||||
|
|
||||||
ENCOBJS = @EXTERNAL_ENCOBJS@
|
ENCOBJS = <%encs.map {|e|"#{e}.$(OBJEXT)"}.join(" \\\n\t ")+"\n"%>
|
||||||
ENCSOS = @ENCSOS@
|
ENCSOS = <%encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")+"\n"%>
|
||||||
empty =
|
empty =
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
OUTFLAG = @OUTFLAG@$(empty)
|
OUTFLAG = @OUTFLAG@$(empty)
|
||||||
|
@ -26,3 +26,17 @@ XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
|
||||||
LIBS = @LIBS@ $(EXTLIBS)
|
LIBS = @LIBS@ $(EXTLIBS)
|
||||||
LDSHARED = @LDSHARED@
|
LDSHARED = @LDSHARED@
|
||||||
DLDFLAGS = @DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@
|
DLDFLAGS = @DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@
|
||||||
|
|
||||||
|
#!#! if File.exist?(depend = File.join($srcdir, "depend"))
|
||||||
|
#### depend ####
|
||||||
|
#!#<% depend_rules(depend).join%>
|
||||||
|
#!#! end
|
||||||
|
#!#! encs.each do |e|
|
||||||
|
#!#
|
||||||
|
#!#$(ENCSODIR)/<%e%>.$(DLEXT): <%e%>.$(OBJEXT)
|
||||||
|
#!# <%LINK_SO.gsub(/\n/, "\n\t")%>
|
||||||
|
#!#! end
|
||||||
|
#!#! encs.each do |e|
|
||||||
|
#!#
|
||||||
|
#!#<%e%>.$(OBJEXT): <% (RULE_SUBST || "%s") % "#{e}.c" %>
|
||||||
|
#!#! end
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#! ./miniruby
|
||||||
|
|
||||||
|
dir = File.expand_path("../..", __FILE__)
|
||||||
|
$:.unshift(File.join(dir, "lib"))
|
||||||
|
$:.unshift(dir)
|
||||||
|
File.directory?("enc") || File.mkdir("enc")
|
||||||
|
$:.unshift(".")
|
||||||
|
require 'mkmf'
|
||||||
|
require 'tool/serb'
|
||||||
|
|
||||||
|
encdir = File.join($top_srcdir, "enc")
|
||||||
|
|
||||||
|
encs = Dir.open(encdir) {|d| d.grep(/.+\.c\z/)}
|
||||||
|
encs -= CONFIG["BUILTIN_ENCS"].split
|
||||||
|
encs.each {|e| e.chomp!(".c")}
|
||||||
|
mkin = File.read(File.join(encdir, "Makefile.in"))
|
||||||
|
mkin.gsub!(/^\#!\# ?/, '')
|
||||||
|
mkin.gsub!(/@(#{RbConfig::MAKEFILE_CONFIG.keys.join('|')})@/) {CONFIG[$1]}
|
||||||
|
tmp = ''
|
||||||
|
eval(serb(mkin, 'tmp'))
|
||||||
|
open(ARGV[0], 'w') {|f|
|
||||||
|
f.puts tmp
|
||||||
|
}
|
|
@ -42,15 +42,6 @@ def sysquote(x)
|
||||||
@quote ? x.quote : x
|
@quote ? x.quote : x
|
||||||
end
|
end
|
||||||
|
|
||||||
def relative_from(path, base)
|
|
||||||
dir = File.join(path, "")
|
|
||||||
if File.expand_path(dir) == File.expand_path(dir, base)
|
|
||||||
path
|
|
||||||
else
|
|
||||||
File.join(base, path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def extract_makefile(makefile, keep = true)
|
def extract_makefile(makefile, keep = true)
|
||||||
m = File.read(makefile)
|
m = File.read(makefile)
|
||||||
if !(target = m[/^TARGET[ \t]*=[ \t]*(\S*)/, 1])
|
if !(target = m[/^TARGET[ \t]*=[ \t]*(\S*)/, 1])
|
||||||
|
|
117
lib/mkmf.rb
117
lib/mkmf.rb
|
@ -74,6 +74,15 @@ def dir_re(dir)
|
||||||
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
|
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def relative_from(path, base)
|
||||||
|
dir = File.join(path, "")
|
||||||
|
if File.expand_path(dir) == File.expand_path(dir, base)
|
||||||
|
path
|
||||||
|
else
|
||||||
|
File.join(base, path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
INSTALL_DIRS = [
|
INSTALL_DIRS = [
|
||||||
[dir_re('commondir'), "$(RUBYCOMMONDIR)"],
|
[dir_re('commondir'), "$(RUBYCOMMONDIR)"],
|
||||||
[dir_re('sitedir'), "$(RUBYCOMMONDIR)"],
|
[dir_re('sitedir'), "$(RUBYCOMMONDIR)"],
|
||||||
|
@ -136,7 +145,7 @@ end
|
||||||
|
|
||||||
topdir = File.dirname(libdir = File.dirname(__FILE__))
|
topdir = File.dirname(libdir = File.dirname(__FILE__))
|
||||||
extdir = File.expand_path("ext", topdir)
|
extdir = File.expand_path("ext", topdir)
|
||||||
$extmk = File.expand_path($0)[0, extdir.size+1] == extdir+"/"
|
$extmk = File.expand_path($0)[0, topdir.size+1] == topdir+"/"
|
||||||
if not $extmk and File.exist?(($hdrdir = RbConfig::CONFIG["rubyhdrdir"]) + "/ruby/ruby.h")
|
if not $extmk and File.exist?(($hdrdir = RbConfig::CONFIG["rubyhdrdir"]) + "/ruby/ruby.h")
|
||||||
$topdir = $hdrdir
|
$topdir = $hdrdir
|
||||||
$top_srcdir = $hdrdir
|
$top_srcdir = $hdrdir
|
||||||
|
@ -1257,6 +1266,60 @@ all install static install-so install-rb: Makefile
|
||||||
RULES
|
RULES
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def depend_rules(depend)
|
||||||
|
suffixes = []
|
||||||
|
depout = []
|
||||||
|
depout << "$(OBJS): $(RUBY_EXTCONF_H)\n\n" if $extconf_h
|
||||||
|
unless suffixes.empty?
|
||||||
|
depout << ".SUFFIXES: ." + suffixes.uniq.join(" .") + "\n\n"
|
||||||
|
end
|
||||||
|
open(depend, "r") do |dfile|
|
||||||
|
cont = implicit = nil
|
||||||
|
impconv = proc do
|
||||||
|
COMPILE_RULES.each {|rule| depout << (rule % implicit[0]) << implicit[1]}
|
||||||
|
implicit = nil
|
||||||
|
end
|
||||||
|
ruleconv = proc do |line|
|
||||||
|
if implicit
|
||||||
|
if /\A\t/ =~ line
|
||||||
|
implicit[1] << line
|
||||||
|
next
|
||||||
|
else
|
||||||
|
impconv[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if m = /\A\.(\w+)\.(\w+)(?:\s*:)/.match(line)
|
||||||
|
suffixes << m[1] << m[2]
|
||||||
|
implicit = [[m[1], m[2]], [m.post_match]]
|
||||||
|
next
|
||||||
|
elsif RULE_SUBST and /\A(?!\s*\w+\s*=)[$\w][^#]*:/ =~ line
|
||||||
|
line.gsub!(%r"(?<=\s)(?!\.)([^$(){}+=:\s\/\\,]+)(?=\s|\z)", &RULE_SUBST.method(:%))
|
||||||
|
end
|
||||||
|
depout << line
|
||||||
|
end
|
||||||
|
while line = dfile.gets()
|
||||||
|
line.gsub!(/\.o\b/, ".#{$OBJEXT}")
|
||||||
|
line.gsub!(/\$\((?:hdr|top)dir\)\/config.h/, $config_h) if $config_h
|
||||||
|
line.gsub!(%r"\$\(hdrdir\)/(?!ruby/)", '\&ruby/')
|
||||||
|
if /(?:^|[^\\])(?:\\\\)*\\$/ =~ line
|
||||||
|
(cont ||= []) << line
|
||||||
|
next
|
||||||
|
elsif cont
|
||||||
|
line = (cont << line).join
|
||||||
|
cont = nil
|
||||||
|
end
|
||||||
|
ruleconv.call(line)
|
||||||
|
end
|
||||||
|
if cont
|
||||||
|
ruleconv.call(cont.join)
|
||||||
|
elsif implicit
|
||||||
|
impconv.call
|
||||||
|
end
|
||||||
|
end
|
||||||
|
depout.flatten!
|
||||||
|
depout
|
||||||
|
end
|
||||||
|
|
||||||
# Generates the Makefile for your extension, passing along any options and
|
# Generates the Makefile for your extension, passing along any options and
|
||||||
# preprocessor constants that you may have generated through other methods.
|
# preprocessor constants that you may have generated through other methods.
|
||||||
#
|
#
|
||||||
|
@ -1518,57 +1581,7 @@ site-install-rb: install-rb
|
||||||
|
|
||||||
depend = File.join(srcdir, "depend")
|
depend = File.join(srcdir, "depend")
|
||||||
if File.exist?(depend)
|
if File.exist?(depend)
|
||||||
suffixes = []
|
mfile.print("###\n", *depend_rules(depend))
|
||||||
depout = []
|
|
||||||
open(depend, "r") do |dfile|
|
|
||||||
mfile.printf "###\n"
|
|
||||||
cont = implicit = nil
|
|
||||||
impconv = proc do
|
|
||||||
COMPILE_RULES.each {|rule| depout << (rule % implicit[0]) << implicit[1]}
|
|
||||||
implicit = nil
|
|
||||||
end
|
|
||||||
ruleconv = proc do |line|
|
|
||||||
if implicit
|
|
||||||
if /\A\t/ =~ line
|
|
||||||
implicit[1] << line
|
|
||||||
next
|
|
||||||
else
|
|
||||||
impconv[]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if m = /\A\.(\w+)\.(\w+)(?:\s*:)/.match(line)
|
|
||||||
suffixes << m[1] << m[2]
|
|
||||||
implicit = [[m[1], m[2]], [m.post_match]]
|
|
||||||
next
|
|
||||||
elsif RULE_SUBST and /\A(?!\s*\w+\s*=)[$\w][^#]*:/ =~ line
|
|
||||||
line.gsub!(%r"(?<=\s)(?!\.)([^$(){}+=:\s\/\\,]+)(?=\s|\z)", &RULE_SUBST.method(:%))
|
|
||||||
end
|
|
||||||
depout << line
|
|
||||||
end
|
|
||||||
while line = dfile.gets()
|
|
||||||
line.gsub!(/\.o\b/, ".#{$OBJEXT}")
|
|
||||||
line.gsub!(/\$\((?:hdr|top)dir\)\/config.h/, $config_h) if $config_h
|
|
||||||
line.gsub!(%r"\$\(hdrdir\)/(?!ruby/)", '\&ruby/')
|
|
||||||
if /(?:^|[^\\])(?:\\\\)*\\$/ =~ line
|
|
||||||
(cont ||= []) << line
|
|
||||||
next
|
|
||||||
elsif cont
|
|
||||||
line = (cont << line).join
|
|
||||||
cont = nil
|
|
||||||
end
|
|
||||||
ruleconv.call(line)
|
|
||||||
end
|
|
||||||
if cont
|
|
||||||
ruleconv.call(cont.join)
|
|
||||||
elsif implicit
|
|
||||||
impconv.call
|
|
||||||
end
|
|
||||||
end
|
|
||||||
unless suffixes.empty?
|
|
||||||
mfile.print ".SUFFIXES: .", suffixes.uniq.join(" ."), "\n\n"
|
|
||||||
end
|
|
||||||
mfile.print "$(OBJS): $(RUBY_EXTCONF_H)\n\n" if $extconf_h
|
|
||||||
mfile.print(*depout.flatten)
|
|
||||||
else
|
else
|
||||||
headers = %w[ruby.h defines.h]
|
headers = %w[ruby.h defines.h]
|
||||||
if RULE_SUBST
|
if RULE_SUBST
|
||||||
|
|
|
@ -54,23 +54,7 @@ lines_list = preludes.map {|filename|
|
||||||
[setup_lines, lines]
|
[setup_lines, lines]
|
||||||
}
|
}
|
||||||
|
|
||||||
def serb(str, var)
|
require 'tool/serb'
|
||||||
result = ''
|
|
||||||
str.each_line {|line|
|
|
||||||
if /\A!/ =~ line
|
|
||||||
result << $'
|
|
||||||
else
|
|
||||||
line.split(/(<%.*?%>)/).each {|x|
|
|
||||||
if /\A<%(.*)%>\z/ =~ x
|
|
||||||
result << "#{var} << (#{$1}).to_s\n"
|
|
||||||
else
|
|
||||||
result << "#{var} << #{x.dump}\n"
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
}
|
|
||||||
result
|
|
||||||
end
|
|
||||||
|
|
||||||
tmp = ''
|
tmp = ''
|
||||||
eval(serb(<<'EOS', 'tmp'))
|
eval(serb(<<'EOS', 'tmp'))
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
def serb(str, var)
|
||||||
|
result = ''
|
||||||
|
str.each_line {|line|
|
||||||
|
if /\A!/ =~ line
|
||||||
|
result << $'
|
||||||
|
else
|
||||||
|
line.split(/(<%.*?%>)/).each {|x|
|
||||||
|
if /\A<%(.*)%>\z/ =~ x
|
||||||
|
result << "#{var} << (#{$1}).to_s\n"
|
||||||
|
else
|
||||||
|
result << "#{var} << #{x.dump}\n"
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
||||||
|
result
|
||||||
|
end
|
Загрузка…
Ссылка в новой задаче