Handle case of install_subdirring a subdir.

pull/579/head
Jussi Pakkanen 9 years ago
parent 8e734a8c9f
commit 0482635c12
  1. 11
      mesonbuild/backend/ninjabackend.py
  2. 5
      mesonbuild/scripts/meson_install.py
  3. 1
      test cases/common/66 install subdir/installed_files.txt
  4. 1
      test cases/common/66 install subdir/meson.build
  5. 1
      test cases/common/66 install subdir/sub/sub1/third.dat

@ -545,8 +545,15 @@ int dummy;
def generate_subdir_install(self, d):
for sd in self.build.get_install_subdirs():
src_dir = os.path.join(self.environment.get_source_dir(), sd.source_subdir)
inst_dir = sd.installable_subdir
inst_subdir = sd.installable_subdir.rstrip('/')
idir_parts = inst_subdir.split('/')
if len(idir_parts) > 1:
subdir = os.path.join(sd.source_subdir, '/'.join(idir_parts[:-1]))
inst_dir = idir_parts[-1]
else:
subdir = sd.source_subdir
inst_dir = sd.installable_subdir
src_dir = os.path.join(self.environment.get_source_dir(), subdir)
dst_dir = os.path.join(self.environment.get_prefix(), sd.install_dir)
d.install_subdirs.append([src_dir, inst_dir, dst_dir])

@ -55,7 +55,6 @@ def install_subdirs(data):
if not os.path.exists(dst_dir):
os.makedirs(dst_dir)
for root, dirs, files in os.walk(src_prefix):
print(root)
for d in dirs:
abs_src = os.path.join(src_dir, root, d)
filepart = abs_src[len(src_dir)+1:]
@ -75,6 +74,10 @@ def install_subdirs(data):
print('Tried to copy file %s but a directory of that name already exists.' % abs_dst)
if os.path.exists(abs_dst):
os.unlink(abs_dst)
parent_dir = os.path.split(abs_dst)[0]
if not os.path.isdir(parent_dir):
os.mkdir(parent_dir)
shutil.copystat(os.path.split(abs_src)[0], parent_dir)
shutil.copy2(abs_src, abs_dst, follow_symlinks=False)
def install_data(d):

@ -1,3 +1,4 @@
usr/share/sub1/data1.dat
usr/share/sub1/second.dat
usr/share/sub1/third.dat
usr/share/sub1/sub2/data2.dat

@ -2,3 +2,4 @@ project('install a whole subdir', 'c')
subdir('subdir')
install_subdir('sub1', install_dir : 'share')
install_subdir('sub/sub1', install_dir : 'share')

@ -0,0 +1 @@
This is a third data file for sub1 dir.
Loading…
Cancel
Save