aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/minstall.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-02-12 03:02:09 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2020-02-17 23:58:20 +0530
commit53265e3bc23e33b91f7ef9865621bc3f71fb1f30 (patch)
tree1858e5f6d51767f3bf4aaafa67cf4f8a6732e93a /mesonbuild/minstall.py
parent130048583237c30d24b0a09fb6273acb360f2bb6 (diff)
downloadmeson-53265e3bc23e33b91f7ef9865621bc3f71fb1f30.zip
meson-53265e3bc23e33b91f7ef9865621bc3f71fb1f30.tar.gz
meson-53265e3bc23e33b91f7ef9865621bc3f71fb1f30.tar.bz2
minstall: Add a new option --quiet
This is a significant speed-up on Windows because terminals are slow to print things out. Speed-up in gst-build on Windows: ``` meson install: before: 5.1 seconds after: 4.0 seconds ```
Diffstat (limited to 'mesonbuild/minstall.py')
-rw-r--r--mesonbuild/minstall.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 21bf420..64bcca2 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -42,6 +42,8 @@ def add_arguments(parser):
help='Do not rebuild before installing.')
parser.add_argument('--only-changed', default=False, action='store_true',
help='Only overwrite files that are older than the copied file.')
+ parser.add_argument('--quiet', default=False, action='store_true',
+ help='Do not print every file that was installed.')
class DirMaker:
def __init__(self, lf):
@@ -219,6 +221,10 @@ class Installer:
self.lf = lf
self.preserved_file_count = 0
+ def log(self, msg):
+ if not self.options.quiet:
+ print(msg)
+
def should_preserve_existing_file(self, from_file, to_file):
if not self.options.only_changed:
return False
@@ -251,7 +257,7 @@ class Installer:
dirmaker, outdir = makedirs
# Create dirs if needed
dirmaker.makedirs(outdir, exist_ok=True)
- print('Installing %s to %s' % (from_file, outdir))
+ self.log('Installing %s to %s' % (from_file, outdir))
if os.path.islink(from_file):
if not os.path.exists(from_file):
# Dangling symlink. Replicate as is.
@@ -356,10 +362,10 @@ class Installer:
restore_selinux_contexts()
self.run_install_script(d)
if not self.did_install_something:
- print('Nothing to install.')
- if self.preserved_file_count > 0:
- print('Preserved {} unchanged files, see {} for the full list'
- .format(self.preserved_file_count, os.path.normpath(self.lf.name)))
+ self.log('Nothing to install.')
+ if not self.options.quiet and self.preserved_file_count > 0:
+ self.log('Preserved {} unchanged files, see {} for the full list'
+ .format(self.preserved_file_count, os.path.normpath(self.lf.name)))
except PermissionError:
if shutil.which('pkexec') is not None and 'PKEXEC_UID' not in os.environ:
print('Installation failed due to insufficient permissions.')
@@ -373,7 +379,7 @@ class Installer:
for (src_dir, dst_dir, mode, exclude) in d.install_subdirs:
self.did_install_something = True
full_dst_dir = get_destdir_path(d, dst_dir)
- print('Installing subdir %s to %s' % (src_dir, full_dst_dir))
+ self.log('Installing subdir %s to %s' % (src_dir, full_dst_dir))
d.dirmaker.makedirs(full_dst_dir, exist_ok=True)
self.do_copydir(d, src_dir, full_dst_dir, exclude, mode)
@@ -415,6 +421,8 @@ class Installer:
'MESON_INSTALL_DESTDIR_PREFIX': d.fullprefix,
'MESONINTROSPECT': ' '.join([shlex.quote(x) for x in d.mesonintrospect]),
}
+ if self.options.quiet:
+ env['MESON_INSTALL_QUIET'] = '1'
child_env = os.environ.copy()
child_env.update(env)
@@ -424,7 +432,7 @@ class Installer:
script = i['exe']
args = i['args']
name = ' '.join(script + args)
- print('Running custom install script {!r}'.format(name))
+ self.log('Running custom install script {!r}'.format(name))
try:
rc = subprocess.call(script + args, env=child_env)
if rc != 0:
@@ -438,7 +446,7 @@ class Installer:
if not os.path.exists(t.fname):
# For example, import libraries of shared modules are optional
if t.optional:
- print('File {!r} not found, skipping'.format(t.fname))
+ self.log('File {!r} not found, skipping'.format(t.fname))
continue
else:
raise RuntimeError('File {!r} could not be found'.format(t.fname))
@@ -459,9 +467,9 @@ class Installer:
set_mode(outname, install_mode, d.install_umask)
if should_strip and d.strip_bin is not None:
if fname.endswith('.jar'):
- print('Not stripping jar target:', os.path.basename(fname))
+ self.log('Not stripping jar target:', os.path.basename(fname))
continue
- print('Stripping target {!r} using {}.'.format(fname, d.strip_bin[0]))
+ self.log('Stripping target {!r} using {}.'.format(fname, d.strip_bin[0]))
ps, stdo, stde = Popen_safe(d.strip_bin + [outname])
if ps.returncode != 0:
print('Could not strip file.\n')