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

Commit

Permalink
build: i18n: implement --with-icu-source
Browse files Browse the repository at this point in the history
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
  • Loading branch information
srl295 committed Dec 9, 2014
1 parent a121a52 commit 6f6d337
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ parser.add_option('--with-intl',
parser.add_option('--with-icu-source',
action='store',
dest='with_icu_source',
help='Intl mode: optional path to ICU tarball')
help='Intl mode: optional path to ICU zip or existing icu directory.')

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

with_intl = options.with_intl
with_icu_source = options.with_icu_source
have_icu_path = bool(options.with_icu_path)
if have_icu_path and with_intl:
print 'Error: Cannot specify both --with-icu-path and --with-intl'
Expand Down Expand Up @@ -812,16 +813,53 @@ def configure_intl(o):
icu_full_path = os.path.join(icu_parent_path, 'icu')
icu_small_path = os.path.join(icu_parent_path, 'icu-small')
icu_small_tag = os.path.join(icu_full_path, 'is-small-icu.txt')

## Use (or not) an embedded small-icu.
if with_intl == 'small-icu':
icu_tmp_path = os.path.join(icu_parent_path, 'icu-tmp')

## Has the user specified an ICU source path?
if with_icu_source:
if os.path.isdir(icu_full_path):
print 'Deleting old ICU source: %s' % (icu_full_path)
shutil.rmtree(icu_full_path)
# now, what path was given?
if os.path.isdir(with_icu_source):
# it's a path. Copy it.
print '%s -> %s' % (with_icu_source, icu_full_path)
shutil.copytree(with_icu_source, icu_full_path)
else:
# could be file or URL. Set up temporary area
if os.path.isdir(icu_tmp_path):
shutil.rmtree(icu_tmp_path)
os.mkdir(icu_tmp_path)
icu_tarball = None
if os.path.isfile(with_icu_source):
# it's a file. Try to unpack it.
icu_tarball = with_icu_source
else:
# download tarball
print 'file missing and cant download'
sys.exit(1)
# continue with "icu_tarball"
nodedownload.unpack(icu_tarball, icu_tmp_path)
# Did it unpack correctly? Should contain 'icu'
tmp_icu = os.path.join(icu_tmp_path, 'icu')
if os.path.isdir(tmp_icu):
os.rename(tmp_icu, icu_full_path)
shutil.rmtree(icu_tmp_path)
else:
print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
shutil.rmtree(icu_tmp_path)
sys.exit(1)

elif with_intl == 'small-icu':
## Use (or not) an embedded small-icu.
if not os.path.isdir(icu_full_path) and os.path.isdir(icu_small_path):
# deps/small-icu -> deps/icu
print 'Copying small ICU %s to %s' % (icu_small_path, icu_full_path)
shutil.copytree(icu_small_path, icu_full_path)
#else:
# print 'Not copying %s to %s' % (icu_small_path, icu_full_path)
elif os.path.isfile(icu_small_tag):
## Not small ICU nor custom path. Delete the old deps/icu
print 'deleting small-icu %s for --with-intl=%s' % (icu_full_path, with_intl)
shutil.rmtree(icu_full_path)

Expand Down

0 comments on commit 6f6d337

Please sign in to comment.