~ubuntu-branches/ubuntu/trusty/nodejs/trusty

« back to all changes in this revision

Viewing changes to .pc/2002_build_without_libv8_debug.patch/wscript

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
 
3
 
# Copyright Joyent, Inc. and other Node contributors.
4
 
#
5
 
# Permission is hereby granted, free of charge, to any person obtaining a
6
 
# copy of this software and associated documentation files (the
7
 
# "Software"), to deal in the Software without restriction, including
8
 
# without limitation the rights to use, copy, modify, merge, publish,
9
 
# distribute, sublicense, and/or sell copies of the Software, and to permit
10
 
# persons to whom the Software is furnished to do so, subject to the
11
 
# following conditions:
12
 
#
13
 
# The above copyright notice and this permission notice shall be included
14
 
# in all copies or substantial portions of the Software.
15
 
#
16
 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
 
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
 
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19
 
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20
 
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
 
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22
 
# USE OR OTHER DEALINGS IN THE SOFTWARE.
23
 
 
24
 
import re
25
 
import Options
26
 
import sys, os, shutil, glob
27
 
import Utils
28
 
from Utils import cmd_output
29
 
from os.path import join, dirname, abspath, normpath
30
 
from logging import fatal
31
 
 
32
 
cwd = os.getcwd()
33
 
APPNAME="node.js"
34
 
 
35
 
# Use the directory that this file is found in to find the tools
36
 
# directory where the js2c.py file can be found.
37
 
sys.path.append(sys.argv[0] + '/tools');
38
 
import js2c
39
 
 
40
 
if sys.platform.startswith("cygwin"):
41
 
  print "cygwin not supported"
42
 
  sys.exit(1)
43
 
 
44
 
srcdir = '.'
45
 
blddir = 'out'
46
 
supported_archs = ('arm', 'ia32', 'x64') # 'mips' supported by v8, but not node
47
 
 
48
 
jobs=1
49
 
if os.environ.has_key('JOBS'):
50
 
  jobs = int(os.environ['JOBS'])
51
 
 
52
 
def safe_path(path):
53
 
  return path.replace("\\", "/")
54
 
 
55
 
def canonical_cpu_type(arch):
56
 
  m = {'x86': 'ia32', 'i386':'ia32', 'x86_64':'x64', 'amd64':'x64'}
57
 
  if arch in m: arch = m[arch]
58
 
  if not arch in supported_archs:
59
 
    raise Exception("supported architectures are "+', '.join(supported_archs)+\
60
 
                    " but NOT '" + arch + "'.")
61
 
  return arch
62
 
 
63
 
def set_options(opt):
64
 
  # the gcc module provides a --debug-level option
65
 
  opt.tool_options('compiler_cxx')
66
 
  opt.tool_options('compiler_cc')
67
 
  opt.tool_options('misc')
68
 
  opt.add_option( '--libdir'
69
 
                , action='store'
70
 
                , type='string'
71
 
                , default=False
72
 
                , help='Install into this libdir [Release: ${PREFIX}/lib]'
73
 
                )
74
 
  opt.add_option( '--debug'
75
 
                , action='store_true'
76
 
                , default=False
77
 
                , help='Build debug variant [Release: False]'
78
 
                , dest='debug'
79
 
                )
80
 
  opt.add_option( '--profile'
81
 
                , action='store_true'
82
 
                , default=False
83
 
                , help='Enable profiling [Release: False]'
84
 
                , dest='profile'
85
 
                )
86
 
  opt.add_option( '--efence'
87
 
                , action='store_true'
88
 
                , default=False
89
 
                , help='Build with -lefence for debugging [Release: False]'
90
 
                , dest='efence'
91
 
                )
92
 
 
93
 
  opt.add_option( '--without-npm'
94
 
                , action='store_true'
95
 
                , default=False
96
 
                , help='Don\'t install the bundled npm package manager [Release: False]'
97
 
                , dest='without_npm'
98
 
                )
99
 
 
100
 
  opt.add_option( '--without-snapshot'
101
 
                , action='store_true'
102
 
                , default=False
103
 
                , help='Build without snapshotting V8 libraries. You might want to set this for cross-compiling. [Release: False]'
104
 
                , dest='without_snapshot'
105
 
                )
106
 
 
107
 
  opt.add_option( '--without-ssl'
108
 
                , action='store_true'
109
 
                , default=False
110
 
                , help='Build without SSL'
111
 
                , dest='without_ssl'
112
 
                )
113
 
 
114
 
 
115
 
  opt.add_option('--shared-v8'
116
 
                , action='store_true'
117
 
                , default=False
118
 
                , help='Link to a shared V8 DLL instead of static linking'
119
 
                , dest='shared_v8'
120
 
                )
121
 
 
122
 
  opt.add_option( '--shared-v8-includes'
123
 
                , action='store'
124
 
                , default=False
125
 
                , help='Directory containing V8 header files'
126
 
                , dest='shared_v8_includes'
127
 
                )
128
 
 
129
 
  opt.add_option( '--shared-v8-libpath'
130
 
                , action='store'
131
 
                , default=False
132
 
                , help='A directory to search for the shared V8 DLL'
133
 
                , dest='shared_v8_libpath'
134
 
                )
135
 
 
136
 
  opt.add_option( '--shared-v8-libname'
137
 
                , action='store'
138
 
                , default=False
139
 
                , help="Alternative lib name to link to (default: 'v8')"
140
 
                , dest='shared_v8_libname'
141
 
                )
142
 
 
143
 
  opt.add_option( '--openssl-includes'
144
 
                , action='store'
145
 
                , default=False
146
 
                , help='A directory to search for the OpenSSL includes'
147
 
                , dest='openssl_includes'
148
 
                )
149
 
 
150
 
  opt.add_option( '--openssl-libpath'
151
 
                , action='store'
152
 
                , default=False
153
 
                , help="A directory to search for the OpenSSL libraries"
154
 
                , dest='openssl_libpath'
155
 
                )
156
 
 
157
 
  opt.add_option( '--no-ssl2'
158
 
                , action='store_true'
159
 
                , default=False
160
 
                , help="Disable OpenSSL v2"
161
 
                , dest='openssl_nov2'
162
 
                )
163
 
 
164
 
  opt.add_option( '--gdb'
165
 
                , action='store_true'
166
 
                , default=False
167
 
                , help="add gdb support"
168
 
                , dest='use_gdbjit'
169
 
                )
