Ryan | a3627c0 | 2009-05-27 14:29:55 | [diff] [blame] | 1 | # /usr/bin/env python |
Ryan | 8ddf930 | 2009-09-02 18:19:52 | [diff] [blame] | 2 | import platform |
| 3 | import re |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 4 | import Options |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 5 | import sys, os, shutil |
Ryan Dahl | d979ac9 | 2009-10-09 13:00:12 | [diff] [blame] | 6 | from Utils import cmd_output |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 7 | from os.path import join, dirname, abspath |
Ryan | a4593e3 | 2009-04-23 11:18:38 | [diff] [blame] | 8 | from logging import fatal |
| 9 | |
Ryan Dahl | d979ac9 | 2009-10-09 13:00:12 | [diff] [blame] | 10 | cwd = os.getcwd() |
Ryan Dahl | d79b6e9 | 2009-10-09 16:10:59 | [diff] [blame] | 11 | VERSION="0.1.14" |
Ryan | 4d92199 | 2009-08-26 23:11:16 | [diff] [blame] | 12 | APPNAME="node.js" |
| 13 | |
Ryan | 63a9cd3 | 2009-04-15 08:08:28 | [diff] [blame] | 14 | import js2c |
| 15 | |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 16 | srcdir = '.' |
| 17 | blddir = 'build' |
| 18 | |
| 19 | def set_options(opt): |
| 20 | # the gcc module provides a --debug-level option |
| 21 | opt.tool_options('compiler_cxx') |
| 22 | opt.tool_options('compiler_cc') |
Ryan | 4d92199 | 2009-08-26 23:11:16 | [diff] [blame] | 23 | opt.tool_options('misc') |
Ryan | 29b528c | 2009-04-23 15:29:31 | [diff] [blame] | 24 | opt.add_option( '--debug' |
| 25 | , action='store_true' |
| 26 | , default=False |
| 27 | , help='Build debug variant [Default: False]' |
| 28 | , dest='debug' |
| 29 | ) |
Ryan | 7bad9de | 2009-06-16 13:47:57 | [diff] [blame] | 30 | opt.add_option( '--efence' |
| 31 | , action='store_true' |
| 32 | , default=False |
| 33 | , help='Build with -lefence for debugging [Default: False]' |
| 34 | , dest='efence' |
| 35 | ) |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 36 | |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 37 | def mkdir_p(dir): |
| 38 | if not os.path.exists (dir): |
| 39 | os.makedirs (dir) |
| 40 | |
Ryan Dahl | 18da8ff | 2009-09-28 20:39:00 | [diff] [blame] | 41 | # Copied from Python 2.6 because 2.4.4 at least is broken by not using |
| 42 | # mkdirs |
| 43 | # http://mail.python.org/pipermail/python-bugs-list/2005-January/027118.html |
| 44 | def copytree(src, dst, symlinks=False, ignore=None): |
| 45 | names = os.listdir(src) |
| 46 | if ignore is not None: |
| 47 | ignored_names = ignore(src, names) |
| 48 | else: |
| 49 | ignored_names = set() |
| 50 | |
| 51 | os.makedirs(dst) |
| 52 | errors = [] |
| 53 | for name in names: |
| 54 | if name in ignored_names: |
| 55 | continue |
Ryan Dahl | 53ebe75 | 2009-10-08 21:20:14 | [diff] [blame] | 56 | srcname = join(src, name) |
| 57 | dstname = join(dst, name) |
Ryan Dahl | 18da8ff | 2009-09-28 20:39:00 | [diff] [blame] | 58 | try: |
| 59 | if symlinks and os.path.islink(srcname): |
| 60 | linkto = os.readlink(srcname) |
| 61 | os.symlink(linkto, dstname) |
| 62 | elif os.path.isdir(srcname): |
| 63 | copytree(srcname, dstname, symlinks, ignore) |
| 64 | else: |
| 65 | shutil.copy2(srcname, dstname) |
| 66 | # XXX What about devices, sockets etc.? |
| 67 | except (IOError, os.error), why: |
| 68 | errors.append((srcname, dstname, str(why))) |
| 69 | # catch the Error from the recursive copytree so that we can |
| 70 | # continue with other files |
| 71 | except Error, err: |
| 72 | errors.extend(err.args[0]) |
| 73 | try: |
| 74 | shutil.copystat(src, dst) |
| 75 | except OSError, why: |
| 76 | if WindowsError is not None and isinstance(why, WindowsError): |
| 77 | # Copying file access times may fail on Windows |
| 78 | pass |
| 79 | else: |
| 80 | errors.extend((src, dst, str(why))) |
| 81 | if errors: |
| 82 | raise Error, errors |
| 83 | |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 84 | def conf_subproject (conf, subdir, command=None): |
| 85 | print("---- %s ----" % subdir) |
| 86 | src = join(conf.srcdir, subdir) |
| 87 | if not os.path.exists (src): fatal("no such subproject " + subdir) |
| 88 | |
| 89 | default_tgt = join(conf.blddir, "default", subdir) |
| 90 | |
| 91 | if not os.path.exists(default_tgt): |
Ryan Dahl | 18da8ff | 2009-09-28 20:39:00 | [diff] [blame] | 92 | copytree(src, default_tgt, True) |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 93 | |
| 94 | if command: |
| 95 | if os.system("cd %s && %s" % (default_tgt, command)) != 0: |
| 96 | fatal("Configuring %s failed." % (subdir)) |
| 97 | |
| 98 | debug_tgt = join(conf.blddir, "debug", subdir) |
| 99 | |
| 100 | if not os.path.exists(debug_tgt): |
Ryan Dahl | 18da8ff | 2009-09-28 20:39:00 | [diff] [blame] | 101 | copytree(default_tgt, debug_tgt, True) |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 102 | |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 103 | def configure(conf): |
| 104 | conf.check_tool('compiler_cxx') |
| 105 | conf.check_tool('compiler_cc') |
Ryan | a4593e3 | 2009-04-23 11:18:38 | [diff] [blame] | 106 | |
Ryan | 8e7bbf2 | 2009-04-23 17:26:56 | [diff] [blame] | 107 | conf.env["USE_DEBUG"] = Options.options.debug |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 108 | |
Ryan | 2b6d724 | 2009-06-20 13:07:10 | [diff] [blame] | 109 | conf.check(lib='dl', uselib_store='DL') |
Ryan | 8152f9c | 2009-09-01 12:15:29 | [diff] [blame] | 110 | conf.env.append_value("CCFLAGS", "-rdynamic") |
Ryan | a97dce7 | 2009-08-31 09:14:34 | [diff] [blame] | 111 | conf.env.append_value("LINKFLAGS_DL", "-rdynamic") |
| 112 | |
Ryan | 8152f9c | 2009-09-01 12:15:29 | [diff] [blame] | 113 | #if Options.options.debug: |
| 114 | # conf.check(lib='profiler', uselib_store='PROFILER') |
Ryan | 7bad9de | 2009-06-16 13:47:57 | [diff] [blame] | 115 | |
Ryan | 8152f9c | 2009-09-01 12:15:29 | [diff] [blame] | 116 | #if Options.options.efence: |
| 117 | # conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE') |
Ryan | a3627c0 | 2009-05-27 14:29:55 | [diff] [blame] | 118 | |
Ryan Dahl | 8b62e86 | 2009-10-10 09:58:36 | [diff] [blame] | 119 | if not conf.check(lib="execinfo", libpath=['/usr/lib', '/usr/local/lib'], uselib_store="EXECINFO"): |
| 120 | if sys.platform.startswith("freebsd"): |
Ryan | 7bad9de | 2009-06-16 13:47:57 | [diff] [blame] | 121 | fatal("Install the libexecinfo port from /usr/ports/devel/libexecinfo.") |
Ryan | a3627c0 | 2009-05-27 14:29:55 | [diff] [blame] | 122 | |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 123 | conf.sub_config('deps/libeio') |
| 124 | conf.sub_config('deps/libev') |
| 125 | |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 126 | conf_subproject(conf, 'deps/udns', './configure') |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 127 | |
Ryan | 452d3f1 | 2009-06-11 11:40:14 | [diff] [blame] | 128 | # Not using TLS yet |
| 129 | # if conf.check_cfg(package='gnutls', args='--cflags --libs', uselib_store="GNUTLS"): |
| 130 | # conf.define("HAVE_GNUTLS", 1) |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 131 | |
| 132 | conf.define("HAVE_CONFIG_H", 1) |
Ryan | c62b124 | 2009-04-22 17:55:08 | [diff] [blame] | 133 | |
Ryan | 1df6d61 | 2009-09-03 13:59:48 | [diff] [blame] | 134 | conf.env.append_value("CCFLAGS", "-DX_STACKSIZE=%d" % (1024*64)) |
Ryan | 427e3f5 | 2009-05-14 11:16:45 | [diff] [blame] | 135 | |
Ryan | 67af958 | 2009-04-18 13:35:42 | [diff] [blame] | 136 | # Split off debug variant before adding variant specific defines |
Ryan | 7e1350f | 2009-04-16 09:37:44 | [diff] [blame] | 137 | debug_env = conf.env.copy() |
| 138 | conf.set_env_name('debug', debug_env) |
Ryan | 7e1350f | 2009-04-16 09:37:44 | [diff] [blame] | 139 | |
Ryan | 67af958 | 2009-04-18 13:35:42 | [diff] [blame] | 140 | # Configure debug variant |
| 141 | conf.setenv('debug') |
| 142 | debug_env.set_variant('debug') |
Ryan | 8ddf930 | 2009-09-02 18:19:52 | [diff] [blame] | 143 | debug_env.append_value('CCFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra']) |
| 144 | debug_env.append_value('CXXFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra']) |
Ryan | 67af958 | 2009-04-18 13:35:42 | [diff] [blame] | 145 | conf.write_config_header("config.h") |
| 146 | |
| 147 | # Configure default variant |
| 148 | conf.setenv('default') |
Ryan | 8ddf930 | 2009-09-02 18:19:52 | [diff] [blame] | 149 | conf.env.append_value('CCFLAGS', ['-DNDEBUG', '-O3']) |
| 150 | conf.env.append_value('CXXFLAGS', ['-DNDEBUG', '-O3']) |
Ryan | 67af958 | 2009-04-18 13:35:42 | [diff] [blame] | 151 | conf.write_config_header("config.h") |
Ryan | 63a9cd3 | 2009-04-15 08:08:28 | [diff] [blame] | 152 | |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 153 | def build_udns(bld): |
| 154 | default_build_dir = bld.srcnode.abspath(bld.env_of_name("default")) |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 155 | |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 156 | default_dir = join(default_build_dir, "deps/udns") |
| 157 | |
| 158 | static_lib = bld.env["staticlib_PATTERN"] % "udns" |
| 159 | |
| 160 | rule = 'cd %s && make' |
| 161 | |
| 162 | default = bld.new_task_gen( |
| 163 | target= join("deps/udns", static_lib), |
| 164 | rule= rule % default_dir, |
| 165 | before= "cxx", |
| 166 | install_path= None |
| 167 | ) |
| 168 | |
| 169 | bld.env["CPPPATH_UDNS"] = "deps/udns" |
| 170 | bld.env["STATICLIB_UDNS"] = "udns" |
| 171 | |
| 172 | bld.env_of_name('default')["STATICLIB_UDNS"] = "udns" |
| 173 | bld.env_of_name('default')["LIBPATH_UDNS"] = default_dir |
| 174 | |
| 175 | if bld.env["USE_DEBUG"]: |
| 176 | debug_build_dir = bld.srcnode.abspath(bld.env_of_name("debug")) |
| 177 | debug_dir = join(debug_build_dir, "deps/udns") |
| 178 | debug = default.clone("debug") |
| 179 | debug.rule = rule % debug_dir |
| 180 | #debug.target = join(debug_dir, static_lib) |
| 181 | bld.env_of_name('debug')["STATICLIB_UDNS"] = "udns" |
| 182 | bld.env_of_name('debug')["LIBPATH_UDNS"] = debug_dir |
Ryan Dahl | bf0d278 | 2009-10-03 20:42:03 | [diff] [blame] | 183 | bld.install_files('${PREFIX}/include/node/', 'deps/udns/udns.h') |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 184 | |
Ryan | 8ddf930 | 2009-09-02 18:19:52 | [diff] [blame] | 185 | # XXX Remove this when v8 defaults x86_64 to native builds |
| 186 | def GuessArchitecture(): |
| 187 | id = platform.machine() |
Jeff Smick | bc6f381 | 2009-09-12 10:40:27 | [diff] [blame] | 188 | arch = platform.architecture()[0] |
Ryan | 8ddf930 | 2009-09-02 18:19:52 | [diff] [blame] | 189 | if id.startswith('arm'): |
| 190 | return 'arm' |
Jeff Smick | bc6f381 | 2009-09-12 10:40:27 | [diff] [blame] | 191 | elif ('64' in id) or ('64' in arch): |
Ryan | 8ddf930 | 2009-09-02 18:19:52 | [diff] [blame] | 192 | return 'x64' |
| 193 | elif (not id) or (not re.match('(x|i[3-6])86', id) is None): |
| 194 | return 'ia32' |
| 195 | else: |
| 196 | return None |
| 197 | |
Ryan Dahl | 53ebe75 | 2009-10-08 21:20:14 | [diff] [blame] | 198 | def v8_cmd(bld, variant): |
| 199 | scons = join(cwd, 'tools/scons/scons.py') |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 200 | deps_src = join(bld.path.abspath(),"deps") |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 201 | v8dir_src = join(deps_src,"v8") |
Ryan Dahl | 53ebe75 | 2009-10-08 21:20:14 | [diff] [blame] | 202 | |
Ryan Dahl | bc9b343 | 2009-10-02 12:10:40 | [diff] [blame] | 203 | # NOTE: We want to compile V8 to export its symbols. I.E. Do not want |
| 204 | # -fvisibility=hidden. When using dlopen() it seems that the loaded DSO |
| 205 | # cannot see symbols in the executable which are hidden, even if the |
| 206 | # executable is statically linked together... |
Ryan | 8ddf930 | 2009-09-02 18:19:52 | [diff] [blame] | 207 | |
Ryan Dahl | d85724d | 2009-10-08 22:34:39 | [diff] [blame] | 208 | arch = "" |
| 209 | if GuessArchitecture() == "x64": |
| 210 | arch = "arch=x64" |
| 211 | |
| 212 | if variant == "default": |
| 213 | mode = "release" |
| 214 | else: |
| 215 | mode = "debug" |
Ryan | a4593e3 | 2009-04-23 11:18:38 | [diff] [blame] | 216 | |
Ryan Dahl | 53ebe75 | 2009-10-08 21:20:14 | [diff] [blame] | 217 | cmd_R = 'python %s -C %s -Y %s visibility=default mode=%s %s library=static snapshot=on' |
| 218 | |
| 219 | cmd = cmd_R % ( scons |
| 220 | , bld.srcnode.abspath(bld.env_of_name(variant)) |
| 221 | , v8dir_src |
| 222 | , mode |
| 223 | , arch |
| 224 | ) |
| 225 | return cmd |
| 226 | |
| 227 | |
| 228 | def build_v8(bld): |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 229 | v8 = bld.new_task_gen( |
Ryan Dahl | 59b7a1b | 2009-10-09 10:49:48 | [diff] [blame] | 230 | source = 'deps/v8/SConstruct ' |
| 231 | + bld.path.ant_glob('v8/include/*') |
| 232 | + bld.path.ant_glob('v8/src/*'), |
Ryan Dahl | 53ebe75 | 2009-10-08 21:20:14 | [diff] [blame] | 233 | target = bld.env["staticlib_PATTERN"] % "v8", |
| 234 | rule = v8_cmd(bld, "default"), |
| 235 | before = "cxx", |
| 236 | install_path = None |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 237 | ) |
Ryan Dahl | 8b62e86 | 2009-10-10 09:58:36 | [diff] [blame] | 238 | v8.uselib = "EXECINFO" |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 239 | bld.env["CPPPATH_V8"] = "deps/v8/include" |
Ryan | a4593e3 | 2009-04-23 11:18:38 | [diff] [blame] | 240 | bld.env_of_name('default')["STATICLIB_V8"] = "v8" |
Ryan | 8ddf930 | 2009-09-02 18:19:52 | [diff] [blame] | 241 | bld.env_of_name('default')["LINKFLAGS_V8"] = ["-pthread"] |
Ryan | a4593e3 | 2009-04-23 11:18:38 | [diff] [blame] | 242 | |
| 243 | ### v8 debug |
Ryan | 29b528c | 2009-04-23 15:29:31 | [diff] [blame] | 244 | if bld.env["USE_DEBUG"]: |
Ryan | 29b528c | 2009-04-23 15:29:31 | [diff] [blame] | 245 | v8_debug = v8.clone("debug") |
Ryan Dahl | 53ebe75 | 2009-10-08 21:20:14 | [diff] [blame] | 246 | v8_debug.rule = v8_cmd(bld, "debug") |
| 247 | v8_debug.target = bld.env["staticlib_PATTERN"] % "v8_g" |
Ryan Dahl | 8b62e86 | 2009-10-10 09:58:36 | [diff] [blame] | 248 | v8_debug.uselib = "EXECINFO" |
Ryan | 29b528c | 2009-04-23 15:29:31 | [diff] [blame] | 249 | bld.env_of_name('debug')["STATICLIB_V8"] = "v8_g" |
Ryan | 8ddf930 | 2009-09-02 18:19:52 | [diff] [blame] | 250 | bld.env_of_name('debug')["LINKFLAGS_V8"] = ["-pthread"] |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 251 | |
Ryan Dahl | 53ebe75 | 2009-10-08 21:20:14 | [diff] [blame] | 252 | bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h') |
Ryan | 2b6d724 | 2009-06-20 13:07:10 | [diff] [blame] | 253 | |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 254 | def build(bld): |
| 255 | bld.add_subdirs('deps/libeio deps/libev') |
| 256 | |
| 257 | build_udns(bld) |
| 258 | build_v8(bld) |
| 259 | |
Ryan | 0fb0af3 | 2009-07-25 15:52:21 | [diff] [blame] | 260 | ### evcom |
| 261 | evcom = bld.new_task_gen("cc", "staticlib") |
| 262 | evcom.source = "deps/evcom/evcom.c" |
| 263 | evcom.includes = "deps/evcom/ deps/libev/" |
| 264 | evcom.name = "evcom" |
| 265 | evcom.target = "evcom" |
| 266 | # evcom.uselib = "GNUTLS" |
| 267 | evcom.install_path = None |
Ryan | 29b528c | 2009-04-23 15:29:31 | [diff] [blame] | 268 | if bld.env["USE_DEBUG"]: |
Ryan | 0fb0af3 | 2009-07-25 15:52:21 | [diff] [blame] | 269 | evcom.clone("debug") |
Ryan Dahl | bf0d278 | 2009-10-03 20:42:03 | [diff] [blame] | 270 | bld.install_files('${PREFIX}/include/node/', 'deps/evcom/evcom.h') |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 271 | |
Ryan | 5a071ad | 2009-05-03 12:09:16 | [diff] [blame] | 272 | ### http_parser |
| 273 | http_parser = bld.new_task_gen("cc", "staticlib") |
| 274 | http_parser.source = "deps/http_parser/http_parser.c" |
| 275 | http_parser.includes = "deps/http_parser/" |
| 276 | http_parser.name = "http_parser" |
| 277 | http_parser.target = "http_parser" |
| 278 | http_parser.install_path = None |
Ryan | 29b528c | 2009-04-23 15:29:31 | [diff] [blame] | 279 | if bld.env["USE_DEBUG"]: |
Ryan | 5a071ad | 2009-05-03 12:09:16 | [diff] [blame] | 280 | http_parser.clone("debug") |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 281 | |
Ryan | 17c6a67 | 2009-08-24 18:25:24 | [diff] [blame] | 282 | ### coupling |
| 283 | coupling = bld.new_task_gen("cc", "staticlib") |
| 284 | coupling.source = "deps/coupling/coupling.c" |
| 285 | coupling.includes = "deps/coupling/" |
| 286 | coupling.name = "coupling" |
| 287 | coupling.target = "coupling" |
| 288 | coupling.install_path = None |
| 289 | if bld.env["USE_DEBUG"]: |
| 290 | coupling.clone("debug") |
| 291 | |
Ryan | 63a9cd3 | 2009-04-15 08:08:28 | [diff] [blame] | 292 | ### src/native.cc |
| 293 | def javascript_in_c(task): |
| 294 | env = task.env |
| 295 | source = map(lambda x: x.srcpath(env), task.inputs) |
| 296 | targets = map(lambda x: x.srcpath(env), task.outputs) |
| 297 | js2c.JS2C(source, targets) |
| 298 | |
| 299 | native_cc = bld.new_task_gen( |
Ryan | 2ecd7ff | 2009-06-25 17:13:20 | [diff] [blame] | 300 | source = """ |
Ryan | eb10553 | 2009-07-16 15:19:02 | [diff] [blame] | 301 | src/util.js |
Ryan | 2ecd7ff | 2009-06-25 17:13:20 | [diff] [blame] | 302 | src/events.js |
Ryan | 2ecd7ff | 2009-06-25 17:13:20 | [diff] [blame] | 303 | src/file.js |
| 304 | src/node.js |
| 305 | """, |
Ryan Dahl | 53ebe75 | 2009-10-08 21:20:14 | [diff] [blame] | 306 | target="src/node_natives.h", |
Ryan | 63a9cd3 | 2009-04-15 08:08:28 | [diff] [blame] | 307 | before="cxx" |
| 308 | ) |
Ryan | 8e7bbf2 | 2009-04-23 17:26:56 | [diff] [blame] | 309 | native_cc.install_path = None |
Ryan Dahl | 4bcb01c | 2009-10-16 20:53:44 | [diff] [blame^] | 310 | |
| 311 | # Add the rule /after/ cloning the debug |
| 312 | # This is a work around for an error had in python 2.4.3 (I'll paste the |
| 313 | # error that was had into the git commit meessage. git-blame to find out |
| 314 | # where.) |
Ryan | 29b528c | 2009-04-23 15:29:31 | [diff] [blame] | 315 | if bld.env["USE_DEBUG"]: |
Ryan Dahl | 4bcb01c | 2009-10-16 20:53:44 | [diff] [blame^] | 316 | native_cc_debug = native_cc.clone("debug") |
| 317 | native_cc_debug.rule = javascript_in_c |
| 318 | native_cc.rule = javascript_in_c |
Ryan | 63a9cd3 | 2009-04-15 08:08:28 | [diff] [blame] | 319 | |
Ryan | 2b6d724 | 2009-06-20 13:07:10 | [diff] [blame] | 320 | ### node lib |
Ryan | 8152f9c | 2009-09-01 12:15:29 | [diff] [blame] | 321 | node = bld.new_task_gen("cxx", "program") |
| 322 | node.name = "node" |
| 323 | node.target = "node" |
| 324 | node.source = """ |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 325 | src/node.cc |
Ryan | 2ecd7ff | 2009-06-25 17:13:20 | [diff] [blame] | 326 | src/events.cc |
Ryan | 67af958 | 2009-04-18 13:35:42 | [diff] [blame] | 327 | src/http.cc |
Ryan | 707f244 | 2009-04-21 17:56:30 | [diff] [blame] | 328 | src/net.cc |
Ryan | 17c6a67 | 2009-08-24 18:25:24 | [diff] [blame] | 329 | src/node_stdio.cc |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 330 | src/dns.cc |
Ryan | 63a9cd3 | 2009-04-15 08:08:28 | [diff] [blame] | 331 | src/file.cc |
Brandon Beacher | f068251 | 2009-10-06 00:56:33 | [diff] [blame] | 332 | src/signal_handler.cc |
Ryan | f213a27 | 2009-04-29 09:00:46 | [diff] [blame] | 333 | src/timer.cc |
Ryan | ad9d683 | 2009-08-26 20:11:51 | [diff] [blame] | 334 | src/child_process.cc |
Ryan | b260a91 | 2009-05-26 17:48:49 | [diff] [blame] | 335 | src/constants.cc |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 336 | """ |
Ryan | 8152f9c | 2009-09-01 12:15:29 | [diff] [blame] | 337 | node.includes = """ |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 338 | src/ |
| 339 | deps/v8/include |
| 340 | deps/libev |
Ryan | 41d89f6 | 2009-07-28 10:29:18 | [diff] [blame] | 341 | deps/udns |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 342 | deps/libeio |
Ryan | 0fb0af3 | 2009-07-25 15:52:21 | [diff] [blame] | 343 | deps/evcom |
Ryan | 5a071ad | 2009-05-03 12:09:16 | [diff] [blame] | 344 | deps/http_parser |
Ryan | 17c6a67 | 2009-08-24 18:25:24 | [diff] [blame] | 345 | deps/coupling |
Ryan | 1a126ed | 2009-04-04 12:50:15 | [diff] [blame] | 346 | """ |
Ryan | 8152f9c | 2009-09-01 12:15:29 | [diff] [blame] | 347 | node.uselib_local = "evcom ev eio http_parser coupling" |
| 348 | node.uselib = "UDNS V8 EXECINFO DL" |
| 349 | node.install_path = '${PREFIX}/lib' |
Ryan | 8e7bbf2 | 2009-04-23 17:26:56 | [diff] [blame] | 350 | node.install_path = '${PREFIX}/bin' |
| 351 | node.chmod = 0755 |
| 352 | |
Ryan | 4d92199 | 2009-08-26 23:11:16 | [diff] [blame] | 353 | def subflags(program): |
Ryan Dahl | d979ac9 | 2009-10-09 13:00:12 | [diff] [blame] | 354 | if os.path.exists(join(cwd, ".git")): |
Ryan Dahl | 962e929 | 2009-10-09 14:16:27 | [diff] [blame] | 355 | actual_version=cmd_output("git describe").strip() |
Ryan Dahl | d979ac9 | 2009-10-09 13:00:12 | [diff] [blame] | 356 | else: |
| 357 | actual_version=VERSION |
| 358 | |
Ryan | b73264d | 2009-08-27 00:15:11 | [diff] [blame] | 359 | x = { 'CCFLAGS' : " ".join(program.env["CCFLAGS"]) |
| 360 | , 'CPPFLAGS' : " ".join(program.env["CPPFLAGS"]) |
| 361 | , 'LIBFLAGS' : " ".join(program.env["LIBFLAGS"]) |
Ryan Dahl | d979ac9 | 2009-10-09 13:00:12 | [diff] [blame] | 362 | , 'VERSION' : actual_version |
Ryan | b73264d | 2009-08-27 00:15:11 | [diff] [blame] | 363 | , 'PREFIX' : program.env["PREFIX"] |
Ryan | 4d92199 | 2009-08-26 23:11:16 | [diff] [blame] | 364 | } |
Ryan Dahl | bf0d278 | 2009-10-03 20:42:03 | [diff] [blame] | 365 | return x |
Ryan | 4d92199 | 2009-08-26 23:11:16 | [diff] [blame] | 366 | |
Ryan | 4d92199 | 2009-08-26 23:11:16 | [diff] [blame] | 367 | # process file.pc.in -> file.pc |
Ryan Dahl | d979ac9 | 2009-10-09 13:00:12 | [diff] [blame] | 368 | |
Ryan | b73264d | 2009-08-27 00:15:11 | [diff] [blame] | 369 | node_version = bld.new_task_gen('subst', before="cxx") |
| 370 | node_version.source = 'src/node_version.h.in' |
| 371 | node_version.target = 'src/node_version.h' |
| 372 | node_version.dict = subflags(node) |
Ryan | a97dce7 | 2009-08-31 09:14:34 | [diff] [blame] | 373 | node_version.install_path = '${PREFIX}/include/node' |
Ryan | 4d92199 | 2009-08-26 23:11:16 | [diff] [blame] | 374 | |
Ryan | 29b528c | 2009-04-23 15:29:31 | [diff] [blame] | 375 | if bld.env["USE_DEBUG"]: |
Ryan | 2b6d724 | 2009-06-20 13:07:10 | [diff] [blame] | 376 | node_g = node.clone("debug") |
| 377 | node_g.target = "node_g" |
Ryan | 4d92199 | 2009-08-26 23:11:16 | [diff] [blame] | 378 | |
Ryan | b73264d | 2009-08-27 00:15:11 | [diff] [blame] | 379 | node_version_g = node_version.clone("debug") |
| 380 | node_version_g.dict = subflags(node_g) |
Ryan | a97dce7 | 2009-08-31 09:14:34 | [diff] [blame] | 381 | node_version_g.install_path = None |
Ryan | 4d92199 | 2009-08-26 23:11:16 | [diff] [blame] | 382 | |
Ryan | a97dce7 | 2009-08-31 09:14:34 | [diff] [blame] | 383 | |
| 384 | bld.install_files('${PREFIX}/include/node/', """ |
| 385 | config.h |
| 386 | src/node.h |
| 387 | src/object_wrap.h |
| 388 | src/events.h |
| 389 | src/net.h |
Ryan Dahl | bf0d278 | 2009-10-03 20:42:03 | [diff] [blame] | 390 | """) |
| 391 | |
| 392 | # Only install the man page if it exists. |
| 393 | # Do 'make doc install' to build and install it. |
| 394 | if os.path.exists('doc/node.1'): |
| 395 | bld.install_files('${PREFIX}/share/man/man1/', 'doc/node.1') |
| 396 | |
| 397 | bld.install_files('${PREFIX}/bin/', 'bin/*', chmod=0755) |
Ryan Dahl | 6f17ca5 | 2009-10-03 17:08:05 | [diff] [blame] | 398 | |
| 399 | # Why am I using two lines? Because WAF SUCKS. |
Ryan Dahl | bf0d278 | 2009-10-03 20:42:03 | [diff] [blame] | 400 | bld.install_files('${PREFIX}/lib/node/wafadmin', 'tools/wafadmin/*.py') |
| 401 | bld.install_files('${PREFIX}/lib/node/wafadmin/Tools', 'tools/wafadmin/Tools/*.py') |
Ryan Dahl | 6f17ca5 | 2009-10-03 17:08:05 | [diff] [blame] | 402 | |
Ryan Dahl | bf0d278 | 2009-10-03 20:42:03 | [diff] [blame] | 403 | bld.install_files('${PREFIX}/lib/node/libraries/', 'lib/*.js') |