From 4ba3255dd12bc9fe473c38cc1db507daf8777f4c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 13 Jul 2014 21:26:32 +0530 Subject: [PATCH] Build option to not strip the generated linux/os x binaries --- setup/installer/__init__.py | 5 +++++ setup/installer/linux/freeze2.py | 8 +++++++- setup/installer/osx/app/main.py | 14 +++++++++----- setup/installer/windows/freeze.py | 3 +++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/setup/installer/__init__.py b/setup/installer/__init__.py index 2b21a5bdca..4ce2fdbd8f 100644 --- a/setup/installer/__init__.py +++ b/setup/installer/__init__.py @@ -109,6 +109,9 @@ class VMInstaller(Command): if not parser.has_option('--dont-shutdown'): parser.add_option('-s', '--dont-shutdown', default=False, action='store_true', help='Dont shutdown the VM after building') + if not parser.has_option('--dont-strip'): + parser.add_option('-x', '--dont-strip', default=False, + action='store_true', help='Dont strip the generated binaries') def get_build_script(self): rs = ['export RSYNC_PASSWORD=%s'%get_rsync_pw()] @@ -156,6 +159,8 @@ class VMInstaller(Command): return installer_name(self.INSTALLER_EXT, self.IS_64_BIT) def run(self, opts): + if opts.dont_strip: + self.FREEZE_COMMAND += ' --dont-strip' subprocess.call(['chmod', '-R', '+r', 'recipes']) start_time = time.time() self.start_vm() diff --git a/setup/installer/linux/freeze2.py b/setup/installer/linux/freeze2.py index 6dff93fc7b..3b86946830 100644 --- a/setup/installer/linux/freeze2.py +++ b/setup/installer/linux/freeze2.py @@ -155,6 +155,11 @@ def strip_files(files, argv_max=(256 * 1024)): class LinuxFreeze(Command): + def add_options(self, parser): + if not parser.has_option('--dont-strip'): + parser.add_option('-x', '--dont-strip', default=False, + action='store_true', help='Dont strip the generated binaries') + def run(self, opts): self.drop_privileges() self.opts = opts @@ -167,7 +172,8 @@ class LinuxFreeze(Command): self.copy_libs() self.copy_python() self.build_launchers() - self.strip_files() + if not self.opts.dont_strip: + self.strip_files() self.create_tarfile() def initbase(self): diff --git a/setup/installer/osx/app/main.py b/setup/installer/osx/app/main.py index de1392a516..10aaa07b19 100644 --- a/setup/installer/osx/app/main.py +++ b/setup/installer/osx/app/main.py @@ -38,11 +38,14 @@ class OSX32_Freeze(Command): parser.add_option('--test-launchers', default=False, action='store_true', help='Only build launchers') + if not parser.has_option('--dont-strip'): + parser.add_option('-x', '--dont-strip', default=False, + action='store_true', help='Dont strip the generated binaries') def run(self, opts): global info, warn info, warn = self.info, self.warn - main(opts.test_launchers) + main(opts.test_launchers, opts.dont_strip) def compile_launcher_lib(contents_dir, gcc, base): info('\tCompiling calibre_launcher.dylib') @@ -147,8 +150,9 @@ class Py2App(object): FID = '@executable_path/../Frameworks' - def __init__(self, build_dir, test_launchers=False): + def __init__(self, build_dir, test_launchers=False, dont_strip=False): self.build_dir = build_dir + self.dont_strip = dont_strip self.contents_dir = join(self.build_dir, 'Contents') self.resources_dir = join(self.contents_dir, 'Resources') self.frameworks_dir = join(self.contents_dir, 'Frameworks') @@ -192,7 +196,7 @@ class Py2App(object): self.copy_site() self.create_exe() - if not test_launchers: + if not test_launchers and not self.dont_strip: self.strip_files() ret = self.makedmg(self.build_dir, APPNAME+'-'+VERSION) @@ -671,11 +675,11 @@ def test_exe(): return 0 -def main(test=False): +def main(test=False, dont_strip=False): if 'test_exe' in sys.argv: return test_exe() build_dir = abspath(join(os.path.dirname(SRC), 'build', APPNAME+'.app')) - Py2App(build_dir, test_launchers=test) + Py2App(build_dir, test_launchers=test, dont_strip=dont_strip) return 0 diff --git a/setup/installer/windows/freeze.py b/setup/installer/windows/freeze.py index 18ed1241cd..9a576044fc 100644 --- a/setup/installer/windows/freeze.py +++ b/setup/installer/windows/freeze.py @@ -109,6 +109,9 @@ class Win32Freeze(Command, WixMixIn): help='Keep human readable site.py') parser.add_option('--verbose', default=0, action="count", help="Be more verbose") + if not parser.has_option('--dont-strip'): + parser.add_option('-x', '--dont-strip', default=False, + action='store_true', help='Dont strip the generated binaries (no-op on windows)') def run(self, opts): self.SW = SW