From 26ff3fa23e07f8c4409675d52e30eeef11b63a66 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 10 Feb 2013 21:26:27 +0200 Subject: [PATCH] Strip on install and generate pch properly. --- builder_install.py | 10 ++++++++++ generators.py | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/builder_install.py b/builder_install.py index 9df56127d..5f9722d56 100755 --- a/builder_install.py +++ b/builder_install.py @@ -74,10 +74,20 @@ def install_targets(d): fname = os.path.split(fullfilename)[1] aliases = t[2] outname = os.path.join(outdir, fname) + should_strip = t[3] print('Installing %s to %s' % (fname, outdir)) os.makedirs(outdir, exist_ok=True) shutil.copyfile(fullfilename, outname) shutil.copystat(fullfilename, outname) + if should_strip: + print('Stripping target') + ps = subprocess.Popen(['strip', outname], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (stdo, stde) = ps.communicate() + if ps.returncode != 0: + print('Could not strip file.\n') + print('Stdout:\n%s\n' % stdo.decode()) + print('Stderr:\n%s\n' % stde.decode()) + sys.exit(1) for alias in aliases: os.symlink(fname, os.path.join(outdir, alias)) p = subprocess.Popen([d.depfixer, outname, d.dep_prefix], stdout=subprocess.PIPE, diff --git a/generators.py b/generators.py index 41d872211..6f4eb9cf1 100755 --- a/generators.py +++ b/generators.py @@ -198,13 +198,14 @@ class NinjaGenerator(Generator): libdir = os.path.join(prefix, self.environment.get_libdir()) bindir = os.path.join(prefix, self.environment.get_bindir()) + should_strip = self.environment.options.strip for t in self.build.get_targets().values(): if t.should_install(): if isinstance(t, interpreter.Executable): outdir = bindir else: outdir = libdir - i = [os.path.join(self.environment.get_build_dir(), self.get_target_filename(t)), outdir, t.get_aliaslist()] + i = [os.path.join(self.environment.get_build_dir(), self.get_target_filename(t)), outdir, t.get_aliaslist(), should_strip] d.targets.append(i) def generate_header_install(self, d): @@ -360,12 +361,15 @@ class NinjaGenerator(Generator): src = os.path.join(self.build_to_src, target.get_source_subdir(), pch) dst = os.path.join(self.get_target_private_dir(target), os.path.split(pch)[-1] + '.' + compiler.get_pch_suffix()) + dep = dst + '.' + compiler.get_depfile_suffix() build = 'build %s: %s %s\n' % (ninja_quote(dst), ninja_quote(compiler.get_language() + '_COMPILER'), ninja_quote(src)) - flags = ' FLAGS = %s\n\n' % ' '.join([ninja_quote(t) for t in commands]) + flags = ' FLAGS = %s\n' % ' '.join([ninja_quote(t) for t in commands]) + depfile = ' DEPFILE = %s\n\n' % ninja_quote(dep) outfile.write(build) outfile.write(flags) + outfile.write(depfile) def generate_link(self, target, outfile, outname, obj_list): if isinstance(target, interpreter.StaticLibrary):