The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / configure @ 300dd349

History | View | Annotate | Download (21.4 KB)

1
#!/usr/bin/env python
2
import optparse
3
import os
4
import pprint
5
import re
6
import shlex
7
import subprocess
8
import sys
9

    
10
CC = os.environ.get('CC', 'cc')
11

    
12
root_dir = os.path.dirname(__file__)
13
sys.path.insert(0, os.path.join(root_dir, 'tools', 'gyp', 'pylib'))
14
from gyp.common import GetFlavor
15

    
16
# parse our options
17
parser = optparse.OptionParser()
18

    
19
# Options should be in alphabetical order but keep --prefix at the top,
20
# that's arguably the one people will be looking for most.
21
parser.add_option('--prefix',
22
    action='store',
23
    dest='prefix',
24
    help='select the install prefix (defaults to /usr/local)')
25

    
26
parser.add_option('--debug',
27
    action='store_true',
28
    dest='debug',
29
    help='also build debug build')
30

    
31
parser.add_option('--dest-cpu',
32
    action='store',
33
    dest='dest_cpu',
34
    help='CPU architecture to build for. Valid values are: arm, ia32, x64')
35

    
36
parser.add_option('--dest-os',
37
    action='store',
38
    dest='dest_os',
39
    help='operating system to build for. Valid values are: '
40
         'win, mac, solaris, freebsd, openbsd, linux, android')
41

    
42
parser.add_option('--gdb',
43
    action='store_true',
44
    dest='gdb',
45
    help='add gdb support')
46

    
47
parser.add_option('--ninja',
48
    action='store_true',
49
    dest='use_ninja',
50
    help='generate files for the ninja build system')
51

    
52
parser.add_option('--no-ifaddrs',
53
    action='store_true',
54
    dest='no_ifaddrs',
55
    help='use on deprecated SunOS systems that do not support ifaddrs.h')
56

    
57
# deprecated
58
parser.add_option('--openssl-includes',
59
    action='store',
60
    dest='shared_openssl_includes',
61
    help=optparse.SUPPRESS_HELP)
62

    
63
# deprecated
64
parser.add_option('--openssl-libpath',
65
    action='store',
66
    dest='shared_openssl_libpath',
67
    help=optparse.SUPPRESS_HELP)
68

    
69
# deprecated
70
parser.add_option('--openssl-use-sys',
71
    action='store_true',
72
    dest='shared_openssl',
73
    help=optparse.SUPPRESS_HELP)
74

    
75
parser.add_option('--shared-cares',
76
    action='store_true',
77
    dest='shared_cares',
78
    help='link to a shared cares DLL instead of static linking')
79

    
80
parser.add_option('--shared-cares-includes',
81
    action='store',
82
    dest='shared_cares_includes',
83
    help='directory containing cares header files')
84

    
85
parser.add_option('--shared-cares-libname',
86
    action='store',
87
    dest='shared_cares_libname',
88
    help='alternative lib name to link to (default: \'cares\')')
89

    
90
parser.add_option('--shared-cares-libpath',
91
    action='store',
92
    dest='shared_cares_libpath',
93
    help='a directory to search for the shared cares DLL')
94

    
95
parser.add_option('--shared-http-parser',
96
    action='store_true',
97
    dest='shared_http_parser',
98
    help='link to a shared http_parser DLL instead of static linking')
99

    
100
parser.add_option('--shared-http-parser-includes',
101
    action='store',
102
    dest='shared_http_parser_includes',
103
    help='directory containing http_parser header files')
104

    
105
parser.add_option('--shared-http-parser-libname',
106
    action='store',
107
    dest='shared_http_parser_libname',
108
    help='alternative lib name to link to (default: \'http_parser\')')
109

    
110
parser.add_option('--shared-http-parser-libpath',
111
    action='store',
112
    dest='shared_http_parser_libpath',
113
    help='a directory to search for the shared http_parser DLL')
