From 15da1e3cd2819b8954e5a72849b039b87623a8b1 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 2 Jun 2015 13:41:54 +0000 Subject: buildsystems: Add strip commands This adds strip commands to all build systems, that will be hooked up into the cache and build logic. Change-Id: I37ad3e43311a417a949e7dfef860a50fdf6b8c43 --- morphlib/buildsystem.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'morphlib/buildsystem.py') diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py index 7ed50d11..5c16a9fe 100644 --- a/morphlib/buildsystem.py +++ b/morphlib/buildsystem.py @@ -18,6 +18,23 @@ import os import morphlib +# TODO: Make idempotent when files are hardlinks +_STRIP_COMMAND = r'''find "$DESTDIR" -type f \ + '(' -perm -111 -o -name '*.so*' -o -name '*.cmxs' -o -name '*.node' ')' \ + -exec sh -ec \ + 'read -n4 hdr <"$1" # check for elf header + if [ "$hdr" != "$(printf \\x7fELF)" ]; then + exit 0 + fi + debugfile="$DESTDIR$PREFIX/lib/debug/$(basename "$1")" + mkdir -p "$(dirname "$debugfile")" + objcopy --only-keep-debug "$1" "$debugfile" + chmod 644 "$debugfile" + strip --remove-section=.comment --remove-section=.note --strip-unneeded "$1" + objcopy --add-gnu-debuglink "$debugfile" "$1"' - {} ';' +''' + + class BuildSystem(object): '''An abstraction of an upstream build system. @@ -45,6 +62,9 @@ class BuildSystem(object): self.pre_install_commands = [] self.install_commands = [] self.post_install_commands = [] + self.pre_strip_commands = [] + self.strip_commands = [_STRIP_COMMAND] + self.post_strip_commands = [] def __getitem__(self, key): key = '_'.join(key.split('-')) @@ -91,6 +111,7 @@ class DummyBuildSystem(BuildSystem): self.build_commands = ['echo dummy build'] self.test_commands = ['echo dummy test'] self.install_commands = ['echo dummy install'] + self.strip_commands = ['echo dummy strip'] def used_by_project(self, file_list): return False -- cgit v1.2.1