summaryrefslogtreecommitdiff
path: root/tool/update-deps
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-21 09:12:56 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-21 09:12:56 +0000
commit2aaba598d6232c3238a62b528223a1a5653a1c1f (patch)
treec7231ac4a326e4e3bef08b8ca4ed5b30952209d4 /tool/update-deps
parent539b39af23988eb22b8cf1195f7a597d5bf42277 (diff)
* tool/update-deps: Refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/update-deps')
-rwxr-xr-xtool/update-deps173
1 files changed, 89 insertions, 84 deletions
diff --git a/tool/update-deps b/tool/update-deps
index 24cb7a4..f5cfa5c 100755
--- a/tool/update-deps
+++ b/tool/update-deps
@@ -28,16 +28,99 @@ require 'pathname'
require 'open3'
require 'pp'
-ENV['LC_ALL'] = 'C'
+# These files are not in the svn repository.
+# Thier locaiton vary in out-of-place build.
+# They are built in the build directory if the source is obtained via svn.
+# However they are exist in tarball and exist in the source directory if the source is obtained as tarball.
+FILES_NEED_VPATH = %w[
+ encdb.h
+ id.c
+ id.h
+ lex.c
+ miniprelude.c
+ newline.c
+ parse.c
+ parse.h
+ prelude.c
+ probes.h
+ transdb.h
+ verconf.h
+]
+
+# Multiple files with one filename.
+# It is not good idea to refer them using VPATH.
+FILES_SAME_NAME = %w[
+ include/ruby.h
+ include/ruby/ruby.h
+ version.h
+ include/ruby/version.h
+]
-$opt_fix = false
-$opt_a = false
-$opt_actual_fix = false
-$i_not_found = false
+def in_makefile(target, source)
+ target = target.to_s
+ source = source.to_s
+ case target
+ when %r{\A[^/]*\z}
+ target2 = "#{target.sub(/\.o\z/, '.$(OBJEXT)')}"
+ case source
+ when *FILES_NEED_VPATH then source2 = "{$(VPATH)}#{source}"
+ when *FILES_SAME_NAME then source2 = "$(top_srcdir)/#{source}"
+ when 'revision.h' then source2 = '$(srcdir)/revision.h' # This file is always generated in $(srcdir).
+ when 'thread_pthread.c' then source2 = '{$(VPATH)}thread_$(THREAD_MODEL).c'
+ when 'thread_pthread.h' then source2 = '{$(VPATH)}thread_$(THREAD_MODEL).h'
+ when %r{\A[^/]*\z} then source2 = "{$(VPATH)}#{File.basename source}"
+ when %r{\A\.ext/include/[^/]+/ruby/} then source2 = "{$(VPATH)}#{$'}"
+ when %r{\Ainclude/ruby/} then source2 = "{$(VPATH)}#{$'}"
+ when %r{\Aenc/} then source2 = "{$(VPATH)}#{$'}"
+ when %r{\Amissing/} then source2 = "{$(VPATH)}#{$'}"
+ when %r{\Accan/} then source2 = "$(CCAN_DIR)/#{$'}"
+ when %r{\Adefs/} then source2 = "{$(VPATH)}#{source}"
+ else source2 = "$(top_srcdir)/#{source}"
+ end
+ ["common.mk", target2, source2]
+ when %r{\Aenc/}
+ target2 = "#{target.sub(/\.o\z/, '.$(OBJEXT)')}"
+ case source
+ when *FILES_NEED_VPATH then source2 = source
+ when *FILES_SAME_NAME then source2 = "$(top_srcdir)/#{source}"
+ when %r{\A\.ext/include/[^/]+/ruby/} then source2 = $'
+ when %r{\Ainclude/ruby/} then source2 = $'
+ when %r{\Aenc/} then source2 = source
+ else source2 = "$(top_srcdir)/#{source}"
+ end
+ ["enc/depend", target2, source2]
+ when %r{\Aext/}
+ unless File.exist?("#{File.dirname(target)}/extconf.rb")
+ warn "warning: not found: #{File.dirname(target)}/extconf.rb"
+ end
+ target2 = File.basename(target)
+ case source
+ when *FILES_NEED_VPATH then source2 = "{$(VPATH)}#{source}"
+ when *FILES_SAME_NAME then source2 = "$(top_srcdir)/#{source}"
+ when %r{\A\.ext/include/[^/]+/ruby/} then source2 = "$(arch_hdrdir)/ruby/#{$'}"
+ when %r{\Ainclude/} then source2 = "$(hdrdir)/#{$'}"
+ when %r{\A#{Regexp.escape File.dirname(target)}/extconf\.h\z} then source2 = "$(RUBY_EXTCONF_H)"
+ when %r{\A#{Regexp.escape File.dirname(target)}/} then source2 = $'
+ else source2 = "$(top_srcdir)/#{source}"
+ end
+ ["#{File.dirname(target)}/depend", target2, source2]
+ else
+ raise "unexpected target: #{target}"
+ end
+end
DEPENDENCIES_SECTION_START_MARK = "\# AUTOGENERATED DEPENDENCIES START\n"
DEPENDENCIES_SECTION_END_MARK = "\# AUTOGENERATED DEPENDENCIES END\n"
+def init_global
+ ENV['LC_ALL'] = 'C'
+
+ $opt_fix = false
+ $opt_a = false
+ $opt_actual_fix = false
+ $i_not_found = false
+end
+
def optionparser
op = OptionParser.new
op.banner = 'Usage: ruby tool/update-deps'
@@ -196,85 +279,6 @@ def sort_paths(paths)
}
end
-# These files are not in the svn repository.
-# They are built in the build directory if the source is obtained via svn.
-# However they are exist in tarball and exist in the source directory if the source is obtained as tarball.
-FILES_NEED_VPATH = %w[
- encdb.h
- id.c
- id.h
- lex.c
- miniprelude.c
- newline.c
- parse.c
- parse.h
- prelude.c
- probes.h
- transdb.h
- verconf.h
-]
-
-# Multiple files with one filename.
-FILES_CONFUSING = %w[
- include/ruby.h
- include/ruby/ruby.h
- version.h
- include/ruby/version.h
-]
-
-def in_makefile(target, source)
- target = target.to_s
- source = source.to_s
- case target
- when %r{\A[^/]*\z}
- target2 = "#{target.sub(/\.o\z/, '.$(OBJEXT)')}"
- case source
- when *FILES_NEED_VPATH then source2 = "{$(VPATH)}#{source}"
- when *FILES_CONFUSING then source2 = "$(top_srcdir)/#{source}"
- when 'revision.h' then source2 = '$(srcdir)/revision.h' # This file is always generated in $(srcdir).
- when 'thread_pthread.c' then source2 = '{$(VPATH)}thread_$(THREAD_MODEL).c'
- when 'thread_pthread.h' then source2 = '{$(VPATH)}thread_$(THREAD_MODEL).h'
- when %r{\A[^/]*\z} then source2 = "{$(VPATH)}#{File.basename source}"
- when %r{\A\.ext/include/[^/]+/ruby/} then source2 = "{$(VPATH)}#{$'}"
- when %r{\Ainclude/ruby/} then source2 = "{$(VPATH)}#{$'}"
- when %r{\Aenc/} then source2 = "{$(VPATH)}#{$'}"
- when %r{\Amissing/} then source2 = "{$(VPATH)}#{$'}"
- when %r{\Accan/} then source2 = "$(CCAN_DIR)/#{$'}"
- when %r{\Adefs/} then source2 = "{$(VPATH)}#{source}"
- else source2 = "$(top_srcdir)/#{source}"
- end
- ["common.mk", target2, source2]
- when %r{\Aenc/}
- target2 = "#{target.sub(/\.o\z/, '.$(OBJEXT)')}"
- case source
- when *FILES_NEED_VPATH then source2 = source
- when *FILES_CONFUSING then source2 = "$(top_srcdir)/#{source}"
- when %r{\A\.ext/include/[^/]+/ruby/} then source2 = $'
- when %r{\Ainclude/ruby/} then source2 = $'
- when %r{\Aenc/} then source2 = source
- else source2 = "$(top_srcdir)/#{source}"
- end
- ["enc/depend", target2, source2]
- when %r{\Aext/}
- unless File.exist?("#{File.dirname(target)}/extconf.rb")
- warn "warning: not found: #{File.dirname(target)}/extconf.rb"
- end
- target2 = File.basename(target)
- case source
- when *FILES_NEED_VPATH then source2 = "{$(VPATH)}#{source}"
- when *FILES_CONFUSING then source2 = "$(top_srcdir)/#{source}"
- when %r{\A\.ext/include/[^/]+/ruby/} then source2 = "$(arch_hdrdir)/ruby/#{$'}"
- when %r{\Ainclude/} then source2 = "$(hdrdir)/#{$'}"
- when %r{\A#{Regexp.escape File.dirname(target)}/extconf\.h\z} then source2 = "$(RUBY_EXTCONF_H)"
- when %r{\A#{Regexp.escape File.dirname(target)}/} then source2 = $'
- else source2 = "$(top_srcdir)/#{source}"
- end
- ["#{File.dirname(target)}/depend", target2, source2]
- else
- raise "unexpected target: #{target}"
- end
-end
-
def show_deps(tag, deps)
targets = sort_paths(deps.keys)
targets.each {|t|
@@ -478,6 +482,7 @@ def run
end
end
+init_global
run
if $i_not_found
warn "warning: missing *.i files, see help in #$0 and ensure ccache is disabled"