mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* tool/update-deps: Refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
539b39af23
commit
2aaba598d6
2 changed files with 93 additions and 84 deletions
|
@ -1,3 +1,7 @@
|
|||
Fri Nov 21 18:12:37 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* tool/update-deps: Refactored.
|
||||
|
||||
Fri Nov 21 14:25:40 2014 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/Makefile.sub (top_srcdir): added because lacking this macro
|
||||
|
|
173
tool/update-deps
173
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
|
||||
]
|
||||
|
||||
$opt_fix = false
|
||||
$opt_a = false
|
||||
$opt_actual_fix = false
|
||||
$i_not_found = false
|
||||
# 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
|
||||
]
|
||||
|
||||
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"
|
||||
|
|
Loading…
Add table
Reference in a new issue