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

Side by Side Diff: third_party/yasm/patched-yasm/tools/python-yasm/setup.py

Issue 6170009: Update our yasm copy to yasm 1.1.0 (Part 1: yasm side)... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 9 years, 11 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
OLDNEW
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 # Build Python extension with configuration file input 2 # Build Python extension with configuration file input
3 # 3 #
4 # Copyright (C) 2006 Peter Johnson 4 # Copyright (C) 2006 Peter Johnson
5 # 5 #
6 # Redistribution and use in source and binary forms, with or without 6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions 7 # modification, are permitted provided that the following conditions
8 # are met: 8 # are met:
9 # 1. Redistributions of source code must retain the above copyright 9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright 11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the 12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution. 13 # documentation and/or other materials provided with the distribution.
14 # 14 #
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' 15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
16 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE 18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
19 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE. 25 # POSSIBILITY OF SUCH DAMAGE.
26 26
27 from distutils.core import setup 27 from distutils.core import setup
28 from distutils.extension import Extension 28 from distutils.extension import Extension
29 from Pyrex.Distutils import build_ext 29 from Cython.Distutils import build_ext
30 from os.path import basename, join, exists 30 from os.path import basename, join, exists
31 31
32 def ReadSetup(filename): 32 def ReadSetup(filename):
33 """ReadSetup goes through filename and parses out the values stored 33 """ReadSetup goes through filename and parses out the values stored
34 in the file. Values need to be stored in a 34 in the file. Values need to be stored in a
35 \"key=value format\"""" 35 \"key=value format\""""
36 return dict(line.split('=', 1) for line in open(filename)) 36 return dict(line.split('=', 1) for line in open(filename))
37 37
38 def ParseCPPFlags(flags): 38 def ParseCPPFlags(flags):
39 """parse the CPPFlags macro""" 39 """parse the CPPFlags macro"""
40 incl_dir = [x[2:] for x in flags.split() if x.startswith("-I")] 40 incl_dir = [x[2:] for x in flags.split() if x.startswith("-I")]
41 cppflags = [x for x in flags.split() if not x.startswith("-I")] 41 cppflags = [x for x in flags.split() if not x.startswith("-I")]
42 cppflags.append("-DYASM_LIB_INTERNAL") 42 cppflags.append("-DYASM_LIB_INTERNAL")
43 cppflags.append("-DYASM_BC_INTERNAL") 43 cppflags.append("-DYASM_BC_INTERNAL")
44 cppflags.append("-DYASM_EXPR_INTERNAL") 44 cppflags.append("-DYASM_EXPR_INTERNAL")
45 return (incl_dir, cppflags) 45 return (incl_dir, cppflags)
46 46
47 def ParseSources(src, srcdir): 47 def ParseSources(src, srcdir):
48 """parse the Sources macro""" 48 """parse the Sources macro"""
49 # do the dance of detecting if the source file is in the current 49 # do the dance of detecting if the source file is in the current
50 # directory, and if it's not, prepend srcdir 50 # directory, and if it's not, prepend srcdir
51 sources = [] 51 sources = []
52 for tok in src.split(): 52 for tok in src.split():
53 if tok.endswith(".c"): 53 if tok.endswith(".c"):
54 fn = tok 54 fn = tok
55 elif tok.endswith(".y"):
56 fn = basename(tok)[:-2] + ".c"
57 else: 55 else:
58 continue 56 continue
59 if not exists(fn): 57 if not exists(fn):
60 fn = join(srcdir, fn) 58 fn = join(srcdir, fn)
61 sources.append(fn) 59 sources.append(fn)
62 60
63 return sources 61 return sources
64 62
65 def RunSetup(incldir, cppflags, sources): 63 def RunSetup(incldir, cppflags, sources):
66 setup( 64 setup(
67 name='yasm', 65 name='yasm',
68 version='0.0', 66 version='0.0',
69 description='Python bindings for Yasm', 67 description='Python bindings for Yasm',
70 author='Michael Urman, Peter Johnson', 68 author='Michael Urman, Peter Johnson',
71 url='http://www.tortall.net/projects/yasm', 69 url='http://www.tortall.net/projects/yasm',
72 ext_modules=[ 70 ext_modules=[
73 Extension('yasm', 71 Extension('yasm',
74 sources=sources, 72 sources=sources,
75 extra_compile_args=cppflags, 73 extra_compile_args=cppflags,
76 include_dirs=incldir, 74 include_dirs=incldir,
77 library_dirs=['.'],
78 libraries=['yasm'],
79 ), 75 ),
80 ], 76 ],
81 cmdclass = dict(build_ext=build_ext), 77 cmdclass = dict(build_ext=build_ext),
82 ) 78 )
83 79
84 if __name__ == "__main__": 80 if __name__ == "__main__":
85 opts = ReadSetup("python-setup.txt") 81 opts = ReadSetup("python-setup.txt")
86 incldir, cppflags = ParseCPPFlags(opts["includes"]) 82 incldir, cppflags = ParseCPPFlags(opts["includes"])
87 sources = ParseSources(opts["sources"], opts["srcdir"].strip()) 83 sources = ParseSources(opts["sources"], opts["srcdir"].strip())
88 sources.append('yasm_python.c') 84 sources.append('yasm_python.c')
89 if opts["gcc"].strip() == "yes": 85 if opts["gcc"].strip() == "yes":
90 cppflags.append('-w') 86 cppflags.append('-w')
91 RunSetup(incldir, cppflags, sources) 87 RunSetup(incldir, cppflags, sources)
92 88
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698