114

    
115
parser.add_option('--shared-libuv',
116
    action='store_true',
117
    dest='shared_libuv',
118
    help='link to a shared libuv DLL instead of static linking')
119

    
120
parser.add_option('--shared-libuv-includes',
121
    action='store',
122
    dest='shared_libuv_includes',
123
    help='directory containing libuv header files')
124

    
125
parser.add_option('--shared-libuv-libname',
126
    action='store',
127
    dest='shared_libuv_libname',
128
    help='alternative lib name to link to (default: \'uv\')')
129

    
130
parser.add_option('--shared-libuv-libpath',
131
    action='store',
132
    dest='shared_libuv_libpath',
133
    help='a directory to search for the shared libuv DLL')
134

    
135
parser.add_option('--shared-openssl',
136
    action='store_true',
137
    dest='shared_openssl',
138
    help='link to a shared OpenSSl DLL instead of static linking')
139

    
140
parser.add_option('--shared-openssl-includes',
141
    action='store',
142
    dest='shared_openssl_includes',
143
    help='directory containing OpenSSL header files')
144

    
145
parser.add_option('--shared-openssl-libname',
146
    action='store',
147
    dest='shared_openssl_libname',
148
    help='alternative lib name to link to (default: \'crypto,ssl\')')
149

    
150
parser.add_option('--shared-openssl-libpath',
151
    action='store',
152
    dest='shared_openssl_libpath',
153
    help='a directory to search for the shared OpenSSL DLLs')
154

    
155
parser.add_option('--shared-v8',
156
    action='store_true',
157
    dest='shared_v8',
158
    help='link to a shared V8 DLL instead of static linking')
159

    
160
parser.add_option('--shared-v8-includes',
161
    action='store',
162
    dest='shared_v8_includes',
163
    help='directory containing V8 header files')
164

    
165
parser.add_option('--shared-v8-libname',
166
    action='store',
167
    dest='shared_v8_libname',
168
    help='alternative lib name to link to (default: \'v8\')')
169

    
170
parser.add_option('--shared-v8-libpath',
171
    action='store',
172
    dest='shared_v8_libpath',
173
    help='a directory to search for the shared V8 DLL')
174

    
175
parser.add_option('--shared-zlib',
176
    action='store_true',
177
    dest='shared_zlib',
178
    help='link to a shared zlib DLL instead of static linking')
179

    
180
parser.add_option('--shared-zlib-includes',
181
    action='store',
182
    dest='shared_zlib_includes',
183
    help='directory containing zlib header files')
184

    
185
parser.add_option('--shared-zlib-libname',
186
    action='store',
187
    dest='shared_zlib_libname',
188
    help='alternative lib name to link to (default: \'z\')')
189

    
190
parser.add_option('--shared-zlib-libpath',
191
    action='store',
192
    dest='shared_zlib_libpath',
193
    help='a directory to search for the shared zlib DLL')
194

    
195
# TODO document when we've decided on what the tracing API and its options will
196
# look like
197
parser.add_option('--systemtap-includes',
198
    action='store',
199
    dest='systemtap_includes',
200
    help=optparse.SUPPRESS_HELP)
201

    
202
parser.add_option('--tag',
203
    action='store',
204
    dest='tag',
205
    help='custom build tag')
206

    
207
parser.add_option('--v8-options',
208
    action='store',
209
    dest='v8_options',
210
    help='v8 options to pass, see `node --v8-options` for examples.')
211

    
212
parser.add_option('--with-arm-float-abi',
213
    action='store',
214
    dest='arm_float_abi',
215
    help='specifies which floating-point ABI to use. Valid values are: '
216
         'soft, softfp, hard')
217

    
218
parser.add_option('--with-dtrace',
219
    action='store_true',
220
    dest='with_dtrace',
221
    help='build with DTrace (default is true on sunos)')
222

    
223
parser.add_option('--with-etw',
224
    action='store_true',
225
    dest='with_etw',
226
    help='build with ETW (default is true on Windows)')
