Changed introspection target format

pull/4731/head
Daniel Mensinger 6 years ago
parent 3bf2ca483e
commit a1d8c1d3e9
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 19
      mesonbuild/mintro.py
  2. 28
      run_unittests.py

@ -117,6 +117,7 @@ def list_installed(installdata):
def list_targets(builddata: build.Build, installdata, backend: backends.Backend): def list_targets(builddata: build.Build, installdata, backend: backends.Backend):
tlist = [] tlist = []
build_dir = builddata.environment.get_build_dir()
# Fast lookup table for installation files # Fast lookup table for installation files
install_lookuptable = {} install_lookuptable = {}
@ -128,24 +129,18 @@ def list_targets(builddata: build.Build, installdata, backend: backends.Backend)
if not isinstance(target, build.Target): if not isinstance(target, build.Target):
raise RuntimeError('The target object in `builddata.get_targets()` is not of type `build.Target`. Please file a bug with this error message.') raise RuntimeError('The target object in `builddata.get_targets()` is not of type `build.Target`. Please file a bug with this error message.')
# TODO Change this to the full list in a seperate PR
fname = [os.path.join(target.subdir, x) for x in target.get_outputs()]
if len(fname) == 1:
fname = fname[0]
t = { t = {
'name': target.get_basename(), 'name': target.get_basename(),
'id': idname, 'id': idname,
'type': target.get_typename(), 'type': target.get_typename(),
'filename': fname, 'filename': [os.path.join(build_dir, target.subdir, x) for x in target.get_outputs()],
'build_by_default': target.build_by_default, 'build_by_default': target.build_by_default,
'target_sources': backend.get_introspection_data(idname, target) 'target_sources': backend.get_introspection_data(idname, target)
} }
if installdata and target.should_install(): if installdata and target.should_install():
t['installed'] = True t['installed'] = True
# TODO Change this to the full list in a seperate PR t['install_filename'] = [install_lookuptable.get(x, None) for x in target.get_outputs()]
t['install_filename'] = [install_lookuptable.get(x, None) for x in target.get_outputs()][0]
else: else:
t['installed'] = False t['installed'] = False
tlist.append(t) tlist.append(t)
@ -298,7 +293,7 @@ def list_buildoptions_from_source(sourcedir, backend, indent):
mlog.enable() mlog.enable()
print(json.dumps(list_buildoptions(intr.coredata), indent=indent)) print(json.dumps(list_buildoptions(intr.coredata), indent=indent))
def list_target_files(target_name, targets, builddata: build.Build): def list_target_files(target_name, targets):
result = [] result = []
tgt = None tgt = None
@ -314,9 +309,6 @@ def list_target_files(target_name, targets, builddata: build.Build):
for i in tgt['target_sources']: for i in tgt['target_sources']:
result += i['sources'] + i['generated_sources'] result += i['sources'] + i['generated_sources']
# TODO Remove this line in a future PR with other breaking changes
result = list(map(lambda x: os.path.relpath(x, builddata.environment.get_source_dir()), result))
return result return result
def list_buildoptions(coredata: cdata.CoreData): def list_buildoptions(coredata: cdata.CoreData):
@ -531,8 +523,7 @@ def run(options):
targets_file = os.path.join(infodir, 'intro-targets.json') targets_file = os.path.join(infodir, 'intro-targets.json')
with open(targets_file, 'r') as fp: with open(targets_file, 'r') as fp:
targets = json.load(fp) targets = json.load(fp)
builddata = build.load(options.builddir) # TODO remove this in a breaking changes PR results += [('target_files', list_target_files(options.target_files, targets))]
results += [('target_files', list_target_files(options.target_files, targets, builddata))]
# Extract introspection information from JSON # Extract introspection information from JSON
for i in toextract: for i in toextract:

@ -1439,7 +1439,7 @@ class AllPlatformTests(BasePlatformTests):
# Get name of static library # Get name of static library
targets = self.introspect('--targets') targets = self.introspect('--targets')
self.assertEqual(len(targets), 1) self.assertEqual(len(targets), 1)
libname = targets[0]['filename'] # TODO Change filename back to a list again libname = targets[0]['filename'][0]
# Build and get contents of static library # Build and get contents of static library
self.build() self.build()
before = self._run(['ar', 't', os.path.join(self.builddir, libname)]).split() before = self._run(['ar', 't', os.path.join(self.builddir, libname)]).split()
@ -1496,8 +1496,8 @@ class AllPlatformTests(BasePlatformTests):
intro = self.introspect('--targets') intro = self.introspect('--targets')
if intro[0]['type'] == 'executable': if intro[0]['type'] == 'executable':
intro = intro[::-1] intro = intro[::-1]
self.assertPathListEqual([intro[0]['install_filename']], ['/usr/lib/libstat.a']) self.assertPathListEqual(intro[0]['install_filename'], ['/usr/lib/libstat.a'])
self.assertPathListEqual([intro[1]['install_filename']], ['/usr/bin/prog' + exe_suffix]) self.assertPathListEqual(intro[1]['install_filename'], ['/usr/bin/prog' + exe_suffix])
def test_install_introspection_multiple_outputs(self): def test_install_introspection_multiple_outputs(self):
''' '''
@ -1514,14 +1514,10 @@ class AllPlatformTests(BasePlatformTests):
intro = self.introspect('--targets') intro = self.introspect('--targets')
if intro[0]['type'] == 'executable': if intro[0]['type'] == 'executable':
intro = intro[::-1] intro = intro[::-1]
#self.assertPathListEqual(intro[0]['install_filename'], ['/usr/include/diff.h', '/usr/bin/diff.sh']) self.assertPathListEqual(intro[0]['install_filename'], ['/usr/include/diff.h', '/usr/bin/diff.sh'])
#self.assertPathListEqual(intro[1]['install_filename'], ['/opt/same.h', '/opt/same.sh']) self.assertPathListEqual(intro[1]['install_filename'], ['/opt/same.h', '/opt/same.sh'])
#self.assertPathListEqual(intro[2]['install_filename'], ['/usr/include/first.h', None]) self.assertPathListEqual(intro[2]['install_filename'], ['/usr/include/first.h', None])
#self.assertPathListEqual(intro[3]['install_filename'], [None, '/usr/bin/second.sh']) self.assertPathListEqual(intro[3]['install_filename'], [None, '/usr/bin/second.sh'])
self.assertPathListEqual([intro[0]['install_filename']], ['/usr/include/diff.h'])
self.assertPathListEqual([intro[1]['install_filename']], ['/opt/same.h'])
self.assertPathListEqual([intro[2]['install_filename']], ['/usr/include/first.h'])
self.assertPathListEqual([intro[3]['install_filename']], [None])
def test_uninstall(self): def test_uninstall(self):
exename = os.path.join(self.installdir, 'usr/bin/prog' + exe_suffix) exename = os.path.join(self.installdir, 'usr/bin/prog' + exe_suffix)
@ -2569,7 +2565,7 @@ int main(int argc, char **argv) {
for t in t_intro: for t in t_intro:
id = t['id'] id = t['id']
tf_intro = self.introspect(['--target-files', id]) tf_intro = self.introspect(['--target-files', id])
#tf_intro = list(map(lambda x: os.path.relpath(x, testdir), tf_intro)) TODO make paths absolute in future PR tf_intro = list(map(lambda x: os.path.relpath(x, testdir), tf_intro))
self.assertEqual(tf_intro, expected[id]) self.assertEqual(tf_intro, expected[id])
self.wipe() self.wipe()
@ -2584,9 +2580,7 @@ int main(int argc, char **argv) {
for t in t_intro: for t in t_intro:
id = t['id'] id = t['id']
tf_intro = self.introspect(['--target-files', id]) tf_intro = self.introspect(['--target-files', id])
print(tf_intro) tf_intro = list(map(lambda x: os.path.relpath(x, testdir), tf_intro))
#tf_intro = list(map(lambda x: os.path.relpath(x, testdir), tf_intro)) TODO make paths absolute in future PR
print(tf_intro)
self.assertEqual(tf_intro, expected[id]) self.assertEqual(tf_intro, expected[id])
self.wipe() self.wipe()
@ -3180,7 +3174,7 @@ recommended as it is not supported on some platforms''')
('name', str), ('name', str),
('id', str), ('id', str),
('type', str), ('type', str),
('filename', str), ('filename', list),
('build_by_default', bool), ('build_by_default', bool),
('target_sources', list), ('target_sources', list),
('installed', bool), ('installed', bool),
@ -4417,7 +4411,7 @@ class LinuxlikeTests(BasePlatformTests):
break break
self.assertIsInstance(docbook_target, dict) self.assertIsInstance(docbook_target, dict)
ifile = self.introspect(['--target-files', 'generated-gdbus-docbook@cus'])[0] ifile = self.introspect(['--target-files', 'generated-gdbus-docbook@cus'])[0]
self.assertListEqual([t['filename']], ['gdbus/generated-gdbus-doc-' + os.path.basename(ifile)]) self.assertListEqual(t['filename'], [os.path.join(self.builddir ,'gdbus/generated-gdbus-doc-' + os.path.basename(ifile))])
def test_build_rpath(self): def test_build_rpath(self):
if is_cygwin(): if is_cygwin():

Loading…
Cancel
Save