@@ -1798,7 +1798,8 @@ def glob_to_var(dir_base, dir_sub, patch_dir):
1798
1798
return file_list
1799
1799
1800
1800
def configure_intl (o ):
1801
- def icu_download (path ):
1801
+ def icu_download ():
1802
+ """Download or verify ICU from the deps file (current_ver.dep)"""
1802
1803
depFile = tools_path / 'icu' / 'current_ver.dep'
1803
1804
icus = json .loads (depFile .read_text (encoding = 'utf-8' ))
1804
1805
# download ICU, if needed
@@ -1848,6 +1849,17 @@ def icu_download(path):
1848
1849
1849
1850
with_intl = options .with_intl
1850
1851
with_icu_source = options .with_icu_source
1852
+ if not with_icu_source :
1853
+ with_icu_source_path = None
1854
+ # no --with-icu-source
1855
+ elif with_icu_source .startswith ('http://' ) or with_icu_source .startswith ('https://' ):
1856
+ # --with-icu-source isn't a path.
1857
+ with_icu_source_path = None
1858
+ else :
1859
+ # convert to a resolved path for the dep check (below)
1860
+ with_icu_source = Path (with_icu_source ).resolve ()
1861
+ # pre-convert to a path for later checks.
1862
+ with_icu_source_path = Path (with_icu_source )
1851
1863
have_icu_path = bool (options .with_icu_path )
1852
1864
if have_icu_path and with_intl != 'none' :
1853
1865
error ('Cannot specify both --with-icu-path and --with-intl' )
@@ -1936,16 +1948,16 @@ def icu_download(path):
1936
1948
icu_config ['variables' ]['icu_full_canned' ] = 1
1937
1949
# --with-icu-source processing
1938
1950
# now, check that they didn't pass --with-icu-source=deps/icu
1939
- elif with_icu_source and Path (icu_full_path ).resolve () == Path ( with_icu_source ). resolve () :
1940
- warn (f'Ignoring redundant --with-icu-source={ with_icu_source } ' )
1951
+ elif with_icu_source and Path (icu_full_path ).resolve () == with_icu_source :
1952
+ warn (f'Ignoring redundant --with-icu-source={ options . with_icu_source } ' )
1941
1953
with_icu_source = None
1942
1954
# if with_icu_source is still set, try to use it.
1943
1955
if with_icu_source :
1944
1956
if Path (icu_full_path ).is_dir ():
1945
1957
print (f'Deleting old ICU source: { icu_full_path } ' )
1946
1958
shutil .rmtree (icu_full_path )
1947
1959
# now, what path was given?
1948
- if Path ( with_icu_source ) .is_dir ():
1960
+ if with_icu_source_path and with_icu_source_path .is_dir ():
1949
1961
# it's a path. Copy it.
1950
1962
print (f'{ with_icu_source } -> { icu_full_path } ' )
1951
1963
shutil .copytree (with_icu_source , icu_full_path )
@@ -1956,13 +1968,15 @@ def icu_download(path):
1956
1968
shutil .rmtree (icu_tmp_path )
1957
1969
icu_tmp_path .mkdir ()
1958
1970
icu_tarball = None
1959
- if Path ( with_icu_source ) .is_file ():
1971
+ if with_icu_source_path and with_icu_source_path .is_file ():
1960
1972
# it's a file. Try to unpack it.
1961
- icu_tarball = with_icu_source
1962
- else :
1963
- # Can we download it?
1973
+ icu_tarball = str ( with_icu_source . as_posix ()) # resolved path
1974
+ elif not with_icu_source_path :
1975
+ # Can we download it? (not a path)
1964
1976
local = icu_tmp_path / with_icu_source .split ('/' )[- 1 ] # local part
1965
1977
icu_tarball = nodedownload .retrievefile (with_icu_source , local )
1978
+ else :
1979
+ error (f'Cannot find ICU, not a file, dir, or URL: --with-icu-source={ options .with_icu_source } ' )
1966
1980
# continue with "icu_tarball"
1967
1981
nodedownload .unpack (icu_tarball , icu_tmp_path )
1968
1982
# Did it unpack correctly? Should contain 'icu'
@@ -1972,15 +1986,15 @@ def icu_download(path):
1972
1986
shutil .rmtree (icu_tmp_path )
1973
1987
else :
1974
1988
shutil .rmtree (icu_tmp_path )
1975
- error (f'--with-icu-source={ with_icu_source } did not result in an "icu" dir.' )
1989
+ error (f'--with-icu-source={ options . with_icu_source } did not result in an "icu" dir.' )
1976
1990
1977
1991
# ICU mode. (icu-generic.gyp)
1978
1992
o ['variables' ]['icu_gyp_path' ] = 'tools/icu/icu-generic.gyp'
1979
1993
# ICU source dir relative to tools/icu (for .gyp file)
1980
1994
o ['variables' ]['icu_path' ] = icu_full_path
1981
1995
if not Path (icu_full_path ).is_dir ():
1982
1996
# can we download (or find) a zipfile?
1983
- localzip = icu_download (icu_full_path )
1997
+ localzip = icu_download ()
1984
1998
if localzip :
1985
1999
nodedownload .unpack (localzip , icu_parent_path )
1986
2000
else :
0 commit comments