Installing subdirs now merges with existing files in the target dir.

pull/579/head
Jussi Pakkanen 9 years ago
parent 144565fabf
commit beb6827413
  1. 7
      mesonbuild/backend/ninjabackend.py
  2. 44
      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/sub1/second.dat

@ -459,8 +459,6 @@ int dummy;
mlog.log(mlog.red('Warning:'), 'coverage requested but neither gcovr nor lcov/genhtml found.')
def generate_install(self, outfile):
script_root = self.environment.get_script_dir()
install_script = os.path.join(script_root, 'meson_install.py')
install_data_file = os.path.join(self.environment.get_scratch_dir(), 'install.dat')
d = InstallData(self.environment.get_source_dir(),
self.environment.get_build_dir(),
@ -548,9 +546,10 @@ 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, sd.installable_subdir)
src_dir = os.path.join(self.environment.get_source_dir(), sd.source_subdir)
inst_dir = sd.installable_subdir
dst_dir = os.path.join(self.environment.get_prefix(), sd.install_dir)
d.install_subdirs.append([src_dir, dst_dir])
d.install_subdirs.append([src_dir, inst_dir, dst_dir])
def write_test_suite_targets(self, cmd, outfile):
suites = {}

@ -42,20 +42,40 @@ def do_install(datafilename):
install_data(d)
run_install_script(d)
def install_subdirs(d):
for (src_dir, dst_dir) in d.install_subdirs:
def install_subdirs(data):
for (src_dir, inst_dir, dst_dir) in data.install_subdirs:
if src_dir.endswith('/'):
src_dir = src_dir[:-1]
src_prefix = os.path.join(src_dir, inst_dir)
print('Installing subdir %s to %s.' % (src_prefix, dst_dir))
if os.path.isabs(dst_dir):
dst_dir = destdir_join(d.destdir, dst_dir)
dst_dir = destdir_join(data.destdir, dst_dir)
else:
dst_dir = d.fullprefix + dst_dir
# Python's copytree works in strange ways.
last_level = os.path.split(src_dir)[-1]
final_dst = os.path.join(dst_dir, last_level)
# Don't do rmtree because final_dst might point to e.g. /var/www
# We might need to revert to walking the directory tree by hand.
# shutil.rmtree(final_dst, ignore_errors=True)
shutil.copytree(src_dir, final_dst, symlinks=True)
print('Installing subdir %s to %s.' % (src_dir, dst_dir))
dst_dir = data.fullprefix + dst_dir
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:]
abs_dst = os.path.join(dst_dir, filepart)
if os.path.isdir(abs_dst):
continue
if os.path.exists(abs_dst):
print('Tried to copy directory %s but a file of that name already exists.' % abs_dst)
sys.exit(1)
os.makedirs(abs_dst)
shutil.copystat(abs_src, abs_dst)
for f in files:
abs_src = os.path.join(src_dir, root, f)
filepart = abs_src[len(src_dir)+1:]
abs_dst = os.path.join(dst_dir, filepart)
if os.path.isdir(abs_dst):
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)
shutil.copy2(abs_src, abs_dst, follow_symlinks=False)
def install_data(d):
for i in d.data:

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

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

@ -0,0 +1 @@
Test that multiple install_subdirs meld their results.
Loading…
Cancel
Save