170
 
 
171
 
 
172
 
  opt.add_option( '--shared-zlib'
173
 
                , action='store_true'
174
 
                , default=False
175
 
                , help='Link to a shared zlib DLL instead of static linking'
176
 
                , dest='shared_zlib'
177
 
                )
178
 
 
179
 
  opt.add_option( '--shared-zlib-includes'
180
 
                , action='store'
181
 
                , default=False
182
 
                , help='Directory containing zlib header files'
183
 
                , dest='shared_zlib_includes'
184
 
                )
185
 
 
186
 
  opt.add_option( '--shared-zlib-libpath'
187
 
                , action='store'
188
 
                , default=False
189
 
                , help='A directory to search for the shared zlib DLL'
190
 
                , dest='shared_zlib_libpath'
191
 
                )
192
 
 
193
 
 
194
 
  opt.add_option( '--shared-cares'
195
 
                , action='store_true'
196
 
                , default=False
197
 
                , help='Link to a shared C-Ares DLL instead of static linking'
198
 
                , dest='shared_cares'
199
 
                )
200
 
 
201
 
  opt.add_option( '--shared-cares-includes'
202
 
                , action='store'
203
 
                , default=False
204
 
                , help='Directory containing C-Ares header files'
205
 
                , dest='shared_cares_includes'
206
 
                )
207
 
 
208
 
  opt.add_option( '--shared-cares-libpath'
209
 
                , action='store'
210
 
                , default=False
211
 
                , help='A directory to search for the shared C-Ares DLL'
212
 
                , dest='shared_cares_libpath'
213
 
                )
214
 
 
215
 
 
216
 
  opt.add_option( '--with-dtrace'
217
 
                , action='store_true'
218
 
                , default=False
219
 
                , help='Build with DTrace (experimental)'
220
 
                , dest='dtrace'
221
 
                )
222
 
 
223
 
 
224
 
  opt.add_option( '--product-type'
225
 
                , action='store'
226
 
                , default='program'
227
 
                , help='What kind of product to produce (program, cstaticlib '\
228
 
                       'or cshlib) [default: %default]'
229
 
                , dest='product_type'
230
 
                )
231
 
 
232
 
  opt.add_option( '--dest-cpu'
233
 
                , action='store'
234
 
                , default=None
235
 
                , help='CPU architecture to build for. Valid values are: '+\
236
 
                       ', '.join(supported_archs)
237
 
                , dest='dest_cpu'
238
 
                )
239
 
 
240
 
def get_node_version():
241
 
  def get_define_value(lines, define):
242
 
    for line in lines:
243
 
      if define in line:
244
 
        return line.split()[-1] #define <NAME> <VALUE>
245
 
 
246
 
  lines = open("src/node_version.h").readlines()
247
 
  node_major_version = get_define_value(lines, 'NODE_MAJOR_VERSION')
248
 
  node_minor_version = get_define_value(lines, 'NODE_MINOR_VERSION')
249
 
  node_patch_version = get_define_value(lines, 'NODE_PATCH_VERSION')
250
 
  node_is_release    = get_define_value(lines, 'NODE_VERSION_IS_RELEASE')
251
 
 
252
 
  return "%s.%s.%s%s" % ( node_major_version,
253
 
                           node_minor_version,
254
 
                           node_patch_version,
255
 
                           node_is_release == "0" and "-pre" or ""
256
 
                         )
257
 
 
258
 
def arch_cflags(conf):
259
 
  flags = []
260
 
 
261
 
  if 'DEST_CPU' in conf.env:
262
 
    arch = conf.env['DEST_CPU']
263
 
    if arch == 'ia32':
264
 
      flags += ['-m32']
265
 
    elif arch == 'x64':
266
 
      flags += ['-m64']
267
 
    if sys.platform.startswith('darwin'):
268
 
      flags += ['-arch', {'ia32':'i386', 'x64':'x86_64'}.get(arch, arch)]
269
 
 
270
 
  return flags
271
 
 
272
 
def configure(conf):
273
 
  conf.check_tool('compiler_cxx')
274
 
  if not conf.env.CXX: conf.fatal('c++ compiler not found')
275
 
  conf.check_tool('compiler_cc')
276
 
  if not conf.env.CC: conf.fatal('c compiler not found')
277
 
 
278
 
  o = Options.options
279
 
 
280
 
  if o.libdir:
281
 
    conf.env['LIBDIR'] = o.libdir
282
 
  else:
283
 
    conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
284
 
 
285
 
  conf.env["USE_DEBUG"] = o.debug
286
 
  # Snapshot building does noet seem to work on mingw32
287
 
  conf.env["SNAPSHOT_V8"] = not o.without_snapshot and not sys.platform.startswith("win32")
288
 
  if sys.platform.startswith("sunos"):
289
 
    conf.env["SNAPSHOT_V8"] = False
290
 
  conf.env["USE_PROFILING"] = o.profile
291
 
 
292
 
  conf.env["USE_SHARED_V8"] = o.shared_v8 or o.shared_v8_includes or o.shared_v8_libpath or o.shared_v8_libname
293
 
  conf.env["USE_SHARED_CARES"] = o.shared_cares or o.shared_cares_includes or o.shared_cares_libpath
294
 
  conf.env["USE_SHARED_ZLIB"] = o.shared_zlib or o.shared_zlib_includes or o.shared_zlib_libpath
295
 
 
296
 
  conf.env["USE_GDBJIT"] = o.use_gdbjit
297
 
  conf.env['USE_NPM'] = not o.without_npm
298
 
 
299
 
  if not conf.env["USE_SHARED_ZLIB"] and not sys.platform.startswith("win32"):
300
 
    conf.env.append_value("LINKFLAGS", "-lz")
301
 
 
302
 
  conf.check(lib='dl', uselib_store='DL')
303
 
  if not sys.platform.startswith("sunos") and not sys.platform.startswith("win32"):
304
 
    conf.env.append_value("CCFLAGS", "-rdynamic")
305
 
    conf.env.append_value("LINKFLAGS_DL", "-rdynamic")
306
 
 
307
 
  if 'bsd' in sys.platform:
308
 
    conf.check(lib='kvm', uselib_store='KVM')
309
 
 
310
 
  #if Options.options.debug:
