aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/minstall.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2022-03-02 20:04:15 -0500
committerXavier Claessens <xclaesse@gmail.com>2022-03-09 10:38:28 -0500
commiteafb8a8e10c1b520bb2af5b6028ea816236309d5 (patch)
tree16422d304c9b295ba2fb07c5395f1149899f899e /mesonbuild/minstall.py
parent6ec6e0c9ec5a9f0a01fe573cfc76fb26986fbd18 (diff)
downloadmeson-eafb8a8e10c1b520bb2af5b6028ea816236309d5.zip
meson-eafb8a8e10c1b520bb2af5b6028ea816236309d5.tar.gz
meson-eafb8a8e10c1b520bb2af5b6028ea816236309d5.tar.bz2
install: Add --strip option
Diffstat (limited to 'mesonbuild/minstall.py')
-rw-r--r--mesonbuild/minstall.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index b51d4f0..f33ad0a 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -61,6 +61,7 @@ if T.TYPE_CHECKING:
dry_run: bool
skip_subprojects: str
tags: str
+ strip: bool
symlink_warning = '''Warning: trying to copy a symlink that points to a file. This will copy the file,
@@ -88,6 +89,8 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
help='Do not install files from given subprojects. (Since 0.58.0)')
parser.add_argument('--tags', default=None,
help='Install only targets having one of the given tags. (Since 0.60.0)')
+ parser.add_argument('--strip', action='store_true',
+ help='Strip targets even if strip option was not set during configure. (Since 0.62.0)')
class DirMaker:
def __init__(self, lf: T.TextIO, makedirs: T.Callable[..., None]):
@@ -564,6 +567,15 @@ class Installer:
else:
raise
+ def do_strip(self, strip_bin: T.List[str], fname: str, outname: str) -> None:
+ self.log(f'Stripping target {fname!r}.')
+ returncode, stdo, stde = self.Popen_safe(strip_bin + [outname])
+ if returncode != 0:
+ print('Could not strip file.\n')
+ print(f'Stdout:\n{stdo}\n')
+ print(f'Stderr:\n{stde}\n')
+ sys.exit(1)
+
def install_subdirs(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix: str) -> None:
for i in d.install_subdirs:
if not self.should_install(i):
@@ -676,7 +688,7 @@ class Installer:
outdir = get_destdir_path(destdir, fullprefix, t.outdir)
outname = os.path.join(outdir, os.path.basename(fname))
final_path = os.path.join(d.prefix, t.outdir, os.path.basename(fname))
- should_strip = t.strip
+ should_strip = t.strip or (t.can_strip and self.options.strip)
install_rpath = t.install_rpath
install_name_mappings = t.install_name_mappings
install_mode = t.install_mode
@@ -689,13 +701,7 @@ class Installer:
if fname.endswith('.jar'):
self.log('Not stripping jar target: {}'.format(os.path.basename(fname)))
continue
- self.log('Stripping target {!r} using {}.'.format(fname, d.strip_bin[0]))
- returncode, stdo, stde = self.Popen_safe(d.strip_bin + [outname])
- if returncode != 0:
- print('Could not strip file.\n')
- print(f'Stdout:\n{stdo}\n')
- print(f'Stderr:\n{stde}\n')
- sys.exit(1)
+ self.do_strip(d.strip_bin, fname, outname)
if fname.endswith('.js'):
# Emscripten outputs js files and optionally a wasm file.
# If one was generated, install it as well.
@@ -721,7 +727,6 @@ class Installer:
else:
raise
-
def rebuild_all(wd: str) -> bool:
if not (Path(wd) / 'build.ninja').is_file():
print('Only ninja backend is supported to rebuild the project before installation.')