summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-02-12 03:02:09 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2020-02-17 22:58:50 +0530
commit4a959fdb0160c67e028f755dfa7bbae59d56d3df (patch)
tree5abd964570936a306fff5b1ded4c34abf228dc60
parentfa219bca5305b682b1895efd709bfcd1e118e9c9 (diff)
downloadmeson-nirbheek/minstall-perf-improvements-and-new-option-quiet.tar.gz
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 ```
-rw-r--r--docs/markdown/Reference-manual.md7
-rw-r--r--docs/markdown/snippets/minstall_quiet.md11
-rw-r--r--mesonbuild/minstall.py28
3 files changed, 34 insertions, 12 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 510d44323..be4d3d7ff 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -1718,8 +1718,11 @@ the following methods.
given as an argument to be run during the install step, this script
will have the environment variables `MESON_SOURCE_ROOT`,
`MESON_BUILD_ROOT`, `MESON_INSTALL_PREFIX`,
- `MESON_INSTALL_DESTDIR_PREFIX`, and `MESONINTROSPECT` set. All
- additional arguments are passed as parameters.
+ `MESON_INSTALL_DESTDIR_PREFIX`, and `MESONINTROSPECT` set.
+ All positional arguments are passed as parameters.
+
+ *(added 0.54)* If `meson install` is called with the `--quiet` option, the
+ environment variable `MESON_INSTALL_QUIET` will be set.
Meson uses the `DESTDIR` environment variable as set by the
inherited environment to determine the (temporary) installation
diff --git a/docs/markdown/snippets/minstall_quiet.md b/docs/markdown/snippets/minstall_quiet.md
new file mode 100644
index 000000000..3a7ff318d
--- /dev/null
+++ b/docs/markdown/snippets/minstall_quiet.md
@@ -0,0 +1,11 @@
+## New option `--quiet` to `meson install`
+
+Now you can run `meson install --quiet` and meson will not verbosely print
+every file as it is being installed. As before, the full log is always
+available inside the builddir in `meson-logs/install-log.txt`.
+
+When this option is passed, install scripts will have the environment variable
+`MESON_INSTALL_QUIET` set.
+
+Numerous speed-ups were also made for the install step, especially on Windows
+where it is now 300% to 1200% faster than before depending on your workload.
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 21bf420e5..64bcca23c 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')