blob: e422cfa0c0ad824a5333a5c4a86e5ea3b88a7b88 [file] [log] [blame]
Ryan1a126ed2009-04-04 12:50:151#! /usr/bin/env python
2import Options
Ryan63a9cd32009-04-15 08:08:283import sys
Ryan1a126ed2009-04-04 12:50:154import os
5from os.path import join, dirname, abspath
6
Ryan63a9cd32009-04-15 08:08:287import js2c
8
Ryan1a126ed2009-04-04 12:50:159VERSION='0.0.1'
10APPNAME='node'
11
12srcdir = '.'
13blddir = 'build'
14
15def set_options(opt):
16 # the gcc module provides a --debug-level option
17 opt.tool_options('compiler_cxx')
18 opt.tool_options('compiler_cc')
Ryan63a9cd32009-04-15 08:08:2819 opt.tool_options('ragel', tdir=".")
Ryan1a126ed2009-04-04 12:50:1520
21def configure(conf):
22 conf.check_tool('compiler_cxx')
23 conf.check_tool('compiler_cc')
Ryan63a9cd32009-04-15 08:08:2824 conf.check_tool('ragel', tooldir=".")
Ryan1a126ed2009-04-04 12:50:1525
26 conf.sub_config('deps/libeio')
27 conf.sub_config('deps/libev')
28
29 # needs to match the symbols found in libeio and libev
30 # __solaris
31 # __linux
32 # __freebsd
33 # __hpux
34 # __solaris
35 platform_string = "__" + Options.platform
36 if Options.platform == "linux2":
37 platform_string = "__linux"
38 conf.define(platform_string, 1)
39
40 # liboi config
41 print "--- liboi ---"
42 if conf.check_cfg(package='gnutls', args='--cflags --libs', uselib_store="GNUTLS"):
43 conf.define("HAVE_GNUTLS", 1)
44
45 conf.define("HAVE_CONFIG_H", 1)
46 conf.write_config_header('config.h')
47
Ryan63a9cd32009-04-15 08:08:2848
Ryan1a126ed2009-04-04 12:50:1549def build(bld):
Ryan1a126ed2009-04-04 12:50:1550 bld.add_subdirs('deps/libeio deps/libev')
51
52 ### v8
53 deps_src = join(bld.path.abspath(),"deps")
54 deps_tgt = join(bld.srcnode.abspath(bld.env),"deps")
55 v8dir_src = join(deps_src,"v8")
56 v8dir_tgt = join(deps_tgt, "v8")
57 v8lib = bld.env["staticlib_PATTERN"] % "v8"
58 v8 = bld.new_task_gen(
59 target=join("deps/v8",v8lib),
Ryan63a9cd32009-04-15 08:08:2860 rule='cp -rf %s %s && cd %s && scons -Q library=static snapshot=on'
Ryan1a126ed2009-04-04 12:50:1561 % ( v8dir_src
62 , deps_tgt
63 , v8dir_tgt
64 ),
65 before="cxx"
66 )
67 bld.env["CPPPATH_V8"] = "deps/v8/include"
68 bld.env["STATICLIB_V8"] = "v8"
69 bld.env["LIBPATH_V8"] = v8dir_tgt
70 bld.env["LINKFLAGS_V8"] = "-pthread"
71
72 ### oi
73 oi = bld.new_task_gen("cc", "staticlib")
74 oi.source = "deps/oi/oi_socket.c deps/oi/oi_buf.c"
75 oi.includes = "deps/oi/"
76 oi.name = "oi"
77 oi.target = "oi"
78 oi.uselib = "GNUTLS"
79
80 ### ebb
81 ebb = bld.new_task_gen("cc", "staticlib")
82 ebb.source = "deps/ebb/ebb_request_parser.rl"
83 ebb.includes = "deps/ebb/"
84 ebb.name = "ebb"
85 ebb.target = "ebb"
86
Ryan63a9cd32009-04-15 08:08:2887 ### src/native.cc
88 def javascript_in_c(task):
89 env = task.env
90 source = map(lambda x: x.srcpath(env), task.inputs)
91 targets = map(lambda x: x.srcpath(env), task.outputs)
92 js2c.JS2C(source, targets)
93
94 native_cc = bld.new_task_gen(
95 source="src/main.js",
96 target="src/natives.h",
97 rule=javascript_in_c,
98 before="cxx"
99 )
100
101
Ryan1a126ed2009-04-04 12:50:15102 ### node
103 node = bld.new_task_gen("cxx", "program")
104 node.target = 'node'
105 node.source = """
106 src/node.cc
107 src/node_http.cc
Ryan63a9cd32009-04-15 08:08:28108 src/process.cc
109 src/file.cc
Ryan1a126ed2009-04-04 12:50:15110 src/node_timer.cc
111 """
112 node.includes = """
113 src/
114 deps/v8/include
115 deps/libev
116 deps/libeio
117 deps/oi
118 deps/ebb
119 """
120 node.uselib_local = "oi ev eio ebb"
Ryan0e9e9272009-04-04 14:53:43121 node.uselib = "V8"