Exposes the install names of targets in introspection. Closes #829.

pull/972/head
Jussi Pakkanen 9 years ago
parent 43a8ef72fc
commit 6762d30c6a
  1. 3
      mesonbuild/build.py
  2. 27
      mesonbuild/mintro.py
  3. 14
      run_unittests.py

@ -1267,6 +1267,9 @@ class CustomTarget:
def get_outputs(self):
return self.output
def get_filename(self):
return self.output[0]
def get_sources(self):
return self.sources

@ -20,7 +20,7 @@ Currently only works for the Ninja backend. Others use generated
project files and don't need this info."""
import json, pickle
from . import coredata, build, mesonlib
from . import coredata, build
import argparse
import sys, os
@ -41,7 +41,20 @@ parser.add_argument('--dependencies', action='store_true', dest='dependencies',
help='list external dependencies.')
parser.add_argument('args', nargs='+')
def list_targets(coredata, builddata):
def determine_installed_path(target, installdata):
install_target = None
for i in installdata.targets:
if os.path.split(i[0])[1] == target.get_filename(): # FIXME, might clash due to subprojects.
install_target = i
break
if install_target is None:
raise RuntimeError('Something weird happened. File a bug.')
fname = i[0]
outdir = i[1]
outname = os.path.join(installdata.prefix, outdir, os.path.split(fname)[-1])
return outname
def list_targets(coredata, builddata, installdata):
tlist = []
for (idname, target) in builddata.get_targets().items():
t = {}
@ -68,6 +81,7 @@ def list_targets(coredata, builddata):
t['type'] = typename
if target.should_install():
t['installed'] = True
t['install_filename'] = determine_installed_path(target, installdata)
else:
t['installed'] = False
tlist.append(t)
@ -173,6 +187,7 @@ def run(args):
bdir = ''
corefile = os.path.join(bdir, 'meson-private/coredata.dat')
buildfile = os.path.join(bdir, 'meson-private/build.dat')
installfile = os.path.join(bdir, 'meson-private/install.dat')
testfile = os.path.join(bdir, 'meson-private/meson_test_setup.dat')
benchmarkfile = os.path.join(bdir, 'meson-private/meson_benchmark_setup.dat')
with open(corefile, 'rb') as f:
@ -180,11 +195,13 @@ def run(args):
with open(buildfile, 'rb') as f:
builddata = pickle.load(f)
with open(testfile, 'rb') as f:
testdata = pickle.load(f)
testdata = pickle.load(f)
with open(benchmarkfile, 'rb') as f:
benchmarkdata = pickle.load(f)
benchmarkdata = pickle.load(f)
with open(installfile, 'rb') as f:
installdata = pickle.load(f)
if options.list_targets:
list_targets(coredata, builddata)
list_targets(coredata, builddata, installdata)
elif options.target_files is not None:
list_target_files(options.target_files, coredata, builddata)
elif options.buildsystem_files:

@ -43,6 +43,7 @@ class LinuxlikeTests(unittest.TestCase):
self.builddir = tempfile.mkdtemp()
self.meson_command = [sys.executable, os.path.join(src_root, 'meson.py')]
self.mconf_command = [sys.executable, os.path.join(src_root, 'mesonconf.py')]
self.mintro_command = [sys.executable, os.path.join(src_root, 'mesonintrospect.py')]
self.ninja_command = [detect_ninja(), '-C', self.builddir]
self.common_test_dir = os.path.join(src_root, 'test cases/common')
self.vala_test_dir = os.path.join(src_root, 'test cases/vala')
@ -67,6 +68,10 @@ class LinuxlikeTests(unittest.TestCase):
with open(os.path.join(self.builddir, 'compile_commands.json')) as ifile:
return json.load(ifile)
def introspect(self, arg):
out = subprocess.check_output(self.mintro_command + [arg, self.builddir])
return json.loads(out.decode('utf-8'))
def test_basic_soname(self):
testdir = os.path.join(self.common_test_dir, '4 shared')
self.init(testdir)
@ -147,5 +152,14 @@ class LinuxlikeTests(unittest.TestCase):
self.assertTrue(compdb[3]['file'].endswith("libfile4.c"))
# FIXME: We don't have access to the linker command
def test_install_introspection(self):
testdir = os.path.join(self.common_test_dir, '8 install')
self.init(testdir)
intro = self.introspect('--targets')
if intro[0]['type'] == 'executable':
intro = intro[::-1]
self.assertEqual(intro[0]['install_filename'], '/usr/local/libtest/libstat.a')
self.assertEqual(intro[1]['install_filename'], '/usr/local/bin/prog')
if __name__ == '__main__':
unittest.main()

Loading…
Cancel
Save