Permalink
Browse files

enc: fix dependencies

* enc/depend (ENCOBJS): add dependencies.
* enc/make_encmake.rb (target_encodings): extract dependencies.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 52f0c67 commit fb2e6803b0df64cadfc6b1189c25332e948e9ddd @nobu nobu committed May 21, 2012
Showing with 36 additions and 3 deletions.
  1. +6 −0 ChangeLog
  2. +3 −0 enc/depend
  3. +27 −3 enc/make_encmake.rb
View
@@ -1,3 +1,9 @@
+Mon May 21 12:11:25 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * enc/depend (ENCOBJS): add dependencies.
+
+ * enc/make_encmake.rb (target_encodings): extract dependencies.
+
Mon May 21 11:26:17 2012 NARUSE, Yui <naruse@ruby-lang.org>
* lib/net/ftp.rb (Net::FTP#transfercmd): rescue shutdown.
View
@@ -84,6 +84,9 @@ srcs: $(TRANSCSRCS)
% unless ENCS.empty?
$(ENCOBJS): regenc.h oniguruma.h config.h defines.h
% end
+% ENC_DEPS.each do |e, deps|
+enc/<%=e%>.$(OBJEXT): <%=deps.map {|n| rule_subst % n}.join(' ')%>
+% end
% unless TRANS.empty?
$(TRANSOBJS): ruby.h intern.h config.h defines.h missing.h encoding.h oniguruma.h st.h transcode_data.h
% end
View
@@ -48,8 +48,32 @@ def target_encodings
encs.reject! {|e| !ENC_PATTERNS.any? {|p| File.fnmatch?(p, e)}} if !ENC_PATTERNS.empty?
encs.reject! {|e| NOENC_PATTERNS.any? {|p| File.fnmatch?(p, e)}}
encs = encs.sort_by(&ALPHANUMERIC_ORDER)
- encs.unshift(encs.delete("encdb"))
- return encs
+ deps = Hash.new {[]}
+ inc_srcs = Hash.new {[]}
+ default_deps = %w[regenc.h oniguruma.h config.h defines.h]
+ db = encs.delete("encdb")
+ encs.each do |e|
+ File.foreach("#$srcdir/#{e}.c") do |l|
+ if /^\s*#\s*include\s+(?:"([^\"]+)"|<(ruby\/\sw+.h)>)/ =~ l
+ n = $1 || $2
+ if /\.c$/ =~ n
+ inc_srcs[e] <<= $`
+ n = "enc/#{n}"
+ end
+ deps[e] <<= n unless default_deps.include?(n)
+ end
+ end
+ end
+ class << inc_srcs; self; end.class_eval do
+ define_method(:expand) do |d|
+ d.map {|n| deps[n] | self.expand(self[n])}.flatten
+ end
+ end
+ inc_srcs.each do |e, d|
+ deps[e].concat(inc_srcs.expand(d))
+ end
+ encs.unshift(db)
+ return encs, deps
end
def target_transcoders
@@ -79,7 +103,7 @@ def target_transcoders
# Constants that "depend" needs.
MODULE_TYPE = module_type
-ENCS = target_encodings
+ENCS, ENC_DEPS = target_encodings
ATRANS, TRANS = target_transcoders
if File.exist?(depend = File.join($srcdir, "depend"))

0 comments on commit fb2e680

Please sign in to comment.