common.mk: separate Unicode files directory

* common.mk: download Unicode files into separate directory for the
  version.

* tool/downloader.rb (Downloader::Unicode.download): strip version
  directory.

* tool/downloader.rb (Downloader.download): strip directory name
  if download directory is given.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-10-30 07:39:51 +00:00
Родитель 40cc9231a9
Коммит 39713bd927
2 изменённых файлов: 21 добавлений и 14 удалений

Просмотреть файл

@ -10,6 +10,8 @@ Q1 = $(V:1=)
Q = $(Q1:0=@)
ECHO = $(ECHO1:0=@echo)
UNICODE_VERSION = 7.0.0
RUBYLIB = $(PATH_SEPARATOR)
RUBYOPT = -
RUN_OPTS = --disable-gems
@ -1103,21 +1105,25 @@ update-gems: PHONY
### the Unicode data files are updated every minute.
# ALWAYS_UPDATE_UNICODE = yes
UNICODE_FILES = $(srcdir)/enc/unicode/data/UnicodeData.txt \
$(srcdir)/enc/unicode/data/CompositionExclusions.txt \
$(srcdir)/enc/unicode/data/NormalizationTest.txt
UNICODE_FILES = $(srcdir)/enc/unicode/data/$(UNICODE_VERSION)/UnicodeData.txt \
$(srcdir)/enc/unicode/data/$(UNICODE_VERSION)/CompositionExclusions.txt \
$(srcdir)/enc/unicode/data/$(UNICODE_VERSION)/NormalizationTest.txt
update-unicode: $(UNICODE_FILES) PHONY
$(UNICODE_FILES): ./.update-unicode.time
$(UNICODE_FILES): ./.unicode-$(UNICODE_VERSION).time
UPDATE_UNICODE_FILES_DEPS = $(ALWAYS_UPDATE_UNICODE:yes=PHONY)
./.update-unicode.time: $(UPDATE_UNICODE_FILES_DEPS:no=)
$(ECHO) Downloading Unicode data files...
$(Q) $(MAKEDIRS) "$(srcdir)/enc/unicode/data"
$(Q) $(BASERUBY) -C "$(srcdir)/enc/unicode/data" \
../../../tool/downloader.rb -e $(ALWAYS_UPDATE_UNICODE:yes=-a) unicode \
UnicodeData.txt CompositionExclusions.txt NormalizationTest.txt
./.unicode-tables.time: ./.unicode-$(UNICODE_VERSION).time
./.unicode-$(UNICODE_VERSION).time: $(UPDATE_UNICODE_FILES_DEPS:no=)
$(ECHO) Downloading Unicode $(UNICODE_VERSION) data files...
$(Q) $(MAKEDIRS) "$(srcdir)/enc/unicode/data/$(UNICODE_VERSION)"
$(Q) $(BASERUBY) -C "$(srcdir)" tool/downloader.rb \
-d enc/unicode/data/$(UNICODE_VERSION) \
-e $(ALWAYS_UPDATE_UNICODE:yes=-a) unicode \
$(UNICODE_VERSION)/ucd/UnicodeData.txt \
$(UNICODE_VERSION)/ucd/CompositionExclusions.txt \
$(UNICODE_VERSION)/ucd/NormalizationTest.txt
@exit > .update-unicode.time
$(srcdir)/lib/unicode_normalize/tables.rb: ./.unicode-tables.time
@ -1127,7 +1133,8 @@ $(srcdir)/lib/unicode_normalize/tables.rb: ./.unicode-tables.time
$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb \
-c -t$@ -o $(srcdir)/lib/unicode_normalize/tables.rb \
-I $(srcdir) \
$(srcdir)/template/unicode_norm_gen.tmpl enc/unicode/data lib/unicode_normalize
$(srcdir)/template/unicode_norm_gen.tmpl \
enc/unicode/data/$(UNICODE_VERSION) lib/unicode_normalize
info: info-program info-libruby_a info-libruby_so info-arch
info-program: PHONY

Просмотреть файл

@ -17,7 +17,7 @@ class Downloader
class Unicode < self
def self.download(name, *rest)
super("http://www.unicode.org/Public/7.0.0/ucd/#{name}", name, *rest)
super("http://www.unicode.org/Public/#{name}", name, *rest)
end
end
@ -53,7 +53,7 @@ class Downloader
# download 'http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt',
# 'UnicodeData.txt', 'enc/unicode/data'
def self.download(url, name, dir = nil, ims = true)
file = dir ? File.join(dir, name) : name
file = dir ? File.join(dir, File.basename(name)) : name
return true if ims.nil? and File.exist?(file)
url = URI(url)
if $VERBOSE
@ -124,7 +124,7 @@ if $0 == __FILE__
end
dl = Downloader.constants.find do |name|
ARGV[0].casecmp(name.to_s) == 0
end
end unless ARGV.empty?
$VERBOSE = true
if dl
dl = Downloader.const_get(dl)