Code cleanup and renamed variables

pull/4547/head
Daniel Mensinger 6 years ago
parent 248adbab9a
commit bd8bad46c3
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 4
      docs/markdown/IDE-integration.md
  2. 2
      docs/markdown/snippets/introspect_multiple.md
  3. 5
      mesonbuild/backend/ninjabackend.py
  4. 8
      mesonbuild/mintro.py
  5. 4
      run_unittests.py

@ -40,7 +40,7 @@ The most important file for an IDE is probably `intro-targets.json`. Here each t
"type": "<TYPE>",
"filename": ["list", "of", "generated", "files"],
"build_by_default": true / false,
"sources": [],
"target_sources": [],
"installed": true / false,
}
```
@ -51,7 +51,7 @@ A target usually generates only one file. However, it is possible for custom tar
### Target sources
The `intro-sources.json` file stores a list of all source objects of the target. With this information, an IDE can provide code completion for all source files.
The `intro-targets.json` file also stores a list of all source objects of the target in the `target_sources`. With this information, an IDE can provide code completion for all source files.
```json
{

@ -7,7 +7,7 @@ object.
The format for a single command was not changed to keep backward
compatibility.
Furthermore the option `-a,--all`, `-i,--indent` and `-f,--force-dict-output`
Furthermore the option `-a,--all`, `-i,--indent` and `-f,--force-object-output`
were added to print all introspection information in one go, format the
JSON output (the default is still compact JSON) and force use the new
output format, even if only one introspection command was given.

@ -343,7 +343,7 @@ int dummy;
lang = comp.get_language()
tgt = self.introspection_data[id]
# Find an existing entry or create a new one
id_hash = (lang, CompilerArgs)
id_hash = (lang, parameters)
src_block = tgt.get(id_hash, None)
if src_block is None:
# Convert parameters
@ -351,7 +351,7 @@ int dummy;
parameters = parameters.to_native(copy=True)
parameters = comp.compute_parameters_with_absolute_paths(parameters, self.build_dir)
if target.is_cross:
parameters += comp.get_cross_extra_flags(self.environment, False)
parameters.insert(0, comp.get_cross_extra_flags(self.environment, False))
# The new entry
src_block = {
'language': lang,
@ -360,7 +360,6 @@ int dummy;
'sources': [],
'generated_sources': [],
}
self._intro_last_index = len(tgt)
tgt[id_hash] = src_block
# Make source files absolute
sources = [x.absolute_path(self.source_dir, self.build_dir) if isinstance(x, File) else os.path.normpath(os.path.join(self.build_dir, x))

@ -35,8 +35,6 @@ from .compilers import compilers
import sys, os
import pathlib
INTROSPECTION_OUTPUT_FILE = 'meson-introspection.json'
def add_arguments(parser):
parser.add_argument('--targets', action='store_true', dest='list_targets', default=False,
help='List top level targets.')
@ -62,7 +60,7 @@ def add_arguments(parser):
help='Print all available information.')
parser.add_argument('-i', '--indent', dest='indent', type=int, default=0,
help='Number of spaces used for indentation.')
parser.add_argument('-f', '--force-dict-output', action='store_true', dest='force_dict', default=False,
parser.add_argument('-f', '--force-object-output', action='store_true', dest='force_dict', default=False,
help='Always use the new JSON format for multiple entries (even for 0 and 1 introspection commands)')
parser.add_argument('builddir', nargs='?', default='.', help='The build directory')
@ -104,7 +102,7 @@ def list_targets(builddata: build.Build, installdata, backend: backends.Backend)
'type': target.get_typename(),
'filename': fname,
'build_by_default': target.build_by_default,
'sources': backend.get_introspection_data(idname, target)
'target_sources': backend.get_introspection_data(idname, target)
}
if installdata and target.should_install():
@ -276,7 +274,7 @@ def list_target_files(target_name, targets, builddata: build.Build):
print('Target with the ID "{}" could not be found'.format(target_name))
sys.exit(1)
for i in tgt['sources']:
for i in tgt['target_sources']:
result += i['sources'] + i['generated_sources']
# TODO Remove this line in a future PR with other breaking changes

@ -3182,7 +3182,7 @@ recommended as it is not supported on some platforms''')
('type', str),
('filename', str),
('build_by_default', bool),
('sources', list),
('target_sources', list),
('installed', bool),
]
@ -3260,7 +3260,7 @@ recommended as it is not supported on some platforms''')
self.assertEqual(i['build_by_default'], tgt[1])
self.assertEqual(i['installed'], tgt[2])
targets_to_find.pop(i['name'], None)
for j in i['sources']:
for j in i['target_sources']:
assertKeyTypes(targets_sources_typelist, j)
self.assertDictEqual(targets_to_find, {})

Loading…
Cancel
Save