Guest User

Untitled

a guest
Sep 10th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.26 KB | None | 0 0
  1. Index: pylib/gyp/generator/ninja.py
  2. ===================================================================
  3. --- pylib/gyp/generator/ninja.py (revision 1491)
  4. +++ pylib/gyp/generator/ninja.py (working copy)
  5. @@ -945,6 +945,7 @@
  6. if self.xcode_settings:
  7. variables.append(('libtool_flags',
  8. self.xcode_settings.GetLibtoolflags(config_name)))
  9. +
  10. self.ninja.build(self.target.binary, 'alink', link_deps,
  11. order_only=compile_deps, variables=variables)
  12. else:
  13. @@ -1211,6 +1212,7 @@
  14. global generator_additional_non_configuration_keys
  15. global generator_additional_path_sections
  16. flavor = gyp.common.GetFlavor(params)
  17. + default_variables.setdefault('HOST_OS', gyp.common.GetHostOS())
  18. if flavor == 'mac':
  19. default_variables.setdefault('OS', 'mac')
  20. default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib')
  21. @@ -1284,6 +1286,7 @@
  22. config_name):
  23. options = params['options']
  24. flavor = gyp.common.GetFlavor(params)
  25. + host_os = gyp.common.GetHostOS()
  26. generator_flags = params.get('generator_flags', {})
  27.  
  28. # build_dir: relative path from source root to our output files.
  29. @@ -1298,7 +1301,7 @@
  30. width=120)
  31.  
  32. # Put build-time support tools in out/{config_name}.
  33. - gyp.common.CopyTool(flavor, toplevel_build)
  34. + gyp.common.CopyTool(host_os, toplevel_build)
  35.  
  36. # Grab make settings for CC/CXX.
  37. # The rules are
  38. @@ -1345,7 +1348,7 @@
  39. ld_host = os.path.join(build_to_root, value)
  40.  
  41. flock = 'flock'
  42. - if flavor == 'mac':
  43. + if host_os == 'mac':
  44. flock = './gyp-mac-tool flock'
  45. cc = GetEnvironFallback(['CC_target', 'CC'], cc)
  46. master_ninja.variable('cc', cc)
  47. @@ -1388,7 +1391,7 @@
  48. else:
  49. master_ninja.variable('ld_host', flock + ' linker.lock ' + ld_host)
  50.  
  51. - if flavor == 'mac':
  52. + if host_os == 'mac':
  53. master_ninja.variable('mac_tool', os.path.join('.', 'gyp-mac-tool'))
  54. master_ninja.newline()
  55.  
  56. @@ -1396,13 +1399,13 @@
  57. master_ninja.rule(
  58. 'cc',
  59. description='CC $out',
  60. - command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_c '
  61. + command=('$cc_host -MMD -MF $out.d $defines $includes $cflags $cflags_c '
  62. '$cflags_pch_c -c $in -o $out'),
  63. depfile='$out.d')
  64. master_ninja.rule(
  65. 'cxx',
  66. description='CXX $out',
  67. - command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc '
  68. + command=('$cxx_host -MMD -MF $out.d $defines $includes $cflags $cflags_cc '
  69. '$cflags_pch_cc -c $in -o $out'),
  70. depfile='$out.d')
  71. else:
  72. @@ -1414,12 +1417,12 @@
  73. # when compiling PCH.
  74. cc_template = ('ninja-deplist-helper -r . -q -f cl -o $out.dl -e $arch '
  75. '--command '
  76. - '$cc /nologo /showIncludes /FC '
  77. + '$cc_host /nologo /showIncludes /FC '
  78. '@$out.rsp '
  79. '$cflags_pch_c /c $in %(outspec)s /Fd$pdbname ')
  80. cxx_template = ('ninja-deplist-helper -r . -q -f cl -o $out.dl -e $arch '
  81. '--command '
  82. - '$cxx /nologo /showIncludes /FC '
  83. + '$cxx_host /nologo /showIncludes /FC '
  84. '@$out.rsp '
  85. '$cflags_pch_cc /c $in %(outspec)s $pchobj /Fd$pdbname ')
  86. master_ninja.rule(
  87. @@ -1470,7 +1473,7 @@
  88. '$arch $asm $defines $includes /c /Fo $out $in' %
  89. sys.executable))
  90.  
  91. - if flavor != 'mac' and flavor != 'win':
  92. + if host_os != 'mac' and host_os != 'win':
  93. master_ninja.rule(
  94. 'alink',
  95. description='AR $out',
  96. @@ -1511,7 +1514,7 @@
  97. description='LINK $out',
  98. command=('$ld $ldflags -o $out -Wl,-rpath=\$$ORIGIN/lib '
  99. '-Wl,--start-group $in $solibs -Wl,--end-group $libs'))
  100. - elif flavor == 'win':
  101. + elif host_os == 'win':
  102. master_ninja.rule(
  103. 'alink',
  104. description='LIB $out',
  105. @@ -1547,27 +1550,14 @@
  106. (sys.executable, sys.executable)),
  107. rspfile='$out.rsp',
  108. rspfile_content='$in_newline $libs $ldflags')
  109. - else:
  110. + else: # host_os == 'mac'
  111. master_ninja.rule(
  112. - 'objc',
  113. - description='OBJC $out',
  114. - command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_objc '
  115. - '$cflags_pch_objc -c $in -o $out'),
  116. - depfile='$out.d')
  117. - master_ninja.rule(
  118. - 'objcxx',
  119. - description='OBJCXX $out',
  120. - command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_objcc '
  121. - '$cflags_pch_objcc -c $in -o $out'),
  122. - depfile='$out.d')
  123. - master_ninja.rule(
  124. 'alink',
  125. description='LIBTOOL-STATIC $out, POSTBUILDS',
  126. command='rm -f $out && '
  127. './gyp-mac-tool filter-libtool libtool $libtool_flags '
  128. '-static -o $out $in'
  129. '$postbuilds')
  130. -
  131. # Record the public interface of $lib in $lib.TOC. See the corresponding
  132. # comment in the posix section above for details.
  133. mtime_preserving_solink_base = (
  134. @@ -1608,20 +1598,72 @@
  135. description='LINK $out, POSTBUILDS',
  136. command=('$ld $ldflags -o $out '
  137. '$in $solibs $libs$postbuilds'))
  138. +
  139. + if flavor == 'mac':
  140. master_ninja.rule(
  141. + 'objc',
  142. + description='OBJC $out',
  143. + command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_objc '
  144. + '$cflags_pch_objc -c $in -o $out'),
  145. + depfile='$out.d')
  146. + master_ninja.rule(
  147. + 'objcxx',
  148. + description='OBJCXX $out',
  149. + command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_objcc '
  150. + '$cflags_pch_objcc -c $in -o $out'),
  151. + depfile='$out.d')
  152. + master_ninja.rule(
  153. 'infoplist',
  154. description='INFOPLIST $out',
  155. command=('$cc -E -P -Wno-trigraphs -x c $defines $in -o $out && '
  156. 'plutil -convert xml1 $out $out'))
  157. master_ninja.rule(
  158. - 'mac_tool',
  159. - description='MACTOOL $mactool_cmd $in',
  160. - command='$env $mac_tool $mactool_cmd $in $out')
  161. - master_ninja.rule(
  162. 'package_framework',
  163. description='PACKAGE FRAMEWORK $out, POSTBUILDS',
  164. command='$mac_tool package-framework $out $version$postbuilds '
  165. '&& touch $out')
  166. + elif flavor == 'android':
  167. + master_ninja.rule(
  168. + 'alink_target',
  169. + description='AR $out',
  170. + command='rm -f $out && $ar rcsT $out $in')
  171. +
  172. + # This allows targets that only need to depend on $lib's API to declare an
  173. + # order-only dependency on $lib.TOC and avoid relinking such downstream
  174. + # dependencies when $lib changes only in non-public ways.
  175. + # The resulting string leaves an uninterpolated %{suffix} which
  176. + # is used in the final substitution below.
  177. + mtime_preserving_solink_base = (
  178. + 'if [ ! -e $lib -o ! -e ${lib}.TOC ]; then '
  179. + '%(solink_target)s && %(extract_toc)s > ${lib}.TOC; else '
  180. + '%(solink_target)s && %(extract_toc)s > ${lib}.tmp && '
  181. + 'if ! cmp -s ${lib}.tmp ${lib}.TOC; then mv ${lib}.tmp ${lib}.TOC ; '
  182. + 'fi; fi'
  183. + % { 'solink_target':
  184. + '$ld_target -shared $ldflags -o $lib -Wl,-soname=$soname %(suffix)s',
  185. build.ninja
  186. rule solink_module
  187. command = if [ ! -e $lib -o ! -e ${lib}.TOC ] || otool -l $lib | grep -q LC_REEXPORT_DYLIB ; then $ld -shared $
  188. $ldflags -o $lib $in $solibs $libs$postbuilds && { otool -l $lib | grep LC_ID_DYLIB -A 5; nm -gP $lib | cut $
  189. -f1-2 -d' ' | grep -v U$$; true; } > ${lib}.TOC; else $ld -shared $ldflags -o $lib $in $solibs $libs$postbuilds $
  190. && { otool -l $lib | grep LC_ID_DYLIB -A 5; nm -gP $lib | cut -f1-2 -d' ' | grep -v U$$; true; } > ${lib}.tmp $
  191. && if ! cmp -s ${lib}.tmp ${lib}.TOC; then mv ${lib}.tmp ${lib}.TOC ; fi; fi
  192. description = SOLINK(module) $lib, POSTBUILDS
  193. restat = 1
  194. rule link
  195. command = $ld $ldflags -o $out $in $solibs $libs$postbuilds
  196. description = LINK $out, POSTBUILDS
  197. rule alink_target
  198. command = rm -f $out && $ar rcsT $out $in
  199. description = AR $out
  200. rule solink_target
  201. command = if [ ! -e $lib -o ! -e ${lib}.TOC ]; then $ld_target -shared $ldflags -o $lib -Wl,-soname=$soname $
  202. -Wl,--whole-archive $in $solibs -Wl,--no-whole-archive $libs && { readelf -d ${lib} | grep SONAME ; nm -gD -f p $
  203. ${lib} | cut -f1-2 -d' '; } > ${lib}.TOC; else $ld_target -shared $ldflags -o $lib -Wl,-soname=$soname $
  204. -Wl,--whole-archive $in $solibs -Wl,--no-whole-archive $libs && { readelf -d ${lib} | grep SONAME ; nm -gD -f p $
  205. ${lib} | cut -f1-2 -d' '; } > ${lib}.tmp && if ! cmp -s ${lib}.tmp ${lib}.TOC; then mv ${lib}.tmp ${lib}.TOC ; $
  206. fi; fi
  207. description = SOLINK $lib
  208. restat = 1
  209. rule solink_module_target
  210. command = if [ ! -e $lib -o ! -e ${lib}.TOC ]; then $ld_target -shared $ldflags -o $lib -Wl,-soname=$soname $
  211. -Wl,--start-group $in $solibs -Wl,--end-group $libs && { readelf -d ${lib} | grep SONAME ; nm -gD -f p ${lib} | $
  212. cut -f1-2 -d' '; } > ${lib}.TOC; else $ld_target -shared $ldflags -o $lib -Wl,-soname=$soname -Wl,--start-group $
  213. ~/projects/webrtc-jingle-client/trunk/out/Debug/build.ninja CWD: /Users/luke/projects/webrtc-jingle-client/trunk/out/Debug Line: 37
  214. + 'extract_toc':
  215. + ('{ readelf -d ${lib} | grep SONAME ; '
  216. + 'nm -gD -f p ${lib} | cut -f1-2 -d\' \'; }')})
  217. +
  218. + master_ninja.rule(
  219. + 'solink_target',
  220. + description='SOLINK $lib',
  221. + restat=True,
  222. + command=(mtime_preserving_solink_base % {
  223. + 'suffix': '-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive '
  224. + '$libs'}))
  225. + master_ninja.rule(
  226. + 'solink_module_target',
  227. + description='SOLINK(module) $lib',
  228. + restat=True,
  229. + command=(mtime_preserving_solink_base % {
  230. + 'suffix': '-Wl,--start-group $in $solibs -Wl,--end-group $libs'}))
  231. + master_ninja.rule(
  232. + 'link_target',
  233. + description='LINK $out',
  234. + command=('$ld $ldflags -o $out -Wl,-rpath=\$$ORIGIN/lib '
  235. + '-Wl,--start-group $in $solibs -Wl,--end-group $libs'))
  236. +
  237. if flavor == 'win':
  238. master_ninja.rule(
  239. 'stamp',
Advertisement
Add Comment
Please, Sign In to add comment