diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2015-06-02 13:41:54 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2015-06-12 08:52:17 +0000 |
commit | 15da1e3cd2819b8954e5a72849b039b87623a8b1 (patch) | |
tree | 2b580285a9a884cfd71a19e8740f3b342d801fd4 /morphlib/buildsystem.py | |
parent | 0feb10bf20e44d97cb585a41f3508f40dbe1dab1 (diff) | |
download | morph-15da1e3cd2819b8954e5a72849b039b87623a8b1.tar.gz |
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
Diffstat (limited to 'morphlib/buildsystem.py')
-rw-r--r-- | morphlib/buildsystem.py | 21 |
1 files changed, 21 insertions, 0 deletions
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 |