Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Unified Diff: pylib/gyp/generator/ninja.py

Issue 10704054: ninja mac: Smarter dylib linking. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pylib/gyp/generator/ninja.py
===================================================================
--- pylib/gyp/generator/ninja.py (revision 1425)
+++ pylib/gyp/generator/ninja.py (working copy)
@@ -153,14 +153,16 @@
"""Return true if this is a target that can be linked against."""
return self.type in ('static_library', 'shared_library')
- def SharedLinkable(self):
+ def SharedLinkable(self, flavor):
"""Return true if this is a shared library/module."""
+ if flavor == 'win':
Ami GONE FROM CHROMIUM 2012/06/30 22:37:04 I almost did this in my CL but couldn't justify th
+ return False
return self.type in ('shared_library', 'loadable_module')
def PreActionInput(self, flavor):
"""Return the path, if any, that should be used as a dependency of
any dependent action step."""
- if self.SharedLinkable() and flavor not in ['mac', 'win']:
+ if self.SharedLinkable(flavor):
return self.FinalOutput() + '.TOC'
return self.FinalOutput() or self.preaction_stamp
@@ -840,7 +842,7 @@
extra_link_deps |= set(target.component_objs)
elif self.flavor == 'win' and target.import_lib:
extra_link_deps.add(target.import_lib)
- elif target.SharedLinkable() and self.flavor not in ['mac', 'win']:
+ elif target.SharedLinkable(self.flavor):
solibs.add(target.binary)
implicit_deps.add(target.binary + '.TOC')
else:
@@ -895,7 +897,7 @@
extra_bindings.append(('dll', output))
extra_bindings.append(('implib', self.target.import_lib))
output = [output, self.target.import_lib]
- elif self.flavor != 'mac':
+ else:
output = [output, output + '.TOC']
if len(solibs):
@@ -1476,23 +1478,41 @@
command='rm -f $out && '
'./gyp-mac-tool filter-libtool libtool -static -o $out $in'
'$postbuilds')
+
+ # Record the public interface of $lib in $lib.TOC. See the corresponding
+ # comment in the posix section above for details.
+ mtime_preserving_solink_base = (
+ 'if [ ! -e $lib -o ! -e ${lib}.TOC ]; then '
+ '%(solink)s && %(extract_toc)s > ${lib}.TOC; else '
+ '%(solink)s && %(extract_toc)s > ${lib}.tmp && '
+ 'if ! cmp -s ${lib}.tmp ${lib}.TOC; then mv ${lib}.tmp ${lib}.TOC ; '
+ 'fi; fi'
+ % { 'solink':
+ '$ld -shared $ldflags -o $lib %(suffix)s',
+ 'extract_toc':
+ ('{ ' #readelf -d ${lib} | grep SONAME ; '
+ 'nm -U -P ${lib} |cut -f1-2 -d\' \' |grep \'[A-Z]$$\'; }')})
Ami GONE FROM CHROMIUM 2012/06/30 22:37:04 I don't know what this means, but FTR in the other
+
# TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass
# -bundle -single_module here (for osmesa.so).
master_ninja.rule(
'solink',
- description='SOLINK $out, POSTBUILDS',
- command=('$ld -shared $ldflags -o $out '
- '$in $libs$postbuilds'))
+ description='SOLINK $lib, POSTBUILDS',
+ restat=True,
+ command=(mtime_preserving_solink_base % {
+ 'suffix': '$in $solibs $libs$postbuilds'}))
master_ninja.rule(
'solink_module',
- description='SOLINK(module) $out, POSTBUILDS',
- command=('$ld -shared $ldflags -o $out '
- '$in $libs$postbuilds'))
+ description='SOLINK(module) $lib, POSTBUILDS',
+ restat=True,
+ command=(mtime_preserving_solink_base % {
+ 'suffix': '$in $solibs $libs$postbuilds'}))
+
master_ninja.rule(
'link',
description='LINK $out, POSTBUILDS',
command=('$ld $ldflags -o $out '
- '$in $libs$postbuilds'))
+ '$in $solibs $libs$postbuilds'))
master_ninja.rule(
'infoplist',
description='INFOPLIST $out',

Powered by Google App Engine
This is Rietveld 408576698