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

Side by Side Diff: third_party/yasm/run_yasm.py

Issue 321323004: Add yasm to the GN build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/yasm/BUILD.gn ('k') | third_party/yasm/yasm_assemble.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """A wrapper to run yasm.
6
7 Its main job is to provide a Python wrapper for GN integration, and to write
8 the makefile-style output yasm generates in stdout to a .d file for dependency
9 management of .inc files.
10
11 Run with:
12 python run_yasm.py <yasm_binary_path> <all other yasm args>
13
14 Note that <all other yasm args> must include an explicit output file (-o). This
15 script will append a ".d" to this and write the dependencies there. This script
16 will add "-M" to cause yasm to write the deps to stdout, so you don't need to
17 specify that.
18 """
19
20 import argparse
21 import sys
22 import subprocess
23
24 # Extract the output file name from the yasm command line so we can generate a
25 # .d file with the same base name.
26 parser = argparse.ArgumentParser()
27 parser.add_argument("-o", dest="objfile")
28 options, _ = parser.parse_known_args()
29
30 objfile = options.objfile
31 depfile = objfile + '.d'
32
33 # Assemble.
34 result_code = subprocess.call(sys.argv[1:])
35 if result_code != 0:
36 sys.exit(result_code)
37
38 # Now generate the .d file listing the dependencies. The -M option makes yasm
39 # write the Makefile-style dependencies to stdout, but it seems that inhibits
40 # generating any compiled output so we need to do this in a separate pass.
41 # However, outputting deps seems faster than actually assembling, and yasm is
42 # so fast anyway this is not a big deal.
43 #
44 # This guarantees proper dependency management for assembly files. Otherwise,
45 # we would have to require people to manually specify the .inc files they
46 # depend on in the build file, which will surely be wrong or out-of-date in
47 # some cases.
48 deps = subprocess.check_output(sys.argv[1:] + ['-M'])
49 with open(depfile, "wb") as f:
50 f.write(deps)
51
OLDNEW
« no previous file with comments | « third_party/yasm/BUILD.gn ('k') | third_party/yasm/yasm_assemble.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698