311
 
  #  conf.check(lib='profiler', uselib_store='PROFILER')
312
 
 
313
 
  if Options.options.dtrace:
314
 
    if not sys.platform.startswith("sunos"):
315
 
      conf.fatal('DTrace support only currently available on Solaris')
316
 
 
317
 
    conf.find_program('dtrace', var='DTRACE', mandatory=True)
318
 
    conf.env["USE_DTRACE"] = True
319
 
    conf.env.append_value("CXXFLAGS", "-DHAVE_DTRACE=1")
320
 
 
321
 
  if Options.options.efence:
322
 
    conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE')
323
 
 
324
 
  if 'bsd' in sys.platform:
325
 
     if not conf.check(lib="execinfo",
326
 
                       includes=['/usr/include', '/usr/local/include'],
327
 
                       libpath=['/usr/lib', '/usr/local/lib'],
328
 
                       uselib_store="EXECINFO"):
329
 
       conf.fatal("Install the libexecinfo port from /usr/ports/devel/libexecinfo.")
330
 
 
331
 
  if not Options.options.without_ssl:
332
 
    # Don't override explicitly supplied openssl paths with pkg-config results.
333
 
    explicit_openssl = o.openssl_includes or o.openssl_libpath
334
 
 
335
 
    # Disable ssl v2 methods
336
 
    if o.openssl_nov2:
337
 
      conf.env.append_value("CPPFLAGS", "-DOPENSSL_NO_SSL2=1")
338
 
 
339
 
    if not explicit_openssl and conf.check_cfg(package='openssl',
340
 
                                               args='--cflags --libs',
341
 
                                               uselib_store='OPENSSL'):
342
 
      Options.options.use_openssl = conf.env["USE_OPENSSL"] = True
343
 
      conf.env.append_value("CPPFLAGS", "-DHAVE_OPENSSL=1")
344
 
    else:
345
 
      if o.openssl_libpath: 
346
 
        openssl_libpath = [o.openssl_libpath]
347
 
      elif not sys.platform.startswith('win32'):
348
 
        openssl_libpath = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/usr/sfw/lib']
349
 
      else:
350
 
        openssl_libpath = [normpath(join(cwd, '../openssl'))]
351
 
 
352
 
      if o.openssl_includes: 
353
 
        openssl_includes = [o.openssl_includes]
354
 
      elif not sys.platform.startswith('win32'):
355
 
        openssl_includes = [];
356
 
      else:
357
 
        openssl_includes = [normpath(join(cwd, '../openssl/include'))];
358
 
 
359
 
      openssl_lib_names = ['ssl', 'crypto']
360
 
      if sys.platform.startswith('win32'):
361
 
        openssl_lib_names += ['ws2_32', 'gdi32']
362
 
 
363
 
      libssl = conf.check_cc(lib=openssl_lib_names,
364
 
                             header_name='openssl/ssl.h',
365
 
                             function_name='SSL_library_init',
366
 
                             includes=openssl_includes,
367
 
                             libpath=openssl_libpath,
368
 
                             uselib_store='OPENSSL')
369
 
 
370
 
      libcrypto = conf.check_cc(lib='crypto',
371
 
                                header_name='openssl/crypto.h',
372
 
                                includes=openssl_includes,
373
 
                                libpath=openssl_libpath,
374
 
                                uselib_store='OPENSSL')
375
 
 
376
 
      if libcrypto and libssl:
377
 
        conf.env["USE_OPENSSL"] = Options.options.use_openssl = True
378
 
        conf.env.append_value("CPPFLAGS", "-DHAVE_OPENSSL=1")
379
 
      elif sys.platform.startswith('win32'):
380
 
        conf.fatal("Could not autodetect OpenSSL support. " +
381
 
                   "Use the --openssl-libpath and --openssl-includes options to set the search path. " +
382
 
                   "Use configure --without-ssl to disable this message.")
383
 
      else:
384
 
        conf.fatal("Could not autodetect OpenSSL support. " +
385
 
                   "Make sure OpenSSL development packages are installed. " +
386
 
                   "Use configure --without-ssl to disable this message.")
387
 
  else:
388
 
    Options.options.use_openssl = conf.env["USE_OPENSSL"] = False
389
 
 
390
 
  conf.check(lib='util', libpath=['/usr/lib', '/usr/local/lib'],
391
 
             uselib_store='UTIL')
392
 
 
393
 
  # normalize DEST_CPU from --dest-cpu, DEST_CPU or built-in value
394
 
  if Options.options.dest_cpu and Options.options.dest_cpu:
395
 
    conf.env['DEST_CPU'] = canonical_cpu_type(Options.options.dest_cpu)
396
 
  elif 'DEST_CPU' in os.environ and os.environ['DEST_CPU']:
397
 
    conf.env['DEST_CPU'] = canonical_cpu_type(os.environ['DEST_CPU'])
398
 
  elif 'DEST_CPU' in conf.env and conf.env['DEST_CPU']:
399
 
    conf.env['DEST_CPU'] = canonical_cpu_type(conf.env['DEST_CPU'])
400
 
 
401
 
  have_librt = conf.check(lib='rt', uselib_store='RT')
402
 
 
403
 
  if sys.platform.startswith("sunos"):
404
 
    code =  """
405
 
      #include <ifaddrs.h>
406
 
      int main(void) {
407
 
        struct ifaddrs hello;
408
 
        return 0;
409
 
      }
410
 
    """
411
 
 
412
 
    if conf.check_cc(msg="Checking for ifaddrs on solaris", fragment=code):
413
 
      conf.env.append_value('CPPFLAGS',  '-DSUNOS_HAVE_IFADDRS')
414
 
 
415
 
    if not conf.check(lib='socket', uselib_store="SOCKET"):
416
 
      conf.fatal("Cannot find socket library")
417
 
    if not conf.check(lib='nsl', uselib_store="NSL"):
418
 
      conf.fatal("Cannot find nsl library")
419
 
    if not conf.check(lib='kstat', uselib_store="KSTAT"):
420
 
      conf.fatal("Cannot find kstat library")
421
 
 
422
 
  if conf.env['USE_SHARED_V8']:
423
 
    v8_includes = [];
424
 
    if o.shared_v8_includes: v8_includes.append(o.shared_v8_includes);
425
 
 
426
 
    v8_libpath = [];
