diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-06-07 20:22:05 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-06-07 20:22:05 +0300 |
commit | d4cfc5d2ccddc3b226f6baeab9658c06c118dfef (patch) | |
tree | fd54a62823ab8b33772f4d40b877c9f6fed4eeb3 | |
parent | ed61e6f19a84bfd295cfa6928804b5accc65f821 (diff) | |
download | meson-d4cfc5d2ccddc3b226f6baeab9658c06c118dfef.zip meson-d4cfc5d2ccddc3b226f6baeab9658c06c118dfef.tar.gz meson-d4cfc5d2ccddc3b226f6baeab9658c06c118dfef.tar.bz2 |
Only relink if exported symbols of dependencies change.
-rwxr-xr-x | backends.py | 28 | ||||
-rwxr-xr-x | symbolextractor.py | 4 |
2 files changed, 28 insertions, 4 deletions
diff --git a/backends.py b/backends.py index 427a421..f26f096 100755 --- a/backends.py +++ b/backends.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): @@ -628,6 +640,11 @@ class NinjaBackend(Backend): elem.add_item('FLAGS', commands) 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): @@ -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() diff --git a/symbolextractor.py b/symbolextractor.py index 19b6259..ef08cf3 100755 --- a/symbolextractor.py +++ b/symbolextractor.py @@ -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': |