Skip to content

Commit 4dc1e78

Browse files
srl295rvagg
authored andcommittedNov 28, 2018
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 7e2a284 commit 4dc1e78

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
@@ -434,7 +434,7 @@
434434
dest='with_icu_source',
435435
help='Intl mode: optional local path to icu/ dir, or path/URL of '
436436
'the icu4c source archive. '
437-
'v%d.x or later recommended.' % icu_versions["minimum_icu"])
437+
'v%d.x or later recommended.' % icu_versions['minimum_icu'])
438438

439439
parser.add_option('--with-ltcg',
440440
action='store_true',
@@ -622,17 +622,21 @@ def b(value):
622622

623623

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

@@ -1119,7 +1123,7 @@ def configure_library(lib, output):
11191123
output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib))
11201124

11211125
if getattr(options, shared_lib):
1122-
(pkg_libs, pkg_cflags, pkg_libpath) = pkg_config(lib)
1126+
(pkg_libs, pkg_cflags, pkg_libpath, pkg_modversion) = pkg_config(lib)
11231127

11241128
if options.__dict__[shared_lib + '_includes']:
11251129
output['include_dirs'] += [options.__dict__[shared_lib + '_includes']]
@@ -1354,7 +1358,12 @@ def write_config(data, name):
13541358
if pkgicu[0] is None:
13551359
error('''Could not load pkg-config data for "icu-i18n".
13561360
See above errors or the README.md.''')
1357-
(libs, cflags, libpath) = pkgicu
1361+
(libs, cflags, libpath, icuversion) = pkgicu
1362+
icu_ver_major = icuversion.split('.')[0]
1363+
o['variables']['icu_ver_major'] = icu_ver_major
1364+
if int(icu_ver_major) < icu_versions['minimum_icu']:
1365+
error('icu4c v%s is too old, v%d.x or later is required.' %
1366+
(icuversion, icu_versions['minimum_icu']))
13581367
# libpath provides linker path which may contain spaces
13591368
if libpath:
13601369
o['libraries'] += [libpath]
@@ -1473,9 +1482,9 @@ def write_config(data, name):
14731482
icu_ver_major = m.group(1)
14741483
if not icu_ver_major:
14751484
error('Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h)
1476-
elif int(icu_ver_major) < icu_versions["minimum_icu"]:
1477-
error('icu4c v%d.x is too old, v%d.x or later is required.' % (int(icu_ver_major),
1478-
icu_versions["minimum_icu"]))
1485+
elif int(icu_ver_major) < icu_versions['minimum_icu']:
1486+
error('icu4c v%s.x is too old, v%d.x or later is required.' %
1487+
(icu_ver_major, icu_versions['minimum_icu']))
14791488
icu_endianness = sys.byteorder[0];
14801489
o['variables']['icu_ver_major'] = icu_ver_major
14811490
o['variables']['icu_endianness'] = icu_endianness

0 commit comments

Comments
 (0)
Please sign in to comment.