427
 
    if o.shared_v8_libpath: v8_libpath.append(o.shared_v8_libpath);
428
 
 
429
 
    if not o.shared_v8_libname: o.shared_v8_libname = 'v8'
430
 
 
431
 
    if not conf.check_cxx(lib=o.shared_v8_libname, header_name='v8.h',
432
 
                          uselib_store='V8',
433
 
                          includes=v8_includes,
434
 
                          libpath=v8_libpath):
435
 
      conf.fatal("Cannot find v8")
436
 
 
437
 
    if o.debug:
438
 
      if not conf.check_cxx(lib=o.shared_v8_libname + '_g', header_name='v8.h',
439
 
                            uselib_store='V8_G',
440
 
                            includes=v8_includes,
441
 
                            libpath=v8_libpath):
442
 
        conf.fatal("Cannot find v8_g")
443
 
 
444
 
  conf.define("HAVE_CONFIG_H", 1)
445
 
 
446
 
  if sys.platform.startswith("sunos"):
447
 
    conf.env.append_value ('CCFLAGS', '-threads')
448
 
    conf.env.append_value ('CXXFLAGS', '-threads')
449
 
    #conf.env.append_value ('LINKFLAGS', ' -threads')
450
 
  elif not sys.platform.startswith("win32"):
451
 
    threadflags='-pthread'
452
 
    conf.env.append_value ('CCFLAGS', threadflags)
453
 
    conf.env.append_value ('CXXFLAGS', threadflags)
454
 
    conf.env.append_value ('LINKFLAGS', threadflags)
455
 
 
456
 
  if sys.platform.startswith('darwin'):
457
 
    # used by platform_darwin_*.cc
458
 
    conf.env.append_value('LINKFLAGS', ['-framework','Carbon'])
459
 
 
460
 
  flags = arch_cflags(conf)
461
 
  conf.env.append_value('CCFLAGS', flags)
462
 
  conf.env.append_value('CXXFLAGS', flags)
463
 
  conf.env.append_value('LINKFLAGS', flags)
464
 
 
465
 
  # LFS
466
 
  conf.env.append_value('CPPFLAGS',  '-D_LARGEFILE_SOURCE')
467
 
  conf.env.append_value('CPPFLAGS',  '-D_FILE_OFFSET_BITS=64')
468
 
 
469
 
  if sys.platform.startswith('darwin'):
470
 
    conf.env.append_value('CPPFLAGS', '-D_DARWIN_USE_64_BIT_INODE=1')
471
 
 
472
 
  # Makes select on windows support more than 64 FDs
473
 
  if sys.platform.startswith("win32"):
474
 
    conf.env.append_value('CPPFLAGS', '-DFD_SETSIZE=1024');
475
 
 
476
 
  ## needed for node_file.cc fdatasync
477
 
  ## Strangely on OSX 10.6 the g++ doesn't see fdatasync but gcc does?
478
 
  code =  """
479
 
    #include <unistd.h>
480
 
    int main(void)
481
 
    {
482
 
       int fd = 0;
483
 
       fdatasync (fd);
484
 
       return 0;
485
 
    }
486
 
  """
487
 
  if conf.check_cxx(msg="Checking for fdatasync(2) with c++", fragment=code):
488
 
    conf.env.append_value('CPPFLAGS', '-DHAVE_FDATASYNC=1')
489
 
  else:
490
 
    conf.env.append_value('CPPFLAGS', '-DHAVE_FDATASYNC=0')
491
 
 
492
 
  # arch
493
 
  conf.env.append_value('CPPFLAGS', '-DARCH="' + conf.env['DEST_CPU'] + '"')
494
 
 
495
 
  # platform
496
 
  conf.env.append_value('CPPFLAGS', '-DPLATFORM="' + conf.env['DEST_OS'] + '"')
497
 
 
498
 
  # posix?
499
 
  if not sys.platform.startswith('win'):
500
 
    conf.env.append_value('CPPFLAGS', '-D__POSIX__=1')
501
 
 
502
 
  platform_file = "src/platform_%s.cc" % conf.env['DEST_OS']
503
 
  if os.path.exists(join(cwd, platform_file)):
504
 
    Options.options.platform_file = True
505
 
    conf.env["PLATFORM_FILE"] = platform_file
506
 
  else:
507
 
    Options.options.platform_file = False
508
 
    conf.env["PLATFORM_FILE"] = "src/platform_none.cc"
509
 
 
510
 
  if conf.env['USE_PROFILING'] == True:
511
 
    conf.env.append_value('CPPFLAGS', '-pg')
512
 
    conf.env.append_value('LINKFLAGS', '-pg')
513
 
 
514
 
  if sys.platform.startswith("win32"):
515
 
    conf.env.append_value('LIB', 'psapi')
516
 
    conf.env.append_value('LIB', 'winmm')
517
 
    # This enforces ws2_32 to be linked after crypto, otherwise the linker
518
 
    # will run into undefined references from libcrypto.a
519
 
    if not Options.options.use_openssl:
520
 
      conf.env.append_value('LIB', 'ws2_32')
521
 
 
522
 
  conf.env.append_value('CPPFLAGS', '-Wno-unused-parameter');
523
 
  conf.env.append_value('CPPFLAGS', '-D_FORTIFY_SOURCE=2');
524
 
 
525
 
  # Split off debug variant before adding variant specific defines
526
 
  debug_env = conf.env.copy()
527
 
  conf.set_env_name('Debug', debug_env)
528
 
 
529
 
  # Configure debug variant
530
 
  conf.setenv('Debug')
531
 
  debug_env.set_variant('Debug')
532
 
  debug_env.append_value('CPPFLAGS', '-DDEBUG')
533
 
  debug_compile_flags = ['-g', '-O0', '-Wall', '-Wextra']
534
 
  debug_env.append_value('CCFLAGS', debug_compile_flags)
535
 
  debug_env.append_value('CXXFLAGS', debug_compile_flags)
536
 
  conf.write_config_header("config.h")
537
 
 
538
 
  # Configure default variant
539
 
  conf.setenv('Release')
540
 
  default_compile_flags = ['-g', '-O3']
541
 
  conf.env.append_value('CCFLAGS', default_compile_flags)
542
 
  conf.env.append_value('CXXFLAGS', default_compile_flags)
