munstable_coredata.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # Copyright 2019 The Meson development team
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. # Unless required by applicable law or agreed to in writing, software
  7. # distributed under the License is distributed on an "AS IS" BASIS,
  8. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing permissions and
  10. # limitations under the License.
  11. from . import coredata as cdata
  12. import os.path
  13. import pprint
  14. import textwrap
  15. def add_arguments(parser):
  16. parser.add_argument('--all', action='store_true', dest='all', default=False,
  17. help='Show data not used by current backend.')
  18. parser.add_argument('builddir', nargs='?', default='.', help='The build directory')
  19. def dump_compilers(compilers):
  20. for lang, compiler in compilers.items():
  21. print(' ' + lang + ':')
  22. print(' Id: ' + compiler.id)
  23. print(' Command: ' + ' '.join(compiler.exelist))
  24. print(' Full version: ' + compiler.full_version)
  25. print(' Detected version: ' + compiler.version)
  26. print(' Detected type: ' + repr(compiler.compiler_type))
  27. #pprint.pprint(compiler.__dict__)
  28. def dump_guids(d):
  29. for name, value in d.items():
  30. print(' ' + name + ': ' + value)
  31. def run(options):
  32. datadir = 'meson-private'
  33. if options.builddir is not None:
  34. datadir = os.path.join(options.builddir, datadir)
  35. if not os.path.isdir(datadir):
  36. print('Current directory is not a build dir. Please specify it or '
  37. 'change the working directory to it.')
  38. return 1
  39. all = options.all
  40. print('This is a dump of the internal unstable cache of meson. This is for debugging only.')
  41. print('Do NOT parse, this will change from version to version in incompatible ways')
  42. print('')
  43. coredata = cdata.load(options.builddir)
  44. backend = coredata.get_builtin_option('backend')
  45. for k, v in sorted(coredata.__dict__.items()):
  46. if k in ('backend_options', 'base_options', 'builtins', 'compiler_options', 'user_options'):
  47. # use `meson configure` to view these
  48. pass
  49. elif k in ['install_guid', 'test_guid', 'regen_guid']:
  50. if all or backend.startswith('vs'):
  51. print(k + ': ' + v)
  52. elif k == 'target_guids':
  53. if all or backend.startswith('vs'):
  54. print(k + ':')
  55. dump_guids(v)
  56. elif k in ['lang_guids']:
  57. if all or backend.startswith('vs') or backend == 'xcode':
  58. print(k + ':')
  59. dump_guids(v)
  60. elif k == 'meson_command':
  61. if all or backend.startswith('vs'):
  62. print('Meson command used in build file regeneration: ' + ' '.join(v))
  63. elif k == 'pkgconf_envvar':
  64. print('Last seen PKGCONFIG enviroment variable value: ' + v)
  65. elif k == 'version':
  66. print('Meson version: ' + v)
  67. elif k == 'cross_file':
  68. print('Cross File: ' + (v or 'None'))
  69. elif k == 'config_files':
  70. if v:
  71. print('Native File: ' + ' '.join(v))
  72. elif k == 'compilers':
  73. print('Cached native compilers:')
  74. dump_compilers(v)
  75. elif k == 'cross_compilers':
  76. print('Cached cross compilers:')
  77. dump_compilers(v)
  78. elif k == 'deps':
  79. native = []
  80. cross = []
  81. for dep_key, dep in sorted(v.items()):
  82. if dep_key[2]:
  83. cross.append((dep_key, dep))
  84. else:
  85. native.append((dep_key, dep))
  86. def print_dep(dep_key, dep):
  87. print(' ' + dep_key[0] + ": ")
  88. print(' compile args: ' + repr(dep.get_compile_args()))
  89. print(' link args: ' + repr(dep.get_link_args()))
  90. if dep.get_sources():
  91. print(' sources: ' + repr(dep.get_sources()))
  92. print(' version: ' + repr(dep.get_version()))
  93. if native:
  94. print('Cached native dependencies:')
  95. for dep_key, dep in native:
  96. print_dep(dep_key, dep)
  97. if cross:
  98. print('Cached dependencies:')
  99. for dep_key, dep in cross:
  100. print_dep(dep_key, dep)
  101. elif k == 'external_preprocess_args':
  102. for lang, opts in v.items():
  103. if opts:
  104. print('Preprocessor args for ' + lang + ': ' + ' '.join(opts))
  105. else:
  106. print(k + ':')
  107. print(textwrap.indent(pprint.pformat(v), ' '))