machine-files: deprecate the paths section

pull/6597/head
Dylan Baker 4 years ago
parent e981798e0b
commit 601789cc7c
  1. 4
      docs/markdown/Machine-files.md
  2. 5
      mesonbuild/coredata.py
  3. 40
      mesonbuild/envconfig.py
  4. 26
      mesonbuild/environment.py
  5. 34
      run_unittests.py

@ -172,8 +172,10 @@ An incomplete list of internally used programs that can be overridden here is:
### Paths and Directories
*Deprecated in 0.55.0* use the built-in section instead.
As of 0.50.0 paths and directories such as libdir can be defined in the native
and cross files in a paths section. These should be strings
and cross files in a paths section. These should be strings.
```ini
[paths]

@ -778,11 +778,6 @@ class CoreData:
k = '{}:{}'.format(subproject, k)
cmd_line_options[k] = v
# Override project default_options using conf files (cross or native)
for k, v in env.paths.host:
if v is not None:
cmd_line_options[k] = v
from .compilers import all_languages
# Report that [properties]c_args
for lang in all_languages:

@ -407,43 +407,3 @@ class BinaryTable:
if command is not None and (len(command) == 0 or len(command[0].strip()) == 0):
command = None
return command
class Directories:
"""Data class that holds information about directories for native and cross
builds.
"""
def __init__(self, bindir: T.Optional[str] = None, datadir: T.Optional[str] = None,
includedir: T.Optional[str] = None, infodir: T.Optional[str] = None,
libdir: T.Optional[str] = None, libexecdir: T.Optional[str] = None,
localedir: T.Optional[str] = None, localstatedir: T.Optional[str] = None,
mandir: T.Optional[str] = None, prefix: T.Optional[str] = None,
sbindir: T.Optional[str] = None, sharedstatedir: T.Optional[str] = None,
sysconfdir: T.Optional[str] = None):
self.bindir = bindir
self.datadir = datadir
self.includedir = includedir
self.infodir = infodir
self.libdir = libdir
self.libexecdir = libexecdir
self.localedir = localedir
self.localstatedir = localstatedir
self.mandir = mandir
self.prefix = prefix
self.sbindir = sbindir
self.sharedstatedir = sharedstatedir
self.sysconfdir = sysconfdir
def __contains__(self, key: str) -> bool:
return hasattr(self, key)
def __getitem__(self, key: str) -> T.Optional[str]:
# Mypy can't figure out what to do with getattr here, so we'll case for it
return T.cast(T.Optional[str], getattr(self, key))
def __setitem__(self, key: str, value: T.Optional[str]) -> None:
setattr(self, key, value)
def __iter__(self) -> T.Iterator[T.Tuple[str, str]]:
return iter(self.__dict__.items())

@ -27,7 +27,7 @@ from .mesonlib import (
from . import mlog
from .envconfig import (
BinaryTable, Directories, MachineInfo,
BinaryTable, MachineInfo,
Properties, known_cpu_families,
)
from . import compilers
@ -548,11 +548,6 @@ class Environment:
# Misc other properties about each machine.
properties = PerMachineDefaultable()
# Store paths for native and cross build files. There is no target
# machine information here because nothing is installed for the target
# architecture, just the build and host architectures
paths = PerMachineDefaultable()
# We only need one of these as project options are not per machine
user_options = {}
@ -580,11 +575,9 @@ class Environment:
project = ''
store[project] = config.get(section, {})
if self.coredata.config_files is not None:
config = coredata.parse_machine_files(self.coredata.config_files)
binaries.build = BinaryTable(config.get('binaries', {}))
paths.build = Directories(**config.get('paths', {}))
properties.build = Properties(config.get('properties', {}))
# Don't run this if there are any cross files, we don't want to use
@ -592,6 +585,9 @@ class Environment:
if not self.coredata.cross_files:
load_options('project options', user_options)
meson_options.build = {}
if config.get('paths') is not None:
mlog.deprecation('The [paths] section is deprecated, use the [built-in options] section instead.')
load_options('paths', meson_options.build)
load_options('built-in options', meson_options.build)
## Read in cross file(s) to override host machine configuration
@ -604,9 +600,11 @@ class Environment:
machines.host = MachineInfo.from_literal(config['host_machine'])
if 'target_machine' in config:
machines.target = MachineInfo.from_literal(config['target_machine'])
paths.host = Directories(**config.get('paths', {}))
load_options('project options', user_options)
meson_options.host = {}
if config.get('paths') is not None:
mlog.deprecation('The [paths] section is deprecated, use the [built-in options] section instead.')
load_options('paths', meson_options.host)
load_options('built-in options', meson_options.host)
## "freeze" now initialized configuration, and "save" to the class.
@ -614,19 +612,9 @@ class Environment:
self.machines = machines.default_missing()
self.binaries = binaries.default_missing()
self.properties = properties.default_missing()
self.paths = paths.default_missing()
self.user_options = user_options
self.meson_options = meson_options.default_missing()
# Ensure that no paths are passed via built-in options:
if '' in self.meson_options.host:
for each in coredata.BUILTIN_DIR_OPTIONS.keys():
# These are not per-subdirectory and probably never will be
if each in self.meson_options.host['']:
raise EnvironmentException(
'Invalid entry {} in [built-in options] section. '
'Use the [paths] section instead.'.format(each))
exe_wrapper = self.lookup_binary_entry(MachineChoice.HOST, 'exe_wrapper')
if exe_wrapper is not None:
from .dependencies import ExternalProgram

@ -8151,6 +8151,40 @@ class NativeFileTests(BasePlatformTests):
else:
self.fail('Did not find c_args in build options?')
def test_builtin_options_paths(self):
# the properties section can have lang_args, and those need to be
# overwritten by the built-in options
testcase = os.path.join(self.common_test_dir, '1 trivial')
config = self.helper_create_native_file({
'built-in options': {'bindir': 'foo'},
'paths': {'bindir': 'bar'},
})
self.init(testcase, extra_args=['--native-file', config])
configuration = self.introspect('--buildoptions')
for each in configuration:
if each['name'] == 'bindir':
self.assertEqual(each['value'], 'foo')
break
else:
self.fail('Did not find bindir in build options?')
def test_builtin_options_paths_legacy(self):
testcase = os.path.join(self.common_test_dir, '1 trivial')
config = self.helper_create_native_file({
'built-in options': {'default_library': 'static'},
'paths': {'bindir': 'bar'},
})
self.init(testcase, extra_args=['--native-file', config])
configuration = self.introspect('--buildoptions')
for each in configuration:
if each['name'] == 'bindir':
self.assertEqual(each['value'], 'bar')
break
else:
self.fail('Did not find bindir in build options?')
class CrossFileTests(BasePlatformTests):

Loading…
Cancel
Save