543
 
  conf.write_config_header("config.h")
544
 
 
545
 
 
546
 
def v8_cmd(bld, variant):
547
 
  scons = join(cwd, 'tools/scons/scons.py')
548
 
  deps_src = join(bld.path.abspath(),"deps")
549
 
  v8dir_src = join(deps_src,"v8")
550
 
 
551
 
  # NOTE: We want to compile V8 to export its symbols. I.E. Do not want
552
 
  # -fvisibility=hidden. When using dlopen() it seems that the loaded DSO
553
 
  # cannot see symbols in the executable which are hidden, even if the
554
 
  # executable is statically linked together...
555
 
 
556
 
  # XXX Change this when v8 defaults x86_64 to native builds
557
 
  # Possible values are (arm, ia32, x64, mips).
558
 
  arch = ""
559
 
  if bld.env['DEST_CPU']:
560
 
    arch = "arch="+bld.env['DEST_CPU']
561
 
 
562
 
  toolchain = "gcc"
563
 
 
564
 
  if variant == "Release":
565
 
    mode = "release"
566
 
  else:
567
 
    mode = "debug"
568
 
 
569
 
  if bld.env["SNAPSHOT_V8"]:
570
 
    snapshot = "snapshot=on"
571
 
  else:
572
 
    snapshot = ""
573
 
 
574
 
  cmd_R = sys.executable + ' "%s" -j %d -C "%s" -Y "%s" visibility=default mode=%s %s toolchain=%s library=static %s'
575
 
 
576
 
  cmd = cmd_R % ( scons
577
 
                , Options.options.jobs
578
 
                , safe_path(bld.srcnode.abspath(bld.env_of_name(variant)))
579
 
                , safe_path(v8dir_src)
580
 
                , mode
581
 
                , arch
582
 
                , toolchain
583
 
                , snapshot
584
 
                )
585
 
 
586
 
  if bld.env["USE_GDBJIT"]:
587
 
    cmd += ' gdbjit=on '
588
 
 
589
 
  if sys.platform.startswith("sunos"):
590
 
    cmd += ' toolchain=gcc strictaliasing=off'
591
 
 
592
 
 
593
 
 
594
 
  return ("echo '%s' && " % cmd) + cmd
595
 
 
596
 
 
597
 
def build_v8(bld):
598
 
  v8 = bld.new_task_gen(
599
 
    source        = 'deps/v8/SConstruct '
600
 
                    + bld.path.ant_glob('v8/include/*')
601
 
                    + bld.path.ant_glob('v8/src/*'),
602
 
    target        = bld.env["staticlib_PATTERN"] % "v8",
603
 
    rule          = v8_cmd(bld, "Release"),
604
 
    before        = "cxx",
605
 
    install_path  = None)
606
 
 
607
 
  v8.env.env = dict(os.environ)
608
 
  v8.env.env['CC'] = sh_escape(bld.env['CC'][0])
609
 
  v8.env.env['CXX'] = sh_escape(bld.env['CXX'][0])
610
 
 
611
 
  v8.uselib = "EXECINFO"
612
 
  bld.env["CPPPATH_V8"] = "deps/v8/include"
613
 
  t = join(bld.srcnode.abspath(bld.env_of_name("Release")), v8.target)
614
 
  bld.env_of_name('Release').append_value("LINKFLAGS_V8", t)
615
 
 
616
 
  ### v8 debug
617
 
  if bld.env["USE_DEBUG"]:
618
 
    v8_debug = v8.clone("Debug")
619
 
    v8_debug.rule   = v8_cmd(bld, "Debug")
620
 
    v8_debug.target = bld.env["staticlib_PATTERN"] % "v8_g"
621
 
    v8_debug.uselib = "EXECINFO"
622
 
    bld.env["CPPPATH_V8_G"] = "deps/v8/include"
623
 
    t = join(bld.srcnode.abspath(bld.env_of_name("Debug")), v8_debug.target)
624
 
    bld.env_of_name('Debug').append_value("LINKFLAGS_V8_G", t)
625
 
 
626
 
  bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h')
627
 
 
628
 
def sh_escape(s):
629
 
  if sys.platform.startswith('win32'):
630
 
    return '"' + s + '"'
631
 
  else:
632
 
    return s.replace("\\", "\\\\").replace("(","\\(").replace(")","\\)").replace(" ","\\ ")
633
 
 
634
 
def uv_cmd(bld, variant):
635
 
  srcdeps = join(bld.path.abspath(), "deps")
636
 
  srcdir = join(srcdeps, "uv")
637
 
  blddir = bld.srcnode.abspath(bld.env_of_name(variant)) + '/deps/uv'
638
 
  #
639
 
  # FIXME This is awful! We're copying the entire source directory into the
640
 
  # build directory before each compile. This could be much improved by
641
 
  # modifying libuv's build to send object files to a separate directory.
642
 
  #
643
 
  cmd = 'cp -r ' + sh_escape(srcdir)  + '/* ' + sh_escape(blddir)
644
 
  if not sys.platform.startswith('win32'):
645
 
    make = ('if [ -z "$NODE_MAKE" ]; then NODE_MAKE=make; fi; '
646
 
            '$NODE_MAKE -C ' + sh_escape(blddir))
647
 
    flags = arch_cflags(bld)
648
 
    if flags: make += ' CFLAGS=\'%s\'' % ' '.join(flags) # don't escape
649
 
  else:
650
 
    make = 'make -C ' + sh_escape(blddir)
651
 
  return '%s && (%s clean) && (%s all)' % (cmd, make, make)
652
 
 
653
 
 
654
 
def build_uv(bld):
655
 
  uv = bld.new_task_gen(
656
 
    name = 'uv',
657
 
    source = 'deps/uv/include/uv.h',
658
 
    target = 'deps/uv/uv.a',
659
 
    before = "cxx",
660
 
    rule = uv_cmd(bld, 'Release')
661
 
  )
662
 
 
663
 
  uv.env.env = dict(os.environ)
664
 
  uv.env.env['CC'] = sh_escape(bld.env['CC'][0])
665
 
  uv.env.env['CXX'] = sh_escape(bld.env['CXX'][0])
666
 
 
667
 
  t = join(bld.srcnode.abspath(bld.env_of_name("Release")), uv.target)
668
 
  bld.env_of_name('Release').append_value("LINKFLAGS_UV", t)
