interpreter: Add always set default value for version and set it ASAP

Ideally we wouldn't need to have the default dict here and could just
rely on it being set as soon as project is called. There is a corner
case exercised by test case common/35 run program, which is that if a
FeatureNew or FeatureDeprecated is called to generate the meson version
it will be unset, to work around this I've changed the type from a dict
to a default dict with '' as the default value.

A better fix would probably be to store all of the
FeatureNew/FeatureDeprecated checks until the end, then evaluate them,
but for now this results in no loss of functionality, only more
functionality, even if it isn't prefect.
pull/7123/head
Dylan Baker 5 years ago
parent d51551231f
commit e35584e9ff
  1. 7
      mesonbuild/interpreter.py
  2. 4
      mesonbuild/mesonlib.py

@ -2985,11 +2985,14 @@ external dependencies (including libraries) must go to "dependencies".''')
if ':' in proj_name:
raise InvalidArguments("Project name {!r} must not contain ':'".format(proj_name))
# This needs to be evaluated as early as possible, as meson uses this
# for things like deprecation testing.
if 'meson_version' in kwargs:
cv = coredata.version
pv = kwargs['meson_version']
if not mesonlib.version_compare(cv, pv):
raise InterpreterException('Meson version is %s but project requires %s' % (cv, pv))
mesonlib.project_meson_versions[self.subproject] = kwargs['meson_version']
if os.path.exists(self.option_file):
oi = optinterpreter.OptionInterpreter(self.subproject)
@ -3036,10 +3039,6 @@ external dependencies (including libraries) must go to "dependencies".''')
self.build.subproject_dir = self.subproject_dir
mesonlib.project_meson_versions[self.subproject] = ''
if 'meson_version' in kwargs:
mesonlib.project_meson_versions[self.subproject] = kwargs['meson_version']
self.build.projects[self.subproject] = proj_name
mlog.log('Project name:', mlog.bold(proj_name))
mlog.log('Project version:', mlog.bold(self.project_version))

@ -39,8 +39,10 @@ _U = T.TypeVar('_U')
have_fcntl = False
have_msvcrt = False
# TODO: this is such a hack, this really should be either in coredata or in the
# interpreter
# {subproject: project_meson_version}
project_meson_versions = {} # type: T.Dict[str, str]
project_meson_versions = collections.defaultdict(str) # type: T.DefaultDict[str, str]
try:
import fcntl

Loading…
Cancel
Save