aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hostettler <textshell@uchuujin.de>2018-12-29 12:53:23 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2019-01-07 22:55:45 +0200
commit768fa502ac6aed64ffd3dfc6952ac56b295e6648 (patch)
tree30616f93e95980db5683b941186cfc9428a174d5
parent3232f780d8c3baba0cbca3f9fea18d1a722bf957 (diff)
downloadmeson-768fa502ac6aed64ffd3dfc6952ac56b295e6648.zip
meson-768fa502ac6aed64ffd3dfc6952ac56b295e6648.tar.gz
meson-768fa502ac6aed64ffd3dfc6952ac56b295e6648.tar.bz2
Add new meson.py unstable-coredata subcommand.
This adds a hidden option to dump the current otherwise hidden peristant state in coredata.dat. This interface is unstable as meson has no compatibility promises about coredata.dat.
-rw-r--r--mesonbuild/mesonmain.py4
-rw-r--r--mesonbuild/munstable_coredata.py126
2 files changed, 129 insertions, 1 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index c11d044..7236d1a 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -20,7 +20,7 @@ import argparse
from . import mesonlib
from . import mlog
-from . import mconf, minit, minstall, mintro, msetup, mtest, rewriter, msubprojects
+from . import mconf, minit, minstall, mintro, msetup, mtest, rewriter, msubprojects, munstable_coredata
from .mesonlib import MesonException
from .environment import detect_msys2_arch
from .wrap import wraptool
@@ -57,6 +57,8 @@ class CommandLineParser:
help=argparse.SUPPRESS)
self.add_command('runpython', self.add_runpython_arguments, self.run_runpython_command,
help=argparse.SUPPRESS)
+ self.add_command('unstable-coredata', munstable_coredata.add_arguments, munstable_coredata.run,
+ help=argparse.SUPPRESS)
def add_command(self, name, add_arguments_func, run_func, help):
# FIXME: Cannot have hidden subparser:
diff --git a/mesonbuild/munstable_coredata.py b/mesonbuild/munstable_coredata.py
new file mode 100644
index 0000000..78f3f34
--- /dev/null
+++ b/mesonbuild/munstable_coredata.py
@@ -0,0 +1,126 @@
+# Copyright 2019 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+from . import coredata as cdata
+
+import os.path
+import pprint
+import textwrap
+
+def add_arguments(parser):
+ parser.add_argument('--all', action='store_true', dest='all', default=False,
+ help='Show data not used by current backend.')
+
+ parser.add_argument('builddir', nargs='?', default='.', help='The build directory')
+
+
+def dump_compilers(compilers):
+ for lang, compiler in compilers.items():
+ print(' ' + lang + ':')
+ print(' Id: ' + compiler.id)
+ print(' Command: ' + ' '.join(compiler.exelist))
+ print(' Full version: ' + compiler.full_version)
+ print(' Detected version: ' + compiler.version)
+ print(' Detected type: ' + repr(compiler.compiler_type))
+ #pprint.pprint(compiler.__dict__)
+
+
+def dump_guids(d):
+ for name, value in d.items():
+ print(' ' + name + ': ' + value)
+
+
+def run(options):
+ datadir = 'meson-private'
+ if options.builddir is not None:
+ datadir = os.path.join(options.builddir, datadir)
+ if not os.path.isdir(datadir):
+ print('Current directory is not a build dir. Please specify it or '
+ 'change the working directory to it.')
+ return 1
+
+ all = options.all
+
+ print('This is a dump of the internal unstable cache of meson. This is for debugging only.')
+ print('Do NOT parse, this will change from version to version in incompatible ways')
+ print('')
+
+ coredata = cdata.load(options.builddir)
+ backend = coredata.get_builtin_option('backend')
+ for k, v in sorted(coredata.__dict__.items()):
+ if k in ('backend_options', 'base_options', 'builtins', 'compiler_options', 'user_options'):
+ # use `meson configure` to view these
+ pass
+ elif k in ['install_guid', 'test_guid', 'regen_guid']:
+ if all or backend.startswith('vs'):
+ print(k + ': ' + v)
+ elif k == 'target_guids':
+ if all or backend.startswith('vs'):
+ print(k + ':')
+ dump_guids(v)
+ elif k in ['lang_guids']:
+ if all or backend.startswith('vs') or backend == 'xcode':
+ print(k + ':')
+ dump_guids(v)
+ elif k == 'meson_command':
+ if all or backend.startswith('vs'):
+ print('Meson command used in build file regeneration: ' + ' '.join(v))
+ elif k == 'pkgconf_envvar':
+ print('Last seen PKGCONFIG enviroment variable value: ' + v)
+ elif k == 'version':
+ print('Meson version: ' + v)
+ elif k == 'cross_file':
+ print('Cross File: ' + (v or 'None'))
+ elif k == 'config_files':
+ if v:
+ print('Native File: ' + ' '.join(v))
+ elif k == 'compilers':
+ print('Cached native compilers:')
+ dump_compilers(v)
+ elif k == 'cross_compilers':
+ print('Cached cross compilers:')
+ dump_compilers(v)
+ elif k == 'deps':
+ native = []
+ cross = []
+ for dep_key, dep in sorted(v.items()):
+ if dep_key[2]:
+ cross.append((dep_key, dep))
+ else:
+ native.append((dep_key, dep))
+
+ def print_dep(dep_key, dep):
+ print(' ' + dep_key[0] + ": ")
+ print(' compile args: ' + repr(dep.get_compile_args()))
+ print(' link args: ' + repr(dep.get_link_args()))
+ if dep.get_sources():
+ print(' sources: ' + repr(dep.get_sources()))
+ print(' version: ' + repr(dep.get_version()))
+
+ if native:
+ print('Cached native dependencies:')
+ for dep_key, dep in native:
+ print_dep(dep_key, dep)
+ if cross:
+ print('Cached dependencies:')
+ for dep_key, dep in cross:
+ print_dep(dep_key, dep)
+ elif k == 'external_preprocess_args':
+ for lang, opts in v.items():
+ if opts:
+ print('Preprocessor args for ' + lang + ': ' + ' '.join(opts))
+ else:
+ print(k + ':')
+ print(textwrap.indent(pprint.pformat(v), ' '))