669
 
 
670
 
  if bld.env["USE_DEBUG"]:
671
 
    uv_debug = uv.clone("Debug")
672
 
    uv_debug.rule = uv_cmd(bld, 'Debug')
673
 
    uv_debug.env.env = dict(os.environ)
674
 
 
675
 
    t = join(bld.srcnode.abspath(bld.env_of_name("Debug")), uv_debug.target)
676
 
    bld.env_of_name('Debug').append_value("LINKFLAGS_UV", t)
677
 
 
678
 
  bld.install_files('${PREFIX}/include/node/', 'deps/uv/include/*.h')
679
 
  bld.install_files('${PREFIX}/include/node/uv-private', 'deps/uv/include/uv-private/*.h')
680
 
  bld.install_files('${PREFIX}/include/node/ev', 'deps/uv/src/ev/*.h')
681
 
  bld.install_files('${PREFIX}/include/node/c-ares', """
682
 
    deps/uv/include/ares.h
683
 
    deps/uv/include/ares_version.h
684
 
  """)
685
 
 
686
 
 
687
 
def build(bld):
688
 
  ## This snippet is to show full commands as WAF executes
689
 
  import Build
690
 
  old = Build.BuildContext.exec_command
691
 
  def exec_command(self, cmd, **kw):
692
 
    if isinstance(cmd, list): print(" ".join(cmd))
693
 
    return old(self, cmd, **kw)
694
 
  Build.BuildContext.exec_command = exec_command
695
 
 
696
 
  Options.options.jobs=jobs
697
 
  product_type = Options.options.product_type
698
 
  product_type_is_lib = product_type != 'program'
699
 
 
700
 
  print "DEST_OS: " + bld.env['DEST_OS']
701
 
  print "DEST_CPU: " + bld.env['DEST_CPU']
702
 
  print "Parallel Jobs: " + str(Options.options.jobs)
703
 
  print "Product type: " + product_type
704
 
 
705
 
  build_uv(bld)
706
 
 
707
 
  if not bld.env['USE_SHARED_V8']: build_v8(bld)
708
 
 
709
 
 
710
 
  ### http_parser
711
 
  http_parser = bld.new_task_gen("cc")
712
 
  http_parser.source = "deps/http_parser/http_parser.c"
713
 
  http_parser.includes = "deps/http_parser/"
714
 
  http_parser.name = "http_parser"
715
 
  http_parser.target = "http_parser"
716
 
  http_parser.install_path = None
717
 
  if bld.env["USE_DEBUG"]:
718
 
    http_parser.clone("Debug")
719
 
  if product_type_is_lib:
720
 
    http_parser.ccflags = '-fPIC'
721
 
 
722
 
  ### src/native.cc
723
 
  def make_macros(loc, content):
724
 
    f = open(loc, 'a')
725
 
    f.write(content)
726
 
    f.close
727
 
 
728
 
  macros_loc_debug   = join(
729
 
     bld.srcnode.abspath(bld.env_of_name("Debug")),
730
 
     "macros.py"
731
 
  )
732
 
 
733
 
  macros_loc_default = join(
734
 
    bld.srcnode.abspath(bld.env_of_name("Release")),
735
 
    "macros.py"
736
 
  )
737
 
 
738
 
  ### We need to truncate the macros.py file
739
 
  f = open(macros_loc_debug, 'w')
740
 
  f.close
741
 
  f = open(macros_loc_default, 'w')
742
 
  f.close
743
 
 
744
 
  make_macros(macros_loc_debug, "")  # leave debug(x) as is in debug build
745
 
  # replace debug(x) with nothing in release build
746
 
  make_macros(macros_loc_default, "macro debug(x) = ;\n")
747
 
  make_macros(macros_loc_default, "macro assert(x) = ;\n")
748
 
 
749
 
  if not bld.env["USE_DTRACE"]:
750
 
    probes = [
751
 
      'DTRACE_HTTP_CLIENT_REQUEST',
752
 
      'DTRACE_HTTP_CLIENT_RESPONSE',
753
 
      'DTRACE_HTTP_SERVER_REQUEST',
754
 
      'DTRACE_HTTP_SERVER_RESPONSE',
755
 
      'DTRACE_NET_SERVER_CONNECTION',
756
 
      'DTRACE_NET_STREAM_END',
757
 
      'DTRACE_NET_SOCKET_READ',
758
 
      'DTRACE_NET_SOCKET_WRITE'
759
 
    ]
760
 
 
761
 
    for probe in probes:
762
 
      make_macros(macros_loc_default, "macro %s(x) = ;\n" % probe)
763
 
      make_macros(macros_loc_debug, "macro %s(x) = ;\n" % probe)
764
 
 
765
 
  def javascript_in_c(task):
766
 
    env = task.env
767
 
    source = map(lambda x: x.srcpath(env), task.inputs)
768
 
    targets = map(lambda x: x.srcpath(env), task.outputs)
769
 
    source.append(macros_loc_default)
770
 
    js2c.JS2C(source, targets)
771
 
 
772
 
  def javascript_in_c_debug(task):
773
 
    env = task.env
774
 
    source = map(lambda x: x.srcpath(env), task.inputs)
775
 
    targets = map(lambda x: x.srcpath(env), task.outputs)
776
 
    source.append(macros_loc_debug)
777
 
    js2c.JS2C(source, targets)
778
 
 
779
 
  native_cc = bld.new_task_gen(
780
 
    source='src/node.js ' + bld.path.ant_glob('lib/*.js'),
781
 
    target="src/node_natives.h",
782
 
    before="cxx",
783
 
    install_path=None
784
 
  )
785
 
 
786
 
  # Add the rule /after/ cloning the debug
787
 
  # This is a work around for an error had in python 2.4.3 (I'll paste the
788
 
  # error that was had into the git commit meessage. git-blame to find out
789
 
  # where.)
790
 
  if bld.env["USE_DEBUG"]:
791
 
    native_cc_debug = native_cc.clone("Debug")
792
 
    native_cc_debug.rule = javascript_in_c_debug
793
 
 
794
 
  native_cc.rule = javascript_in_c_debug
795
 
 
796
 
  if bld.env["USE_DTRACE"]:
