load_configs: generalise the search path

Instead of hard-coding the fact that load_configs() searches for files under
meson/native, pass in the subdirectory allowing the cross-file code to use the
same logic.
pull/5083/head
Ross Burton 6 years ago
parent 44dd5535f0
commit d57dd1092e
  1. 6
      mesonbuild/coredata.py
  2. 2
      mesonbuild/environment.py

@ -211,8 +211,8 @@ class UserFeatureOption(UserComboOption):
return self.value == 'auto'
def load_configs(filenames):
"""Load native files."""
def load_configs(filenames, subdir):
"""Load configuration files from a named subdirectory."""
def gen():
for f in filenames:
f = os.path.expanduser(os.path.expandvars(f))
@ -225,7 +225,7 @@ def load_configs(filenames):
os.environ.get('XDG_DATA_HOME', os.path.expanduser('~/.local/share')),
] + os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':')
for path in paths:
path_to_try = os.path.join(path, 'meson', 'native', f)
path_to_try = os.path.join(path, 'meson', subdir, f)
if os.path.isfile(path_to_try):
yield path_to_try
break

@ -408,7 +408,7 @@ class Environment:
if self.coredata.config_files is not None:
config = MesonConfigFile.from_config_parser(
coredata.load_configs(self.coredata.config_files))
coredata.load_configs(self.coredata.config_files, 'native'))
self.binaries.build = BinaryTable(config.get('binaries', {}))
self.paths.build = Directories(**config.get('paths', {}))

Loading…
Cancel
Save