Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 747 lines (620 sloc) 25.985 kB
97c9745 @ry Back to WAF
ry authored
1 #!/usr/bin/env python
2 import re
3 import Options
4 import sys, os, shutil
5 from Utils import cmd_output
6 from os.path import join, dirname, abspath
7 from logging import fatal
8
9 cwd = os.getcwd()
10 APPNAME="node.js"
11
a326eeb @ry Put tools/ into PYTHON_PATH
ry authored
12 # Use the directory that this file is found in to find the tools
13 # directory where the js2c.py file can be found.
14 sys.path.append(sys.argv[0] + '/tools');
97c9745 @ry Back to WAF
ry authored
15 import js2c
16
17 srcdir = '.'
18 blddir = 'build'
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
19 supported_archs = ('arm', 'ia32', 'x64') # 'mips' supported by v8, but not node
97c9745 @ry Back to WAF
ry authored
20
21 jobs=1
22 if os.environ.has_key('JOBS'):
23 jobs = int(os.environ['JOBS'])
24
6f08fdb @piscisaureus Backslashes in paths wreak havoc
piscisaureus authored
25 def safe_path(path):
26 return path.replace("\\", "/")
97c9745 @ry Back to WAF
ry authored
27
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
28 def canonical_cpu_type(arch):
25eecd1 @ry Fix configure on x86
ry authored
29 m = {'x86': 'ia32', 'i386':'ia32', 'x86_64':'x64', 'amd64':'x64'}
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
30 if arch in m: arch = m[arch]
31 if not arch in supported_archs:
32 raise Exception("supported architectures are "+', '.join(supported_archs)+\
33 " but NOT '" + arch + "'.")
34 return arch
35
97c9745 @ry Back to WAF
ry authored
36 def set_options(opt):
37 # the gcc module provides a --debug-level option
38 opt.tool_options('compiler_cxx')
39 opt.tool_options('compiler_cc')
40 opt.tool_options('misc')
41 opt.add_option( '--debug'
42 , action='store_true'
43 , default=False
44 , help='Build debug variant [Default: False]'
45 , dest='debug'
46 )
5d80bdb @bnoordhuis Add --profile flag to configure script, enables gprof profiling.
bnoordhuis authored
47 opt.add_option( '--profile'
48 , action='store_true'
49 , default=False
50 , help='Enable profiling [Default: False]'
51 , dest='profile'
52 )
97c9745 @ry Back to WAF
ry authored
53 opt.add_option( '--efence'
54 , action='store_true'
55 , default=False
56 , help='Build with -lefence for debugging [Default: False]'
57 , dest='efence'
58 )
59
60 opt.add_option( '--without-snapshot'
61 , action='store_true'
62 , default=False
63 , help='Build without snapshotting V8 libraries. You might want to set this for cross-compiling. [Default: False]'
64 , dest='without_snapshot'
65 )
66
67 opt.add_option( '--without-ssl'
68 , action='store_true'
69 , default=False
70 , help='Build without SSL'
71 , dest='without_ssl'
72 )
73
74
75 opt.add_option('--shared-v8'
76 , action='store_true'
77 , default=False
78 , help='Link to a shared V8 DLL instead of static linking'
79 , dest='shared_v8'
80 )
81
82 opt.add_option( '--shared-v8-includes'
83 , action='store'
84 , default=False
85 , help='Directory containing V8 header files'
86 , dest='shared_v8_includes'
87 )
88
89 opt.add_option( '--shared-v8-libpath'
90 , action='store'
91 , default=False
92 , help='A directory to search for the shared V8 DLL'
93 , dest='shared_v8_libpath'
94 )
95
96 opt.add_option( '--shared-v8-libname'
97 , action='store'
98 , default=False
99 , help="Alternative lib name to link to (default: 'v8')"
100 , dest='shared_v8_libname'
101 )
102
33685fe @ry Add configure flag for oprofile
ry authored
103 opt.add_option( '--oprofile'
104 , action='store_true'
105 , default=False
106 , help="add oprofile support"
107 , dest='use_oprofile'
108 )
109
97c9745 @ry Back to WAF
ry authored
110
111 opt.add_option('--shared-cares'
112 , action='store_true'
113 , default=False
114 , help='Link to a shared C-Ares DLL instead of static linking'
115 , dest='shared_cares'
116 )
117
118 opt.add_option( '--shared-cares-includes'
119 , action='store'
120 , default=False
121 , help='Directory containing C-Ares header files'
122 , dest='shared_cares_includes'
123 )
124
125 opt.add_option( '--shared-cares-libpath'
126 , action='store'
127 , default=False
128 , help='A directory to search for the shared C-Ares DLL'
129 , dest='shared_cares_libpath'
130 )
131
132
133 opt.add_option('--shared-libev'
134 , action='store_true'
135 , default=False
136 , help='Link to a shared libev DLL instead of static linking'
137 , dest='shared_libev'
138 )
139
140 opt.add_option( '--shared-libev-includes'
141 , action='store'
142 , default=False
143 , help='Directory containing libev header files'
144 , dest='shared_libev_includes'
145 )
146
147 opt.add_option( '--shared-libev-libpath'
148 , action='store'
149 , default=False
150 , help='A directory to search for the shared libev DLL'
151 , dest='shared_libev_libpath'
152 )
153
154
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
155 opt.add_option( '--product-type'
156 , action='store'
157 , default='program'
158 , help='What kind of product to produce (program, cstaticlib '\
159 'or cshlib) [default: %default]'
160 , dest='product_type'
161 )
162
163 opt.add_option( '--dest-cpu'
164 , action='store'
165 , default=None
166 , help='CPU architecture to build for. Valid values are: '+\
167 ', '.join(supported_archs)
168 , dest='dest_cpu'
169 )
170
171
97c9745 @ry Back to WAF
ry authored
172
173
174 def configure(conf):
175 conf.check_tool('compiler_cxx')
176 if not conf.env.CXX: conf.fatal('c++ compiler not found')
177 conf.check_tool('compiler_cc')
178 if not conf.env.CC: conf.fatal('c compiler not found')
179
180 o = Options.options
181
182 conf.env["USE_DEBUG"] = o.debug
13699c1 @piscisaureus V8: Don't attempt to build w/ snapshot, doesn't seem to work on mingw32
piscisaureus authored
183 # Snapshot building does noet seem to work on mingw32
184 conf.env["SNAPSHOT_V8"] = not o.without_snapshot and not sys.platform.startswith("win32")
c9d3a81 @ry Patch V8 to compile on solaris
ry authored
185 if sys.platform.startswith("sunos"):
186 conf.env["SNAPSHOT_V8"] = False
5d80bdb @bnoordhuis Add --profile flag to configure script, enables gprof profiling.
bnoordhuis authored
187 conf.env["USE_PROFILING"] = o.profile
97c9745 @ry Back to WAF
ry authored
188
189 conf.env["USE_SHARED_V8"] = o.shared_v8 or o.shared_v8_includes or o.shared_v8_libpath or o.shared_v8_libname
190 conf.env["USE_SHARED_CARES"] = o.shared_cares or o.shared_cares_includes or o.shared_cares_libpath
191 conf.env["USE_SHARED_LIBEV"] = o.shared_libev or o.shared_libev_includes or o.shared_libev_libpath
192
33685fe @ry Add configure flag for oprofile
ry authored
193 conf.env["USE_OPROFILE"] = o.use_oprofile
194
7d73779 @ry Make oprofile work
ry authored
195 if o.use_oprofile:
196 conf.check(lib=['bfd', 'opagent'], uselib_store="OPROFILE")
197
97c9745 @ry Back to WAF
ry authored
198 conf.check(lib='dl', uselib_store='DL')
d56e1a3 @piscisaureus No -rdynamic and -pthread flags when building with mingw
piscisaureus authored
199 if not sys.platform.startswith("sunos") and not sys.platform.startswith("cygwin") and not sys.platform.startswith("win32"):
97c9745 @ry Back to WAF
ry authored
200 conf.env.append_value("CCFLAGS", "-rdynamic")
201 conf.env.append_value("LINKFLAGS_DL", "-rdynamic")
202
d75c338 @mscdex Add more functionality to the os module
mscdex authored
203 if sys.platform.startswith("freebsd") or sys.platform.startswith("openbsd"):
97c9745 @ry Back to WAF
ry authored
204 conf.check(lib='kvm', uselib_store='KVM')
205
206 #if Options.options.debug:
207 # conf.check(lib='profiler', uselib_store='PROFILER')
208
209 if Options.options.efence:
210 conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE')
211
212 if sys.platform.startswith("freebsd"):
213 if not conf.check(lib="execinfo",
214 includes=['/usr/include', '/usr/local/include'],
215 libpath=['/usr/lib', '/usr/local/lib'],
216 uselib_store="EXECINFO"):
217 conf.fatal("Install the libexecinfo port from /usr/ports/devel/libexecinfo.")
218
219 if not Options.options.without_ssl:
220 if conf.check_cfg(package='openssl',
221 args='--cflags --libs',
222 uselib_store='OPENSSL'):
223 Options.options.use_openssl = conf.env["USE_OPENSSL"] = True
224 conf.env.append_value("CPPFLAGS", "-DHAVE_OPENSSL=1")
225 else:
952bbb8 @mscdex Fix OpenSSL SSL_library_init function check on OpenBSD.
mscdex authored
226 libssl = conf.check_cc(lib=['ssl', 'crypto'],
97c9745 @ry Back to WAF
ry authored
227 header_name='openssl/ssl.h',
228 function_name='SSL_library_init',
229 libpath=['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/usr/sfw/lib'],
230 uselib_store='OPENSSL')
231 libcrypto = conf.check_cc(lib='crypto',
232 header_name='openssl/crypto.h',
233 uselib_store='OPENSSL')
234 if libcrypto and libssl:
235 conf.env["USE_OPENSSL"] = Options.options.use_openssl = True
236 conf.env.append_value("CPPFLAGS", "-DHAVE_OPENSSL=1")
237 else:
238 conf.fatal("Could not autodetect OpenSSL support. " +
239 "Make sure OpenSSL development packages are installed. " +
240 "Use configure --without-ssl to disable this message.")
241 else:
242 Options.options.use_openssl = conf.env["USE_OPENSSL"] = False
243
a0e9a51 @ry Introduce require('tty')
ry authored
244 conf.check(lib='util', libpath=['/usr/lib', '/usr/local/lib'],
245 uselib_store='UTIL')
246
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
247 # normalize DEST_CPU from --dest-cpu, DEST_CPU or built-in value
248 if Options.options.dest_cpu and Options.options.dest_cpu:
249 conf.env['DEST_CPU'] = canonical_cpu_type(Options.options.dest_cpu)
250 elif 'DEST_CPU' in os.environ and os.environ['DEST_CPU']:
251 conf.env['DEST_CPU'] = canonical_cpu_type(os.environ['DEST_CPU'])
252 elif 'DEST_CPU' in conf.env and conf.env['DEST_CPU']:
253 conf.env['DEST_CPU'] = canonical_cpu_type(conf.env['DEST_CPU'])
254
97c9745 @ry Back to WAF
ry authored
255 conf.check(lib='rt', uselib_store='RT')
256
257 if sys.platform.startswith("sunos"):
258 if not conf.check(lib='socket', uselib_store="SOCKET"):
259 conf.fatal("Cannot find socket library")
260 if not conf.check(lib='nsl', uselib_store="NSL"):
261 conf.fatal("Cannot find nsl library")
262
263 conf.sub_config('deps/libeio')
264
265 if conf.env['USE_SHARED_V8']:
266 v8_includes = [];
267 if o.shared_v8_includes: v8_includes.append(o.shared_v8_includes);
268
269 v8_libpath = [];
270 if o.shared_v8_libpath: v8_libpath.append(o.shared_v8_libpath);
271
272 if not o.shared_v8_libname: o.shared_v8_libname = 'v8'
273
274 if not conf.check_cxx(lib=o.shared_v8_libname, header_name='v8.h',
275 uselib_store='V8',
276 includes=v8_includes,
277 libpath=v8_libpath):
278 conf.fatal("Cannot find v8")
279
280 if o.debug:
281 if not conf.check_cxx(lib=o.shared_v8_libname + '_g', header_name='v8.h',
282 uselib_store='V8_G',
283 includes=v8_includes,
284 libpath=v8_libpath):
285 conf.fatal("Cannot find v8_g")
286
276b0b1 @piscisaureus Always use statically linked c-ares on windows; fix build
piscisaureus authored
287 if sys.platform.startswith("win32"):
288 # On win32 CARES is always static, so we can call internal functions like ares_inet_pton et al.
289 # CARES_STATICLIB must be defined or gcc will try to make DLL stub calls
290 conf.env.append_value('CPPFLAGS', '-DCARES_STATICLIB=1')
291 conf.sub_config('deps/c-ares')
292 elif conf.env['USE_SHARED_CARES']:
97c9745 @ry Back to WAF
ry authored
293 cares_includes = [];
294 if o.shared_cares_includes: cares_includes.append(o.shared_cares_includes);
295 cares_libpath = [];
296 if o.shared_cares_libpath: cares_libpath.append(o.shared_cares_libpath);
297 if not conf.check_cxx(lib='cares',
298 header_name='ares.h',
299 uselib_store='CARES',
300 includes=cares_includes,
301 libpath=cares_libpath):
302 conf.fatal("Cannot find c-ares")
303 else:
304 conf.sub_config('deps/c-ares')
305
306
307 if conf.env['USE_SHARED_LIBEV']:
308 libev_includes = [];
309 if o.shared_libev_includes: libev_includes.append(o.shared_libev_includes);
310 libev_libpath = [];
311 if o.shared_libev_libpath: libev_libpath.append(o.shared_libev_libpath);
312 if not conf.check_cxx(lib='ev', header_name='ev.h',
313 uselib_store='EV',
314 includes=libev_includes,
315 libpath=libev_libpath):
316 conf.fatal("Cannot find libev")
317 else:
318 conf.sub_config('deps/libev')
319
320
321
322 conf.define("HAVE_CONFIG_H", 1)
323
324 if sys.platform.startswith("sunos"):
325 conf.env.append_value ('CCFLAGS', '-threads')
326 conf.env.append_value ('CXXFLAGS', '-threads')
327 #conf.env.append_value ('LINKFLAGS', ' -threads')
d56e1a3 @piscisaureus No -rdynamic and -pthread flags when building with mingw
piscisaureus authored
328 elif not sys.platform.startswith("cygwin") and not sys.platform.startswith("win32"):
97c9745 @ry Back to WAF
ry authored
329 threadflags='-pthread'
330 conf.env.append_value ('CCFLAGS', threadflags)
331 conf.env.append_value ('CXXFLAGS', threadflags)
332 conf.env.append_value ('LINKFLAGS', threadflags)
333 if sys.platform.startswith("darwin"):
334 # used by platform_darwin_*.cc
335 conf.env.append_value('LINKFLAGS', ['-framework','Carbon'])
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
336 # cross compile for architecture specified by DEST_CPU
337 if 'DEST_CPU' in conf.env:
338 arch = conf.env['DEST_CPU']
339 # map supported_archs to GCC names:
340 arch_mappings = {'ia32': 'i386', 'x64': 'x86_64'}
341 if arch in arch_mappings:
342 arch = arch_mappings[arch]
343 flags = ['-arch', arch]
344 conf.env.append_value('CCFLAGS', flags)
345 conf.env.append_value('CXXFLAGS', flags)
346 conf.env.append_value('LINKFLAGS', flags)
347 if 'DEST_CPU' in conf.env:
348 arch = conf.env['DEST_CPU']
349 # TODO: -m32 is only available on 64 bit machines, so check host type
350 flags = None
351 if arch == 'ia32':
352 flags = '-m32'
353 if flags:
354 conf.env.append_value('CCFLAGS', flags)
355 conf.env.append_value('CXXFLAGS', flags)
356 conf.env.append_value('LINKFLAGS', flags)
97c9745 @ry Back to WAF
ry authored
357
358 # Needed for getaddrinfo in libeio
359 conf.env.append_value("CPPFLAGS", "-DX_STACKSIZE=%d" % (1024*64))
360 # LFS
361 conf.env.append_value('CPPFLAGS', '-D_LARGEFILE_SOURCE')
362 conf.env.append_value('CPPFLAGS', '-D_FILE_OFFSET_BITS=64')
363 conf.env.append_value('CPPFLAGS', '-DEV_MULTIPLICITY=0')
364
2655269 @piscisaureus Make select work on >64 FDs on windows
piscisaureus authored
365 # Makes select on windows support more than 64 FDs
366 if sys.platform.startswith("win32"):
367 conf.env.append_value('CPPFLAGS', '-DFD_SETSIZE=1024');
368
97c9745 @ry Back to WAF
ry authored
369 ## needed for node_file.cc fdatasync
370 ## Strangely on OSX 10.6 the g++ doesn't see fdatasync but gcc does?
371 code = """
372 #include <unistd.h>
373 int main(void)
374 {
375 int fd = 0;
376 fdatasync (fd);
377 return 0;
378 }
379 """
380 if conf.check_cxx(msg="Checking for fdatasync(2) with c++", fragment=code):
381 conf.env.append_value('CPPFLAGS', '-DHAVE_FDATASYNC=1')
382 else:
383 conf.env.append_value('CPPFLAGS', '-DHAVE_FDATASYNC=0')
384
385 # platform
386 conf.env.append_value('CPPFLAGS', '-DPLATFORM="' + conf.env['DEST_OS'] + '"')
387
99ba903 @piscisaureus win: Define __POSIX__ constant when the platform is POSIX-y
piscisaureus authored
388 # posix?
389 if not sys.platform.startswith('win'):
390 conf.env.append_value('CPPFLAGS', '-D__POSIX__=1')
391
4737219 @ry Print warning when using platform_none.cc
ry authored
392 platform_file = "src/platform_%s.cc" % conf.env['DEST_OS']
393 if os.path.exists(join(cwd, platform_file)):
394 Options.options.platform_file = True
395 conf.env["PLATFORM_FILE"] = platform_file
396 else:
397 Options.options.platform_file = False
398 conf.env["PLATFORM_FILE"] = "src/platform_none.cc"
399
5d80bdb @bnoordhuis Add --profile flag to configure script, enables gprof profiling.
bnoordhuis authored
400 if conf.env['USE_PROFILING'] == True:
401 conf.env.append_value('CPPFLAGS', '-pg')
402 conf.env.append_value('LINKFLAGS', '-pg')
403
f37cc87 @piscisaureus On windows, link with Winsock and WinMM
piscisaureus authored
404 if sys.platform.startswith("win32"):
405 conf.env.append_value('LIB', 'ws2_32')
406 conf.env.append_value('LIB', 'winmm')
407
a87172f @bnoordhuis Compile with `-Wno-unused-parameter -D_FORTIFY_SOURCE=2`
bnoordhuis authored
408 conf.env.append_value('CPPFLAGS', '-Wno-unused-parameter');
409 conf.env.append_value('CPPFLAGS', '-D_FORTIFY_SOURCE=2');
410
97c9745 @ry Back to WAF
ry authored
411 # Split off debug variant before adding variant specific defines
412 debug_env = conf.env.copy()
413 conf.set_env_name('debug', debug_env)
4a2cb07 @piscisaureus Fix whitespace errors introduced by porting efforts
piscisaureus authored
414
62af617 @piscisaureus Dynamically link with pthreads-w32
piscisaureus authored
415 if (sys.platform.startswith("win32")):
416 # Static pthread - crashes
417 #conf.env.append_value('LINKFLAGS', '../deps/pthreads-w32/libpthreadGC2.a')
418 #debug_env.append_value('LINKFLAGS', '../deps/pthreads-w32/libpthreadGC2d.a')
419 # Pthread dll
420 conf.env.append_value('LIB', 'pthread.dll')
97c9745 @ry Back to WAF
ry authored
421
422 # Configure debug variant
423 conf.setenv('debug')
424 debug_env.set_variant('debug')
425 debug_env.append_value('CPPFLAGS', '-DDEBUG')
426 debug_compile_flags = ['-g', '-O0', '-Wall', '-Wextra']
427 debug_env.append_value('CCFLAGS', debug_compile_flags)
428 debug_env.append_value('CXXFLAGS', debug_compile_flags)
429 conf.write_config_header("config.h")
430
431 # Configure default variant
432 conf.setenv('default')
433 conf.env.append_value('CPPFLAGS', '-DNDEBUG')
434 default_compile_flags = ['-g', '-O3']
435 conf.env.append_value('CCFLAGS', default_compile_flags)
436 conf.env.append_value('CXXFLAGS', default_compile_flags)
437 conf.write_config_header("config.h")
438
439
440 def v8_cmd(bld, variant):
441 scons = join(cwd, 'tools/scons/scons.py')
442 deps_src = join(bld.path.abspath(),"deps")
443 v8dir_src = join(deps_src,"v8")
444
445 # NOTE: We want to compile V8 to export its symbols. I.E. Do not want
446 # -fvisibility=hidden. When using dlopen() it seems that the loaded DSO
447 # cannot see symbols in the executable which are hidden, even if the
448 # executable is statically linked together...
449
450 # XXX Change this when v8 defaults x86_64 to native builds
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
451 # Possible values are (arm, ia32, x64, mips).
97c9745 @ry Back to WAF
ry authored
452 arch = ""
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
453 if bld.env['DEST_CPU']:
454 arch = "arch="+bld.env['DEST_CPU']
97c9745 @ry Back to WAF
ry authored
455
456 if variant == "default":
457 mode = "release"
458 else:
459 mode = "debug"
460
461 if bld.env["SNAPSHOT_V8"]:
462 snapshot = "snapshot=on"
463 else:
464 snapshot = ""
465
33685fe @ry Add configure flag for oprofile
ry authored
466 if bld.env["USE_OPROFILE"]:
467 profile = "prof=oprofile"
468 else:
469 profile = ""
470
471 cmd_R = sys.executable + ' "%s" -j %d -C "%s" -Y "%s" visibility=default mode=%s %s library=static %s %s'
97c9745 @ry Back to WAF
ry authored
472
473 cmd = cmd_R % ( scons
474 , Options.options.jobs
6f08fdb @piscisaureus Backslashes in paths wreak havoc
piscisaureus authored
475 , safe_path(bld.srcnode.abspath(bld.env_of_name(variant)))
476 , safe_path(v8dir_src)
97c9745 @ry Back to WAF
ry authored
477 , mode
478 , arch
479 , snapshot
33685fe @ry Add configure flag for oprofile
ry authored
480 , profile
97c9745 @ry Back to WAF
ry authored
481 )
d793fca @ry Add toolchain=gcc to V8 build for Sun
ry authored
482
483 if sys.platform.startswith("sunos"): cmd += ' toolchain=gcc'
484
485
97c9745 @ry Back to WAF
ry authored
486 return ("echo '%s' && " % cmd) + cmd
487
488
489 def build_v8(bld):
490 v8 = bld.new_task_gen(
491 source = 'deps/v8/SConstruct '
492 + bld.path.ant_glob('v8/include/*')
493 + bld.path.ant_glob('v8/src/*'),
494 target = bld.env["staticlib_PATTERN"] % "v8",
495 rule = v8_cmd(bld, "default"),
496 before = "cxx",
497 install_path = None)
498 v8.uselib = "EXECINFO"
499 bld.env["CPPPATH_V8"] = "deps/v8/include"
500 t = join(bld.srcnode.abspath(bld.env_of_name("default")), v8.target)
501 bld.env_of_name('default').append_value("LINKFLAGS_V8", t)
502
503
504 ### v8 debug
505 if bld.env["USE_DEBUG"]:
506 v8_debug = v8.clone("debug")
507 v8_debug.rule = v8_cmd(bld, "debug")
508 v8_debug.target = bld.env["staticlib_PATTERN"] % "v8_g"
509 v8_debug.uselib = "EXECINFO"
510 bld.env["CPPPATH_V8_G"] = "deps/v8/include"
511 t = join(bld.srcnode.abspath(bld.env_of_name("debug")), v8_debug.target)
512 bld.env_of_name('debug').append_value("LINKFLAGS_V8_G", t)
513
514 bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h')
515
516
517 def build(bld):
518 ## This snippet is to show full commands as WAF executes
519 import Build
520 old = Build.BuildContext.exec_command
521 def exec_command(self, cmd, **kw):
522 if isinstance(cmd, list): print(" ".join(cmd))
523 return old(self, cmd, **kw)
524 Build.BuildContext.exec_command = exec_command
525
526 Options.options.jobs=jobs
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
527 product_type = Options.options.product_type
528 product_type_is_lib = product_type != 'program'
97c9745 @ry Back to WAF
ry authored
529
530 print "DEST_OS: " + bld.env['DEST_OS']
531 print "DEST_CPU: " + bld.env['DEST_CPU']
532 print "Parallel Jobs: " + str(Options.options.jobs)
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
533 print "Product type: " + product_type
97c9745 @ry Back to WAF
ry authored
534
535 bld.add_subdirs('deps/libeio')
536
537 if not bld.env['USE_SHARED_V8']: build_v8(bld)
538 if not bld.env['USE_SHARED_LIBEV']: bld.add_subdirs('deps/libev')
539 if not bld.env['USE_SHARED_CARES']: bld.add_subdirs('deps/c-ares')
540
541
542 ### http_parser
543 http_parser = bld.new_task_gen("cc")
544 http_parser.source = "deps/http_parser/http_parser.c"
545 http_parser.includes = "deps/http_parser/"
546 http_parser.name = "http_parser"
547 http_parser.target = "http_parser"
548 http_parser.install_path = None
549 if bld.env["USE_DEBUG"]:
550 http_parser.clone("debug")
551
552 ### src/native.cc
553 def make_macros(loc, content):
554 f = open(loc, 'w')
555 f.write(content)
556 f.close
557
558 macros_loc_debug = join(
559 bld.srcnode.abspath(bld.env_of_name("debug")),
560 "macros.py"
561 )
562
563 macros_loc_default = join(
564 bld.srcnode.abspath(bld.env_of_name("default")),
565 "macros.py"
566 )
567
568 make_macros(macros_loc_debug, "") # leave debug(x) as is in debug build
569 # replace debug(x) with nothing in release build
570 make_macros(macros_loc_default, "macro debug(x) = ;\n")
571
572 def javascript_in_c(task):
573 env = task.env
574 source = map(lambda x: x.srcpath(env), task.inputs)
575 targets = map(lambda x: x.srcpath(env), task.outputs)
576 source.append(macros_loc_default)
577 js2c.JS2C(source, targets)
578
579 def javascript_in_c_debug(task):
580 env = task.env
581 source = map(lambda x: x.srcpath(env), task.inputs)
582 targets = map(lambda x: x.srcpath(env), task.outputs)
583 source.append(macros_loc_debug)
584 js2c.JS2C(source, targets)
585
586 native_cc = bld.new_task_gen(
587 source='src/node.js ' + bld.path.ant_glob('lib/*.js'),
588 target="src/node_natives.h",
589 before="cxx",
590 install_path=None
591 )
592
593 # Add the rule /after/ cloning the debug
594 # This is a work around for an error had in python 2.4.3 (I'll paste the
595 # error that was had into the git commit meessage. git-blame to find out
596 # where.)
597 if bld.env["USE_DEBUG"]:
598 native_cc_debug = native_cc.clone("debug")
599 native_cc_debug.rule = javascript_in_c_debug
600
601 native_cc.rule = javascript_in_c
602
603 ### node lib
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
604 node = bld.new_task_gen("cxx", product_type)
97c9745 @ry Back to WAF
ry authored
605 node.name = "node"
606 node.target = "node"
7d73779 @ry Make oprofile work
ry authored
607 node.uselib = 'RT EV OPENSSL CARES EXECINFO DL KVM SOCKET NSL UTIL OPROFILE'
97c9745 @ry Back to WAF
ry authored
608 node.add_objects = 'eio http_parser'
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
609 if product_type_is_lib:
610 node.install_path = '${PREFIX}/lib'
611 else:
612 node.install_path = '${PREFIX}/bin'
97c9745 @ry Back to WAF
ry authored
613 node.chmod = 0755
614 node.source = """
615 src/node.cc
616 src/node_buffer.cc
617 src/node_javascript.cc
618 src/node_extensions.cc
619 src/node_http_parser.cc
620 src/node_net.cc
621 src/node_io_watcher.cc
622 src/node_child_process.cc
623 src/node_constants.cc
624 src/node_cares.cc
625 src/node_events.cc
626 src/node_file.cc
627 src/node_signal_watcher.cc
628 src/node_stat_watcher.cc
629 src/node_stdio.cc
630 src/node_timer.cc
631 src/node_script.cc
f1762ff @mscdex Add os module and getHostname
mscdex authored
632 src/node_os.cc
97c9745 @ry Back to WAF
ry authored
633 """
4737219 @ry Print warning when using platform_none.cc
ry authored
634 node.source += bld.env["PLATFORM_FILE"]
e5a0fbe @rsms Added support for cross compilation and also fixed DEST_CPU to repres…
rsms authored
635 if not product_type_is_lib:
636 node.source = 'src/node_main.cc '+node.source
97c9745 @ry Back to WAF
ry authored
637
638 if bld.env["USE_OPENSSL"]: node.source += " src/node_crypto.cc "
639
640 node.includes = """
641 src/
642 deps/libeio
643 deps/http_parser
644 """
645
646 if not bld.env["USE_SHARED_V8"]: node.includes += ' deps/v8/include '
647
648 if not bld.env["USE_SHARED_LIBEV"]:
649 node.add_objects += ' ev '
650 node.includes += ' deps/libev '
651
652 if not bld.env["USE_SHARED_CARES"]:
653 node.add_objects += ' cares '
654 node.includes += ' deps/c-ares deps/c-ares/' + bld.env['DEST_OS'] + '-' + bld.env['DEST_CPU']
655
656 if sys.platform.startswith('cygwin'):
657 bld.env.append_value('LINKFLAGS', '-Wl,--export-all-symbols')
658 bld.env.append_value('LINKFLAGS', '-Wl,--out-implib,default/libnode.dll.a')
659 bld.env.append_value('LINKFLAGS', '-Wl,--output-def,default/libnode.def')
660 bld.install_files('${PREFIX}/lib', "build/default/libnode.*")
661
662 def subflags(program):
663 x = { 'CCFLAGS' : " ".join(program.env["CCFLAGS"]).replace('"', '\\"')
664 , 'CPPFLAGS' : " ".join(program.env["CPPFLAGS"]).replace('"', '\\"')
665 , 'LIBFLAGS' : " ".join(program.env["LIBFLAGS"]).replace('"', '\\"')
6f08fdb @piscisaureus Backslashes in paths wreak havoc
piscisaureus authored
666 , 'PREFIX' : safe_path(program.env["PREFIX"])
4bb914b @ry Bump version to v0.3.2
ry authored
667 , 'VERSION' : '0.3.2' # FIXME should not be hard-coded, see NODE_VERSION_STRING in src/node_version.
97c9745 @ry Back to WAF
ry authored
668 }
669 return x
670
671 # process file.pc.in -> file.pc
672
673 node_conf = bld.new_task_gen('subst', before="cxx")
674 node_conf.source = 'src/node_config.h.in'
675 node_conf.target = 'src/node_config.h'
676 node_conf.dict = subflags(node)
677 node_conf.install_path = '${PREFIX}/include/node'
678
679 if bld.env["USE_DEBUG"]:
680 node_g = node.clone("debug")
681 node_g.target = "node_g"
682 node_g.uselib += ' V8_G'
683
684 node_conf_g = node_conf.clone("debug")
685 node_conf_g.dict = subflags(node_g)
686 node_conf_g.install_path = None
687
688 # After creating the debug clone, append the V8 dep
689 node.uselib += ' V8'
690
691 bld.install_files('${PREFIX}/include/node/', """
692 config.h
693 src/node.h
694 src/node_object_wrap.h
695 src/node_buffer.h
696 src/node_events.h
697 src/node_version.h
698 """)
699
700 # Only install the man page if it exists.
701 # Do 'make doc install' to build and install it.
702 if os.path.exists('doc/node.1'):
703 bld.install_files('${PREFIX}/share/man/man1/', 'doc/node.1')
704
029180a @ry Install node-waf
ry authored
705 bld.install_files('${PREFIX}/bin/', 'tools/node-waf', chmod=0755)
97c9745 @ry Back to WAF
ry authored
706 bld.install_files('${PREFIX}/lib/node/wafadmin', 'tools/wafadmin/*.py')
707 bld.install_files('${PREFIX}/lib/node/wafadmin/Tools', 'tools/wafadmin/Tools/*.py')
708
709 # create a pkg-config(1) file
710 node_conf = bld.new_task_gen('subst', before="cxx")
711 node_conf.source = 'tools/nodejs.pc.in'
712 node_conf.target = 'tools/nodejs.pc'
713 node_conf.dict = subflags(node)
714
715 bld.install_files('${PREFIX}/lib/pkgconfig', 'tools/nodejs.pc')
716
717 def shutdown():
718 Options.options.debug
719 # HACK to get binding.node out of build directory.
720 # better way to do this?
721 if Options.commands['configure']:
722 if not Options.options.use_openssl:
723 print "WARNING WARNING WARNING"
724 print "OpenSSL not found. Will compile Node without crypto support!"
4737219 @ry Print warning when using platform_none.cc
ry authored
725
726 if not Options.options.platform_file:
727 print "WARNING: Platform not fully supported. Using src/platform_none.cc"
728
97c9745 @ry Back to WAF
ry authored
729 elif not Options.commands['clean']:
9f93329 @piscisaureus wscript: use "node.exe" and avoid symlinks on windows
piscisaureus authored
730 if sys.platform.startswith("win32"):
d1bf9cf @piscisaureus After building overwrite existing ./node(_g)?.exe
piscisaureus authored
731 if os.path.exists('build/default/node.exe'):
9f93329 @piscisaureus wscript: use "node.exe" and avoid symlinks on windows
piscisaureus authored
732 os.system('cp build/default/node.exe .')
d1bf9cf @piscisaureus After building overwrite existing ./node(_g)?.exe
piscisaureus authored
733 if os.path.exists('build/debug/node_g.exe'):
9f93329 @piscisaureus wscript: use "node.exe" and avoid symlinks on windows
piscisaureus authored
734 os.system('cp build/debug/node_g.exe .')
735 else:
736 if os.path.exists('build/default/node') and not os.path.exists('node'):
737 os.symlink('build/default/node', 'node')
738 if os.path.exists('build/debug/node_g') and not os.path.exists('node_g'):
739 os.symlink('build/debug/node_g', 'node_g')
97c9745 @ry Back to WAF
ry authored
740 else:
9f93329 @piscisaureus wscript: use "node.exe" and avoid symlinks on windows
piscisaureus authored
741 if sys.platform.startswith("win32"):
742 if os.path.exists('node.exe'): os.unlink('node.exe')
743 if os.path.exists('node_g.exe'): os.unlink('node_g.exe')
744 else:
745 if os.path.exists('node'): os.unlink('node')
746 if os.path.exists('node_g'): os.unlink('node_g')
Something went wrong with that request. Please try again.