Merge pull request #2800 from lantw44/master

Fix -L order, LDFLAGS, LD_LIBRARY_PATH issues in GNOME module
pull/2915/head
Jussi Pakkanen 7 years ago committed by GitHub
commit 933eaf6022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      mesonbuild/modules/gnome.py
  2. 18
      mesonbuild/scripts/gtkdochelper.py

@ -372,7 +372,7 @@ class GnomeModule(ExtensionModule):
continue continue
if gir_has_extra_lib_arg() and use_gir_args: if gir_has_extra_lib_arg() and use_gir_args:
fixed_ldflags = set() fixed_ldflags = OrderedSet()
for ldflag in ldflags: for ldflag in ldflags:
if ldflag.startswith("-l"): if ldflag.startswith("-l"):
fixed_ldflags.add(ldflag.replace('-l', '--extra-library=', 1)) fixed_ldflags.add(ldflag.replace('-l', '--extra-library=', 1))
@ -565,6 +565,7 @@ class GnomeModule(ExtensionModule):
ldflags += list(dep_ldflags) ldflags += list(dep_ldflags)
scan_command += ['--cflags-begin'] scan_command += ['--cflags-begin']
scan_command += cflags scan_command += cflags
scan_command += state.environment.coredata.external_args[lang]
scan_command += ['--cflags-end'] scan_command += ['--cflags-end']
# need to put our output directory first as we need to use the # need to put our output directory first as we need to use the
# generated libraries instead of any possibly installed system/prefix # generated libraries instead of any possibly installed system/prefix
@ -595,6 +596,11 @@ class GnomeModule(ExtensionModule):
d = os.path.join(state.environment.get_build_dir(), d) d = os.path.join(state.environment.get_build_dir(), d)
scan_command.append('-L' + d) scan_command.append('-L' + d)
scan_command += ['--library', libname] scan_command += ['--library', libname]
for link_arg in state.environment.coredata.external_link_args[lang]:
if link_arg.startswith('-L'):
scan_command.append(link_arg)
scankwargs = {'output': girfile, scankwargs = {'output': girfile,
'command': scan_command, 'command': scan_command,
'depends': depends} 'depends': depends}
@ -823,6 +829,8 @@ This will become a hard error in the future.''')
raise MesonException( raise MesonException(
'Gir include dirs should be include_directories().') 'Gir include dirs should be include_directories().')
cflags.update(get_include_args(inc_dirs)) cflags.update(get_include_args(inc_dirs))
cflags.update(state.environment.coredata.external_args['c'])
ldflags.update(state.environment.coredata.external_link_args['c'])
if cflags: if cflags:
args += ['--cflags=%s' % ' '.join(cflags)] args += ['--cflags=%s' % ' '.join(cflags)]
if ldflags: if ldflags:

@ -14,6 +14,7 @@
import sys, os import sys, os
import subprocess import subprocess
import shlex
import shutil import shutil
import argparse import argparse
from ..mesonlib import MesonException, Popen_safe from ..mesonlib import MesonException, Popen_safe
@ -45,10 +46,13 @@ parser.add_argument('--namespace', dest='namespace', default='')
parser.add_argument('--mode', dest='mode', default='') parser.add_argument('--mode', dest='mode', default='')
parser.add_argument('--installdir', dest='install_dir') parser.add_argument('--installdir', dest='install_dir')
def gtkdoc_run_check(cmd, cwd): def gtkdoc_run_check(cmd, cwd, library_path=None):
env = dict(os.environ)
if library_path:
env['LD_LIBRARY_PATH'] = library_path
# Put stderr into stdout since we want to print it out anyway. # Put stderr into stdout since we want to print it out anyway.
# This preserves the order of messages. # This preserves the order of messages.
p, out = Popen_safe(cmd, cwd=cwd, stderr=subprocess.STDOUT)[0:2] p, out = Popen_safe(cmd, cwd=cwd, env=env, stderr=subprocess.STDOUT)[0:2]
if p.returncode != 0: if p.returncode != 0:
err_msg = ["{!r} failed with status {:d}".format(cmd[0], p.returncode)] err_msg = ["{!r} failed with status {:d}".format(cmd[0], p.returncode)]
if out: if out:
@ -115,7 +119,15 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs,
'--ldflags=' + ldflags, '--ldflags=' + ldflags,
'--ld=' + ld] '--ld=' + ld]
gtkdoc_run_check(scanobjs_cmd, abs_out) library_paths = []
for ldflag in shlex.split(ldflags):
if ldflag.startswith('-Wl,-rpath,'):
library_paths.append(ldflag[11:])
if 'LD_LIBRARY_PATH' in os.environ:
library_paths.append(os.environ['LD_LIBRARY_PATH'])
library_path = ':'.join(library_paths)
gtkdoc_run_check(scanobjs_cmd, abs_out, library_path)
# Make docbook files # Make docbook files
if mode == 'auto': if mode == 'auto':

Loading…
Cancel
Save