Only relink if exported symbols of dependencies change.

pull/15/head
Jussi Pakkanen 12 years ago
parent ed61e6f19a
commit d4cfc5d2cc
  1. 28
      backends.py
  2. 4
      symbolextractor.py

@ -473,7 +473,7 @@ class NinjaBackend(Backend):
outfile.write(' description = $DESC\n')
outfile.write(' restat = 1\n\n')
outfile.write('rule REGENERATE_BUILD\n')
c = (sys.executable,
c = (ninja_quote(sys.executable),
ninja_quote(self.environment.get_build_command()),
ninja_quote(self.environment.get_source_dir()),
ninja_quote(self.environment.get_build_dir()))
@ -505,6 +505,18 @@ class NinjaBackend(Backend):
outfile.write(command)
outfile.write(description)
outfile.write('\n')
scriptdir = self.environment.get_script_dir()
outfile.write('\n')
symrule = 'rule SHSYM\n'
symcmd = ' command = %s %s %s %s\n' % (ninja_quote(sys.executable),
ninja_quote(os.path.join(scriptdir, 'symbolextractor.py')),
'$in', '$out')
synstat = ' restat = 1\n'
syndesc = ' description = Generating symbol file $out.\n'
outfile.write(symrule)
outfile.write(symcmd)
outfile.write(synstat)
outfile.write(syndesc)
outfile.write('\n')
def generate_compile_rules(self, outfile):
@ -629,6 +641,11 @@ class NinjaBackend(Backend):
elem.add_item('DEPFILE', dep)
elem.write(outfile)
def generate_shsym(self, outfile, target_name):
symname = target_name + '.symbols'
elem = NinjaBuildElement(symname, 'SHSYM', target_name)
elem.write(outfile)
def generate_link(self, target, outfile, outname, obj_list):
if isinstance(target, interpreter.StaticLibrary):
linker = self.build.static_linker
@ -636,6 +653,8 @@ class NinjaBackend(Backend):
else:
linker = self.build.compilers[0]
linker_base = linker.get_language() # Fixme.
if isinstance(target, interpreter.SharedLibrary):
self.generate_shsym(outfile, outname)
linker_rule = linker_base + '_LINKER'
commands = []
if isinstance(target, interpreter.Executable):
@ -653,12 +672,17 @@ class NinjaBackend(Backend):
commands += self.build_target_link_arguments(dependencies)
if self.environment.coredata.coverage:
commands += linker.get_coverage_link_flags()
dep_targets = [self.get_target_filename(t) for t in dependencies]
dep_targets = [self.get_dependency_filename(t) for t in dependencies]
elem = NinjaBuildElement(outname, linker_rule, obj_list)
elem.add_dep(dep_targets)
elem.add_item('LINK_FLAGS', commands)
return elem
def get_dependency_filename(self, t):
if isinstance(t, interpreter.SharedLibrary):
return self.get_target_filename(t) + '.symbols'
return self.get_target_filename(t)
def generate_shlib_aliases(self, target, outdir, outfile, elem):
basename = target.get_filename()
aliases = target.get_aliaslist()

@ -43,14 +43,14 @@ def linux_syms(libfilename, outfilename):
if pe.returncode != 0:
raise RuntimeError('Readelf does not work')
result = [x for x in output.split('\n') if 'SONAME' in x]
assert(len(result) == 1)
assert(len(result) <= 1)
pnm = subprocess.Popen(['nm', '--dynamic', '--extern-only', '--defined-only', '--format=posix', libfilename],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = pnm.communicate()[0].decode()
if pnm.returncode != 0:
raise RuntimeError('nm does not work.')
result += [x.split()[0] for x in output.split('\n') if len(x) > 0]
write_if_changed('\n'.join(result), outfilename)
write_if_changed('\n'.join(result) + '\n', outfilename)
def gen_symbols(libfilename, outfilename):
if platform.system() == 'Linux':

Loading…
Cancel
Save