227

    
228
parser.add_option('--with-icu-path',
229
    action='store',
230
    dest='with_icu_path',
231
    help='Path to icu.gyp (ICU i18n, Chromium version only.)')
232

    
233
parser.add_option('--with-perfctr',
234
    action='store_true',
235
    dest='with_perfctr',
236
    help='build with performance counters (default is true on Windows)')
237

    
238
parser.add_option('--with-sslv2',
239
    action='store_true',
240
    dest='with_sslv2',
241
    help='enable SSL v2')
242

    
243
parser.add_option('--without-dtrace',
244
    action='store_true',
245
    dest='without_dtrace',
246
    help='build without DTrace')
247

    
248
parser.add_option('--without-etw',
249
    action='store_true',
250
    dest='without_etw',
251
    help='build without ETW')
252

    
253
parser.add_option('--without-npm',
254
    action='store_true',
255
    dest='without_npm',
256
    help='don\'t install the bundled npm package manager')
257

    
258
parser.add_option('--without-perfctr',
259
    action='store_true',
260
    dest='without_perfctr',
261
    help='build without performance counters')
262

    
263
parser.add_option('--without-snapshot',
264
    action='store_true',
265
    dest='without_snapshot',
266
    help='build without snapshotting V8 libraries. You might want to set'
267
         ' this for cross-compiling. [Default: False]')
268

    
269
parser.add_option('--without-ssl',
270
    action='store_true',
271
    dest='without_ssl',
272
    help='build without SSL')
273

    
274
parser.add_option('--xcode',
275
    action='store_true',
276
    dest='use_xcode',
277
    help='generate build files for use with xcode')
278

    
279
(options, args) = parser.parse_args()
280

    
281

    
282
def b(value):
283
  """Returns the string 'true' if value is truthy, 'false' otherwise."""
284
  if value:
285
    return 'true'
286
  else:
287
    return 'false'
288

    
289

    
290
def pkg_config(pkg):
291
  cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
292
  libs = cmd.readline().strip()
293
  ret = cmd.close()
294
  if (ret): return None
295

    
296
  cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
297
  cflags = cmd.readline().strip()
298
  ret = cmd.close()
299
  if (ret): return None
300

    
301
  return (libs, cflags)
302

    
303

    
304
def cc_macros():
305
  """Checks predefined macros using the CC command."""
306

    
307
  try:
308
    p = subprocess.Popen(shlex.split(CC) + ['-dM', '-E', '-'],
309
                         stdin=subprocess.PIPE,
310
                         stdout=subprocess.PIPE,
311
                         stderr=subprocess.PIPE)
312
  except OSError:
313
    print '''Node.js configure error: No acceptable C compiler found!
314

    
315
        Please make sure you have a C compiler installed on your system and/or
316
        consider adjusting the CC environment variable if you installed
317
        it in a non-standard prefix.
318
        '''
319
    sys.exit()
320

    
321
  p.stdin.write('\n')
322
  out = p.communicate()[0]
323

    
324
  out = str(out).split('\n')
325

    
326
  k = {}
327
  for line in out:
328
    lst = shlex.split(line)
329
    if len(lst) > 2:
330
      key = lst[1]
331
      val = lst[2]
332
      k[key] = val
333
  return k
334

    
335

    
336
def is_arch_armv7():
337
  """Check for ARMv7 instructions"""
338
  cc_macros_cache = cc_macros()
339
  return ('__ARM_ARCH_7__' in cc_macros_cache or
340
          '__ARM_ARCH_7A__' in cc_macros_cache or
341
          '__ARM_ARCH_7R__' in cc_macros_cache or
342
          '__ARM_ARCH_7M__' in cc_macros_cache)
343

    
344

    
345
def is_arch_armv6():
346
  """Check for ARMv6 instructions"""
347
  cc_macros_cache = cc_macros()
