Permalink
Browse files

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

  • Loading branch information...
jpakkane committed Oct 16, 2016
1 parent 43a8ef7 commit 6762d30c6a9b5da6a90f7c1eadc06d449dbd9a33
Showing with 39 additions and 5 deletions.
  1. +3 −0 mesonbuild/build.py
  2. +22 −5 mesonbuild/mintro.py
  3. +14 −0 run_unittests.py
@@ -1267,6 +1267,9 @@ def get_subdir(self):
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 @@
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 @@
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,18 +187,21 @@ 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:
coredata = pickle.load(f)
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 @@ def setUp(self):
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 @@ def get_compdb(self):
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 @@ def test_static_compile_order(self):
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()

0 comments on commit 6762d30

Please sign in to comment.