diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-03-30 22:09:36 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-03-30 22:09:36 +0300 |
commit | 67377e69b5cbf61d557d372b81990d5c0f28b5e3 (patch) | |
tree | c2e79a825f7ce427e521f478967a81298c063c37 /mesonbuild/scripts/depfixer.py | |
parent | c0c9a96c364e9c6f773568645017860ce19ccc0e (diff) | |
download | meson-67377e69b5cbf61d557d372b81990d5c0f28b5e3.zip meson-67377e69b5cbf61d557d372b81990d5c0f28b5e3.tar.gz meson-67377e69b5cbf61d557d372b81990d5c0f28b5e3.tar.bz2 |
Invoke depfixer in-process to make it faster. Closes #480.
Diffstat (limited to 'mesonbuild/scripts/depfixer.py')
-rw-r--r-- | mesonbuild/scripts/depfixer.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py index 1ab83b6..8ff0dd1 100644 --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2013-2014 The Meson development team +# Copyright 2013-2016 The Meson development team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -110,8 +110,9 @@ class SectionHeader(DataSizes): self.sh_entsize = struct.unpack(self.Word, ifile.read(self.WordSize))[0] class Elf(DataSizes): - def __init__(self, bfile): + def __init__(self, bfile, verbose=True): self.bfile = bfile + self.verbose = verbose self.bf = open(bfile, 'r+b') (self.ptrsize, self.is_le) = self.detect_elf_type() super().__init__(self.ptrsize, self.is_le) @@ -124,22 +125,21 @@ class Elf(DataSizes): if data[1:4] != b'ELF': # This script gets called to non-elf targets too # so just ignore them. - print('File "%s" is not an ELF file.' % self.bfile) + if self.verbose: + print('File "%s" is not an ELF file.' % self.bfile) sys.exit(0) if data[4] == 1: ptrsize = 32 elif data[4] == 2: ptrsize = 64 else: - print('File "%s" has unknown ELF class.' % self.bfile) - sys.exit(1) + sys.exit('File "%s" has unknown ELF class.' % self.bfile) if data[5] == 1: is_le = True elif data[5] == 2: is_le = False else: - print('File "%s" has unknown ELF endianness.' % self.bfile) - sys.exit(1) + sys.exit('File "%s" has unknown ELF endianness.' % self.bfile) return (ptrsize, is_le) def parse_header(self): @@ -257,14 +257,17 @@ class Elf(DataSizes): self.bf.write(newname) def fix_rpath(self, new_rpath): + if isinstance(new_rpath, str): + new_rpath = new_rpath.encode('utf8') rp_off = self.get_rpath_offset() if rp_off is None: - print('File does not have rpath. It should be a fully static executable.') + if self.verbose: + print('File does not have rpath. It should be a fully static executable.') return self.bf.seek(rp_off) old_rpath = self.read_str() if len(old_rpath) < len(new_rpath): - print("New rpath must not be longer than the old one.") + sys.exit("New rpath must not be longer than the old one.") self.bf.seek(rp_off) self.bf.write(new_rpath) self.bf.write(b'\0'*(len(old_rpath) - len(new_rpath) + 1)) @@ -295,7 +298,7 @@ def run(args): e.print_rpath() else: new_rpath = args[1] - e.fix_rpath(new_rpath.encode('utf8')) + e.fix_rpath(new_rpath) return 0 if __name__ == '__main__': |