Invoke depfixer in-process to make it faster. Closes #480.

pull/493/head
Jussi Pakkanen 9 years ago
parent c0c9a96c36
commit 67377e69b5
  1. 3
      mesonbuild/backend/backends.py
  2. 3
      mesonbuild/backend/ninjabackend.py
  3. 23
      mesonbuild/scripts/depfixer.py
  4. 18
      mesonbuild/scripts/meson_install.py

@ -21,12 +21,11 @@ import subprocess
from ..coredata import MesonException
class InstallData():
def __init__(self, source_dir, build_dir, prefix, depfixer):
def __init__(self, source_dir, build_dir, prefix):
self.source_dir = source_dir
self.build_dir= build_dir
self.prefix = prefix
self.targets = []
self.depfixer = depfixer
self.headers = []
self.man = []
self.data = []

@ -458,10 +458,9 @@ int dummy;
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')
depfixer = [sys.executable, self.environment.get_build_command(), '--internal', 'depfixer']
d = InstallData(self.environment.get_source_dir(),
self.environment.get_build_dir(),
self.environment.get_prefix(), depfixer)
self.environment.get_prefix())
elem = NinjaBuildElement(self.all_outputs, 'install', 'CUSTOM_COMMAND', 'PHONY')
elem.add_dep('all')
elem.add_item('DESC', 'Installing files.')

@ -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__':

@ -16,6 +16,7 @@
import sys, pickle, os, shutil, subprocess, gzip, platform
from glob import glob
from mesonbuild.scripts import depfixer
def do_install(datafilename):
ifile = open(datafilename, 'rb')
@ -203,15 +204,14 @@ def install_targets(d):
print("Symlink creation does not work on this platform.")
printed_symlink_error = True
if is_elf_platform():
p = subprocess.Popen(d.depfixer + [outname, install_rpath],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdo, stde) = p.communicate()
if p.returncode != 0:
print('Could not fix dependency info.\n')
print('Stdout:\n%s\n' % stdo.decode())
print('Stderr:\n%s\n' % stde.decode())
sys.exit(1)
try:
e = depfixer.Elf(outname, True)
e.fix_rpath(install_rpath)
except SystemExit as e:
if isinstance(e.code, int) and e.code == 0:
pass
else:
raise
def run(args):
if len(args) != 1:

Loading…
Cancel
Save