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

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 197823008: ninja: Use rsp files for SOLINK and SOLINK(module) on linux and mac. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import collections 5 import collections
6 import copy 6 import copy
7 import hashlib 7 import hashlib
8 import json 8 import json
9 import multiprocessing 9 import multiprocessing
10 import os.path 10 import os.path
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 libraries = self.msvs_settings.AdjustLibraries(libraries) 1087 libraries = self.msvs_settings.AdjustLibraries(libraries)
1088 1088
1089 self.WriteVariableList(ninja_file, 'libs', library_dirs + libraries) 1089 self.WriteVariableList(ninja_file, 'libs', library_dirs + libraries)
1090 1090
1091 linked_binary = output 1091 linked_binary = output
1092 1092
1093 if command in ('solink', 'solink_module'): 1093 if command in ('solink', 'solink_module'):
1094 extra_bindings.append(('soname', os.path.split(output)[1])) 1094 extra_bindings.append(('soname', os.path.split(output)[1]))
1095 extra_bindings.append(('lib', 1095 extra_bindings.append(('lib',
1096 gyp.common.EncodePOSIXShellArgument(output))) 1096 gyp.common.EncodePOSIXShellArgument(output)))
1097 link_file_list = output + '.rsp'
1098 if self.is_mac_bundle:
1099 # 'Dependency Framework.framework/Versions/A/Dependency Framework' ->
1100 # 'Dependency Framework.framework.rsp'
1101 link_file_list = self.xcode_settings.GetWrapperName() + '.rsp'
1102 # If an rspfile contains spaces, ninja surrounds the filename with
1103 # quotes around it and then passes it to open(), creating a file with
1104 # quotes in its name (and when looking for the rsp file, the name makes
1105 # it through bash which strips the quotes) :-/
1106 link_file_list = link_file_list.replace(' ', '_')
1107 extra_bindings.append(
1108 ('link_file_list', gyp.common.EncodePOSIXShellArgument(link_file_list)))
1097 if self.flavor == 'win': 1109 if self.flavor == 'win':
1098 extra_bindings.append(('binary', output)) 1110 extra_bindings.append(('binary', output))
1099 if '/NOENTRY' not in ldflags: 1111 if '/NOENTRY' not in ldflags:
1100 self.target.import_lib = output + '.lib' 1112 self.target.import_lib = output + '.lib'
1101 extra_bindings.append(('implibflag', 1113 extra_bindings.append(('implibflag',
1102 '/IMPLIB:%s' % self.target.import_lib)) 1114 '/IMPLIB:%s' % self.target.import_lib))
1103 pdbname = self.msvs_settings.GetPDBName( 1115 pdbname = self.msvs_settings.GetPDBName(
1104 config_name, self.ExpandSpecial, output + '.pdb') 1116 config_name, self.ExpandSpecial, output + '.pdb')
1105 output = [output, self.target.import_lib] 1117 output = [output, self.target.import_lib]
1106 if pdbname: 1118 if pdbname:
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 % { 'solink': 1896 % { 'solink':
1885 '$ld -shared $ldflags -o $lib -Wl,-soname=$soname %(suffix)s', 1897 '$ld -shared $ldflags -o $lib -Wl,-soname=$soname %(suffix)s',
1886 'extract_toc': 1898 'extract_toc':
1887 ('{ readelf -d $lib | grep SONAME ; ' 1899 ('{ readelf -d $lib | grep SONAME ; '
1888 'nm -gD -f p $lib | cut -f1-2 -d\' \'; }')}) 1900 'nm -gD -f p $lib | cut -f1-2 -d\' \'; }')})
1889 1901
1890 master_ninja.rule( 1902 master_ninja.rule(
1891 'solink', 1903 'solink',
1892 description='SOLINK $lib', 1904 description='SOLINK $lib',
1893 restat=True, 1905 restat=True,
1894 command=(mtime_preserving_solink_base % { 1906 command=mtime_preserving_solink_base % {'suffix': '@$link_file_list'},
1895 'suffix': '-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive ' 1907 rspfile='$link_file_list',
1896 '$libs'}), 1908 rspfile_content=
1909 '-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive $libs',
1897 pool='link_pool') 1910 pool='link_pool')
1898 master_ninja.rule( 1911 master_ninja.rule(
1899 'solink_module', 1912 'solink_module',
1900 description='SOLINK(module) $lib', 1913 description='SOLINK(module) $lib',
1901 restat=True, 1914 restat=True,
1902 command=(mtime_preserving_solink_base % { 1915 command=mtime_preserving_solink_base % {'suffix': '@$link_file_list'},
1903 'suffix': '-Wl,--start-group $in $solibs -Wl,--end-group ' 1916 rspfile='$link_file_list',
1904 '$libs'}), 1917 rspfile_content='-Wl,--start-group $in $solibs -Wl,--end-group $libs',
1905 pool='link_pool') 1918 pool='link_pool')
1906 master_ninja.rule( 1919 master_ninja.rule(
1907 'link', 1920 'link',
1908 description='LINK $out', 1921 description='LINK $out',
1909 command=('$ld $ldflags -o $out ' 1922 command=('$ld $ldflags -o $out '
1910 '-Wl,--start-group $in $solibs -Wl,--end-group $libs'), 1923 '-Wl,--start-group $in $solibs -Wl,--end-group $libs'),
1911 pool='link_pool') 1924 pool='link_pool')
1912 elif flavor == 'win': 1925 elif flavor == 'win':
1913 master_ninja.rule( 1926 master_ninja.rule(
1914 'alink', 1927 'alink',
1915 description='LIB $out', 1928 description='LIB $out',
1916 command=('%s gyp-win-tool link-wrapper $arch False ' 1929 command=('%s gyp-win-tool link-wrapper $arch False '
1917 '$ar /nologo /ignore:4221 /OUT:$out @$out.rsp' % 1930 '$ar /nologo /ignore:4221 /OUT:$out @$link_file_list' %
1918 sys.executable), 1931 sys.executable),
1919 rspfile='$out.rsp', 1932 rspfile='$link_file_list',
1920 rspfile_content='$in_newline $libflags') 1933 rspfile_content='$in_newline $libflags')
1921 _AddWinLinkRules(master_ninja, embed_manifest=True) 1934 _AddWinLinkRules(master_ninja, embed_manifest=True)
1922 _AddWinLinkRules(master_ninja, embed_manifest=False) 1935 _AddWinLinkRules(master_ninja, embed_manifest=False)
1923 else: 1936 else:
1924 master_ninja.rule( 1937 master_ninja.rule(
1925 'objc', 1938 'objc',
1926 description='OBJC $out', 1939 description='OBJC $out',
1927 command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_objc ' 1940 command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_objc '
1928 '$cflags_pch_objc -c $in -o $out'), 1941 '$cflags_pch_objc -c $in -o $out'),
1929 depfile='$out.d', 1942 depfile='$out.d',
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 '%(solink)s && %(extract_toc)s > $lib.tmp && ' 1974 '%(solink)s && %(extract_toc)s > $lib.tmp && '
1962 'if ! cmp -s $lib.tmp $lib.TOC; then ' 1975 'if ! cmp -s $lib.tmp $lib.TOC; then '
1963 'mv $lib.tmp $lib.TOC ; ' 1976 'mv $lib.tmp $lib.TOC ; '
1964 'fi; ' 1977 'fi; '
1965 'fi' 1978 'fi'
1966 % { 'solink': solink_base, 1979 % { 'solink': solink_base,
1967 'extract_toc': 1980 'extract_toc':
1968 '{ otool -l $lib | grep LC_ID_DYLIB -A 5; ' 1981 '{ otool -l $lib | grep LC_ID_DYLIB -A 5; '
1969 'nm -gP $lib | cut -f1-2 -d\' \' | grep -v U$$; true; }'}) 1982 'nm -gP $lib | cut -f1-2 -d\' \' | grep -v U$$; true; }'})
1970 1983
1971 solink_suffix = '$in $solibs $libs$postbuilds' 1984
1985 solink_suffix = '@$link_file_list$postbuilds'
1972 master_ninja.rule( 1986 master_ninja.rule(
1973 'solink', 1987 'solink',
1974 description='SOLINK $lib, POSTBUILDS', 1988 description='SOLINK $lib, POSTBUILDS',
1975 restat=True, 1989 restat=True,
1976 command=mtime_preserving_solink_base % {'suffix': solink_suffix, 1990 command=mtime_preserving_solink_base % {'suffix': solink_suffix,
1977 'type': '-shared'}, 1991 'type': '-shared'},
1992 rspfile='$link_file_list',
1993 rspfile_content='$in $solibs $libs',
1978 pool='link_pool') 1994 pool='link_pool')
1979 master_ninja.rule( 1995 master_ninja.rule(
1980 'solink_notoc', 1996 'solink_notoc',
1981 description='SOLINK $lib, POSTBUILDS', 1997 description='SOLINK $lib, POSTBUILDS',
1982 restat=True, 1998 restat=True,
1983 command=solink_base % {'suffix':solink_suffix, 'type': '-shared'}, 1999 command=solink_base % {'suffix':solink_suffix, 'type': '-shared'},
2000 rspfile='$link_file_list',
2001 rspfile_content='$in $solibs $libs',
1984 pool='link_pool') 2002 pool='link_pool')
1985 2003
1986 solink_module_suffix = '$in $solibs $libs$postbuilds'
1987 master_ninja.rule( 2004 master_ninja.rule(
1988 'solink_module', 2005 'solink_module',
1989 description='SOLINK(module) $lib, POSTBUILDS', 2006 description='SOLINK(module) $lib, POSTBUILDS',
1990 restat=True, 2007 restat=True,
1991 command=mtime_preserving_solink_base % {'suffix': solink_module_suffix, 2008 command=mtime_preserving_solink_base % {'suffix': solink_suffix,
1992 'type': '-bundle'}, 2009 'type': '-bundle'},
2010 rspfile='$link_file_list',
2011 rspfile_content='$in $solibs $libs',
1993 pool='link_pool') 2012 pool='link_pool')
1994 master_ninja.rule( 2013 master_ninja.rule(
1995 'solink_module_notoc', 2014 'solink_module_notoc',
1996 description='SOLINK(module) $lib, POSTBUILDS', 2015 description='SOLINK(module) $lib, POSTBUILDS',
1997 restat=True, 2016 restat=True,
1998 command=solink_base % {'suffix': solink_module_suffix, 'type': '-bundle'}, 2017 command=solink_base % {'suffix': solink_suffix, 'type': '-bundle'},
2018 rspfile='$link_file_list',
2019 rspfile_content='$in $solibs $libs',
1999 pool='link_pool') 2020 pool='link_pool')
2000 2021
2001 master_ninja.rule( 2022 master_ninja.rule(
2002 'link', 2023 'link',
2003 description='LINK $out, POSTBUILDS', 2024 description='LINK $out, POSTBUILDS',
2004 command=('$ld $ldflags -o $out ' 2025 command=('$ld $ldflags -o $out '
2005 '$in $solibs $libs$postbuilds'), 2026 '$in $solibs $libs$postbuilds'),
2006 pool='link_pool') 2027 pool='link_pool')
2007 master_ninja.rule( 2028 master_ninja.rule(
2008 'preprocess_infoplist', 2029 'preprocess_infoplist',
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 arglists.append( 2181 arglists.append(
2161 (target_list, target_dicts, data, params, config_name)) 2182 (target_list, target_dicts, data, params, config_name))
2162 pool.map(CallGenerateOutputForConfig, arglists) 2183 pool.map(CallGenerateOutputForConfig, arglists)
2163 except KeyboardInterrupt, e: 2184 except KeyboardInterrupt, e:
2164 pool.terminate() 2185 pool.terminate()
2165 raise e 2186 raise e
2166 else: 2187 else:
2167 for config_name in config_names: 2188 for config_name in config_names:
2168 GenerateOutputForConfig(target_list, target_dicts, data, params, 2189 GenerateOutputForConfig(target_list, target_dicts, data, params,
2169 config_name) 2190 config_name)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698