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

Side by Side Diff: pylib/gyp/win_tool.py

Issue 111373002: win ninja: Refactor manifest generate and embed to be 1-pass (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: . Created 7 years 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
« pylib/gyp/msvs_emulation.py ('K') | « pylib/gyp/msvs_emulation.py ('k') | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 Google Inc. All rights reserved. 3 # Copyright (c) 2012 Google Inc. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Utility functions for Windows builds. 7 """Utility functions for Windows builds.
8 8
9 These functions are executed via gyp-win-tool when using the ninja generator. 9 These functions are executed via gyp-win-tool when using the ninja generator.
10 """ 10 """
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 shell=True, 109 shell=True,
110 env=env, 110 env=env,
111 stdout=subprocess.PIPE, 111 stdout=subprocess.PIPE,
112 stderr=subprocess.STDOUT) 112 stderr=subprocess.STDOUT)
113 out, _ = link.communicate() 113 out, _ = link.communicate()
114 for line in out.splitlines(): 114 for line in out.splitlines():
115 if not line.startswith(' Creating library '): 115 if not line.startswith(' Creating library '):
116 print line 116 print line
117 return link.returncode 117 return link.returncode
118 118
119 def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname,
120 mt, rc, *manifests):
121 """A wrapper for handling creating a manifest resource and then executing
122 a link command."""
123 # The 'normal' way to do manifests is to have link generate a manifest
124 # based on gathering dependencies from the object files, then merge that
125 # manifest with other manifests supplied as sources, convert the merged
126 # manifest to a resource, and then *relink*, including the compiled
127 # version of the manifest resource. This breaks incremental linking, and
128 # is generally overly complicated. Instead, we merge all the manifests
129 # provided (along with one that includes what would normally be in the
130 # linker-generated one, see msvs_emulation.py), and include that into the
131 # first and only link. We still tell link to generate a manifest, but we
132 # only use that to assert that our simpler process did not miss anything.
133 variables = {
134 'python': sys.executable,
135 'arch': arch,
136 'out': out,
137 'ldcmd': ldcmd,
138 'resname': resname,
139 'mt': mt,
140 'rc': rc,
141 'manifests': ' '.join(manifests),
142 }
143 add_to_ld = ''
144 if manifests:
145 subprocess.check_call(
146 '%(python)s gyp-win-tool manifest-wrapper %(arch)s %(mt)s -nologo '
147 '-manifest %(manifests)s -out:%(out)s.manifest' % variables)
148 if embed_manifest == 'True':
149 subprocess.check_call(
150 '%(python)s gyp-win-tool manifest-to-rc %(arch)s %(out)s.manifest'
151 ' %(out)s.manifest.rc %(resname)s' % variables)
152 subprocess.check_call(
153 '%(python)s gyp-win-tool rc-wrapper %(arch)s %(rc)s '
154 '%(out)s.manifest.rc' % variables)
155 add_to_ld = ' %(out)s.manifest.res' % variables
156 subprocess.check_call(ldcmd + add_to_ld)
157 # TODO(scottmg): Run mt.exe on the theoretically complete manifest we
158 # generated, merging it with the one the linker generated to confirm that
159 # the linker generated one does not add anything.
160
119 def ExecManifestWrapper(self, arch, *args): 161 def ExecManifestWrapper(self, arch, *args):
120 """Run manifest tool with environment set. Strip out undesirable warning 162 """Run manifest tool with environment set. Strip out undesirable warning
121 (some XML blocks are recognized by the OS loader, but not the manifest 163 (some XML blocks are recognized by the OS loader, but not the manifest
122 tool).""" 164 tool)."""
123 env = self._GetEnv(arch) 165 env = self._GetEnv(arch)
124 popen = subprocess.Popen(args, shell=True, env=env, 166 popen = subprocess.Popen(args, shell=True, env=env,
125 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 167 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
126 out, _ = popen.communicate() 168 out, _ = popen.communicate()
127 for line in out.splitlines(): 169 for line in out.splitlines():
128 if line and 'manifest authoring warning 81010002' not in line: 170 if line and 'manifest authoring warning 81010002' not in line:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 def ExecActionWrapper(self, arch, rspfile, *dir): 244 def ExecActionWrapper(self, arch, rspfile, *dir):
203 """Runs an action command line from a response file using the environment 245 """Runs an action command line from a response file using the environment
204 for |arch|. If |dir| is supplied, use that as the working directory.""" 246 for |arch|. If |dir| is supplied, use that as the working directory."""
205 env = self._GetEnv(arch) 247 env = self._GetEnv(arch)
206 args = open(rspfile).read() 248 args = open(rspfile).read()
207 dir = dir[0] if dir else None 249 dir = dir[0] if dir else None
208 return subprocess.call(args, shell=True, env=env, cwd=dir) 250 return subprocess.call(args, shell=True, env=env, cwd=dir)
209 251
210 if __name__ == '__main__': 252 if __name__ == '__main__':
211 sys.exit(main(sys.argv[1:])) 253 sys.exit(main(sys.argv[1:]))
OLDNEW
« pylib/gyp/msvs_emulation.py ('K') | « pylib/gyp/msvs_emulation.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698