Skip to content

Commit 5d2dadc

Browse files
srl295codebytere
authored andcommitted
build: check minimum ICU in configure for system-icu
- check the version number coming out of pkg-config PR-URL: #24255 Fixes: #24253 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent e11d46c commit 5d2dadc

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

configure.py

+17-8
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
dest='with_icu_source',
430430
help='Intl mode: optional local path to icu/ dir, or path/URL of '
431431
'the icu4c source archive. '
432-
'v%d.x or later recommended.' % icu_versions["minimum_icu"])
432+
'v%d.x or later recommended.' % icu_versions['minimum_icu'])
433433

434434
parser.add_option('--with-ltcg',
435435
action='store_true',
@@ -621,17 +621,21 @@ def b(value):
621621

622622

623623
def pkg_config(pkg):
624+
"""Run pkg-config on the specified package
625+
Returns ("-l flags", "-I flags", "-L flags", "version")
626+
otherwise (None, None, None, None)"""
624627
pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config')
625628
retval = ()
626-
for flag in ['--libs-only-l', '--cflags-only-I', '--libs-only-L']:
629+
for flag in ['--libs-only-l', '--cflags-only-I',
630+
'--libs-only-L', '--modversion']:
627631
try:
628632
proc = subprocess.Popen(
629633
shlex.split(pkg_config) + ['--silence-errors', flag, pkg],
630634
stdout=subprocess.PIPE)
631635
val = proc.communicate()[0].strip()
632636
except OSError as e:
633637
if e.errno != errno.ENOENT: raise e # Unexpected error.
634-
return (None, None, None) # No pkg-config/pkgconf installed.
638+
return (None, None, None, None) # No pkg-config/pkgconf installed.
635639
retval += (val,)
636640
return retval
637641

@@ -1123,7 +1127,7 @@ def configure_library(lib, output):
11231127
output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib))
11241128

11251129
if getattr(options, shared_lib):
1126-
(pkg_libs, pkg_cflags, pkg_libpath) = pkg_config(lib)
1130+
(pkg_libs, pkg_cflags, pkg_libpath, pkg_modversion) = pkg_config(lib)
11271131

11281132
if options.__dict__[shared_lib + '_includes']:
11291133
output['include_dirs'] += [options.__dict__[shared_lib + '_includes']]
@@ -1356,7 +1360,12 @@ def write_config(data, name):
13561360
if pkgicu[0] is None:
13571361
error('''Could not load pkg-config data for "icu-i18n".
13581362
See above errors or the README.md.''')
1359-
(libs, cflags, libpath) = pkgicu
1363+
(libs, cflags, libpath, icuversion) = pkgicu
1364+
icu_ver_major = icuversion.split('.')[0]
1365+
o['variables']['icu_ver_major'] = icu_ver_major
1366+
if int(icu_ver_major) < icu_versions['minimum_icu']:
1367+
error('icu4c v%s is too old, v%d.x or later is required.' %
1368+
(icuversion, icu_versions['minimum_icu']))
13601369
# libpath provides linker path which may contain spaces
13611370
if libpath:
13621371
o['libraries'] += [libpath]
@@ -1474,9 +1483,9 @@ def write_config(data, name):
14741483
icu_ver_major = m.group(1)
14751484
if not icu_ver_major:
14761485
error('Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h)
1477-
elif int(icu_ver_major) < icu_versions["minimum_icu"]:
1478-
error('icu4c v%d.x is too old, v%d.x or later is required.' % (int(icu_ver_major),
1479-
icu_versions["minimum_icu"]))
1486+
elif int(icu_ver_major) < icu_versions['minimum_icu']:
1487+
error('icu4c v%s.x is too old, v%d.x or later is required.' %
1488+
(icu_ver_major, icu_versions['minimum_icu']))
14801489
icu_endianness = sys.byteorder[0];
14811490
o['variables']['icu_ver_major'] = icu_ver_major
14821491
o['variables']['icu_endianness'] = icu_endianness

0 commit comments

Comments
 (0)