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

Commit 57cccf1

Browse files
committed
build: i18n: WIP - auto-download and unpack ICU. joyent#7676
1 parent 044a864 commit 57cccf1

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ ipch/
4646
email.md
4747
deps/v8-*
4848
deps/icu
49+
deps/icu*.zip
50+
deps/icu*.tgz
4951
./node_modules
5052
.svn/
5153

configure

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -724,20 +724,21 @@ def icu_download(path):
724724
]
725725
def fmtMb(amt):
726726
return "{:.1f}".format(amt / 1024000.)
727+
spin = "\\|/-"
727728
def reporthook(count, size, total):
728-
sys.stdout.write('%sMB total, %sMB downloaded \r' %
729-
(fmtMb(total),fmtMb(count*size)))
729+
sys.stdout.write('%c %sMB total, %sMB downloaded \r' %
730+
(spin[count%4], fmtMb(total), fmtMb(count*size)))
730731
for icu in icus:
731732
url = icu['url']
732733
md5 = icu['md5']
733734
local = url.split('/')[-1]
734735
targetfile = os.path.join(root_dir, 'deps', local)
735736
if not os.path.isfile(targetfile):
736737
try:
737-
sys.stdout.write('Downloading ICU from %s\nConnecting...\r' % url)
738+
sys.stdout.write('Downloading ICU:\n %s\nConnecting...\r' % url)
738739
sys.stdout.flush()
739740
msg = urllib.urlretrieve(url, targetfile, reporthook=reporthook)
740-
sys.stdout.write('\n') # newline
741+
print '' # clear the line
741742
print 'Downloaded %s' % local
742743
except:
743744
print 'Error occurred while downloading %s' % url
@@ -748,9 +749,8 @@ def icu_download(path):
748749
print 'Not re-downloading %s (delete it to retry)' % targetfile
749750
if os.path.isfile(targetfile) and md5 is not None:
750751
print 'Should have md5sum %s' % md5
751-
print 'TODO: SKIPPING md5sum check'
752-
753-
752+
print 'TODO: SKIPPING md5sum check, assuming OK!'
753+
return targetfile
754754
print 'Please see the README.md - could not automatically download ICU.'
755755
return None
756756

@@ -782,6 +782,8 @@ def configure_intl(o):
782782
o['variables']['icu_gyp_path'] = options.with_icu_path
783783
return
784784
# --with-intl=<with_intl>
785+
if with_intl is None:
786+
with_intl = 'none' # this is the default 'intl' mode.
785787
if with_intl == 'none' or with_intl is None:
786788
o['variables']['v8_enable_i18n_support'] = 0
787789
return # no Intl
@@ -816,14 +818,19 @@ def configure_intl(o):
816818
byteorder = sys.byteorder
817819
o['variables']['icu_gyp_path'] = 'tools/icu/icu-generic.gyp'
818820
# ICU source dir relative to root
819-
icu_full_path = os.path.join(root_dir, 'deps/icu')
821+
icu_parent_path = os.path.join(root_dir, 'deps')
822+
icu_full_path = os.path.join(icu_parent_path, 'icu')
820823
o['variables']['icu_path'] = icu_full_path
821824
if not os.path.isdir(icu_full_path):
825+
print 'ECMA-402 (Intl) needs an ICU in %s' % (icu_full_path)
826+
# can we download (or find) a zipfile?
822827
localzip = icu_download(icu_full_path)
823828
if localzip:
824-
print 'Got local zip: %s' % localzip
829+
with zipfile.ZipFile(localzip, 'r') as icuzip:
830+
print 'Extracting ICU source zip: %s' % localzip
831+
icuzip.extractall(icu_parent_path)
825832
if not os.path.isdir(icu_full_path):
826-
print 'Error: ICU path is not a directory and couldn\'t download: %s' % (icu_full_path)
833+
print 'Cannot continue without ICU in %s.' % (icu_full_path)
827834
sys.exit(1)
828835
# Now, what version of ICU is it? We just need the "major", such as 54.
829836
# uvernum.h contains it as a #define.

0 commit comments

Comments
 (0)