aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-02-26 14:18:57 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2017-02-27 16:49:32 -0500
commitb9274681375b39d4b63f8ece1ced6dcf18789a4f (patch)
tree08eaaea7fd6c6409d8562e047a279de22416bc1b
parent92d18b925679f2c889bf248fa23d6611968203f4 (diff)
downloadmeson-b9274681375b39d4b63f8ece1ced6dcf18789a4f.zip
meson-b9274681375b39d4b63f8ece1ced6dcf18789a4f.tar.gz
meson-b9274681375b39d4b63f8ece1ced6dcf18789a4f.tar.bz2
Use cross stripper when cross compiling and allow overriding native strip executable. Closes #1414.
-rw-r--r--mesonbuild/backend/backends.py3
-rw-r--r--mesonbuild/backend/ninjabackend.py12
-rw-r--r--mesonbuild/build.py10
-rw-r--r--mesonbuild/environment.py4
-rw-r--r--mesonbuild/scripts/meson_install.py4
5 files changed, 29 insertions, 4 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index d6f1c38..26052d3 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.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 = []
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index ee2c40e..5e137ca 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -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.')
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 28456f7..bdb1dc3 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -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):
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 4bdc4df..5217626 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -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
diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py
index 2ffc505..a025b0c 100644
--- a/mesonbuild/scripts/meson_install.py
+++ b/mesonbuild/scripts/meson_install.py
@@ -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)