Skip to content

Commit

Permalink
mintro: Added defined_in key in the targets introspection
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda authored and jpakkane committed Jan 15, 2019
1 parent fff88b3 commit 609ecba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/markdown/IDE-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ for one target is defined as follows:
"name": "Name of the target",
"id": "The internal ID meson uses",
"type": "<TYPE>",
"defined_in": "/Path/to/the/targets/meson.build",
"filename": ["list", "of", "generated", "files"],
"build_by_default": true / false,
"target_sources": [],
Expand Down
1 change: 1 addition & 0 deletions docs/markdown/snippets/introspect_multiple.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ configuration of the build directory.
Additionlly the format of `meson introspect target` was changed:

- New: the `sources` key. It stores the source files of a target and their compiler parameters.
- New: the `defined_in` key. It stores the meson file where a target is defined
- Added new target types (`jar`, `shared module`).
2 changes: 2 additions & 0 deletions mesonbuild/mintro.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def list_installed(installdata):
def list_targets(builddata: build.Build, installdata, backend: backends.Backend):
tlist = []
build_dir = builddata.environment.get_build_dir()
src_dir = builddata.environment.get_source_dir()

# Fast lookup table for installation files
install_lookuptable = {}
Expand All @@ -136,6 +137,7 @@ def list_targets(builddata: build.Build, installdata, backend: backends.Backend)
'name': target.get_basename(),
'id': idname,
'type': target.get_typename(),
'defined_in': os.path.normpath(os.path.join(src_dir, target.subdir, 'meson.build')),
'filename': [os.path.join(build_dir, target.subdir, x) for x in target.get_outputs()],
'build_by_default': target.build_by_default,
'target_sources': backend.get_introspection_data(idname, target)
Expand Down
12 changes: 7 additions & 5 deletions run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3172,6 +3172,7 @@ def assertKeyTypes(key_type_list, obj):
('name', str),
('id', str),
('type', str),
('defined_in', str),
('filename', list),
('build_by_default', bool),
('target_sources', list),
Expand Down Expand Up @@ -3240,11 +3241,11 @@ def assertKeyTypes(key_type_list, obj):

# Check targets
targets_to_find = {
'sharedTestLib': ('shared library', True, False),
'staticTestLib': ('static library', True, False),
'test1': ('executable', True, True),
'test2': ('executable', True, False),
'test3': ('executable', True, False),
'sharedTestLib': ('shared library', True, False, 'sharedlib/meson.build'),
'staticTestLib': ('static library', True, False, 'staticlib/meson.build'),
'test1': ('executable', True, True, 'meson.build'),
'test2': ('executable', True, False, 'meson.build'),
'test3': ('executable', True, False, 'meson.build'),
}
for i in res['targets']:
assertKeyTypes(targets_typelist, i)
Expand All @@ -3253,6 +3254,7 @@ def assertKeyTypes(key_type_list, obj):
self.assertEqual(i['type'], tgt[0])
self.assertEqual(i['build_by_default'], tgt[1])
self.assertEqual(i['installed'], tgt[2])
self.assertPathEqual(i['defined_in'], os.path.join(testdir, tgt[3]))
targets_to_find.pop(i['name'], None)
for j in i['target_sources']:
assertKeyTypes(targets_sources_typelist, j)
Expand Down

0 comments on commit 609ecba

Please sign in to comment.