348
  return ('__ARM_ARCH_6__' in cc_macros_cache or
349
          '__ARM_ARCH_6M__' in cc_macros_cache)
350

    
351

    
352
def is_arm_neon():
353
  """Check for ARM NEON support"""
354
  return '__ARM_NEON__' in cc_macros()
355

    
356

    
357
def is_arm_hard_float_abi():
358
  """Check for hardfloat or softfloat eabi on ARM"""
359
  # GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
360
  # the Floating Point ABI used (PCS stands for Procedure Call Standard).
361
  # We use these as well as a couple of other defines to statically determine
362
  # what FP ABI used.
363
  # GCC versions 4.4 and below don't support hard-fp.
364
  # GCC versions 4.5 may support hard-fp without defining __ARM_PCS or
365
  # __ARM_PCS_VFP.
366

    
367
  if compiler_version() >= (4, 6, 0):
368
    return '__ARM_PCS_VFP' in cc_macros()
369
  elif compiler_version() < (4, 5, 0):
370
    return False
371
  elif '__ARM_PCS_VFP' in cc_macros():
372
    return True
373
  elif ('__ARM_PCS' in cc_macros() or
374
        '__SOFTFP' in cc_macros() or
375
        not '__VFP_FP__' in cc_macros()):
376
    return False
377
  else:
378
    print '''Node.js configure error: Your version of GCC does not report
379
      the Floating-Point ABI to compile for your hardware
380

    
381
      Please manually specify which floating-point ABI to use with the
382
      --with-arm-float-abi option.
383
      '''
384
    sys.exit()
385

    
386

    
387
def host_arch_cc():
388
  """Host architecture check using the CC command."""
389

    
390
  k = cc_macros()
391

    
392
  matchup = {
393
    '__x86_64__'  : 'x64',
394
    '__i386__'    : 'ia32',
395
    '__arm__'     : 'arm',
396
    '__mips__'    : 'mips',
397
  }
398

    
399
  rtn = 'ia32' # default
400

    
401
  for i in matchup:
402
    if i in k and k[i] != '0':
403
      rtn = matchup[i]
404
      break
405

    
406
  return rtn
407

    
408

    
409
def host_arch_win():
410
  """Host architecture check using environ vars (better way to do this?)"""
411

    
412
  observed_arch = os.environ.get('PROCESSOR_ARCHITECTURE', 'x86')
413
  arch = os.environ.get('PROCESSOR_ARCHITEW6432', observed_arch)
414

    
415
  matchup = {
416
    'AMD64'  : 'x64',
417
    'x86'    : 'ia32',
418
    'arm'    : 'arm',
419
    'mips'   : 'mips',
420
  }
421

    
422
  return matchup.get(arch, 'ia32')
423

    
424

    
425
def compiler_version():
426
  try:
427
    proc = subprocess.Popen(shlex.split(CC) + ['--version'],
428
                            stdout=subprocess.PIPE)
429
  except WindowsError:
430
    return (0, False)
431

    
432
  is_clang = 'clang' in proc.communicate()[0].split('\n')[0]
433

    
434
  proc = subprocess.Popen(shlex.split(CC) + ['-dumpversion'],
435
                          stdout=subprocess.PIPE)
436
  version = tuple(map(int, proc.communicate()[0].split('.')))
437

    
438
  return (version, is_clang)
439

    
440

    
441
def configure_arm(o):
442
  if options.arm_float_abi:
443
    arm_float_abi = options.arm_float_abi
444
  elif is_arm_hard_float_abi():
445
    arm_float_abi = 'hard'
446
  else:
447
    arm_float_abi = 'default'
448

    
449
  if is_arch_armv7():
450
    o['variables']['arm_version'] = '7'
451
  elif is_arch_armv6():
452
    o['variables']['arm_version'] = '6'
453
  else:
454
    o['variables']['arm_version'] = 'default'
455

    
456
  o['variables']['arm_fpu'] = 'vfpv3'  # V8 3.18 no longer supports VFP2.
