12 CC = os.environ.get('CC', 'cc')
14 root_dir = os.path.dirname(__file__)
15 sys.path.insert(0, os.path.join(root_dir, 'tools', 'gyp', 'pylib'))
16 from gyp.common import GetFlavor
18 # imports in tools/configure.d
19 sys.path.insert(0, os.path.join(root_dir, 'tools', 'configure.d'))
23 parser = optparse.OptionParser()
25 # Options should be in alphabetical order but keep --prefix at the top,
26 # that's arguably the one people will be looking for most.
27 parser.add_option('--prefix',
30 help='select the install prefix (defaults to /usr/local)')
32 parser.add_option('--debug',
35 help='also build debug build')
37 parser.add_option('--dest-cpu',
40 help='CPU architecture to build for. Valid values are: arm, ia32, x32, x64')
42 parser.add_option('--dest-os',
45 help='operating system to build for. Valid values are: '
46 'win, mac, solaris, freebsd, openbsd, linux, android')
48 parser.add_option('--gdb',
51 help='add gdb support')
53 parser.add_option('--ninja',
56 help='generate files for the ninja build system')
58 parser.add_option('--no-ifaddrs',
61 help='use on deprecated SunOS systems that do not support ifaddrs.h')
63 parser.add_option("--fully-static",
66 help="Generate an executable without external dynamic libraries. This "
67 "will not work on OSX when using default compilation environment")
69 parser.add_option("--openssl-no-asm",
71 dest="openssl_no_asm",
72 help="Do not build optimized assembly for OpenSSL")
75 parser.add_option('--openssl-includes',
77 dest='shared_openssl_includes',
78 help=optparse.SUPPRESS_HELP)
81 parser.add_option('--openssl-libpath',
83 dest='shared_openssl_libpath',
84 help=optparse.SUPPRESS_HELP)
87 parser.add_option('--openssl-use-sys',
89 dest='shared_openssl',
90 help=optparse.SUPPRESS_HELP)
92 parser.add_option('--shared-http-parser',
94 dest='shared_http_parser',
95 help='link to a shared http_parser DLL instead of static linking')
97 parser.add_option('--shared-http-parser-includes',
99 dest='shared_http_parser_includes',
100 help='directory containing http_parser header files')
102 parser.add_option('--shared-http-parser-libname',
104 dest='shared_http_parser_libname',
105 help='alternative lib name to link to (default: \'http_parser\')')
107 parser.add_option('--shared-http-parser-libpath',
109 dest='shared_http_parser_libpath',
110 help='a directory to search for the shared http_parser DLL')
112 parser.add_option('--shared-libuv',
115 help='link to a shared libuv DLL instead of static linking')
117 parser.add_option('--shared-libuv-includes',
119 dest='shared_libuv_includes',
120 help='directory containing libuv header files')
122 parser.add_option('--shared-libuv-libname',
124 dest='shared_libuv_libname',
125 help='alternative lib name to link to (default: \'uv\')')
127 parser.add_option('--shared-libuv-libpath',
129 dest='shared_libuv_libpath',
130 help='a directory to search for the shared libuv DLL')
132 parser.add_option('--shared-openssl',
134 dest='shared_openssl',
135 help='link to a shared OpenSSl DLL instead of static linking')
137 parser.add_option('--shared-openssl-includes',
139 dest='shared_openssl_includes',
140 help='directory containing OpenSSL header files')
142 parser.add_option('--shared-openssl-libname',
144 dest='shared_openssl_libname',
145 help='alternative lib name to link to (default: \'crypto,ssl\')')
147 parser.add_option('--shared-openssl-libpath',
149 dest='shared_openssl_libpath',
150 help='a directory to search for the shared OpenSSL DLLs')
152 parser.add_option('--shared-v8',
155 help='link to a shared V8 DLL instead of static linking')
157 parser.add_option('--shared-v8-includes',
159 dest='shared_v8_includes',
160 help='directory containing V8 header files')
162 parser.add_option('--shared-v8-libname',
164 dest='shared_v8_libname',
165 help='alternative lib name to link to (default: \'v8\')')
167 parser.add_option('--shared-v8-libpath',
169 dest='shared_v8_libpath',
170 help='a directory to search for the shared V8 DLL')
172 parser.add_option('--shared-zlib',
175 help='link to a shared zlib DLL instead of static linking')
177 parser.add_option('--shared-zlib-includes',
179 dest='shared_zlib_includes',
180 help='directory containing zlib header files')
182 parser.add_option('--shared-zlib-libname',
184 dest='shared_zlib_libname',
185 help='alternative lib name to link to (default: \'z\')')
187 parser.add_option('--shared-zlib-libpath',
189 dest='shared_zlib_libpath',
190 help='a directory to search for the shared zlib DLL')
192 # TODO document when we've decided on what the tracing API and its options will
194 parser.add_option('--systemtap-includes',
196 dest='systemtap_includes',
197 help=optparse.SUPPRESS_HELP)
199 parser.add_option('--tag',
202 help='custom build tag')
204 parser.add_option('--v8-options',
207 help='v8 options to pass, see `node --v8-options` for examples.')
209 parser.add_option('--with-arm-float-abi',
211 dest='arm_float_abi',
212 help='specifies which floating-point ABI to use. Valid values are: '
213 'soft, softfp, hard')
215 parser.add_option('--with-dtrace',
218 help='build with DTrace (default is true on sunos)')
220 parser.add_option('--with-etw',
223 help='build with ETW (default is true on Windows)')
225 parser.add_option('--download',
227 dest='download_list',
228 help=nodedownload.help())
230 parser.add_option('--with-icu-path',
232 dest='with_icu_path',
233 help='Path to icu.gyp (ICU i18n, Chromium version only.)')
235 parser.add_option('--with-icu-locales',
237 dest='with_icu_locales',
238 help='Comma-separated list of locales for "small-icu". Default: "root,en". "root" is assumed.')
240 parser.add_option('--with-intl',
243 help='Intl mode: none, full-icu, small-icu (default is none)')
245 parser.add_option('--with-icu-source',
247 dest='with_icu_source',
248 help='Intl mode: optional local path to icu/ dir, or path/URL of icu source archive.')
250 parser.add_option('--with-perfctr',
253 help='build with performance counters (default is true on Windows)')
255 parser.add_option('--without-dtrace',
257 dest='without_dtrace',
258 help='build without DTrace')
260 parser.add_option('--without-etw',
263 help='build without ETW')
265 parser.add_option('--without-npm',
268 help='don\'t install the bundled npm package manager')
270 parser.add_option('--without-perfctr',
272 dest='without_perfctr',
273 help='build without performance counters')
275 parser.add_option('--without-snapshot',
277 dest='without_snapshot',
278 help='build without snapshotting V8 libraries. You might want to set'
279 ' this for cross-compiling. [Default: False]')
281 parser.add_option('--without-ssl',
284 help='build without SSL')
286 parser.add_option('--xcode',
289 help='generate build files for use with xcode')
291 (options, args) = parser.parse_args()
293 # set up auto-download list
294 auto_downloads = nodedownload.parse(options.download_list)
297 """Returns the string 'true' if value is truthy, 'false' otherwise."""
305 cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
306 libs = cmd.readline().strip()
308 if (ret): return None
310 cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
311 cflags = cmd.readline().strip()
313 if (ret): return None
315 return (libs, cflags)
319 """Checks predefined macros using the CC command."""
322 p = subprocess.Popen(shlex.split(CC) + ['-dM', '-E', '-'],
323 stdin=subprocess.PIPE,
324 stdout=subprocess.PIPE,
325 stderr=subprocess.PIPE)
327 print '''Node.js configure error: No acceptable C compiler found!
329 Please make sure you have a C compiler installed on your system and/or
330 consider adjusting the CC environment variable if you installed
331 it in a non-standard prefix.
336 out = p.communicate()[0]
338 out = str(out).split('\n')
342 lst = shlex.split(line)
351 """Check for ARMv7 instructions"""
352 cc_macros_cache = cc_macros()
353 return ('__ARM_ARCH_7__' in cc_macros_cache or
354 '__ARM_ARCH_7A__' in cc_macros_cache or
355 '__ARM_ARCH_7R__' in cc_macros_cache or
356 '__ARM_ARCH_7M__' in cc_macros_cache)
360 """Check for ARMv6 instructions"""
361 cc_macros_cache = cc_macros()
362 return ('__ARM_ARCH_6__' in cc_macros_cache or
363 '__ARM_ARCH_6M__' in cc_macros_cache)
367 """Check for ARM NEON support"""
368 return '__ARM_NEON__' in cc_macros()
371 def is_arm_hard_float_abi():
372 """Check for hardfloat or softfloat eabi on ARM"""
373 # GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
374 # the Floating Point ABI used (PCS stands for Procedure Call Standard).
375 # We use these as well as a couple of other defines to statically determine
378 return '__ARM_PCS_VFP' in cc_macros()
382 """Host architecture check using the CC command."""
387 '__x86_64__' : 'x64',
393 rtn = 'ia32' # default
396 if i in k and k[i] != '0':
404 """Host architecture check using environ vars (better way to do this?)"""
406 observed_arch = os.environ.get('PROCESSOR_ARCHITECTURE', 'x86')
407 arch = os.environ.get('PROCESSOR_ARCHITEW6432', observed_arch)
416 return matchup.get(arch, 'ia32')
419 def configure_arm(o):
420 if options.arm_float_abi:
421 arm_float_abi = options.arm_float_abi
422 elif is_arm_hard_float_abi():
423 arm_float_abi = 'hard'
425 arm_float_abi = 'default'
428 o['variables']['arm_version'] = '7'
429 elif is_arch_armv6():
430 o['variables']['arm_version'] = '6'
432 o['variables']['arm_version'] = 'default'
434 o['variables']['arm_fpu'] = 'vfpv3' # V8 3.18 no longer supports VFP2.
435 o['variables']['arm_neon'] = int(is_arm_neon())
436 o['variables']['arm_thumb'] = 0 # -marm
437 o['variables']['arm_float_abi'] = arm_float_abi
440 def configure_node(o):
441 if options.dest_os == 'android':
442 o['variables']['OS'] = 'android'
443 o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '')
444 o['variables']['node_install_npm'] = b(not options.without_npm)
445 o['default_configuration'] = 'Debug' if options.debug else 'Release'
447 host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
448 target_arch = options.dest_cpu or host_arch
449 o['variables']['host_arch'] = host_arch
450 o['variables']['target_arch'] = target_arch
452 if target_arch != host_arch and not options.without_snapshot:
453 o['variables']['want_separate_host_toolset'] = 1
455 o['variables']['want_separate_host_toolset'] = 0
457 if target_arch == 'arm':
460 if flavor in ('solaris', 'mac', 'linux', 'freebsd'):
461 use_dtrace = not options.without_dtrace
462 # Don't enable by default on linux and freebsd
463 if flavor in ('linux', 'freebsd'):
464 use_dtrace = options.with_dtrace
466 if flavor == 'linux':
467 if options.systemtap_includes:
468 o['include_dirs'] += [options.systemtap_includes]
469 o['variables']['node_use_dtrace'] = b(use_dtrace)
470 o['variables']['uv_use_dtrace'] = b(use_dtrace)
471 o['variables']['uv_parent_path'] = '/deps/uv/'
472 elif options.with_dtrace:
474 'DTrace is currently only supported on SunOS, MacOS or Linux systems.')
476 o['variables']['node_use_dtrace'] = 'false'
478 # if we're on illumos based systems wrap the helper library into the
480 if flavor == 'solaris':
481 o['variables']['node_use_mdb'] = 'true'
483 o['variables']['node_use_mdb'] = 'false'
485 if options.no_ifaddrs:
486 o['defines'] += ['SUNOS_NO_IFADDRS']
488 # By default, enable ETW on Windows.
490 o['variables']['node_use_etw'] = b(not options.without_etw)
491 elif options.with_etw:
492 raise Exception('ETW is only supported on Windows.')
494 o['variables']['node_use_etw'] = 'false'
496 # By default, enable Performance counters on Windows.
498 o['variables']['node_use_perfctr'] = b(not options.without_perfctr)
499 elif options.with_perfctr:
500 raise Exception('Performance counter is only supported on Windows.')
502 o['variables']['node_use_perfctr'] = 'false'
505 o['variables']['node_tag'] = '-' + options.tag
507 o['variables']['node_tag'] = ''
509 if options.v8_options:
510 o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')
513 def configure_libz(o):
514 o['variables']['node_shared_zlib'] = b(options.shared_zlib)
516 # assume shared_zlib if one of these is set?
517 if options.shared_zlib_libpath:
518 o['libraries'] += ['-L%s' % options.shared_zlib_libpath]
519 if options.shared_zlib_libname:
520 o['libraries'] += ['-l%s' % options.shared_zlib_libname]
521 elif options.shared_zlib:
522 o['libraries'] += ['-lz']
523 if options.shared_zlib_includes:
524 o['include_dirs'] += [options.shared_zlib_includes]
527 def configure_http_parser(o):
528 o['variables']['node_shared_http_parser'] = b(options.shared_http_parser)
530 # assume shared http_parser if one of these is set?
531 if options.shared_http_parser_libpath:
532 o['libraries'] += ['-L%s' % options.shared_http_parser_libpath]
533 if options.shared_http_parser_libname:
534 o['libraries'] += ['-l%s' % options.shared_http_parser_libname]
535 elif options.shared_http_parser:
536 o['libraries'] += ['-lhttp_parser']
537 if options.shared_http_parser_includes:
538 o['include_dirs'] += [options.shared_http_parser_includes]
541 def configure_libuv(o):
542 o['variables']['node_shared_libuv'] = b(options.shared_libuv)
544 # assume shared libuv if one of these is set?
545 if options.shared_libuv_libpath:
546 o['libraries'] += ['-L%s' % options.shared_libuv_libpath]
548 o['variables']['uv_library'] = 'static_library'
550 if options.shared_libuv_libname:
551 o['libraries'] += ['-l%s' % options.shared_libuv_libname]
552 elif options.shared_libuv:
553 o['libraries'] += ['-luv']
554 if options.shared_libuv_includes:
555 o['include_dirs'] += [options.shared_libuv_includes]
559 o['variables']['node_shared_v8'] = b(options.shared_v8)
560 o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0
561 o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs.
562 o['variables']['v8_optimized_debug'] = 0 # Compile with -O0 in debug builds.
563 o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables.
564 o['variables']['v8_use_snapshot'] = b(not options.without_snapshot)
566 # assume shared_v8 if one of these is set?
567 if options.shared_v8_libpath:
568 o['libraries'] += ['-L%s' % options.shared_v8_libpath]
569 if options.shared_v8_libname:
570 o['libraries'] += ['-l%s' % options.shared_v8_libname]
571 elif options.shared_v8:
572 o['libraries'] += ['-lv8']
573 if options.shared_v8_includes:
574 o['include_dirs'] += [options.shared_v8_includes]
577 def configure_openssl(o):
578 o['variables']['node_use_openssl'] = b(not options.without_ssl)
579 o['variables']['node_shared_openssl'] = b(options.shared_openssl)
580 o['variables']['openssl_no_asm'] = (
581 1 if options.openssl_no_asm else 0)
583 if options.without_ssl:
586 if options.shared_openssl:
587 (libs, cflags) = pkg_config('openssl') or ('-lssl -lcrypto', '')
589 if options.shared_openssl_libpath:
590 o['libraries'] += ['-L%s' % options.shared_openssl_libpath]
592 if options.shared_openssl_libname:
593 libnames = options.shared_openssl_libname.split(',')
594 o['libraries'] += ['-l%s' % s for s in libnames]
596 o['libraries'] += libs.split()
598 if options.shared_openssl_includes:
599 o['include_dirs'] += [options.shared_openssl_includes]
601 o['cflags'] += cflags.split()
604 def configure_fullystatic(o):
605 if options.fully_static:
606 o['libraries'] += ['-static']
608 print("Generation of static executable will not work on OSX "
609 "when using default compilation environment")
612 def configure_winsdk(o):
616 winsdk_dir = os.environ.get('WindowsSdkDir')
618 if winsdk_dir and os.path.isfile(winsdk_dir + '\\bin\\ctrpp.exe'):
619 print('Found ctrpp in WinSDK--will build generated files '
620 'into tools/msvs/genfiles.')
621 o['variables']['node_has_winsdk'] = 'true'
624 print('ctrpp not found in WinSDK path--using pre-gen files '
625 'from tools/msvs/genfiles.')
627 def write(filename, data):
628 filename = os.path.join(root_dir, filename)
629 print 'creating ', filename
630 f = open(filename, 'w+')
633 do_not_edit = '# Do not edit. Generated by the configure script.\n'
635 def glob_to_var(dir_base, dir_sub):
637 dir_all = os.path.join(dir_base, dir_sub)
638 files = os.walk(dir_all)
640 (path, dirs, files) = ent
642 if file.endswith('.cpp') or file.endswith('.c') or file.endswith('.h'):
643 list.append('%s/%s' % (dir_sub, file))
647 def configure_intl(o):
650 'url': 'http://download.icu-project.org/files/icu4c/54.1/icu4c-54_1-src.zip',
651 # from https://ssl.icu-project.org/files/icu4c/54.1/icu4c-src-54_1.md5:
652 'md5': '6b89d60e2f0e140898ae4d7f72323bca',
655 def icu_download(path):
656 # download ICU, if needed
660 local = url.split('/')[-1]
661 targetfile = os.path.join(root_dir, 'deps', local)
662 if not os.path.isfile(targetfile):
663 if nodedownload.candownload(auto_downloads, "icu"):
664 nodedownload.retrievefile(url, targetfile)
666 print ' Re-using existing %s' % targetfile
667 if os.path.isfile(targetfile):
668 sys.stdout.write(' Checking file integrity with MD5:\r')
669 gotmd5 = nodedownload.md5sum(targetfile)
670 print ' MD5: %s %s' % (gotmd5, targetfile)
674 print ' Expected: %s *MISMATCH*' % md5
675 print '\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile
680 icu_config_name = 'icu_config.gypi'
681 def write_config(data, name):
684 # write an empty file to start with
685 write(icu_config_name, do_not_edit +
686 pprint.pformat(icu_config, indent=2) + '\n')
688 # always set icu_small, node.gyp depends on it being defined.
689 o['variables']['icu_small'] = b(False)
691 with_intl = options.with_intl
692 with_icu_source = options.with_icu_source
693 have_icu_path = bool(options.with_icu_path)
694 if have_icu_path and with_intl:
695 print 'Error: Cannot specify both --with-icu-path and --with-intl'
698 # Chromium .gyp mode: --with-icu-path
699 o['variables']['v8_enable_i18n_support'] = 1
701 o['variables']['icu_gyp_path'] = options.with_icu_path
703 # --with-intl=<with_intl>
705 if with_intl is None:
706 with_intl = 'none' # The default mode of Intl
707 # sanity check localelist
708 if options.with_icu_locales and (with_intl != 'small-icu'):
709 print 'Error: --with-icu-locales only makes sense with --with-intl=small-icu'
711 if with_intl == 'none' or with_intl is None:
712 o['variables']['v8_enable_i18n_support'] = 0
714 elif with_intl == 'small-icu':
715 # small ICU (English only)
716 o['variables']['v8_enable_i18n_support'] = 1
717 o['variables']['icu_small'] = b(True)
718 with_icu_locales = options.with_icu_locales
719 if not with_icu_locales:
720 with_icu_locales = 'root,en'
721 locs = set(with_icu_locales.split(','))
722 locs.add('root') # must have root
723 o['variables']['icu_locales'] = string.join(locs,',')
724 elif with_intl == 'full-icu':
726 o['variables']['v8_enable_i18n_support'] = 1
727 elif with_intl == 'system-icu':
728 # ICU from pkg-config.
729 o['variables']['v8_enable_i18n_support'] = 1
730 pkgicu = pkg_config('icu-i18n')
732 print 'Error: could not load pkg-config data for "icu-i18n".'
733 print 'See above errors or the README.md.'
735 (libs, cflags) = pkgicu
736 o['libraries'] += libs.split()
737 o['cflags'] += cflags.split()
738 # use the "system" .gyp
739 o['variables']['icu_gyp_path'] = 'tools/icu/icu-system.gyp'
742 print 'Error: unknown value --with-intl=%s' % with_intl
744 # Note: non-ICU implementations could use other 'with_intl'
747 # this is just the 'deps' dir. Used for unpacking.
748 icu_parent_path = os.path.join(root_dir, 'deps')
750 # The full path to the ICU source directory.
751 icu_full_path = os.path.join(icu_parent_path, 'icu')
753 # icu-tmp is used to download and unpack the ICU tarball.
754 icu_tmp_path = os.path.join(icu_parent_path, 'icu-tmp')
756 # --with-icu-source processing
757 # first, check that they didn't pass --with-icu-source=deps/icu
758 if with_icu_source and os.path.abspath(icu_full_path) == os.path.abspath(with_icu_source):
759 print 'Ignoring redundant --with-icu-source=%s' % (with_icu_source)
760 with_icu_source = None
761 # if with_icu_source is still set, try to use it.
763 if os.path.isdir(icu_full_path):
764 print 'Deleting old ICU source: %s' % (icu_full_path)
765 shutil.rmtree(icu_full_path)
766 # now, what path was given?
767 if os.path.isdir(with_icu_source):
768 # it's a path. Copy it.
769 print '%s -> %s' % (with_icu_source, icu_full_path)
770 shutil.copytree(with_icu_source, icu_full_path)
772 # could be file or URL.
773 # Set up temporary area
774 if os.path.isdir(icu_tmp_path):
775 shutil.rmtree(icu_tmp_path)
776 os.mkdir(icu_tmp_path)
778 if os.path.isfile(with_icu_source):
779 # it's a file. Try to unpack it.
780 icu_tarball = with_icu_source
782 # Can we download it?
783 local = os.path.join(icu_tmp_path, with_icu_source.split('/')[-1]) # local part
784 icu_tarball = nodedownload.retrievefile(with_icu_source, local)
785 # continue with "icu_tarball"
786 nodedownload.unpack(icu_tarball, icu_tmp_path)
787 # Did it unpack correctly? Should contain 'icu'
788 tmp_icu = os.path.join(icu_tmp_path, 'icu')
789 if os.path.isdir(tmp_icu):
790 os.rename(tmp_icu, icu_full_path)
791 shutil.rmtree(icu_tmp_path)
793 print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
794 shutil.rmtree(icu_tmp_path)
797 # ICU mode. (icu-generic.gyp)
798 byteorder = sys.byteorder
799 o['variables']['icu_gyp_path'] = 'tools/icu/icu-generic.gyp'
800 # ICU source dir relative to root
801 o['variables']['icu_path'] = icu_full_path
802 if not os.path.isdir(icu_full_path):
803 print '* ECMA-402 (Intl) support didn\'t find ICU in %s..' % (icu_full_path)
804 # can we download (or find) a zipfile?
805 localzip = icu_download(icu_full_path)
807 nodedownload.unpack(localzip, icu_parent_path)
808 if not os.path.isdir(icu_full_path):
809 print ' Cannot build Intl without ICU in %s.' % (icu_full_path)
810 print ' (Fix, or disable with "--with-intl=none" )'
813 print '* Using ICU in %s' % (icu_full_path)
814 # Now, what version of ICU is it? We just need the "major", such as 54.
815 # uvernum.h contains it as a #define.
816 uvernum_h = os.path.join(icu_full_path, 'source/common/unicode/uvernum.h')
817 if not os.path.isfile(uvernum_h):
818 print ' Error: could not load %s - is ICU installed?' % uvernum_h
821 matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
822 match_version = re.compile(matchVerExp)
823 for line in open(uvernum_h).readlines():
824 m = match_version.match(line)
826 icu_ver_major = m.group(1)
827 if not icu_ver_major:
828 print ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h
830 icu_endianness = sys.byteorder[0]; # TODO(srl295): EBCDIC should be 'e'
831 o['variables']['icu_ver_major'] = icu_ver_major
832 o['variables']['icu_endianness'] = icu_endianness
833 icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major, 'l')
834 icu_data_file = 'icudt%s%s.dat' % (icu_ver_major, icu_endianness)
835 # relative to configure
836 icu_data_path = os.path.join(icu_full_path,
840 icu_data_in = os.path.join('../../deps/icu/source/data/in', icu_data_file_l)
841 if not os.path.isfile(icu_data_path) and icu_endianness != 'l':
842 # use host endianness
843 icu_data_path = os.path.join(icu_full_path,
847 icu_data_in = os.path.join('icu/source/data/in',
849 # this is the input '.dat' file to use .. icudt*.dat
850 # may be little-endian if from a icu-project.org tarball
851 o['variables']['icu_data_in'] = icu_data_in
852 # this is the icudt*.dat file which node will be using (platform endianness)
853 o['variables']['icu_data_file'] = icu_data_file
854 if not os.path.isfile(icu_data_path):
855 print ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path
856 print ' See the README.md.'
857 # .. and we're not about to build it from .gyp!
859 # map from variable name to subdirs
861 'stubdata': 'stubdata',
865 'tools': 'tools/toolutil',
866 'genccode': 'tools/genccode',
867 'genrb': 'tools/genrb',
868 'icupkg': 'tools/icupkg',
870 # this creates a variable icu_src_XXX for each of the subdirs
871 # with a list of the src files to use
873 var = 'icu_src_%s' % i
874 path = '../../deps/icu/source/%s' % icu_src[i]
875 icu_config['variables'][var] = glob_to_var('tools/icu', path)
876 # write updated icu_config.gypi with a bunch of paths
877 write(icu_config_name, do_not_edit +
878 pprint.pformat(icu_config, indent=2) + '\n')
879 return # end of configure_intl
881 # determine the "flavor" (operating system) we're building for,
882 # leveraging gyp's GetFlavor function
884 if (options.dest_os):
885 flavor_params['flavor'] = options.dest_os
886 flavor = GetFlavor(flavor_params)
889 'variables': { 'python': sys.executable },
896 configure_node(output)
897 configure_libz(output)
898 configure_http_parser(output)
899 configure_libuv(output)
901 configure_openssl(output)
902 configure_winsdk(output)
903 configure_intl(output)
904 configure_fullystatic(output)
906 # variables should be a root level element,
907 # move everything else to target_defaults
908 variables = output['variables']
909 del output['variables']
911 'variables': variables,
912 'target_defaults': output
914 pprint.pprint(output, indent=2)
916 write('config.gypi', do_not_edit +
917 pprint.pformat(output, indent=2) + '\n')
920 'BUILDTYPE': 'Debug' if options.debug else 'Release',
921 'USE_NINJA': str(int(options.use_ninja or 0)),
922 'USE_XCODE': str(int(options.use_xcode or 0)),
923 'PYTHON': sys.executable,
927 config['PREFIX'] = options.prefix
929 config = '\n'.join(map('='.join, config.iteritems())) + '\n'
932 '# Do not edit. Generated by the configure script.\n' + config)
934 gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel']
936 if options.use_ninja:
937 gyp_args += ['-f', 'ninja-' + flavor]
938 elif options.use_xcode:
939 gyp_args += ['-f', 'xcode']
940 elif flavor == 'win' and sys.platform != 'msys':
941 gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto']
943 gyp_args += ['-f', 'make-' + flavor]
947 #print warning when snapshot is enabled and building on armv6
948 if (is_arch_armv6()) and (not options.without_snapshot):
949 print '\033[1;33mWarning!! When building on ARMv6 use --without-snapshot\033[1;m'
951 sys.exit(subprocess.call(gyp_args))