797
 
    dtrace_usdt = bld.new_task_gen(
798
 
      name   = "dtrace_usdt",
799
 
      source = "src/node_provider.d",
800
 
      target = "src/node_provider.h",
801
 
      rule   = "%s -x nolibs -h -o ${TGT} -s ${SRC}" % (bld.env.DTRACE),
802
 
      before = "cxx",
803
 
    )
804
 
 
805
 
    if bld.env["USE_DEBUG"]:
806
 
      dtrace_usdt_g = dtrace_usdt.clone("Debug")
807
 
 
808
 
    bld.install_files('${LIBDIR}/dtrace', 'src/node.d')
809
 
 
810
 
    if sys.platform.startswith("sunos"):
811
 
      #
812
 
      # The USDT DTrace provider works slightly differently on Solaris than on
813
 
      # the Mac; on Solaris, any objects that have USDT DTrace probes must be
814
 
      # post-processed with the DTrace command.  (This is not true on the
815
 
      # Mac, which has first-class linker support for USDT probes.)  On
816
 
      # Solaris, we must therefore post-process our object files.  Waf doesn't
817
 
      # seem to really have a notion for this, so we inject a task after
818
 
      # compiling and before linking, and then find all of the node object
819
 
      # files and shuck them off to dtrace (which will modify them in place
820
 
      # as appropriate).
821
 
      #
822
 
      def dtrace_postprocess(task):
823
 
        abspath = bld.srcnode.abspath(bld.env_of_name(task.env.variant()))
824
 
        objs = glob.glob(abspath + 'src/*.o')
825
 
        source = task.inputs[0].srcpath(task.env)
826
 
        target = task.outputs[0].srcpath(task.env)
827
 
        cmd = '%s -G -x nolibs -s %s -o %s %s' % (task.env.DTRACE,
828
 
                                                  source,
829
 
                                                  target,
830
 
                                                  ' '.join(objs))
831
 
        Utils.exec_command(cmd)
832
 
 
833
 
      #
834
 
      # ustack helpers do not currently work on MacOS.  We currently only
835
 
      # support 32-bit x86.
836
 
      #
837
 
      def dtrace_do_ustack(task):
838
 
        abspath = bld.srcnode.abspath(bld.env_of_name(task.env.variant()))
839
 
        source = task.inputs[0].srcpath(task.env)
840
 
        target = task.outputs[0].srcpath(task.env)
841
 
        cmd = '%s -32 -I../src -C -G -s %s -o %s' % (task.env.DTRACE, source, target)
842
 
        Utils.exec_command(cmd)
843
 
 
844
 
      dtrace_ustack = bld.new_task_gen(
845
 
        name = "dtrace_ustack-postprocess",
846
 
        source = "src/v8ustack.d",
847
 
        target = "v8ustack.o",
848
 
        always = True,
849
 
        before = "cxx_link",
850
 
        after = "cxx",
851
 
        rule = dtrace_do_ustack
852
 
      )
853
 
 
854
 
      dtracepost = bld.new_task_gen(
855
 
        name   = "dtrace_usdt-postprocess",
856
 
        source = "src/node_provider.d",
857
 
        target = "node_provider.o",
858
 
        always = True,
859
 
        before = "cxx_link",
860
 
        after  = "cxx",
861
 
        rule = dtrace_postprocess
862
 
      )
863
 
 
864
 
      t = join(bld.srcnode.abspath(bld.env_of_name("Release")), dtracepost.target)
865
 
      bld.env_of_name('Release').append_value('LINKFLAGS', t)
866
 
 
867
 
      t = join(bld.srcnode.abspath(bld.env_of_name("Release")), dtrace_ustack.target)
868
 
      bld.env_of_name('Release').append_value('LINKFLAGS', t)
869
 
 
870
 
      #
871
 
      # Note that for the same (mysterious) issue outlined above with respect
872
 
      # to assigning the rule to native_cc/native_cc_debug, we must apply the
873
 
      # rule to dtracepost/dtracepost_g only after they have been cloned.  We
874
 
      # also must put node_provider.o on the link line, but because we
875
 
      # (apparently?) lack LINKFLAGS in debug, we (shamelessly) stowaway on
876
 
      # LINKFLAGS_V8_G.
877
 
      #
878
 
      if bld.env["USE_DEBUG"]:
879
 
        dtracepost_g = dtracepost.clone("Debug")
880
 
        dtracepost_g.rule = dtrace_postprocess
881
 
        t = join(bld.srcnode.abspath(bld.env_of_name("Debug")), dtracepost.target)
882
 
        bld.env_of_name("Debug").append_value('LINKFLAGS_V8_G', t)
883
 
 
884
 
 
885
 
  ### node lib
886
 
  node = bld.new_task_gen("cxx", product_type)
887
 
  node.name         = "node"
888
 
  node.target       = "node"
889
 
  node.uselib = 'RT OPENSSL ZLIB CARES EXECINFO DL KVM SOCKET NSL KSTAT UTIL OPROFILE'
890
 
  node.add_objects = 'http_parser'
891
 
  if product_type_is_lib:
892
 
    node.install_path = '${LIBDIR}'
893
 
  else:
894
 
    node.install_path = '${PREFIX}/bin'
895
 
  node.chmod = 0755
896
 
  node.source = """
897
 
    src/node.cc
898
 
    src/node_buffer.cc
899
 
    src/node_javascript.cc
900
 
    src/node_extensions.cc
901
 
    src/node_http_parser.cc
902
 
    src/node_constants.cc
903
 
    src/node_file.cc
904
 
    src/node_script.cc
905
 
    src/node_os.cc
906
 
    src/node_dtrace.cc
907
 
    src/node_string.cc
908
 
    src/node_zlib.cc
909
 
    src/timer_wrap.cc
910
 
    src/handle_wrap.cc
911
 
    src/stream_wrap.cc
912
 
    src/tcp_wrap.cc
913
 
    src/udp_wrap.cc
914
 
    src/pipe_wrap.cc
915
 
    src/cares_wrap.cc
916
 
    src/tty_wrap.cc
917
 
    src/fs_event_wrap.cc
918
 
    src/process_wrap.cc
919
 
    src/v8_typed_array.cc
920
 
  """
921
 
 
922
 
  if bld.env["USE_DTRACE"]:
923
 
    node.source += " src/node_dtrace.cc "
924
 
 
925
 
  if not sys.platform.startswith("win32"):
