Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 274 lines (209 sloc) 7.117 kb
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
1 #!/usr/bin/env python
5cf4ceff »
2010-10-25 add configure
2
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
3 import optparse
4 import os
45605c9b »
2011-12-18 gyp: switch json for pprint when generating config
5 import pprint
b9e1bb3d »
2011-11-15 build: auto-run tools/gyp_node after ./configure
6 import subprocess
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
7 import sys
5cf4ceff »
2010-10-25 add configure
8
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
9 root_dir = os.path.dirname(__file__)
10 sys.path.insert(0, os.path.join(root_dir, 'deps', 'v8', 'tools'))
97c97450 »
2010-11-01 Back to WAF
11
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
12 # parse our options
13 parser = optparse.OptionParser()
97c97450 »
2010-11-01 Back to WAF
14
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
15 parser.add_option("--debug",
16 action="store_true",
17 dest="debug",
18 help="Also build debug build")
19
20 parser.add_option("--prefix",
21 action="store",
22 dest="prefix",
23 help="Select the install prefix (defaults to /usr/local)")
24
a9f2c4aa »
2011-12-17 --without-npm option
25 parser.add_option("--without-npm",
26 action="store_true",
27 dest="without_npm",
28 help="Don\'t install the bundled npm package manager")
29
b3d4938e »
2011-11-29 build: add --without-isolates configure switch
30 parser.add_option("--without-isolates",
31 action="store_true",
32 dest="without_isolates",
33 help="Build without isolates (no threads, single loop) [Default: False]")
34
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
35 parser.add_option("--without-ssl",
36 action="store_true",
37 dest="without_ssl",
38 help="Build without SSL")
39
40 parser.add_option("--without-snapshot",
41 action="store_true",
42 dest="without_snapshot",
43 help="Build without snapshotting V8 libraries. You might want to set"
44 " this for cross-compiling. [Default: False]")
45
46 parser.add_option("--shared-v8",
47 action="store_true",
48 dest="shared_v8",
49 help="Link to a shared V8 DLL instead of static linking")
50
51 parser.add_option("--shared-v8-includes",
52 action="store",
53 dest="shared_v8_includes",
54 help="Directory containing V8 header files")
55
56 parser.add_option("--shared-v8-libpath",
57 action="store",
58 dest="shared_v8_libpath",
59 help="A directory to search for the shared V8 DLL")
60
61 parser.add_option("--shared-v8-libname",
62 action="store",
63 dest="shared_v8_libname",
64 help="Alternative lib name to link to (default: 'v8')")
65
e61de70c »
2011-12-16 gyp: use built-in openssl by default
66 parser.add_option("--openssl-use-sys",
67 action="store",
68 dest="openssl_use_sys",
69 help="Use the system OpenSSL instead of one included with Node")
70
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
71 parser.add_option("--openssl-includes",
72 action="store",
73 dest="openssl_includes",
74 help="A directory to search for the OpenSSL includes")
75
76 parser.add_option("--openssl-libpath",
77 action="store",
78 dest="openssl_libpath",
79 help="A directory to search for the OpenSSL libraries")
80
81 parser.add_option("--no-ssl2",
82 action="store_true",
83 dest="no_ssl2",
84 help="Disable OpenSSL v2")
85
86 parser.add_option("--shared-cares",
87 action="store_true",
88 dest="shared_cares",
89 help="Link to a shared C-Ares DLL instead of static linking")
90
91 parser.add_option("--shared-cares-includes",
92 action="store",
93 dest="shared_cares_includes",
94 help="Directory containing C-Ares header files")
95
96 parser.add_option("--shared-cares-libpath",
97 action="store",
98 dest="shared_cares_libpath",
99 help="A directory to search for the shared C-Ares DLL")
100
101 parser.add_option("--with-dtrace",
102 action="store_true",
103 dest="with_dtrace",
104 help="Build with DTrace (experimental)")
105
106 # CHECKME does this still work with recent releases of V8?
107 parser.add_option("--gdb",
108 action="store_true",
109 dest="gdb",
110 help="add gdb support")
111
112 parser.add_option("--dest-cpu",
113 action="store",
114 dest="dest_cpu",
115 help="CPU architecture to build for. Valid values are: arm, ia32, x64")
116
117 (options, args) = parser.parse_args()
118
119
a033261f »
2011-11-29 build: DRY configure script
120 def b(value):
121 """Returns the string 'true' if value is truthy, 'false' otherwise."""
122 if value:
123 return 'true'
124 else:
125 return 'false'
126
127
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
128 def pkg_config(pkg):
129 cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
130 libs = cmd.readline().strip()
131 ret = cmd.close()
132 if (ret): return None
133
134 cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
135 cflags = cmd.readline().strip()
136 ret = cmd.close()
137 if (ret): return None
138
139 return (libs, cflags)
140
141
142 def uname(switch):
143 f = os.popen('uname %s' % switch)
144 s = f.read().strip()
145 f.close()
146 return s
147
148
149 def host_arch():
150 """Host architecture. One of arm, ia32 or x64."""
151 arch = uname('-p')
152
153 if arch == 'unknown':
154 arch = uname('-m')
155
156 return {
157 'arm': 'arm',
158 'x86': 'ia32',
159 'i386': 'ia32',
160 'x86_64': 'x64',
161 }.get(arch, 'ia32')
162
163
164 def target_arch():
165 # TODO act on options.dest_cpu
166 return host_arch()
167
168
169 def configure_node(o):
170 # TODO add gdb and dest_cpu
b3d4938e »
2011-11-29 build: add --without-isolates configure switch
171 o['variables']['node_use_isolates'] = b(not options.without_isolates)
a033261f »
2011-11-29 build: DRY configure script
172 o['variables']['node_debug'] = b(options.debug)
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
173 o['variables']['node_prefix'] = options.prefix if options.prefix else ''
a033261f »
2011-11-29 build: DRY configure script
174 o['variables']['node_use_dtrace'] = b(options.with_dtrace)
a9f2c4aa »
2011-12-17 --without-npm option
175 o['variables']['node_install_npm'] = b(not options.without_npm)
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
176 o['variables']['host_arch'] = host_arch()
177 o['variables']['target_arch'] = target_arch()
178
179 # TODO move to node.gyp
180 if sys.platform == 'sunos5':
181 o['variables']['visibility'] = '' # FIXME -fvisibility=hidden, should be a gcc check
182
183
184 def configure_libz(o):
185 o['libraries'] += ['-lz']
186
187
188 def configure_v8(o):
a033261f »
2011-11-29 build: DRY configure script
189 o['variables']['v8_use_snapshot'] = b(not options.without_snapshot)
190 o['variables']['node_shared_v8'] = b(options.shared_v8)
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
191
192 # assume shared_v8 if one of these is set?
193 if options.shared_v8_libpath:
194 o['libraries'] += ['-L%s' % options.shared_v8_libpath]
195 if options.shared_v8_libname:
196 o['libraries'] += ['-l%s' % options.shared_v8_libname]
197 if options.shared_v8_includes:
198 o['include_dirs'] += [options.shared_v8_includes]
199
200
201 def configure_cares(o):
a033261f »
2011-11-29 build: DRY configure script
202 o['variables']['node_shared_cares'] = b(options.shared_cares)
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
203
204 # assume shared_cares if one of these is set?
205 if options.shared_cares_libpath:
206 o['libraries'] += ['-L%s' % options.shared_cares_libpath]
207 if options.shared_cares_includes:
208 o['include_dirs'] += [options.shared_cares_includes]
209
210
211 def configure_openssl(o):
a033261f »
2011-11-29 build: DRY configure script
212 o['variables']['node_use_openssl'] = b(not options.without_ssl)
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
213
214 if options.without_ssl:
215 return
216
217 if options.no_ssl2:
218 o['defines'] += ['OPENSSL_NO_SSL2=1']
219
e61de70c »
2011-12-16 gyp: use built-in openssl by default
220 if not options.openssl_use_sys:
221 o['variables']['node_use_system_openssl'] = b(False)
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
222 else:
e61de70c »
2011-12-16 gyp: use built-in openssl by default
223 out = pkg_config('openssl')
224 (libs, cflags) = out if out else ('', '')
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
225
e61de70c »
2011-12-16 gyp: use built-in openssl by default
226 if options.openssl_libpath:
227 o['libraries'] += ['-L%s' % options.openssl_libpath, '-lssl', '-lcrypto']
228 else:
229 o['libraries'] += libs.split()
230
231 if options.openssl_includes:
232 o['include_dirs'] += [options.openssl_includes]
233 else:
234 o['cflags'] += cflags.split()
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
235
e61de70c »
2011-12-16 gyp: use built-in openssl by default
236 o['variables']['node_use_system_openssl'] = b(
237 libs or cflags or options.openssl_libpath or options.openssl_includes)
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
238
239
240 output = {
241 'variables': {},
242 'include_dirs': [],
243 'libraries': [],
244 'defines': [],
245 'cflags': [],
246 }
247
248 configure_node(output)
249 configure_libz(output)
250 configure_v8(output)
251 configure_cares(output)
252 configure_openssl(output)
253
254 # variables should be a root level element,
255 # move everything else to target_defaults
256 variables = output['variables']
257 del output['variables']
258 output = {
259 'variables': variables,
260 'target_defaults': output
261 }
624f70e8 »
2011-12-23 GYP: rename options.gypi to config.gypi
262 pprint.pprint(output, indent=2)
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
263
624f70e8 »
2011-12-23 GYP: rename options.gypi to config.gypi
264 fn = os.path.join(root_dir, 'config.gypi')
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
265 print "creating ", fn
266
267 f = open(fn, 'w+')
268 f.write("# Do not edit. Generated by the configure script.\n")
45605c9b »
2011-12-18 gyp: switch json for pprint when generating config
269 pprint.pprint(output, stream=f, indent=2)
14b04b06 »
2011-11-14 Remove SCONS deprecate WAF
270 f.write("\n")
271 f.close()
97c97450 »
2010-11-01 Back to WAF
272
48d21dd5 »
2011-11-17 Force makefile generation in gyp
273 subprocess.call(['tools/gyp_node','-f', 'make'])
Something went wrong with that request. Please try again.