Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
build: i18n: WIP - auto-download and unpack ICU. joyent#7676
Browse files Browse the repository at this point in the history
  • Loading branch information
srl295 committed Nov 13, 2014
1 parent 044a864 commit 57cccf1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ ipch/
email.md
deps/v8-*
deps/icu
deps/icu*.zip
deps/icu*.tgz
./node_modules
.svn/

Expand Down
27 changes: 17 additions & 10 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -724,20 +724,21 @@ def icu_download(path):
]
def fmtMb(amt):
return "{:.1f}".format(amt / 1024000.)
spin = "\\|/-"
def reporthook(count, size, total):
sys.stdout.write('%sMB total, %sMB downloaded \r' %
(fmtMb(total),fmtMb(count*size)))
sys.stdout.write('%c %sMB total, %sMB downloaded \r' %
(spin[count%4], fmtMb(total), fmtMb(count*size)))
for icu in icus:
url = icu['url']
md5 = icu['md5']
local = url.split('/')[-1]
targetfile = os.path.join(root_dir, 'deps', local)
if not os.path.isfile(targetfile):
try:
sys.stdout.write('Downloading ICU from %s\nConnecting...\r' % url)
sys.stdout.write('Downloading ICU:\n %s\nConnecting...\r' % url)
sys.stdout.flush()
msg = urllib.urlretrieve(url, targetfile, reporthook=reporthook)
sys.stdout.write('\n') # newline
print '' # clear the line
print 'Downloaded %s' % local
except:
print 'Error occurred while downloading %s' % url
Expand All @@ -748,9 +749,8 @@ def icu_download(path):
print 'Not re-downloading %s (delete it to retry)' % targetfile
if os.path.isfile(targetfile) and md5 is not None:
print 'Should have md5sum %s' % md5
print 'TODO: SKIPPING md5sum check'


print 'TODO: SKIPPING md5sum check, assuming OK!'
return targetfile
print 'Please see the README.md - could not automatically download ICU.'
return None

Expand Down Expand Up @@ -782,6 +782,8 @@ def configure_intl(o):
o['variables']['icu_gyp_path'] = options.with_icu_path
return
# --with-intl=<with_intl>
if with_intl is None:
with_intl = 'none' # this is the default 'intl' mode.
if with_intl == 'none' or with_intl is None:
o['variables']['v8_enable_i18n_support'] = 0
return # no Intl
Expand Down Expand Up @@ -816,14 +818,19 @@ def configure_intl(o):
byteorder = sys.byteorder
o['variables']['icu_gyp_path'] = 'tools/icu/icu-generic.gyp'
# ICU source dir relative to root
icu_full_path = os.path.join(root_dir, 'deps/icu')
icu_parent_path = os.path.join(root_dir, 'deps')
icu_full_path = os.path.join(icu_parent_path, 'icu')
o['variables']['icu_path'] = icu_full_path
if not os.path.isdir(icu_full_path):
print 'ECMA-402 (Intl) needs an ICU in %s' % (icu_full_path)
# can we download (or find) a zipfile?
localzip = icu_download(icu_full_path)
if localzip:
print 'Got local zip: %s' % localzip
with zipfile.ZipFile(localzip, 'r') as icuzip:
print 'Extracting ICU source zip: %s' % localzip
icuzip.extractall(icu_parent_path)
if not os.path.isdir(icu_full_path):
print 'Error: ICU path is not a directory and couldn\'t download: %s' % (icu_full_path)
print 'Cannot continue without ICU in %s.' % (icu_full_path)
sys.exit(1)
# Now, what version of ICU is it? We just need the "major", such as 54.
# uvernum.h contains it as a #define.
Expand Down

0 comments on commit 57cccf1

Please sign in to comment.