blob: aa1be93036358b824cc2d54f20899aa0dd802659 [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 Dahl618296e2010-03-20 04:07:0310VERSION="0.1.33"
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
18def set_options(opt):
19 # the gcc module provides a --debug-level option
20 opt.tool_options('compiler_cxx')
21 opt.tool_options('compiler_cc')
Ryan4d921992009-08-26 23:11:1622 opt.tool_options('misc')
Ryan29b528c2009-04-23 15:29:3123 opt.add_option( '--debug'
24 , action='store_true'
25 , default=False
26 , help='Build debug variant [Default: False]'
27 , dest='debug'
28 )
Ryan7bad9de2009-06-16 13:47:5729 opt.add_option( '--efence'
30 , action='store_true'
31 , default=False
32 , help='Build with -lefence for debugging [Default: False]'
33 , dest='efence'
34 )
Jérémy Lalc93bab12010-03-11 21:15:3235 opt.add_option( '--system'
36 , action='store_true'
37 , default=False
38 , help='Build using system libraries and headers (like a debian build) [Default: False]'
39 , dest='system'
40 )
Ryan1a126ed2009-04-04 12:50:1541
Ryan41d89f62009-07-28 10:29:1842def mkdir_p(dir):
43 if not os.path.exists (dir):
44 os.makedirs (dir)
45
Ryan Dahl18da8ff2009-09-28 20:39:0046# Copied from Python 2.6 because 2.4.4 at least is broken by not using
47# mkdirs
48# http://mail.python.org/pipermail/python-bugs-list/2005-January/027118.html
49def copytree(src, dst, symlinks=False, ignore=None):
50 names = os.listdir(src)
51 if ignore is not None:
52 ignored_names = ignore(src, names)
53 else:
54 ignored_names = set()
55
56 os.makedirs(dst)
57 errors = []
58 for name in names:
59 if name in ignored_names:
60 continue
Ryan Dahl53ebe752009-10-08 21:20:1461 srcname = join(src, name)
62 dstname = join(dst, name)
Ryan Dahl18da8ff2009-09-28 20:39:0063 try:
64 if symlinks and os.path.islink(srcname):
65 linkto = os.readlink(srcname)
66 os.symlink(linkto, dstname)
67 elif os.path.isdir(srcname):
68 copytree(srcname, dstname, symlinks, ignore)
69 else:
70 shutil.copy2(srcname, dstname)
71 # XXX What about devices, sockets etc.?
72 except (IOError, os.error), why:
73 errors.append((srcname, dstname, str(why)))
74 # catch the Error from the recursive copytree so that we can
75 # continue with other files
76 except Error, err:
77 errors.extend(err.args[0])
78 try:
79 shutil.copystat(src, dst)
80 except OSError, why:
81 if WindowsError is not None and isinstance(why, WindowsError):
82 # Copying file access times may fail on Windows
83 pass
84 else:
85 errors.extend((src, dst, str(why)))
86 if errors:
87 raise Error, errors
88
Ryan41d89f62009-07-28 10:29:1889def conf_subproject (conf, subdir, command=None):
90 print("---- %s ----" % subdir)
91 src = join(conf.srcdir, subdir)
Simon Cornelius P. Umacobe801f422009-12-09 12:36:1292 if not os.path.exists (src): conf.fatal("no such subproject " + subdir)
Ryan41d89f62009-07-28 10:29:1893
94 default_tgt = join(conf.blddir, "default", subdir)
95
96 if not os.path.exists(default_tgt):
Ryan Dahl18da8ff2009-09-28 20:39:0097 copytree(src, default_tgt, True)
Ryan41d89f62009-07-28 10:29:1898
99 if command:
masuidrive3337e9d2010-02-10 10:21:54100 if os.system("cd \"%s\" && %s" % (default_tgt, command)) != 0:
Simon Cornelius P. Umacobe801f422009-12-09 12:36:12101 conf.fatal("Configuring %s failed." % (subdir))
Ryan41d89f62009-07-28 10:29:18102
103 debug_tgt = join(conf.blddir, "debug", subdir)
104
105 if not os.path.exists(debug_tgt):
Ryan Dahl18da8ff2009-09-28 20:39:00106 copytree(default_tgt, debug_tgt, True)
Ryan41d89f62009-07-28 10:29:18107
Ryan1a126ed2009-04-04 12:50:15108def configure(conf):
109 conf.check_tool('compiler_cxx')
Ryan Dahlf379b772010-01-12 00:43:10110 if not conf.env.CXX: conf.fatal('c++ compiler not found')
Ryan1a126ed2009-04-04 12:50:15111 conf.check_tool('compiler_cc')
Ryan Dahlf379b772010-01-12 00:43:10112 if not conf.env.CC: conf.fatal('c compiler not found')
Ryana4593e32009-04-23 11:18:38113
Ryan8e7bbf22009-04-23 17:26:56114 conf.env["USE_DEBUG"] = Options.options.debug
Jérémy Lalc93bab12010-03-11 21:15:32115 conf.env["USE_SYSTEM"] = Options.options.system
Ryan1a126ed2009-04-04 12:50:15116
Ryan2b6d7242009-06-20 13:07:10117 conf.check(lib='dl', uselib_store='DL')
Ryan Dahl0c125542010-01-19 23:38:20118 if not sys.platform.startswith("sunos"):
119 conf.env.append_value("CCFLAGS", "-rdynamic")
120 conf.env.append_value("LINKFLAGS_DL", "-rdynamic")
Ryana97dce72009-08-31 09:14:34121
Vanilla Hsud22952b2010-01-07 07:37:27122 if sys.platform.startswith("freebsd"):
123 conf.check(lib='kvm', uselib_store='KVM')
124
Ryan8152f9c2009-09-01 12:15:29125 #if Options.options.debug:
126 # conf.check(lib='profiler', uselib_store='PROFILER')
Ryan7bad9de2009-06-16 13:47:57127
Ryan Dahlb8c3d712010-01-27 02:34:42128 if Options.options.efence:
129 conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE')
Ryana3627c02009-05-27 14:29:55130
Ryan Dahl8b62e862009-10-10 09:58:36131 if not conf.check(lib="execinfo", libpath=['/usr/lib', '/usr/local/lib'], uselib_store="EXECINFO"):
Rasmus Andersson6eb8bbc2009-12-15 22:37:49132 # Note on Darwin/OS X: This will fail, but will still be used as the
133 # execinfo stuff are part of the standard library.
Ryan Dahl8b62e862009-10-10 09:58:36134 if sys.platform.startswith("freebsd"):
Simon Cornelius P. Umacobe801f422009-12-09 12:36:12135 conf.fatal("Install the libexecinfo port from /usr/ports/devel/libexecinfo.")
Ryana3627c02009-05-27 14:29:55136
Rhys Jonesb6dda612009-11-22 02:58:08137 if conf.check_cfg(package='gnutls',
138 args='--cflags --libs',
Ryan Dahl8a58e832009-11-28 14:25:10139 atleast_version='2.5.0',
Rhys Jonesb6dda612009-11-22 02:58:08140 #libpath=['/usr/lib', '/usr/local/lib'],
141 uselib_store='GNUTLS'):
142 if conf.check(lib='gpg-error',
Ryan Dahl0b823dc2010-02-17 21:56:44143 libpath=['/usr/lib', '/usr/local/lib', '/opt/local/lib'],
Rhys Jonesb6dda612009-11-22 02:58:08144 uselib_store='GPGERROR'):
145 conf.env.append_value("CCFLAGS", "-DEVCOM_HAVE_GNUTLS=1")
146 conf.env.append_value("CXXFLAGS", "-DEVCOM_HAVE_GNUTLS=1")
147
Ryan Dahl0c125542010-01-19 23:38:20148 if sys.platform.startswith("sunos"):
149 if not conf.check(lib='socket', uselib_store="SOCKET"):
150 conf.fatal("Cannot find socket library")
151 if not conf.check(lib='nsl', uselib_store="NSL"):
152 conf.fatal("Cannot find nsl library")
153
Ryan1a126ed2009-04-04 12:50:15154 conf.sub_config('deps/libeio')
Jérémy Lalc93bab12010-03-11 21:15:32155 if not Options.options.system:
156 conf.sub_config('deps/libev')
157 if sys.platform.startswith("sunos"):
158 conf_subproject(conf, 'deps/udns', 'LIBS="-lsocket -lnsl" ./configure')
159 else:
160 conf_subproject(conf, 'deps/udns', './configure')
Ryan Dahl0c125542010-01-19 23:38:20161 else:
Jérémy Lalc93bab12010-03-11 21:15:32162 if not conf.check(lib='v8', uselib_store='V8'):
163 conf.fatal("Cannot find V8")
164 if not conf.check(lib='ev', uselib_store='EV'):
165 conf.fatal("Cannot find libev")
Ryan Dahlffeb4722010-03-13 20:20:09166 if not conf.check(lib='udns', uselib_store='UDNS'):
Jérémy Lalc93bab12010-03-11 21:15:32167 conf.fatal("Cannot find udns")
Ryan41d89f62009-07-28 10:29:18168
Ryan1a126ed2009-04-04 12:50:15169 conf.define("HAVE_CONFIG_H", 1)
Ryanc62b1242009-04-22 17:55:08170
Ryan Dahl42797252010-03-31 20:36:20171 if sys.platform.startswith("sunos"):
172 conf.env.append_value ('CCFLAGS', '-threads')
173 conf.env.append_value ('CXXFLAGS', '-threads')
174 #conf.env.append_value ('LINKFLAGS', ' -threads')
175 else:
176 threadflags='-pthread'
177 conf.env.append_value ('CCFLAGS', threadflags)
178 conf.env.append_value ('CXXFLAGS', threadflags)
179 conf.env.append_value ('LINKFLAGS', threadflags)
180
Ryan Dahl1beb8402009-12-30 08:01:28181 conf.env.append_value("CCFLAGS", "-DX_STACKSIZE=%d" % (1024*64))
Ryan427e3f52009-05-14 11:16:45182
Ryan Dahl2b743aa2009-10-27 11:05:38183 # LFS
184 conf.env.append_value('CCFLAGS', '-D_LARGEFILE_SOURCE')
185 conf.env.append_value('CXXFLAGS', '-D_LARGEFILE_SOURCE')
186 conf.env.append_value('CCFLAGS', '-D_FILE_OFFSET_BITS=64')
187 conf.env.append_value('CXXFLAGS', '-D_FILE_OFFSET_BITS=64')
188
Ryan Dahlf4811832009-11-02 23:21:00189 # platform
190 platform_def = '-DPLATFORM=' + sys.platform
191 conf.env.append_value('CCFLAGS', platform_def)
192 conf.env.append_value('CXXFLAGS', platform_def)
193
Ryan67af9582009-04-18 13:35:42194 # Split off debug variant before adding variant specific defines
Ryan7e1350f2009-04-16 09:37:44195 debug_env = conf.env.copy()
196 conf.set_env_name('debug', debug_env)
Ryan7e1350f2009-04-16 09:37:44197
Ryan67af9582009-04-18 13:35:42198 # Configure debug variant
199 conf.setenv('debug')
200 debug_env.set_variant('debug')
Ryan8ddf9302009-09-02 18:19:52201 debug_env.append_value('CCFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra'])
202 debug_env.append_value('CXXFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra'])
Ryan67af9582009-04-18 13:35:42203 conf.write_config_header("config.h")
204
205 # Configure default variant
206 conf.setenv('default')
Ryan8ddf9302009-09-02 18:19:52207 conf.env.append_value('CCFLAGS', ['-DNDEBUG', '-O3'])
208 conf.env.append_value('CXXFLAGS', ['-DNDEBUG', '-O3'])
Ryan67af9582009-04-18 13:35:42209 conf.write_config_header("config.h")
Ryan63a9cd32009-04-15 08:08:28210
Ryan41d89f62009-07-28 10:29:18211def build_udns(bld):
212 default_build_dir = bld.srcnode.abspath(bld.env_of_name("default"))
Ryan1a126ed2009-04-04 12:50:15213
Ryan41d89f62009-07-28 10:29:18214 default_dir = join(default_build_dir, "deps/udns")
215
216 static_lib = bld.env["staticlib_PATTERN"] % "udns"
217
masuidrive3337e9d2010-02-10 10:21:54218 rule = 'cd "%s" && make'
Ryan41d89f62009-07-28 10:29:18219
220 default = bld.new_task_gen(
221 target= join("deps/udns", static_lib),
222 rule= rule % default_dir,
223 before= "cxx",
224 install_path= None
225 )
226
227 bld.env["CPPPATH_UDNS"] = "deps/udns"
Ryan Dahlfc937aa2009-10-27 21:50:46228 t = join(bld.srcnode.abspath(bld.env_of_name("default")), default.target)
229 bld.env_of_name('default')["LINKFLAGS_UDNS"] = [t]
Ryan41d89f62009-07-28 10:29:18230
231 if bld.env["USE_DEBUG"]:
232 debug_build_dir = bld.srcnode.abspath(bld.env_of_name("debug"))
233 debug_dir = join(debug_build_dir, "deps/udns")
234 debug = default.clone("debug")
235 debug.rule = rule % debug_dir
Ryan Dahlfc937aa2009-10-27 21:50:46236 t = join(bld.srcnode.abspath(bld.env_of_name("debug")), debug.target)
237 bld.env_of_name('debug')["LINKFLAGS_UDNS"] = [t]
Ryan Dahl0c125542010-01-19 23:38:20238
Ryan Dahlbf0d2782009-10-03 20:42:03239 bld.install_files('${PREFIX}/include/node/', 'deps/udns/udns.h')
Ryan41d89f62009-07-28 10:29:18240
Ryan Dahl53ebe752009-10-08 21:20:14241def v8_cmd(bld, variant):
242 scons = join(cwd, 'tools/scons/scons.py')
Ryan1a126ed2009-04-04 12:50:15243 deps_src = join(bld.path.abspath(),"deps")
Ryan1a126ed2009-04-04 12:50:15244 v8dir_src = join(deps_src,"v8")
Ryan Dahl53ebe752009-10-08 21:20:14245
Ryan Dahlbc9b3432009-10-02 12:10:40246 # NOTE: We want to compile V8 to export its symbols. I.E. Do not want
247 # -fvisibility=hidden. When using dlopen() it seems that the loaded DSO
248 # cannot see symbols in the executable which are hidden, even if the
249 # executable is statically linked together...
Ryan8ddf9302009-09-02 18:19:52250
Ryan Dahl7d9d8812009-10-26 21:27:52251 # XXX Remove this when v8 defaults x86_64 to native builds
Ryan Dahld85724d2009-10-08 22:34:39252 arch = ""
Ryan Dahl7d9d8812009-10-26 21:27:52253 if bld.env['DEST_CPU'] == 'x86_64':
Ryan Dahld85724d2009-10-08 22:34:39254 arch = "arch=x64"
255
256 if variant == "default":
257 mode = "release"
258 else:
259 mode = "debug"
Ryana4593e32009-04-23 11:18:38260
masuidrive3337e9d2010-02-10 10:21:54261 cmd_R = 'python "%s" -C "%s" -Y "%s" visibility=default mode=%s %s library=static snapshot=on'
Ryan Dahl53ebe752009-10-08 21:20:14262
263 cmd = cmd_R % ( scons
264 , bld.srcnode.abspath(bld.env_of_name(variant))
265 , v8dir_src
266 , mode
267 , arch
268 )
269 return cmd
270
271
272def build_v8(bld):
Ryan1a126ed2009-04-04 12:50:15273 v8 = bld.new_task_gen(
Ryan Dahl59b7a1b2009-10-09 10:49:48274 source = 'deps/v8/SConstruct '
275 + bld.path.ant_glob('v8/include/*')
276 + bld.path.ant_glob('v8/src/*'),
Ryan Dahl53ebe752009-10-08 21:20:14277 target = bld.env["staticlib_PATTERN"] % "v8",
278 rule = v8_cmd(bld, "default"),
279 before = "cxx",
280 install_path = None
Ryan1a126ed2009-04-04 12:50:15281 )
Ryan Dahl8b62e862009-10-10 09:58:36282 v8.uselib = "EXECINFO"
Ryan1a126ed2009-04-04 12:50:15283 bld.env["CPPPATH_V8"] = "deps/v8/include"
Ryan Dahlfc937aa2009-10-27 21:50:46284 t = join(bld.srcnode.abspath(bld.env_of_name("default")), v8.target)
Ryan Dahl42797252010-03-31 20:36:20285 bld.env_of_name('default').append_value("LINKFLAGS_V8", t)
286
Ryana4593e32009-04-23 11:18:38287
288 ### v8 debug
Ryan29b528c2009-04-23 15:29:31289 if bld.env["USE_DEBUG"]:
Ryan29b528c2009-04-23 15:29:31290 v8_debug = v8.clone("debug")
Ryan Dahl53ebe752009-10-08 21:20:14291 v8_debug.rule = v8_cmd(bld, "debug")
292 v8_debug.target = bld.env["staticlib_PATTERN"] % "v8_g"
Ryan Dahl8b62e862009-10-10 09:58:36293 v8_debug.uselib = "EXECINFO"
Ryan Dahlfc937aa2009-10-27 21:50:46294 t = join(bld.srcnode.abspath(bld.env_of_name("debug")), v8_debug.target)
Ryan Dahl42797252010-03-31 20:36:20295 bld.env_of_name('debug').append_value("LINKFLAGS_V8", t)
Ryan1a126ed2009-04-04 12:50:15296
Ryan Dahl53ebe752009-10-08 21:20:14297 bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h')
Ryan2b6d7242009-06-20 13:07:10298
Ryan41d89f62009-07-28 10:29:18299def build(bld):
Jérémy Lalc93bab12010-03-11 21:15:32300 if not bld.env["USE_SYSTEM"]:
301 bld.add_subdirs('deps/libeio deps/libev')
302 build_udns(bld)
303 build_v8(bld)
304 else:
305 bld.add_subdirs('deps/libeio')
Ryan41d89f62009-07-28 10:29:18306
Jérémy Lalc93bab12010-03-11 21:15:32307
Ryan41d89f62009-07-28 10:29:18308
Ryan0fb0af32009-07-25 15:52:21309 ### evcom
Ryan Dahl122e74b2009-10-27 21:26:53310 evcom = bld.new_task_gen("cc")
Ryan0fb0af32009-07-25 15:52:21311 evcom.source = "deps/evcom/evcom.c"
Jérémy Lalc93bab12010-03-11 21:15:32312 if not bld.env["USE_SYSTEM"]:
313 evcom.includes = "deps/evcom/ deps/libev/"
314 else:
315 evcom.includes = "deps/evcom/"
Ryan0fb0af32009-07-25 15:52:21316 evcom.name = "evcom"
317 evcom.target = "evcom"
Rhys Jonesb6dda612009-11-22 02:58:08318 evcom.uselib = "GPGERROR GNUTLS"
Ryan0fb0af32009-07-25 15:52:21319 evcom.install_path = None
Ryan29b528c2009-04-23 15:29:31320 if bld.env["USE_DEBUG"]:
Ryan0fb0af32009-07-25 15:52:21321 evcom.clone("debug")
Ryan Dahlbf0d2782009-10-03 20:42:03322 bld.install_files('${PREFIX}/include/node/', 'deps/evcom/evcom.h')
Ryan1a126ed2009-04-04 12:50:15323
Ryan5a071ad2009-05-03 12:09:16324 ### http_parser
Ryan Dahl122e74b2009-10-27 21:26:53325 http_parser = bld.new_task_gen("cc")
Ryan5a071ad2009-05-03 12:09:16326 http_parser.source = "deps/http_parser/http_parser.c"
327 http_parser.includes = "deps/http_parser/"
328 http_parser.name = "http_parser"
329 http_parser.target = "http_parser"
330 http_parser.install_path = None
Ryan29b528c2009-04-23 15:29:31331 if bld.env["USE_DEBUG"]:
Ryan5a071ad2009-05-03 12:09:16332 http_parser.clone("debug")
Ryan1a126ed2009-04-04 12:50:15333
Ryan17c6a672009-08-24 18:25:24334 ### coupling
Ryan Dahl122e74b2009-10-27 21:26:53335 coupling = bld.new_task_gen("cc")
Ryan17c6a672009-08-24 18:25:24336 coupling.source = "deps/coupling/coupling.c"
337 coupling.includes = "deps/coupling/"
338 coupling.name = "coupling"
339 coupling.target = "coupling"
340 coupling.install_path = None
341 if bld.env["USE_DEBUG"]:
342 coupling.clone("debug")
343
Ryan63a9cd32009-04-15 08:08:28344 ### src/native.cc
Zokab29f7872010-03-20 03:56:03345 def make_macros(loc, content):
346 f = open(loc, 'w')
347 f.write(content)
348 f.close
349
350 macros_loc_debug = join(
351 bld.srcnode.abspath(bld.env_of_name("debug")),
352 "macros.py"
353 )
354
355 macros_loc_default = join(
356 bld.srcnode.abspath(bld.env_of_name("default")),
357 "macros.py"
358 )
359
360 make_macros(macros_loc_debug, "") # leave debug(x) as is in debug build
361 # replace debug(x) with nothing in release build
362 make_macros(macros_loc_default, "macro debug(x) = ;\n")
363
Ryan63a9cd32009-04-15 08:08:28364 def javascript_in_c(task):
365 env = task.env
366 source = map(lambda x: x.srcpath(env), task.inputs)
367 targets = map(lambda x: x.srcpath(env), task.outputs)
Zokab29f7872010-03-20 03:56:03368 source.append(macros_loc_default)
369 js2c.JS2C(source, targets)
370
371 def javascript_in_c_debug(task):
372 env = task.env
373 source = map(lambda x: x.srcpath(env), task.inputs)
374 targets = map(lambda x: x.srcpath(env), task.outputs)
375 source.append(macros_loc_debug)
Ryan63a9cd32009-04-15 08:08:28376 js2c.JS2C(source, targets)
377
378 native_cc = bld.new_task_gen(
Ryan Dahl4ccdc502010-03-15 15:00:19379 source='src/node.js ' + bld.path.ant_glob('lib/*.js'),
Ryan Dahl53ebe752009-10-08 21:20:14380 target="src/node_natives.h",
Ryan Dahl4ccdc502010-03-15 15:00:19381 before="cxx",
382 install_path=None
Ryan63a9cd32009-04-15 08:08:28383 )
Ryan Dahl4bcb01c2009-10-16 20:53:44384
385 # Add the rule /after/ cloning the debug
386 # This is a work around for an error had in python 2.4.3 (I'll paste the
387 # error that was had into the git commit meessage. git-blame to find out
388 # where.)
Ryan29b528c2009-04-23 15:29:31389 if bld.env["USE_DEBUG"]:
Ryan Dahl4bcb01c2009-10-16 20:53:44390 native_cc_debug = native_cc.clone("debug")
Zokab29f7872010-03-20 03:56:03391 native_cc_debug.rule = javascript_in_c_debug
392
Ryan Dahl4bcb01c2009-10-16 20:53:44393 native_cc.rule = javascript_in_c
Ryan63a9cd32009-04-15 08:08:28394
Ryan2b6d7242009-06-20 13:07:10395 ### node lib
Ryan8152f9c2009-09-01 12:15:29396 node = bld.new_task_gen("cxx", "program")
397 node.name = "node"
398 node.target = "node"
399 node.source = """
Ryan1a126ed2009-04-04 12:50:15400 src/node.cc
Ryan Dahl630bb7a2009-12-13 07:42:45401 src/node_buffer.cc
Ryan Dahl42ee1692010-01-24 19:21:45402 src/node_http_parser.cc
Ryan Dahlbf803f42010-01-27 23:40:09403 src/node_net2.cc
Ryan Dahlf2199382009-12-13 14:43:58404 src/node_io_watcher.cc
Ryan Dahla5df0f62009-10-27 10:46:58405 src/node_child_process.cc
406 src/node_constants.cc
407 src/node_dns.cc
408 src/node_events.cc
409 src/node_file.cc
410 src/node_http.cc
411 src/node_net.cc
Ryan Dahl8492c522010-03-15 21:05:18412 src/node_signal_watcher.cc
413 src/node_stat_watcher.cc
Ryan17c6a672009-08-24 18:25:24414 src/node_stdio.cc
Ryan Dahla5df0f62009-10-27 10:46:58415 src/node_timer.cc
Ryan Dahlaeb7d6d2010-01-18 18:12:04416 src/node_idle_watcher.cc
Ryan1a126ed2009-04-04 12:50:15417 """
Jérémy Lalc93bab12010-03-11 21:15:32418 if not bld.env["USE_SYSTEM"]:
419 node.includes = """
420 src/
421 deps/v8/include
422 deps/libev
423 deps/udns
424 deps/libeio
425 deps/evcom
426 deps/http_parser
427 deps/coupling
428 """
429 node.add_objects = 'ev eio evcom http_parser coupling'
430 node.uselib_local = ''
431 node.uselib = 'GNUTLS GPGERROR UDNS V8 EXECINFO DL KVM SOCKET NSL'
432 else:
433 node.includes = """
434 src/
435 deps/libeio
436 deps/evcom
437 deps/http_parser
438 deps/coupling
439 """
440 node.add_objects = 'eio evcom http_parser coupling'
441 node.uselib_local = 'eio'
442 node.uselib = 'EV GNUTLS GPGERROR UDNS V8 EXECINFO DL KVM SOCKET NSL'
Rhys Jonesb6dda612009-11-22 02:58:08443
Ryan8152f9c2009-09-01 12:15:29444 node.install_path = '${PREFIX}/lib'
Ryan8e7bbf22009-04-23 17:26:56445 node.install_path = '${PREFIX}/bin'
446 node.chmod = 0755
447
Ryan4d921992009-08-26 23:11:16448 def subflags(program):
Ryan Dahld979ac92009-10-09 13:00:12449 if os.path.exists(join(cwd, ".git")):
Ryan Dahl962e9292009-10-09 14:16:27450 actual_version=cmd_output("git describe").strip()
Ryan Dahld979ac92009-10-09 13:00:12451 else:
452 actual_version=VERSION
453
Ryanb73264d2009-08-27 00:15:11454 x = { 'CCFLAGS' : " ".join(program.env["CCFLAGS"])
455 , 'CPPFLAGS' : " ".join(program.env["CPPFLAGS"])
456 , 'LIBFLAGS' : " ".join(program.env["LIBFLAGS"])
Ryan Dahld979ac92009-10-09 13:00:12457 , 'VERSION' : actual_version
Ryanb73264d2009-08-27 00:15:11458 , 'PREFIX' : program.env["PREFIX"]
Ryan4d921992009-08-26 23:11:16459 }
Ryan Dahlbf0d2782009-10-03 20:42:03460 return x
Ryan4d921992009-08-26 23:11:16461
Ryan4d921992009-08-26 23:11:16462 # process file.pc.in -> file.pc
Ryan Dahld979ac92009-10-09 13:00:12463
Ryanb73264d2009-08-27 00:15:11464 node_version = bld.new_task_gen('subst', before="cxx")
465 node_version.source = 'src/node_version.h.in'
466 node_version.target = 'src/node_version.h'
467 node_version.dict = subflags(node)
Ryana97dce72009-08-31 09:14:34468 node_version.install_path = '${PREFIX}/include/node'
Ryan4d921992009-08-26 23:11:16469
Ryan29b528c2009-04-23 15:29:31470 if bld.env["USE_DEBUG"]:
Ryan2b6d7242009-06-20 13:07:10471 node_g = node.clone("debug")
472 node_g.target = "node_g"
Ryan4d921992009-08-26 23:11:16473
Ryanb73264d2009-08-27 00:15:11474 node_version_g = node_version.clone("debug")
475 node_version_g.dict = subflags(node_g)
Ryana97dce72009-08-31 09:14:34476 node_version_g.install_path = None
Ryan4d921992009-08-26 23:11:16477
Ryana97dce72009-08-31 09:14:34478
479 bld.install_files('${PREFIX}/include/node/', """
480 config.h
481 src/node.h
Ryan Dahl5f466c82009-10-27 19:17:03482 src/node_object_wrap.h
483 src/node_events.h
484 src/node_net.h
Ryan Dahlbf0d2782009-10-03 20:42:03485 """)
486
487 # Only install the man page if it exists.
488 # Do 'make doc install' to build and install it.
489 if os.path.exists('doc/node.1'):
490 bld.install_files('${PREFIX}/share/man/man1/', 'doc/node.1')
491
492 bld.install_files('${PREFIX}/bin/', 'bin/*', chmod=0755)
Ryan Dahl6f17ca52009-10-03 17:08:05493
494 # Why am I using two lines? Because WAF SUCKS.
Ryan Dahlbf0d2782009-10-03 20:42:03495 bld.install_files('${PREFIX}/lib/node/wafadmin', 'tools/wafadmin/*.py')
496 bld.install_files('${PREFIX}/lib/node/wafadmin/Tools', 'tools/wafadmin/Tools/*.py')
Ryan Dahl6f17ca52009-10-03 17:08:05497
Ryan Dahl132d6852009-10-27 17:11:07498def shutdown():
499 Options.options.debug
500 # HACK to get binding.node out of build directory.
501 # better way to do this?
502 if not Options.commands['clean']:
503 if os.path.exists('build/default/node') and not os.path.exists('node'):
504 os.symlink('build/default/node', 'node')
505 if os.path.exists('build/debug/node_g') and not os.path.exists('node_g'):
506 os.symlink('build/debug/node_g', 'node_g')
507 else:
508 if os.path.exists('node'): os.unlink('node')
509 if os.path.exists('node_g'): os.unlink('node_g')