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