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

Commit 6f6d337

Browse files
committed
build: i18n: implement --with-icu-source
Usage: * `--with-icu-source=/path/to/my/other/icu` * `--with-icu-source=/path/to/icu54.zip` In the future, will support `.tgz` and also http/https URL for download. this partially implements srl295/node#11
1 parent a121a52 commit 6f6d337

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

configure

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ parser.add_option('--with-intl',
254254
parser.add_option('--with-icu-source',
255255
action='store',
256256
dest='with_icu_source',
257-
help='Intl mode: optional path to ICU tarball')
257+
help='Intl mode: optional path to ICU zip or existing icu directory.')
258258

259259
parser.add_option('--with-perfctr',
260260
action='store_true',
@@ -765,6 +765,7 @@ def configure_intl(o):
765765
o['variables']['icu_small'] = b(False)
766766

767767
with_intl = options.with_intl
768+
with_icu_source = options.with_icu_source
768769
have_icu_path = bool(options.with_icu_path)
769770
if have_icu_path and with_intl:
770771
print 'Error: Cannot specify both --with-icu-path and --with-intl'
@@ -812,16 +813,53 @@ def configure_intl(o):
812813
icu_full_path = os.path.join(icu_parent_path, 'icu')
813814
icu_small_path = os.path.join(icu_parent_path, 'icu-small')
814815
icu_small_tag = os.path.join(icu_full_path, 'is-small-icu.txt')
815-
816-
## Use (or not) an embedded small-icu.
817-
if with_intl == 'small-icu':
816+
icu_tmp_path = os.path.join(icu_parent_path, 'icu-tmp')
817+
818+
## Has the user specified an ICU source path?
819+
if with_icu_source:
820+
if os.path.isdir(icu_full_path):
821+
print 'Deleting old ICU source: %s' % (icu_full_path)
822+
shutil.rmtree(icu_full_path)
823+
# now, what path was given?
824+
if os.path.isdir(with_icu_source):
825+
# it's a path. Copy it.
826+
print '%s -> %s' % (with_icu_source, icu_full_path)
827+
shutil.copytree(with_icu_source, icu_full_path)
828+
else:
829+
# could be file or URL. Set up temporary area
830+
if os.path.isdir(icu_tmp_path):
831+
shutil.rmtree(icu_tmp_path)
832+
os.mkdir(icu_tmp_path)
833+
icu_tarball = None
834+
if os.path.isfile(with_icu_source):
835+
# it's a file. Try to unpack it.
836+
icu_tarball = with_icu_source
837+
else:
838+
# download tarball
839+
print 'file missing and cant download'
840+
sys.exit(1)
841+
# continue with "icu_tarball"
842+
nodedownload.unpack(icu_tarball, icu_tmp_path)
843+
# Did it unpack correctly? Should contain 'icu'
844+
tmp_icu = os.path.join(icu_tmp_path, 'icu')
845+
if os.path.isdir(tmp_icu):
846+
os.rename(tmp_icu, icu_full_path)
847+
shutil.rmtree(icu_tmp_path)
848+
else:
849+
print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
850+
shutil.rmtree(icu_tmp_path)
851+
sys.exit(1)
852+
853+
elif with_intl == 'small-icu':
854+
## Use (or not) an embedded small-icu.
818855
if not os.path.isdir(icu_full_path) and os.path.isdir(icu_small_path):
819856
# deps/small-icu -> deps/icu
820857
print 'Copying small ICU %s to %s' % (icu_small_path, icu_full_path)
821858
shutil.copytree(icu_small_path, icu_full_path)
822859
#else:
823860
# print 'Not copying %s to %s' % (icu_small_path, icu_full_path)
824861
elif os.path.isfile(icu_small_tag):
862+
## Not small ICU nor custom path. Delete the old deps/icu
825863
print 'deleting small-icu %s for --with-intl=%s' % (icu_full_path, with_intl)
826864
shutil.rmtree(icu_full_path)
827865

0 commit comments

Comments
 (0)