]>
git.proxmox.com Git - rustc.git/blob - src/libuv/gyp_uv
9 CC
= os
.environ
.get('CC', 'cc')
10 script_dir
= os
.path
.dirname(__file__
)
11 uv_root
= os
.path
.normpath(script_dir
)
12 output_dir
= os
.path
.join(os
.path
.abspath(uv_root
), 'out')
14 sys
.path
.insert(0, os
.path
.join(uv_root
, 'build', 'gyp', 'pylib'))
18 print('You need to install gyp in build/gyp first. See the README.')
23 machine
= platform
.machine()
24 if machine
== 'i386': return 'ia32'
25 if machine
== 'x86_64': return 'x64'
26 if machine
.startswith('arm'): return 'arm'
27 return machine
# Return as-is and hope for the best.
30 def compiler_version():
31 proc
= subprocess
.Popen(CC
.split() + ['--version'], stdout
=subprocess
.PIPE
)
32 is_clang
= 'clang' in proc
.communicate()[0].split('\n')[0]
33 proc
= subprocess
.Popen(CC
.split() + ['-dumpversion'], stdout
=subprocess
.PIPE
)
34 version
= proc
.communicate()[0].split('.')
35 version
= map(int, version
[:2])
36 version
= tuple(version
)
37 return (version
, is_clang
)
43 print 'Error running GYP'
47 if __name__
== '__main__':
51 # On msvs it will crash if it gets an absolute path.
52 # On Mac/make it will crash if it doesn't get an absolute path.
53 if sys
.platform
== 'win32':
54 args
.append(os
.path
.join(uv_root
, 'uv.gyp'))
55 common_fn
= os
.path
.join(uv_root
, 'common.gypi')
56 options_fn
= os
.path
.join(uv_root
, 'options.gypi')
57 # we force vs 2010 over 2008 which would otherwise be the default for gyp
58 if not os
.environ
.get('GYP_MSVS_VERSION'):
59 os
.environ
['GYP_MSVS_VERSION'] = '2010'
61 args
.append(os
.path
.join(os
.path
.abspath(uv_root
), 'uv.gyp'))
62 common_fn
= os
.path
.join(os
.path
.abspath(uv_root
), 'common.gypi')
63 options_fn
= os
.path
.join(os
.path
.abspath(uv_root
), 'options.gypi')
65 if os
.path
.exists(common_fn
):
66 args
.extend(['-I', common_fn
])
68 if os
.path
.exists(options_fn
):
69 args
.extend(['-I', options_fn
])
71 args
.append('--depth=' + uv_root
)
73 # There's a bug with windows which doesn't allow this feature.
74 if sys
.platform
!= 'win32':
76 args
.extend('-f make'.split())
77 if 'ninja' not in args
:
78 args
.extend(['-Goutput_dir=' + output_dir
])
79 args
.extend(['--generator-output', output_dir
])
80 (major
, minor
), is_clang
= compiler_version()
81 args
.append('-Dgcc_version=%d' % (10 * major
+ minor
))
82 args
.append('-Dclang=%d' % int(is_clang
))
84 if not any(a
.startswith('-Dhost_arch=') for a
in args
):
85 args
.append('-Dhost_arch=%s' % host_arch())
87 if not any(a
.startswith('-Dtarget_arch=') for a
in args
):
88 args
.append('-Dtarget_arch=%s' % host_arch())
90 if not any(a
.startswith('-Dlibrary=') for a
in args
):
91 args
.append('-Dlibrary=static_library')
93 if not any(a
.startswith('-Dcomponent=') for a
in args
):
94 args
.append('-Dcomponent=static_library')