Skip to content

Commit

Permalink
build: check minimum ICU in configure for system-icu
Browse files Browse the repository at this point in the history
- check the version number coming out of pkg-config

PR-URL: #24255
Fixes: #24253
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
srl295 authored and codebytere committed Jan 12, 2019
1 parent 016ac8b commit c0f0d19
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
dest='with_icu_source',
help='Intl mode: optional local path to icu/ dir, or path/URL of '
'the icu4c source archive. '
'v%d.x or later recommended.' % icu_versions["minimum_icu"])
'v%d.x or later recommended.' % icu_versions['minimum_icu'])

parser.add_option('--with-ltcg',
action='store_true',
Expand Down Expand Up @@ -621,17 +621,21 @@ def b(value):


def pkg_config(pkg):
"""Run pkg-config on the specified package
Returns ("-l flags", "-I flags", "-L flags", "version")
otherwise (None, None, None, None)"""
pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config')
retval = ()
for flag in ['--libs-only-l', '--cflags-only-I', '--libs-only-L']:
for flag in ['--libs-only-l', '--cflags-only-I',
'--libs-only-L', '--modversion']:
try:
proc = subprocess.Popen(
shlex.split(pkg_config) + ['--silence-errors', flag, pkg],
stdout=subprocess.PIPE)
val = proc.communicate()[0].strip()
except OSError as e:
if e.errno != errno.ENOENT: raise e # Unexpected error.
return (None, None, None) # No pkg-config/pkgconf installed.
return (None, None, None, None) # No pkg-config/pkgconf installed.
retval += (val,)
return retval

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

if getattr(options, shared_lib):
(pkg_libs, pkg_cflags, pkg_libpath) = pkg_config(lib)
(pkg_libs, pkg_cflags, pkg_libpath, pkg_modversion) = pkg_config(lib)

if options.__dict__[shared_lib + '_includes']:
output['include_dirs'] += [options.__dict__[shared_lib + '_includes']]
Expand Down Expand Up @@ -1356,7 +1360,12 @@ def write_config(data, name):
if pkgicu[0] is None:
error('''Could not load pkg-config data for "icu-i18n".
See above errors or the README.md.''')
(libs, cflags, libpath) = pkgicu
(libs, cflags, libpath, icuversion) = pkgicu
icu_ver_major = icuversion.split('.')[0]
o['variables']['icu_ver_major'] = icu_ver_major
if int(icu_ver_major) < icu_versions['minimum_icu']:
error('icu4c v%s is too old, v%d.x or later is required.' %
(icuversion, icu_versions['minimum_icu']))
# libpath provides linker path which may contain spaces
if libpath:
o['libraries'] += [libpath]
Expand Down Expand Up @@ -1474,9 +1483,9 @@ def write_config(data, name):
icu_ver_major = m.group(1)
if not icu_ver_major:
error('Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h)
elif int(icu_ver_major) < icu_versions["minimum_icu"]:
error('icu4c v%d.x is too old, v%d.x or later is required.' % (int(icu_ver_major),
icu_versions["minimum_icu"]))
elif int(icu_ver_major) < icu_versions['minimum_icu']:
error('icu4c v%s.x is too old, v%d.x or later is required.' %
(icu_ver_major, icu_versions['minimum_icu']))
icu_endianness = sys.byteorder[0];
o['variables']['icu_ver_major'] = icu_ver_major
o['variables']['icu_endianness'] = icu_endianness
Expand Down

0 comments on commit c0f0d19

Please sign in to comment.