From: André Draszik Date: Mon, 2 Mar 2020 12:17:35 +0000 (+0000) Subject: [PATCH] build: allow use of system-installed brotli X-Git-Tag: archive/raspbian/10.21.0_dfsg-1_deb10u1+rpi1^2~14 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=26408b3490f893bc4618c3c58d21683c7ac58c9b;p=nodejs.git [PATCH] build: allow use of system-installed brotli brotli is available as a shared library since 2016, so it makes sense to allow its use as a system-installed version. Some of the infrastructure was in place already (node.gyp and node.gypi), but some bits in the configure script here were missing. Add them, keeping the default as before, to use the bundled version. Refs: https://github.com/google/brotli/pull/421 Signed-off-by: André Draszik PR-URL: https://github.com/nodejs/node/pull/32046 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau Gbp-Pq: Name system-brotli.patch --- diff --git a/configure.py b/configure.py index 22861a10e..5a786142f 100755 --- a/configure.py +++ b/configure.py @@ -289,6 +289,27 @@ shared_optgroup.add_option('--shared-zlib-libpath', dest='shared_zlib_libpath', help='a directory to search for the shared zlib DLL') +shared_optgroup.add_option('--shared-brotli', + action='store_true', + dest='shared_brotli', + help='link to a shared brotli DLL instead of static linking') + +shared_optgroup.add_option('--shared-brotli-includes', + action='store', + dest='shared_brotli_includes', + help='directory containing brotli header files') + +shared_optgroup.add_option('--shared-brotli-libname', + action='store', + dest='shared_brotli_libname', + default='brotlidec,brotlienc', + help='alternative lib name to link to [default: %default]') + +shared_optgroup.add_option('--shared-brotli-libpath', + action='store', + dest='shared_brotli_libpath', + help='a directory to search for the shared brotli DLL') + shared_optgroup.add_option('--shared-cares', action='store_true', dest='shared_libcares', @@ -621,24 +642,32 @@ def b(value): else: return 'false' +def to_utf8(s): + return s if isinstance(s, str) else s.decode("utf-8") 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') + args = [] # Print pkg-config warnings on first round. retval = () for flag in ['--libs-only-l', '--cflags-only-I', '--libs-only-L', '--modversion']: + args += [flag] + if isinstance(pkg, list): + args += pkg + else: + args += [pkg] try: - proc = subprocess.Popen( - shlex.split(pkg_config) + ['--silence-errors', flag, pkg], - stdout=subprocess.PIPE) - val = proc.communicate()[0].strip() + proc = subprocess.Popen(shlex.split(pkg_config) + args, + stdout=subprocess.PIPE) + val = to_utf8(proc.communicate()[0]).strip() except OSError as e: if e.errno != errno.ENOENT: raise e # Unexpected error. return (None, None, None, None) # No pkg-config/pkgconf installed. retval += (val,) + args = ['--silence-errors'] return retval @@ -1125,12 +1154,13 @@ def configure_node(o): else: o['variables']['node_target_type'] = 'executable' -def configure_library(lib, output): +def configure_library(lib, output, pkgname=None): shared_lib = 'shared_' + lib output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib)) if getattr(options, shared_lib): - (pkg_libs, pkg_cflags, pkg_libpath, pkg_modversion) = pkg_config(lib) + (pkg_libs, pkg_cflags, pkg_libpath, pkg_modversion) = ( + pkg_config(pkgname or lib)) if options.__dict__[shared_lib + '_includes']: output['include_dirs'] += [options.__dict__[shared_lib + '_includes']] @@ -1600,6 +1630,7 @@ configure_node(output) configure_library('zlib', output) configure_library('http_parser', output) configure_library('libuv', output) +configure_library('brotli', output, pkgname=['libbrotlidec', 'libbrotlienc']) configure_library('libcares', output) configure_library('nghttp2', output) # stay backwards compatible with shared cares builds