blob: 951624519871c9fe34c3fbb84f620bd85d224682 [file] [log] [blame]
Ryan Dahl7a251f32010-03-01 22:39:311#!/usr/bin/env python
Ryan8ddf9302009-09-02 18:19:522import re
Ryan1a126ed2009-04-04 12:50:153import Options
Ryan41d89f62009-07-28 10:29:184import sys, os, shutil
Ryan Dahld979ac92009-10-09 13:00:125from Utils import cmd_output
Ryan1a126ed2009-04-04 12:50:156from os.path import join, dirname, abspath
Ryana4593e32009-04-23 11:18:387from logging import fatal
8
Ryan Dahld979ac92009-10-09 13:00:129cwd = os.getcwd()
Ryan Dahl10d8adb2010-06-09 23:13:4010VERSION="0.1.98"
Ryan4d921992009-08-26 23:11:1611APPNAME="node.js"
12
Ryan63a9cd32009-04-15 08:08:2813import js2c
14
Ryan1a126ed2009-04-04 12:50:1515srcdir = '.'
16blddir = 'build'
17
Ryan Dahl311a62d2010-05-26 20:05:3118
Ryan Dahl311a62d2010-05-26 20:05:3119jobs=1
20if os.environ.has_key('JOBS'):
21 jobs = int(os.environ['JOBS'])
22
Ryan1a126ed2009-04-04 12:50:1523def set_options(opt):
24 # the gcc module provides a --debug-level option
25 opt.tool_options('compiler_cxx')
26 opt.tool_options('compiler_cc')
Ryan4d921992009-08-26 23:11:1627 opt.tool_options('misc')
Ryan29b528c2009-04-23 15:29:3128 opt.add_option( '--debug'
29 , action='store_true'
30 , default=False
31 , help='Build debug variant [Default: False]'
32 , dest='debug'
33 )
Ryan7bad9de2009-06-16 13:47:5734 opt.add_option( '--efence'
35 , action='store_true'
36 , default=False
37 , help='Build with -lefence for debugging [Default: False]'
38 , dest='efence'
39 )
Ryan Dahl9e8df0e2010-06-02 21:05:3740
Ryan Dahla9b962a2010-05-14 23:34:4741 opt.add_option( '--without-ssl'
42 , action='store_true'
43 , default=False
44 , help='Build without SSL'
45 , dest='without_ssl'
46 )
Ryan1a126ed2009-04-04 12:50:1547
Ryan Dahl9e8df0e2010-06-02 21:05:3748
49 opt.add_option('--shared-v8'
50 , action='store_true'
51 , default=False
52 , help='Link to a shared V8 DLL instead of static linking'
53 , dest='shared_v8'
54 )
55
56 opt.add_option( '--shared-v8-includes'
57 , action='store'
58 , default=False
59 , help='Directory containing V8 header files'
60 , dest='shared_v8_includes'
61 )
62
63 opt.add_option( '--shared-v8-libpath'
64 , action='store'
65 , default=False
66 , help='A directory to search for the shared V8 DLL'
67 , dest='shared_v8_libpath'
68 )
69
70 opt.add_option( '--shared-v8-libname'
71 , action='store'
72 , default=False
73 , help="Alternative lib name to link to (default: 'v8')"
74 , dest='shared_v8_libname'
75 )
76
77
78 opt.add_option('--shared-cares'
79 , action='store_true'
80 , default=False
81 , help='Link to a shared C-Ares DLL instead of static linking'
82 , dest='shared_cares'
83 )
84
85 opt.add_option( '--shared-cares-includes'
86 , action='store'
87 , default=False
88 , help='Directory containing C-Ares header files'
89 , dest='shared_cares_includes'
90 )
91
92 opt.add_option( '--shared-cares-libpath'
93 , action='store'
94 , default=False
95 , help='A directory to search for the shared C-Ares DLL'
96 , dest='shared_cares_libpath'
97 )
98
99
100 opt.add_option('--shared-libev'
101 , action='store_true'
102 , default=False
103 , help='Link to a shared libev DLL instead of static linking'
104 , dest='shared_libev'
105 )
106
107 opt.add_option( '--shared-libev-includes'
108 , action='store'
109 , default=False
110 , help='Directory containing libev header files'
111 , dest='shared_libev_includes'
112 )
113
114 opt.add_option( '--shared-libev-libpath'
115 , action='store'
116 , default=False
117 , help='A directory to search for the shared libev DLL'
118 , dest='shared_libev_libpath'
119 )
120
121
122
123
Ryan1a126ed2009-04-04 12:50:15124def configure(conf):
125 conf.check_tool('compiler_cxx')
Ryan Dahlf379b772010-01-12 00:43:10126 if not conf.env.CXX: conf.fatal('c++ compiler not found')
Ryan1a126ed2009-04-04 12:50:15127 conf.check_tool('compiler_cc')
Ryan Dahlf379b772010-01-12 00:43:10128 if not conf.env.CC: conf.fatal('c compiler not found')
Ryana4593e32009-04-23 11:18:38129
Ryan Dahl9e8df0e2010-06-02 21:05:37130 o = Options.options
131
132 conf.env["USE_DEBUG"] = o.debug
133
134 conf.env["USE_SHARED_V8"] = o.shared_v8 or o.shared_v8_includes or o.shared_v8_libpath or o.shared_v8_libname
135 conf.env["USE_SHARED_CARES"] = o.shared_cares or o.shared_cares_includes or o.shared_cares_libpath
136 conf.env["USE_SHARED_LIBEV"] = o.shared_libev or o.shared_libev_includes or o.shared_libev_libpath
Ryan1a126ed2009-04-04 12:50:15137
Ryan2b6d7242009-06-20 13:07:10138 conf.check(lib='dl', uselib_store='DL')
Raffaele Senab3b81d62010-06-09 04:08:05139 if not sys.platform.startswith("sunos") and not sys.platform.startswith("cygwin"):
Ryan Dahl0c125542010-01-19 23:38:20140 conf.env.append_value("CCFLAGS", "-rdynamic")
141 conf.env.append_value("LINKFLAGS_DL", "-rdynamic")
Ryana97dce72009-08-31 09:14:34142
Vanilla Hsud22952b2010-01-07 07:37:27143 if sys.platform.startswith("freebsd"):
144 conf.check(lib='kvm', uselib_store='KVM')
145
Ryan8152f9c2009-09-01 12:15:29146 #if Options.options.debug:
147 # conf.check(lib='profiler', uselib_store='PROFILER')
Ryan7bad9de2009-06-16 13:47:57148
Ryan Dahlb8c3d712010-01-27 02:34:42149 if Options.options.efence:
150 conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE')
Ryana3627c02009-05-27 14:29:55151
Vanilla Hsud7a45012010-04-06 16:07:10152 if not conf.check(lib="execinfo", includes=['/usr/include', '/usr/local/include'], libpath=['/usr/lib', '/usr/local/lib'], uselib_store="EXECINFO"):
Rasmus Andersson6eb8bbc2009-12-15 22:37:49153 # Note on Darwin/OS X: This will fail, but will still be used as the
154 # execinfo stuff are part of the standard library.
Ryan Dahl8b62e862009-10-10 09:58:36155 if sys.platform.startswith("freebsd"):
Simon Cornelius P. Umacobe801f422009-12-09 12:36:12156 conf.fatal("Install the libexecinfo port from /usr/ports/devel/libexecinfo.")
Ryana3627c02009-05-27 14:29:55157
Ryan Dahla9b962a2010-05-14 23:34:47158 if not Options.options.without_ssl:
159 if conf.check_cfg(package='openssl',
160 args='--cflags --libs',
161 uselib_store='OPENSSL'):
Standa Opichalfa514a92010-04-18 16:24:08162 conf.env["USE_OPENSSL"] = True
163 conf.env.append_value("CXXFLAGS", "-DHAVE_OPENSSL=1")
Ryan Dahla9b962a2010-05-14 23:34:47164 else:
165 libssl = conf.check_cc(lib='ssl',
166 header_name='openssl/ssl.h',
167 function_name='SSL_library_init',
168 libpath=['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/usr/sfw/lib'],
169 uselib_store='OPENSSL')
170 libcrypto = conf.check_cc(lib='crypto',
171 header_name='openssl/crypto.h',
172 uselib_store='OPENSSL')
173 if libcrypto and libssl:
174 conf.env["USE_OPENSSL"] = True
175 conf.env.append_value("CXXFLAGS", "-DHAVE_OPENSSL=1")
Rhys Jonesfb3a9cd2010-04-02 23:11:53176
Ryan Dahle9a116f2010-04-06 10:41:32177 conf.check(lib='rt', uselib_store='RT')
178
Ryan Dahl0c125542010-01-19 23:38:20179 if sys.platform.startswith("sunos"):
180 if not conf.check(lib='socket', uselib_store="SOCKET"):
181 conf.fatal("Cannot find socket library")
182 if not conf.check(lib='nsl', uselib_store="NSL"):
183 conf.fatal("Cannot find nsl library")
184
Ryan Dahl9e8df0e2010-06-02 21:05:37185
186
Ryan1a126ed2009-04-04 12:50:15187 conf.sub_config('deps/libeio')
Ryan Dahl9e8df0e2010-06-02 21:05:37188
189
190
191 if conf.env['USE_SHARED_V8']:
192 v8_includes = [];
193 if o.shared_v8_includes: v8_includes.append(o.shared_v8_includes);
194
195 v8_libpath = [];
196 if o.shared_v8_libpath: v8_libpath.append(o.shared_v8_libpath);
197
198 if not o.shared_v8_libname: o.shared_v8_libname = 'v8'
199
200 if not conf.check_cxx(lib=o.shared_v8_libname, header_name='v8.h',
201 uselib_store='V8',
202 includes=v8_includes,
203 libpath=v8_libpath):
204 conf.fatal("Cannot find v8")
205
206 if o.debug:
207 if not conf.check_cxx(lib=o.shared_v8_libname + '_g', header_name='v8.h',
208 uselib_store='V8_G',
209 includes=v8_includes,
210 libpath=v8_libpath):
211 conf.fatal("Cannot find v8_g")
212
213 if conf.env['USE_SHARED_CARES']:
214 cares_includes = [];
215 if o.shared_cares_includes: cares_includes.append(o.shared_cares_includes);
216 cares_libpath = [];
217 if o.shared_cares_libpath: cares_libpath.append(o.shared_cares_libpath);
218 if not conf.check_cxx(lib='cares',
219 header_name='ares.h',
220 uselib_store='CARES',
221 includes=cares_includes,
222 libpath=cares_libpath):
Ryan Dahl501136b2010-06-02 16:15:54223 conf.fatal("Cannot find c-ares")
Ryan Dahl9e8df0e2010-06-02 21:05:37224 else:
225 conf.sub_config('deps/c-ares')
226
227
228 if conf.env['USE_SHARED_LIBEV']:
229 libev_includes = [];
230 if o.shared_libev_includes: libev_includes.append(o.shared_libev_includes);
231 libev_libpath = [];
232 if o.shared_libev_libpath: libev_libpath.append(o.shared_libev_libpath);
233 if not conf.check_cxx(lib='ev', header_name='ev.h',
234 uselib_store='EV',
235 includes=libev_includes,
236 libpath=libev_libpath):
237 conf.fatal("Cannot find libev")
238 else:
239 conf.sub_config('deps/libev')
240
241
Ryan41d89f62009-07-28 10:29:18242
Ryan1a126ed2009-04-04 12:50:15243 conf.define("HAVE_CONFIG_H", 1)
Ryanc62b1242009-04-22 17:55:08244
Ryan Dahl42797252010-03-31 20:36:20245 if sys.platform.startswith("sunos"):
246 conf.env.append_value ('CCFLAGS', '-threads')
247 conf.env.append_value ('CXXFLAGS', '-threads')
248 #conf.env.append_value ('LINKFLAGS', ' -threads')
Raffaele Senab3b81d62010-06-09 04:08:05249 elif not sys.platform.startswith("cygwin"):
Ryan Dahl42797252010-03-31 20:36:20250 threadflags='-pthread'
251 conf.env.append_value ('CCFLAGS', threadflags)
252 conf.env.append_value ('CXXFLAGS', threadflags)
253 conf.env.append_value ('LINKFLAGS', threadflags)
254
Ryan Dahl1beb8402009-12-30 08:01:28255 conf.env.append_value("CCFLAGS", "-DX_STACKSIZE=%d" % (1024*64))
Ryan427e3f52009-05-14 11:16:45256
Ryan Dahl2b743aa2009-10-27 11:05:38257 # LFS
258 conf.env.append_value('CCFLAGS', '-D_LARGEFILE_SOURCE')
259 conf.env.append_value('CXXFLAGS', '-D_LARGEFILE_SOURCE')
260 conf.env.append_value('CCFLAGS', '-D_FILE_OFFSET_BITS=64')
261 conf.env.append_value('CXXFLAGS', '-D_FILE_OFFSET_BITS=64')
262
Andrew Johnston95996072010-03-22 07:25:24263 ## needed for node_file.cc fdatasync
264 ## Strangely on OSX 10.6 the g++ doesn't see fdatasync but gcc does?
265 code = """
266 #include <unistd.h>
267 int main(void)
268 {
269 int fd = 0;
270 fdatasync (fd);
271 return 0;
272 }
273 """
274 if conf.check_cxx(msg="Checking for fdatasync(2) with c++", fragment=code):
275 conf.env.append_value('CXXFLAGS', '-DHAVE_FDATASYNC=1')
276 else:
277 conf.env.append_value('CXXFLAGS', '-DHAVE_FDATASYNC=0')
278
Ryan Dahlf4811832009-11-02 23:21:00279 # platform
Ryan Dahl01a8d272010-06-18 01:23:40280 platform_def = '-DPLATFORM=' + conf.env['DEST_OS']
Ryan Dahlf4811832009-11-02 23:21:00281 conf.env.append_value('CCFLAGS', platform_def)
282 conf.env.append_value('CXXFLAGS', platform_def)
283
Ryan67af9582009-04-18 13:35:42284 # Split off debug variant before adding variant specific defines
Ryan7e1350f2009-04-16 09:37:44285 debug_env = conf.env.copy()
286 conf.set_env_name('debug', debug_env)
Ryan7e1350f2009-04-16 09:37:44287
Ryan67af9582009-04-18 13:35:42288 # Configure debug variant
289 conf.setenv('debug')
290 debug_env.set_variant('debug')
Ryan8ddf9302009-09-02 18:19:52291 debug_env.append_value('CCFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra'])
292 debug_env.append_value('CXXFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra'])
Ryan67af9582009-04-18 13:35:42293 conf.write_config_header("config.h")
294
295 # Configure default variant
296 conf.setenv('default')
Ryan Dahl48d58f92010-05-03 01:20:02297 conf.env.append_value('CCFLAGS', ['-DNDEBUG', '-g', '-O3'])
298 conf.env.append_value('CXXFLAGS', ['-DNDEBUG', '-g', '-O3'])
Ryan67af9582009-04-18 13:35:42299 conf.write_config_header("config.h")
Ryan63a9cd32009-04-15 08:08:28300
Ryan41d89f62009-07-28 10:29:18301
Ryan Dahl53ebe752009-10-08 21:20:14302def v8_cmd(bld, variant):
303 scons = join(cwd, 'tools/scons/scons.py')
Ryan1a126ed2009-04-04 12:50:15304 deps_src = join(bld.path.abspath(),"deps")
Ryan1a126ed2009-04-04 12:50:15305 v8dir_src = join(deps_src,"v8")
Ryan Dahl53ebe752009-10-08 21:20:14306
Ryan Dahlbc9b3432009-10-02 12:10:40307 # NOTE: We want to compile V8 to export its symbols. I.E. Do not want
308 # -fvisibility=hidden. When using dlopen() it seems that the loaded DSO
309 # cannot see symbols in the executable which are hidden, even if the
310 # executable is statically linked together...
Ryan8ddf9302009-09-02 18:19:52311
Ryan Dahl7d9d8812009-10-26 21:27:52312 # XXX Remove this when v8 defaults x86_64 to native builds
Ryan Dahld85724d2009-10-08 22:34:39313 arch = ""
Ryan Dahl7d9d8812009-10-26 21:27:52314 if bld.env['DEST_CPU'] == 'x86_64':
Ryan Dahld85724d2009-10-08 22:34:39315 arch = "arch=x64"
316
317 if variant == "default":
318 mode = "release"
319 else:
320 mode = "debug"
Ryana4593e32009-04-23 11:18:38321
Ryan Dahl23d680b2010-05-13 23:24:05322 cmd_R = 'python "%s" -j %d -C "%s" -Y "%s" visibility=default mode=%s %s library=static snapshot=on'
Ryan Dahl53ebe752009-10-08 21:20:14323
324 cmd = cmd_R % ( scons
Ryan Dahl23d680b2010-05-13 23:24:05325 , Options.options.jobs
Ryan Dahl53ebe752009-10-08 21:20:14326 , bld.srcnode.abspath(bld.env_of_name(variant))
327 , v8dir_src
328 , mode
329 , arch
330 )
331 return cmd
332
333
334def build_v8(bld):
Ryan1a126ed2009-04-04 12:50:15335 v8 = bld.new_task_gen(
Ryan Dahl9e8df0e2010-06-02 21:05:37336 source = 'deps/v8/SConstruct '
337 + bld.path.ant_glob('v8/include/*')
338 + bld.path.ant_glob('v8/src/*'),
Ryan Dahl53ebe752009-10-08 21:20:14339 target = bld.env["staticlib_PATTERN"] % "v8",
340 rule = v8_cmd(bld, "default"),
341 before = "cxx",
Ryan Dahl9e8df0e2010-06-02 21:05:37342 install_path = None)
Ryan Dahl8b62e862009-10-10 09:58:36343 v8.uselib = "EXECINFO"
Ryan1a126ed2009-04-04 12:50:15344 bld.env["CPPPATH_V8"] = "deps/v8/include"
Ryan Dahlfc937aa2009-10-27 21:50:46345 t = join(bld.srcnode.abspath(bld.env_of_name("default")), v8.target)
Ryan Dahl42797252010-03-31 20:36:20346 bld.env_of_name('default').append_value("LINKFLAGS_V8", t)
347
Ryana4593e32009-04-23 11:18:38348
349 ### v8 debug
Ryan29b528c2009-04-23 15:29:31350 if bld.env["USE_DEBUG"]:
Ryan29b528c2009-04-23 15:29:31351 v8_debug = v8.clone("debug")
Ryan Dahl53ebe752009-10-08 21:20:14352 v8_debug.rule = v8_cmd(bld, "debug")
353 v8_debug.target = bld.env["staticlib_PATTERN"] % "v8_g"
Ryan Dahl8b62e862009-10-10 09:58:36354 v8_debug.uselib = "EXECINFO"
Ryan Dahl9e8df0e2010-06-02 21:05:37355 bld.env["CPPPATH_V8_G"] = "deps/v8/include"
Ryan Dahlfc937aa2009-10-27 21:50:46356 t = join(bld.srcnode.abspath(bld.env_of_name("debug")), v8_debug.target)
Ryan Dahl9e8df0e2010-06-02 21:05:37357 bld.env_of_name('debug').append_value("LINKFLAGS_V8_G", t)
Ryan1a126ed2009-04-04 12:50:15358
Ryan Dahl53ebe752009-10-08 21:20:14359 bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h')
Ryan2b6d7242009-06-20 13:07:10360
Ryan41d89f62009-07-28 10:29:18361def build(bld):
Ryan Dahlef9f4042010-06-02 19:27:53362 ## This snippet is to show full commands as WAF executes
363 import Build
364 old = Build.BuildContext.exec_command
365 def exec_command(self, cmd, **kw):
366 if isinstance(cmd, list): print(" ".join(cmd))
367 return old(self, cmd, **kw)
368 Build.BuildContext.exec_command = exec_command
369
Ryan Dahl501136b2010-06-02 16:15:54370 Options.options.jobs=jobs
Ryan Dahlef9f4042010-06-02 19:27:53371
Ryan Dahl9ea8c9f2010-04-07 20:34:40372 print "DEST_OS: " + bld.env['DEST_OS']
373 print "DEST_CPU: " + bld.env['DEST_CPU']
Ryan Dahl23d680b2010-05-13 23:24:05374 print "Parallel Jobs: " + str(Options.options.jobs)
Ryan Dahl9ea8c9f2010-04-07 20:34:40375
Ryan Dahl9e8df0e2010-06-02 21:05:37376 bld.add_subdirs('deps/libeio')
377
378 if not bld.env['USE_SHARED_V8']: build_v8(bld)
379 if not bld.env['USE_SHARED_LIBEV']: bld.add_subdirs('deps/libev')
380 if not bld.env['USE_SHARED_CARES']: bld.add_subdirs('deps/c-ares')
Ryan41d89f62009-07-28 10:29:18381
Jérémy Lalc93bab12010-03-11 21:15:32382
Ryan5a071ad2009-05-03 12:09:16383 ### http_parser
Ryan Dahl122e74b2009-10-27 21:26:53384 http_parser = bld.new_task_gen("cc")
Ryan5a071ad2009-05-03 12:09:16385 http_parser.source = "deps/http_parser/http_parser.c"
386 http_parser.includes = "deps/http_parser/"
387 http_parser.name = "http_parser"
388 http_parser.target = "http_parser"
389 http_parser.install_path = None
Ryan29b528c2009-04-23 15:29:31390 if bld.env["USE_DEBUG"]:
Ryan5a071ad2009-05-03 12:09:16391 http_parser.clone("debug")
Ryan1a126ed2009-04-04 12:50:15392
Ryan63a9cd32009-04-15 08:08:28393 ### src/native.cc
Zokab29f7872010-03-20 03:56:03394 def make_macros(loc, content):
395 f = open(loc, 'w')
396 f.write(content)
397 f.close
398
399 macros_loc_debug = join(
400 bld.srcnode.abspath(bld.env_of_name("debug")),
401 "macros.py"
402 )
403
404 macros_loc_default = join(
405 bld.srcnode.abspath(bld.env_of_name("default")),
406 "macros.py"
407 )
408
409 make_macros(macros_loc_debug, "") # leave debug(x) as is in debug build
410 # replace debug(x) with nothing in release build
411 make_macros(macros_loc_default, "macro debug(x) = ;\n")
412
Ryan63a9cd32009-04-15 08:08:28413 def javascript_in_c(task):
414 env = task.env
415 source = map(lambda x: x.srcpath(env), task.inputs)
416 targets = map(lambda x: x.srcpath(env), task.outputs)
Zokab29f7872010-03-20 03:56:03417 source.append(macros_loc_default)
418 js2c.JS2C(source, targets)
419
420 def javascript_in_c_debug(task):
421 env = task.env
422 source = map(lambda x: x.srcpath(env), task.inputs)
423 targets = map(lambda x: x.srcpath(env), task.outputs)
424 source.append(macros_loc_debug)
Ryan63a9cd32009-04-15 08:08:28425 js2c.JS2C(source, targets)
426
427 native_cc = bld.new_task_gen(
Ryan Dahl4ccdc502010-03-15 15:00:19428 source='src/node.js ' + bld.path.ant_glob('lib/*.js'),
Ryan Dahl53ebe752009-10-08 21:20:14429 target="src/node_natives.h",
Ryan Dahl4ccdc502010-03-15 15:00:19430 before="cxx",
431 install_path=None
Ryan63a9cd32009-04-15 08:08:28432 )
Ryan Dahl4bcb01c2009-10-16 20:53:44433
434 # Add the rule /after/ cloning the debug
435 # This is a work around for an error had in python 2.4.3 (I'll paste the
436 # error that was had into the git commit meessage. git-blame to find out
437 # where.)
Ryan29b528c2009-04-23 15:29:31438 if bld.env["USE_DEBUG"]:
Ryan Dahl4bcb01c2009-10-16 20:53:44439 native_cc_debug = native_cc.clone("debug")
Zokab29f7872010-03-20 03:56:03440 native_cc_debug.rule = javascript_in_c_debug
441
Ryan Dahl4bcb01c2009-10-16 20:53:44442 native_cc.rule = javascript_in_c
Ryan63a9cd32009-04-15 08:08:28443
Ryan2b6d7242009-06-20 13:07:10444 ### node lib
Ryan8152f9c2009-09-01 12:15:29445 node = bld.new_task_gen("cxx", "program")
446 node.name = "node"
447 node.target = "node"
Ryan Dahl9e8df0e2010-06-02 21:05:37448 node.uselib = 'RT EV OPENSSL CARES EXECINFO DL KVM SOCKET NSL'
449 node.add_objects = 'eio http_parser'
450 node.install_path = '${PREFIX}/lib'
451 node.install_path = '${PREFIX}/bin'
452 node.chmod = 0755
Ryan8152f9c2009-09-01 12:15:29453 node.source = """
Ryan1a126ed2009-04-04 12:50:15454 src/node.cc
Ryan Dahl630bb7a2009-12-13 07:42:45455 src/node_buffer.cc
Ryan Dahl42ee1692010-01-24 19:21:45456 src/node_http_parser.cc
Ryan Dahl78e49f12010-05-29 20:08:05457 src/node_net.cc
Ryan Dahlf2199382009-12-13 14:43:58458 src/node_io_watcher.cc
Ryan Dahla5df0f62009-10-27 10:46:58459 src/node_child_process.cc
460 src/node_constants.cc
Krishna Rajendrandc1f4eb2010-04-06 10:28:37461 src/node_cares.cc
Ryan Dahla5df0f62009-10-27 10:46:58462 src/node_events.cc
463 src/node_file.cc
Ryan Dahl8492c522010-03-15 21:05:18464 src/node_signal_watcher.cc
465 src/node_stat_watcher.cc
Ryan17c6a672009-08-24 18:25:24466 src/node_stdio.cc
Ryan Dahla5df0f62009-10-27 10:46:58467 src/node_timer.cc
Herbert Vojcikc2a06722010-04-17 15:18:15468 src/node_script.cc
Ryan1a126ed2009-04-04 12:50:15469 """
Ryan Dahl01a8d272010-06-18 01:23:40470
471 platform_file = "src/platform_%s.cc" % bld.env['DEST_OS']
472 if os.path.exists(join(cwd, platform_file)):
473 node.source += platform_file
474 else:
475 node.source += "src/platform_none.cc "
476
477
478 if bld.env["USE_OPENSSL"]: node.source += " src/node_crypto.cc "
Rhys Jonesfb3a9cd2010-04-02 23:11:53479
Ryan Dahl9e8df0e2010-06-02 21:05:37480 node.includes = """
481 src/
482 deps/libeio
483 deps/http_parser
484 """
Ryan Dahle9a116f2010-04-06 10:41:32485
Ryan Dahl9e8df0e2010-06-02 21:05:37486 if not bld.env["USE_SHARED_V8"]: node.includes += ' deps/v8/include '
Vanilla Hsu067f4082010-04-07 16:05:37487
Ryan Dahl9e8df0e2010-06-02 21:05:37488 if not bld.env["USE_SHARED_LIBEV"]:
489 node.add_objects += ' ev '
490 node.includes += ' deps/libev '
Ryan Dahle9a116f2010-04-06 10:41:32491
Ryan Dahl9e8df0e2010-06-02 21:05:37492 if not bld.env["USE_SHARED_CARES"]:
493 node.add_objects += ' cares '
494 node.includes += ' deps/c-ares deps/c-ares/' + bld.env['DEST_OS'] + '-' + bld.env['DEST_CPU']
Ryan8e7bbf22009-04-23 17:26:56495
Brian McKenna431e72c2010-06-11 11:25:05496 if sys.platform.startswith('cygwin'):
497 bld.env.append_value('LINKFLAGS', '-Wl,--export-all-symbols')
498 bld.env.append_value('LINKFLAGS', '-Wl,--out-implib,default/libnode.dll.a')
499 bld.env.append_value('LINKFLAGS', '-Wl,--output-def,default/libnode.def')
500 bld.install_files('${PREFIX}/lib', "build/default/libnode.*")
501
Ryan4d921992009-08-26 23:11:16502 def subflags(program):
Ryan Dahld979ac92009-10-09 13:00:12503 if os.path.exists(join(cwd, ".git")):
Ryan Dahl962e9292009-10-09 14:16:27504 actual_version=cmd_output("git describe").strip()
Ryan Dahld979ac92009-10-09 13:00:12505 else:
506 actual_version=VERSION
507
Ryanb73264d2009-08-27 00:15:11508 x = { 'CCFLAGS' : " ".join(program.env["CCFLAGS"])
509 , 'CPPFLAGS' : " ".join(program.env["CPPFLAGS"])
510 , 'LIBFLAGS' : " ".join(program.env["LIBFLAGS"])
Ryan Dahld979ac92009-10-09 13:00:12511 , 'VERSION' : actual_version
Ryanb73264d2009-08-27 00:15:11512 , 'PREFIX' : program.env["PREFIX"]
Ryan4d921992009-08-26 23:11:16513 }
Ryan Dahlbf0d2782009-10-03 20:42:03514 return x
Ryan4d921992009-08-26 23:11:16515
Ryan4d921992009-08-26 23:11:16516 # process file.pc.in -> file.pc
Ryan Dahld979ac92009-10-09 13:00:12517
Ryanb73264d2009-08-27 00:15:11518 node_version = bld.new_task_gen('subst', before="cxx")
519 node_version.source = 'src/node_version.h.in'
520 node_version.target = 'src/node_version.h'
521 node_version.dict = subflags(node)
Ryana97dce72009-08-31 09:14:34522 node_version.install_path = '${PREFIX}/include/node'
Ryan4d921992009-08-26 23:11:16523
Ryan29b528c2009-04-23 15:29:31524 if bld.env["USE_DEBUG"]:
Ryan2b6d7242009-06-20 13:07:10525 node_g = node.clone("debug")
526 node_g.target = "node_g"
Ryan Dahl9e8df0e2010-06-02 21:05:37527 node_g.uselib += ' V8_G'
528
Ryanb73264d2009-08-27 00:15:11529 node_version_g = node_version.clone("debug")
530 node_version_g.dict = subflags(node_g)
Ryana97dce72009-08-31 09:14:34531 node_version_g.install_path = None
Ryan4d921992009-08-26 23:11:16532
Ryan Dahl9e8df0e2010-06-02 21:05:37533 # After creating the debug clone, append the V8 dep
534 node.uselib += ' V8'
Ryana97dce72009-08-31 09:14:34535
536 bld.install_files('${PREFIX}/include/node/', """
537 config.h
538 src/node.h
Ryan Dahl5f466c82009-10-27 19:17:03539 src/node_object_wrap.h
Ryan Dahld2415942010-05-06 21:14:52540 src/node_buffer.h
Ryan Dahl5f466c82009-10-27 19:17:03541 src/node_events.h
Ryan Dahlbf0d2782009-10-03 20:42:03542 """)
543
Ryan Dahlef9f4042010-06-02 19:27:53544 # Only install the man page if it exists.
Ryan Dahlbf0d2782009-10-03 20:42:03545 # Do 'make doc install' to build and install it.
546 if os.path.exists('doc/node.1'):
547 bld.install_files('${PREFIX}/share/man/man1/', 'doc/node.1')
548
549 bld.install_files('${PREFIX}/bin/', 'bin/*', chmod=0755)
Ryan Dahlbf0d2782009-10-03 20:42:03550 bld.install_files('${PREFIX}/lib/node/wafadmin', 'tools/wafadmin/*.py')
551 bld.install_files('${PREFIX}/lib/node/wafadmin/Tools', 'tools/wafadmin/Tools/*.py')
Ryan Dahl6f17ca52009-10-03 17:08:05552
Ryan Dahl132d6852009-10-27 17:11:07553def shutdown():
554 Options.options.debug
555 # HACK to get binding.node out of build directory.
556 # better way to do this?
557 if not Options.commands['clean']:
558 if os.path.exists('build/default/node') and not os.path.exists('node'):
559 os.symlink('build/default/node', 'node')
560 if os.path.exists('build/debug/node_g') and not os.path.exists('node_g'):
561 os.symlink('build/debug/node_g', 'node_g')
562 else:
563 if os.path.exists('node'): os.unlink('node')
564 if os.path.exists('node_g'): os.unlink('node_g')