Skip to content

Commit c207e8d

Browse files
committed
build: fix pkg-config output parsing in configure
Fix parsing of `pkg-config --cflags-only-I`. The configure_library() step sometimes appended a list in a list instead of list of strings to include_dirs. This commit removes the default handling for includes and libpath options. They don't have defaults at the moment and I don't see that changing anytime soon. Fixing the code is more work and because it's dead code anyway, I opted to remove it instead. Fixes: #1985 PR-URL: #1986 Reviewed-By: Johan Bergström <[email protected]>
1 parent 3806d87 commit c207e8d

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

configure

+14-25
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,6 @@ def pkg_config(pkg):
366366
return retval
367367

368368

369-
def format_libraries(list):
370-
"""Returns string of space separated libraries"""
371-
libraries = list.split(',')
372-
return ' '.join('-l{0}'.format(i) for i in libraries)
373-
374-
375369
def try_check_compiler(cc, lang):
376370
try:
377371
proc = subprocess.Popen(shlex.split(cc) + ['-E', '-P', '-x', lang, '-'],
@@ -689,29 +683,24 @@ def configure_library(lib, output):
689683
output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib))
690684

691685
if getattr(options, shared_lib):
692-
default_cflags = getattr(options, shared_lib + '_includes')
693-
default_lib = format_libraries(getattr(options, shared_lib + '_libname'))
694-
default_libpath = getattr(options, shared_lib + '_libpath')
695-
if default_libpath:
696-
default_libpath = '-L' + default_libpath
697686
(pkg_libs, pkg_cflags, pkg_libpath) = pkg_config(lib)
698-
# Remove empty strings from the list of include_dirs
687+
699688
if pkg_cflags:
700-
cflags = filter(None, map(str.strip, pkg_cflags.split('-I')))
701-
else:
702-
cflags = default_cflags
703-
libs = pkg_libs if pkg_libs else default_lib
704-
libpath = pkg_libpath if pkg_libpath else default_libpath
689+
output['include_dirs'] += (
690+
filter(None, map(str.strip, pkg_cflags.split('-I'))))
705691

706692
# libpath needs to be provided ahead libraries
707-
if libpath:
708-
output['libraries'] += [libpath]
709-
if libs:
710-
# libs passed to the linker cannot contain spaces.
711-
# (libpath on the other hand can)
712-
output['libraries'] += libs.split()
713-
if cflags:
714-
output['include_dirs'] += [cflags]
693+
if pkg_libpath:
694+
output['libraries'] += (
695+
filter(None, map(str.strip, pkg_cflags.split('-L'))))
696+
697+
default_libs = getattr(options, shared_lib + '_libname')
698+
default_libs = map('-l{0}'.format, default_libs.split(','))
699+
700+
if pkg_libs:
701+
output['libraries'] += pkg_libs.split()
702+
elif default_libs:
703+
output['libraries'] += default_libs
715704

716705

717706
def configure_v8(o):

0 commit comments

Comments
 (0)