Add rename parameter to install_data()

pull/3223/head
Aleksey Filippov 7 years ago
parent 22b19995b1
commit f720efa2f4
  1. 9
      mesonbuild/backend/ninjabackend.py
  2. 8
      mesonbuild/build.py
  3. 5
      mesonbuild/interpreter.py

@ -878,11 +878,10 @@ int dummy;
subdir = de.install_dir
if not subdir:
subdir = os.path.join(self.environment.get_datadir(), self.interpreter.build.project_name)
for f in de.sources:
assert(isinstance(f, mesonlib.File))
plain_f = os.path.basename(f.fname)
dstabs = os.path.join(subdir, plain_f)
i = [f.absolute_path(srcdir, builddir), dstabs, de.install_mode]
for src_file, dst_name in zip(de.sources, de.rename):
assert(isinstance(src_file, mesonlib.File))
dst_abs = os.path.join(subdir, dst_name)
i = [src_file.absolute_path(srcdir, builddir), dst_abs, de.install_mode]
d.data.append(i)
def generate_subdir_install(self, d):

@ -1894,13 +1894,19 @@ class ConfigurationData:
# A bit poorly named, but this represents plain data files to copy
# during install.
class Data:
def __init__(self, sources, install_dir, install_mode=None):
def __init__(self, sources, install_dir, install_mode=None, rename=None):
self.sources = sources
self.install_dir = install_dir
self.install_mode = install_mode
self.sources = listify(self.sources)
for s in self.sources:
assert(isinstance(s, File))
if rename is None:
self.rename = [os.path.basename(f.fname) for f in self.sources]
else:
self.rename = stringlistify(rename)
if len(self.rename) != len(self.sources):
raise MesonException('Size of rename argument is different from number of sources')
class RunScript(dict):
def __init__(self, script, args):

@ -1500,7 +1500,7 @@ permitted_kwargs = {'add_global_arguments': {'language'},
'find_program': {'required', 'native'},
'generator': {'arguments', 'output', 'depfile', 'capture', 'preserve_path_from'},
'include_directories': {'is_system'},
'install_data': {'install_dir', 'install_mode', 'sources'},
'install_data': {'install_dir', 'install_mode', 'rename', 'sources'},
'install_headers': {'install_dir', 'subdir'},
'install_man': {'install_dir'},
'install_subdir': {'exclude_files', 'exclude_directories', 'install_dir', 'install_mode', 'strip_directory'},
@ -2826,7 +2826,8 @@ root and issuing %s.
if not isinstance(install_dir, (str, type(None))):
raise InvalidArguments('Keyword argument install_dir not a string.')
install_mode = self._get_kwarg_install_mode(kwargs)
data = DataHolder(build.Data(sources, install_dir, install_mode))
rename = kwargs.get('rename', None)
data = DataHolder(build.Data(sources, install_dir, install_mode, rename))
self.build.data.append(data.held_object)
return data

Loading…
Cancel
Save