457
  o['variables']['arm_neon'] = int(is_arm_neon())
458
  o['variables']['arm_thumb'] = 0      # -marm
459
  o['variables']['arm_float_abi'] = arm_float_abi
460

    
461

    
462
def configure_node(o):
463
  if options.dest_os == 'android':
464
    o['variables']['OS'] = 'android'
465
  o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '')
466
  o['variables']['node_install_npm'] = b(not options.without_npm)
467
  o['default_configuration'] = 'Debug' if options.debug else 'Release'
468

    
469
  host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
470
  target_arch = options.dest_cpu or host_arch
471
  o['variables']['host_arch'] = host_arch
472
  o['variables']['target_arch'] = target_arch
473

    
474
  if target_arch != host_arch and not options.without_snapshot:
475
    o['variables']['want_separate_host_toolset'] = 1
476

    
477
  if target_arch == 'arm':
478
    configure_arm(o)
479

    
480
  cc_version, is_clang = compiler_version()
481
  o['variables']['clang'] = 1 if is_clang else 0
482

    
483
  if not is_clang and cc_version != 0:
484
    o['variables']['gcc_version'] = 10 * cc_version[0] + cc_version[1]
485

    
486
  # clang has always supported -fvisibility=hidden, right?
487
  if not is_clang and cc_version < (4,0,0):
488
    o['variables']['visibility'] = ''
489

    
490
  if flavor in ('solaris', 'mac', 'linux', 'freebsd'):
491
    use_dtrace = not options.without_dtrace
492
    # Don't enable by default on linux and freebsd
493
    if flavor in ('linux', 'freebsd'):
494
      use_dtrace = options.with_dtrace
495

    
496
    if flavor == 'linux':
497
      if options.systemtap_includes:
498
        o['include_dirs'] += [options.systemtap_includes]
499
    o['variables']['node_use_dtrace'] = b(use_dtrace)
500
    o['variables']['uv_use_dtrace'] = b(use_dtrace)
501
    o['variables']['uv_parent_path'] = '/deps/uv/'
502
  elif options.with_dtrace:
503
    raise Exception(
504
       'DTrace is currently only supported on SunOS, MacOS or Linux systems.')
505
  else:
506
    o['variables']['node_use_dtrace'] = 'false'
507

    
508
  # if we're on illumos based systems wrap the helper library into the
509
  # executable
510
  if flavor == 'solaris':
511
    o['variables']['node_use_mdb'] = 'true'
512
  else:
513
    o['variables']['node_use_mdb'] = 'false'
514

    
515
  if options.no_ifaddrs:
516
    o['defines'] += ['SUNOS_NO_IFADDRS']
517

    
518
  # By default, enable ETW on Windows.
519
  if flavor == 'win':
520
    o['variables']['node_use_etw'] = b(not options.without_etw)
521
  elif options.with_etw:
522
    raise Exception('ETW is only supported on Windows.')
523
  else:
524
    o['variables']['node_use_etw'] = 'false'
525

    
526
  # By default, enable Performance counters on Windows.
527
  if flavor == 'win':
528
    o['variables']['node_use_perfctr'] = b(not options.without_perfctr)
529
  elif options.with_perfctr:
530
    raise Exception('Performance counter is only supported on Windows.')
531
  else:
532
    o['variables']['node_use_perfctr'] = 'false'
533

    
534
  if options.tag:
535
    o['variables']['node_tag'] = '-' + options.tag
536
  else:
537
    o['variables']['node_tag'] = ''
538

    
539
  if options.v8_options:
540
    o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')
541

    
542

    
543
def configure_libz(o):
544
  o['variables']['node_shared_zlib'] = b(options.shared_zlib)
545

    
546
  # assume shared_zlib if one of these is set?
547
  if options.shared_zlib_libpath:
548
    o['libraries'] += ['-L%s' % options.shared_zlib_libpath]
549
  if options.shared_zlib_libname:
550
    o['libraries'] += ['-l%s' % options.shared_zlib_libname]
551
  elif options.shared_zlib:
552
    o['libraries'] += ['-lz']
553
  if options.shared_zlib_includes:
554
    o['include_dirs'] += [options.shared_zlib_includes]
555

    
556

    
557
def configure_http_parser(o):
558
    o['variables']['node_shared_http_parser'] = b(options.shared_http_parser)
559

    
560
    # assume shared http_parser if one of these is set?
561
    if options.shared_http_parser_libpath:
562
        o['libraries'] += ['-L%s' % options.shared_http_parser_libpath]
563
    if options.shared_http_parser_libname:
564
        o['libraries'] += ['-l%s' % options.shared_http_parser_libname]
565
    elif options.shared_http_parser:
566
        o['libraries'] += ['-lhttp_parser']
567
    if options.shared_http_parser_includes:
568
        o['include_dirs'] += [options.shared_http_parser_includes]
569

    
570

    
571
def configure_cares(o):
572
    o['variables']['node_shared_cares'] = b(options.shared_cares)
573

    
574
    # assume shared cares if one of these is set?
575
    if options.shared_cares_libpath:
576
        o['libraries'] += ['-L%s' % options.shared_cares_libpath]
577
    if options.shared_cares_libname:
578
        o['libraries'] += ['-l%s' % options.shared_cares_libname]
579
    elif options.shared_cares:
580
        o['libraries'] += ['-lcares']
581
    if options.shared_cares_includes:
582
        o['include_dirs'] += [options.shared_cares_includes]
583

    
584

    
585
def configure_libuv(o):
586
  o['variables']['node_shared_libuv'] = b(options.shared_libuv)
587

    
588
  # assume shared libuv if one of these is set?
589
  if options.shared_libuv_libpath:
590
    o['libraries'] += ['-L%s' % options.shared_libuv_libpath]
591
  else:
592
    o['variables']['uv_library'] = 'static_library'
593

    
594
  if options.shared_libuv_libname:
595
    o['libraries'] += ['-l%s' % options.shared_libuv_libname]
596
  elif options.shared_libuv:
597
    o['libraries'] += ['-luv']
598
  if options.shared_libuv_includes:
599
    o['include_dirs'] += [options.shared_libuv_includes]
600

    
601

    
602
def configure_v8(o):
603
  o['variables']['node_shared_v8'] = b(options.shared_v8)
604
  o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0
605
  o['variables']['v8_no_strict_aliasing'] = 1  # Work around compiler bugs.
606
  o['variables']['v8_optimized_debug'] = 0  # Compile with -O0 in debug builds.
607
  o['variables']['v8_random_seed'] = 0  # Use a random seed for hash tables.
608
  o['variables']['v8_use_snapshot'] = b(not options.without_snapshot)
609

    
610
  # assume shared_v8 if one of these is set?
611
  if options.shared_v8_libpath:
612
    o['libraries'] += ['-L%s' % options.shared_v8_libpath]
613
  if options.shared_v8_libname:
614
    o['libraries'] += ['-l%s' % options.shared_v8_libname]
615
  elif options.shared_v8:
616
    o['libraries'] += ['-lv8']
617
  if options.shared_v8_includes:
618
    o['include_dirs'] += [options.shared_v8_includes]
619

    
620

    
621
def configure_openssl(o):
622
  o['variables']['node_use_openssl'] = b(not options.without_ssl)
623
  o['variables']['node_shared_openssl'] = b(options.shared_openssl)
624

    
625
  if options.without_ssl:
626
    return
627

    
628
  # OpenSSL uses `#ifndef OPENSSL_NO_SSL2` checks so only define the
629
  # macro when we want to _disable_ SSL2.
630
  if not options.with_sslv2:
631
    o['defines'] += ['OPENSSL_NO_SSL2=1']
632

    
633
  if options.shared_openssl:
634
    (libs, cflags) = pkg_config('openssl') or ('-lssl -lcrypto', '')
635

    
636
    if options.shared_openssl_libpath:
637
      o['libraries'] += ['-L%s' % options.shared_openssl_libpath]
638

    
639
    if options.shared_openssl_libname:
640
      libnames = options.shared_openssl_libname.split(',')
641
      o['libraries'] += ['-l%s' % s for s in libnames]
642
    else:
643
      o['libraries'] += libs.split()
644

    
645
    if options.shared_openssl_includes:
646
      o['include_dirs'] += [options.shared_openssl_includes]
647
    else:
648
      o['cflags'] += cflags.split()
649

    
650

    
651
def configure_winsdk(o):
652
  if flavor != 'win':
653
    return
654

    
655
  winsdk_dir = os.environ.get('WindowsSdkDir')
656

    
657
  if winsdk_dir and os.path.isfile(winsdk_dir + '\\bin\\ctrpp.exe'):
658
    print('Found ctrpp in WinSDK--will build generated files '
659
          'into tools/msvs/genfiles.')
660
    o['variables']['node_has_winsdk'] = 'true'
661
    return
662

    
663
  print('ctrpp not found in WinSDK path--using pre-gen files '
664
        'from tools/msvs/genfiles.')
665

    
666

    
667
def configure_icu(o):
668
  have_icu_path = bool(options.with_icu_path)
669
  o['variables']['v8_enable_i18n_support'] = int(have_icu_path)
670
  if have_icu_path:
671
    o['variables']['icu_gyp_path'] = options.with_icu_path
672

    
673

    
674
# determine the "flavor" (operating system) we're building for,
675
# leveraging gyp's GetFlavor function
676
flavor_params = {}
677
if (options.dest_os):
678
  flavor_params['flavor'] = options.dest_os
679
flavor = GetFlavor(flavor_params)
680

    
681
output = {
682
  'variables': { 'python': sys.executable },
683
  'include_dirs': [],
684
  'libraries': [],
685
  'defines': [],
686
  'cflags': [],
687
}
688

    
689
configure_node(output)
690
configure_libz(output)
691
configure_http_parser(output)
692
configure_cares(output)
693
configure_libuv(output)
694
configure_v8(output)
695
configure_openssl(output)
696
configure_winsdk(output)
697
configure_icu(output)
698

    
699
# variables should be a root level element,
700
# move everything else to target_defaults
701
variables = output['variables']
702
del output['variables']
703
output = {
704
  'variables': variables,
705
  'target_defaults': output
706
}
707
pprint.pprint(output, indent=2)
708

    
709
def write(filename, data):
710
  filename = os.path.join(root_dir, filename)
711
  print 'creating ', filename
712
  f = open(filename, 'w+')
713
  f.write(data)
714

    
715
write('config.gypi', '# Do not edit. Generated by the configure script.\n' +
716
      pprint.pformat(output, indent=2) + '\n')
717

    
718
config = {
719
  'BUILDTYPE': 'Debug' if options.debug else 'Release',
720
  'USE_NINJA': str(int(options.use_ninja or 0)),
721
  'USE_XCODE': str(int(options.use_xcode or 0)),
722
  'PYTHON': sys.executable,
723
}
724

    
725
if options.prefix:
726
  config['PREFIX'] = options.prefix
727

    
728
config = '\n'.join(map('='.join, config.iteritems())) + '\n'
729

    
730
write('config.mk',
731
      '# Do not edit. Generated by the configure script.\n' + config)
732

    
733
gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel']
734

    
735
if options.use_ninja:
736
  gyp_args += ['-f', 'ninja-' + flavor]
737
elif options.use_xcode:
738
  gyp_args += ['-f', 'xcode']
739
elif flavor == 'win':
740
  gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto']
741
else:
742
  gyp_args += ['-f', 'make-' + flavor]
743

    
744
gyp_args += args
745

    
746
subprocess.call(gyp_args)