926
 
    node.source += " src/node_signal_watcher.cc "
927
 
    node.source += " src/node_stat_watcher.cc "
928
 
    node.source += " src/node_io_watcher.cc "
929
 
 
930
 
  node.source += bld.env["PLATFORM_FILE"]
931
 
  if not product_type_is_lib:
932
 
    node.source = 'src/node_main.cc '+node.source
933
 
 
934
 
  if bld.env["USE_OPENSSL"]: node.source += " src/node_crypto.cc "
935
 
 
936
 
  node.includes = """
937
 
    src/
938
 
    deps/http_parser
939
 
    deps/uv/include
940
 
    deps/uv/src/ev
941
 
    deps/uv/src/ares
942
 
  """
943
 
 
944
 
  if not bld.env["USE_SHARED_V8"]: node.includes += ' deps/v8/include '
945
 
 
946
 
  if os.environ.has_key('RPATH'):
947
 
    node.rpath = os.environ['RPATH']
948
 
 
949
 
  if (sys.platform.startswith("win32")):
950
 
    # Static libgcc
951
 
    bld.env.append_value('LINKFLAGS', '-static-libgcc')
952
 
    bld.env.append_value('LINKFLAGS', '-static-libstdc++')
953
 
 
954
 
  def subflags(program):
955
 
    x = { 'CCFLAGS'   : " ".join(program.env["CCFLAGS"]).replace('"', '\\"')
956
 
        , 'CPPFLAGS'  : " ".join(program.env["CPPFLAGS"]).replace('"', '\\"')
957
 
        , 'LIBFLAGS'  : " ".join(program.env["LIBFLAGS"]).replace('"', '\\"')
958
 
        , 'PREFIX'    : safe_path(program.env["PREFIX"])
959
 
        , 'VERSION'   : get_node_version()
960
 
        }
961
 
    return x
962
 
 
963
 
  # process file.pc.in -> file.pc
964
 
 
965
 
  node_conf = bld.new_task_gen('subst', before="cxx")
966
 
  node_conf.source = 'src/node_config.h.in'
967
 
  node_conf.target = 'src/node_config.h'
968
 
  node_conf.dict = subflags(node)
969
 
  node_conf.install_path = '${PREFIX}/include/node'
970
 
 
971
 
  if bld.env["USE_DEBUG"]:
972
 
    node_g = node.clone("Debug")
973
 
    node_g.target = "node"
974
 
    node_g.uselib += ' V8_G UV '
975
 
    node_g.install_path = None
976
 
 
977
 
    node_conf_g = node_conf.clone("Debug")
978
 
    node_conf_g.dict = subflags(node_g)
979
 
    node_conf_g.install_path = None
980
 
 
981
 
  # After creating the debug clone, append the V8 dep
982
 
  node.uselib += ' V8 UV '
983
 
 
984
 
  bld.install_files('${PREFIX}/include/node/', """
985
 
    config.h
986
 
    src/node.h
987
 
    src/node_object_wrap.h
988
 
    src/node_buffer.h
989
 
    src/node_version.h
990
 
  """)
991
 
 
992
 
  # Only install the man page if it exists.
993
 
  # Do 'make doc install' to build and install it.
994
 
  if os.path.exists('doc/node.1'):
995
 
    prefix = 'bsd' in sys.platform and '${PREFIX}' or '${PREFIX}/share'
996
 
    bld.install_files(prefix + '/man/man1/', 'doc/node.1')
997
 
 
998
 
  bld.install_files('${PREFIX}/bin/', 'tools/node-waf', chmod=0755)
999
 
  bld.install_files('${LIBDIR}/node/wafadmin', 'tools/wafadmin/*.py')
1000
 
  bld.install_files('${LIBDIR}/node/wafadmin/Tools', 'tools/wafadmin/Tools/*.py')
1001
 
 
1002
 
  if bld.env['USE_NPM']:
1003
 
    install_npm(bld)
1004
 
 
1005
 
def install_npm(bld):
1006
 
  start_dir = bld.path.find_dir('deps/npm')
1007
 
  # The chmod=-1 is a Node hack. We changed WAF so that when chmod was set to
1008
 
  # -1 that the same permission in this tree are used. Necessary to get
1009
 
  # npm-cli.js to be executable without having to list every file in npm.
1010
 
  bld.install_files('${LIBDIR}/node_modules/npm',
1011
 
                    start_dir.ant_glob('**/*'),
1012
 
                    cwd=start_dir,
1013
 
                    relative_trick=True,
1014
 
                    chmod=-1)
1015
 
  bld.symlink_as('${PREFIX}/bin/npm',
1016
 
                 '../lib/node_modules/npm/bin/npm-cli.js')
1017
 
 
1018
 
def shutdown():
1019
 
  Options.options.debug
1020
 
  # HACK to get binding.node out of build directory.
1021
 
  # better way to do this?
1022
 
  if Options.commands['configure']:
1023
 
    if not Options.options.use_openssl:
1024
 
      print "WARNING WARNING WARNING"
1025
 
      print "OpenSSL not found. Will compile Node without crypto support!"
1026
 
 
1027
 
    if not Options.options.platform_file:
1028
 
      print "WARNING: Platform not fully supported. Using src/platform_none.cc"
1029
 
 
1030
 
  elif not Options.commands['clean']:
1031
 
    if sys.platform.startswith("win32"):
1032
 
      if os.path.exists('out/Release/node.exe'):
1033
 
        os.system('cp out/Release/node.exe .')
1034
 
      if os.path.exists('out/Debug/node.exe'):
1035
 
        os.system('cp out/Debug/node.exe node_g.exe')
1036
 
    else:
1037
 
      if os.path.exists('out/Release/node') and not os.path.islink('node'):
1038
 
        os.symlink('out/Release/node', 'node')
1039
 
      if os.path.exists('out/Debug/node') and not os.path.islink('node_g'):
1040
 
        os.symlink('out/Debug/node', 'node_g')
1041
 
  else:
1042
 
    if sys.platform.startswith("win32"):
1043
 
      if os.path.exists('node.exe'): os.unlink('node.exe')
1044
 
      if os.path.exists('node_g.exe'): os.unlink('node_g.exe')
1045
 
    else:
1046
 
      if os.path.exists('node'): os.unlink('node')
1047
 
      if os.path.exists('node_g'): os.unlink('node_g')