Use cross stripper when cross compiling and allow overriding native strip executable. Closes #1414.

pull/1437/head
Jussi Pakkanen 8 years ago
parent 92d18b9256
commit b927468137
  1. 3
      mesonbuild/backend/backends.py
  2. 12
      mesonbuild/backend/ninjabackend.py
  3. 10
      mesonbuild/build.py
  4. 4
      mesonbuild/environment.py
  5. 4
      mesonbuild/scripts/meson_install.py

@ -33,10 +33,11 @@ class CleanTrees:
self.trees = trees
class InstallData:
def __init__(self, source_dir, build_dir, prefix):
def __init__(self, source_dir, build_dir, prefix, strip_bin):
self.source_dir = source_dir
self.build_dir = build_dir
self.prefix = prefix
self.strip_bin = strip_bin
self.targets = []
self.headers = []
self.man = []

@ -594,9 +594,19 @@ int dummy;
def generate_install(self, outfile):
install_data_file = os.path.join(self.environment.get_scratch_dir(), 'install.dat')
if self.environment.is_cross_build():
bins = self.environment.cross_info.config['binaries']
if 'strip' not in bins:
mlog.warning('Cross file does not specify strip binary, result will not be stripped.')
strip_bin = None
else:
strip_bin = mesonlib.stringlistify(bins['strip'])
else:
strip_bin = self.environment.native_strip_bin
d = InstallData(self.environment.get_source_dir(),
self.environment.get_build_dir(),
self.environment.get_prefix())
self.environment.get_prefix(),
strip_bin)
elem = NinjaBuildElement(self.all_outputs, 'install', 'CUSTOM_COMMAND', 'PHONY')
elem.add_dep('all')
elem.add_item('DESC', 'Installing files.')

@ -324,11 +324,16 @@ class BuildTarget(Target):
raise InvalidArguments('Build target %s has no sources.' % name)
self.process_compilers()
self.validate_sources()
self.validate_cross_install(environment)
def __repr__(self):
repr_str = "<{0} {1}: {2}>"
return repr_str.format(self.__class__.__name__, self.get_id(), self.filename)
def validate_cross_install(self, environment):
if environment.is_cross_build() and not self.is_cross and self.install:
raise InvalidArguments('Tried to install a natively built target in a cross build.')
def get_id(self):
# This ID must also be a valid file name on all OSs.
# It should also avoid shell metacharacters for obvious
@ -1481,6 +1486,11 @@ class Jar(BuildTarget):
def get_java_args(self):
return self.java_args
def validate_cross_install(self, environment):
# All jar targets are installable.
pass
class ConfigureFile:
def __init__(self, subdir, sourcename, targetname, configuration_data):

@ -261,6 +261,10 @@ class Environment:
self.exe_suffix = ''
self.object_suffix = 'o'
self.win_libdir_layout = False
if 'STRIP' in os.environ:
self.native_strip_bin = shlex.split('STRIP')
else:
self.native_strip_bin = ['strip']
def is_cross_build(self):
return self.cross_info is not None

@ -236,12 +236,12 @@ def install_targets(d):
raise RuntimeError('File {!r} could not be found'.format(fname))
elif os.path.isfile(fname):
do_copyfile(fname, outname)
if should_strip:
if should_strip and d.strip_bin is not None:
if fname.endswith('.jar'):
print('Not stripping jar target:', os.path.split(fname)[1])
continue
print('Stripping target {!r}'.format(fname))
ps, stdo, stde = Popen_safe(['strip', outname])
ps, stdo, stde = Popen_safe(d.strip_bin + [outname])
if ps.returncode != 0:
print('Could not strip file.\n')
print('Stdout:\n%s\n' % stdo)

Loading…
Cancel
Save