12 CC = os.environ.get('CC', 'cc')
13 CXX = os.environ.get('CXX', 'c++')
15 root_dir = os.path.dirname(__file__)
16 sys.path.insert(0, os.path.join(root_dir, 'tools', 'gyp', 'pylib'))
17 from gyp.common import GetFlavor
19 # imports in tools/configure.d
20 sys.path.insert(0, os.path.join(root_dir, 'tools', 'configure.d'))
24 parser = optparse.OptionParser()
26 # Options should be in alphabetical order but keep --prefix at the top,
27 # that's arguably the one people will be looking for most.
28 parser.add_option('--prefix',
31 help='select the install prefix (defaults to /usr/local)')
33 parser.add_option('--debug',
36 help='also build debug build')
38 parser.add_option('--dest-cpu',
41 help='CPU architecture to build for. Valid values are: arm, ia32, x32, x64')
43 parser.add_option('--dest-os',
46 help='operating system to build for. Valid values are: '
47 'win, mac, solaris, freebsd, openbsd, linux, android')
49 parser.add_option('--gdb',
52 help='add gdb support')
54 parser.add_option('--no-ifaddrs',
57 help='use on deprecated SunOS systems that do not support ifaddrs.h')
59 parser.add_option("--fully-static",
62 help="Generate an executable without external dynamic libraries. This "
63 "will not work on OSX when using default compilation environment")
65 parser.add_option("--openssl-no-asm",
67 dest="openssl_no_asm",
68 help="Do not build optimized assembly for OpenSSL")
71 parser.add_option('--openssl-includes',
73 dest='shared_openssl_includes',
74 help=optparse.SUPPRESS_HELP)
77 parser.add_option('--openssl-libpath',
79 dest='shared_openssl_libpath',
80 help=optparse.SUPPRESS_HELP)
83 parser.add_option('--openssl-use-sys',
85 dest='shared_openssl',
86 help=optparse.SUPPRESS_HELP)
88 parser.add_option('--shared-http-parser',
90 dest='shared_http_parser',
91 help='link to a shared http_parser DLL instead of static linking')
93 parser.add_option('--shared-http-parser-includes',
95 dest='shared_http_parser_includes',
96 help='directory containing http_parser header files')
98 parser.add_option('--shared-http-parser-libname',
100 dest='shared_http_parser_libname',
101 help='alternative lib name to link to (default: \'http_parser\')')
103 parser.add_option('--shared-http-parser-libpath',
105 dest='shared_http_parser_libpath',
106 help='a directory to search for the shared http_parser DLL')
108 parser.add_option('--shared-libuv',
111 help='link to a shared libuv DLL instead of static linking')
113 parser.add_option('--shared-libuv-includes',
115 dest='shared_libuv_includes',
116 help='directory containing libuv header files')
118 parser.add_option('--shared-libuv-libname',
120 dest='shared_libuv_libname',
121 help='alternative lib name to link to (default: \'uv\')')
123 parser.add_option('--shared-libuv-libpath',
125 dest='shared_libuv_libpath',
126 help='a directory to search for the shared libuv DLL')
128 parser.add_option('--shared-openssl',
130 dest='shared_openssl',
131 help='link to a shared OpenSSl DLL instead of static linking')
133 parser.add_option('--shared-openssl-includes',
135 dest='shared_openssl_includes',
136 help='directory containing OpenSSL header files')
138 parser.add_option('--shared-openssl-libname',
140 dest='shared_openssl_libname',
141 help='alternative lib name to link to (default: \'crypto,ssl\')')
143 parser.add_option('--shared-openssl-libpath',
145 dest='shared_openssl_libpath',
146 help='a directory to search for the shared OpenSSL DLLs')
148 parser.add_option('--shared-v8',
151 help='link to a shared V8 DLL instead of static linking')
153 parser.add_option('--shared-v8-includes',
155 dest='shared_v8_includes',
156 help='directory containing V8 header files')
158 parser.add_option('--shared-v8-libname',
160 dest='shared_v8_libname',
161 help='alternative lib name to link to (default: \'v8\')')
163 parser.add_option('--shared-v8-libpath',
165 dest='shared_v8_libpath',
166 help='a directory to search for the shared V8 DLL')
168 parser.add_option('--shared-zlib',
171 help='link to a shared zlib DLL instead of static linking')
173 parser.add_option('--shared-zlib-includes',
175 dest='shared_zlib_includes',
176 help='directory containing zlib header files')
178 parser.add_option('--shared-zlib-libname',
180 dest='shared_zlib_libname',
181 help='alternative lib name to link to (default: \'z\')')
183 parser.add_option('--shared-zlib-libpath',
185 dest='shared_zlib_libpath',
186 help='a directory to search for the shared zlib DLL')
188 # TODO document when we've decided on what the tracing API and its options will
190 parser.add_option('--systemtap-includes',
192 dest='systemtap_includes',
193 help=optparse.SUPPRESS_HELP)
195 parser.add_option('--tag',
198 help='custom build tag')
200 parser.add_option('--v8-options',
203 help='v8 options to pass, see `node --v8-options` for examples.')
205 parser.add_option('--with-arm-float-abi',
207 dest='arm_float_abi',
208 help='specifies which floating-point ABI to use. Valid values are: '
209 'soft, softfp, hard')
211 parser.add_option('--with-dtrace',
214 help='build with DTrace (default is true on sunos)')
216 parser.add_option('--with-etw',
219 help='build with ETW (default is true on Windows)')
221 parser.add_option('--download',
223 dest='download_list',
224 help=nodedownload.help())
226 parser.add_option('--with-icu-path',
228 dest='with_icu_path',
229 help='Path to icu.gyp (ICU i18n, Chromium version only.)')
231 parser.add_option('--with-icu-locales',
233 dest='with_icu_locales',
234 help='Comma-separated list of locales for "small-icu". Default: "root,en". "root" is assumed.')
236 parser.add_option('--with-intl',
239 help='Intl mode: none, full-icu, small-icu (default is none)')
241 parser.add_option('--with-icu-source',
243 dest='with_icu_source',
244 help='Intl mode: optional local path to icu/ dir, or path/URL of icu source archive.')
246 parser.add_option('--with-perfctr',
249 help='build with performance counters (default is true on Windows)')
251 parser.add_option('--without-dtrace',
253 dest='without_dtrace',
254 help='build without DTrace')
256 parser.add_option('--without-etw',
259 help='build without ETW')
261 parser.add_option('--without-npm',
264 help='don\'t install the bundled npm package manager')
266 parser.add_option('--without-perfctr',
268 dest='without_perfctr',
269 help='build without performance counters')
271 parser.add_option('--with-snapshot',
273 dest='with_snapshot',
274 help=optparse.SUPPRESS_HELP)
276 # Dummy option for backwards compatibility.
277 parser.add_option('--without-snapshot',
279 dest='unused_without_snapshot',
280 help=optparse.SUPPRESS_HELP)
282 parser.add_option('--without-ssl',
285 help='build without SSL')
287 parser.add_option('--xcode',
290 help='generate build files for use with xcode')
292 (options, args) = parser.parse_args()
294 # set up auto-download list
295 auto_downloads = nodedownload.parse(options.download_list)
300 prefix = '\033[1m\033[93mWARNING\033[0m' if os.isatty(1) else 'WARNING'
301 print('%s: %s' % (prefix, msg))
303 # track if warnings occured
307 """Returns the string 'true' if value is truthy, 'false' otherwise."""
315 cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
316 libs = cmd.readline().strip()
318 if (ret): return None
320 cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
321 cflags = cmd.readline().strip()
323 if (ret): return None
325 return (libs, cflags)
328 def try_check_compiler(cc, lang):
330 proc = subprocess.Popen(shlex.split(cc) + ['-E', '-P', '-x', lang, '-'],
331 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
333 return (False, False, '', '')
335 proc.stdin.write('__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
336 '__clang_major__ __clang_minor__ __clang_patchlevel__')
338 values = (proc.communicate()[0].split() + ['0'] * 7)[0:7]
339 is_clang = values[0] == '1'
340 gcc_version = '%s.%s.%s' % tuple(values[1:1+3])
341 clang_version = '%s.%s.%s' % tuple(values[4:4+3])
343 return (True, is_clang, clang_version, gcc_version)
346 # Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
347 # the version check more by accident than anything else but a more rigorous
348 # check involves checking the build number against a whitelist. I'm not
349 # quite prepared to go that far yet.
350 def check_compiler():
351 if sys.platform == 'win32':
354 ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, 'c++')
356 warn('failed to autodetect C++ compiler version (CXX=%s)' % CXX)
357 elif clang_version < '3.4.0' if is_clang else gcc_version < '4.8.0':
358 warn('C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=%s)' % CXX)
360 ok, is_clang, clang_version, gcc_version = try_check_compiler(CC, 'c')
362 warn('failed to autodetect C compiler version (CC=%s)' % CC)
363 elif not is_clang and gcc_version < '4.2.0':
364 # clang 3.2 is a little white lie because any clang version will probably
365 # do for the C bits. However, we might as well encourage people to upgrade
366 # to a version that is not completely ancient.
367 warn('C compiler too old, need gcc 4.2 or clang 3.2 (CC=%s)' % CC)
371 """Checks predefined macros using the CC command."""
374 p = subprocess.Popen(shlex.split(CC) + ['-dM', '-E', '-'],
375 stdin=subprocess.PIPE,
376 stdout=subprocess.PIPE,
377 stderr=subprocess.PIPE)
379 print '''Node.js configure error: No acceptable C compiler found!
381 Please make sure you have a C compiler installed on your system and/or
382 consider adjusting the CC environment variable if you installed
383 it in a non-standard prefix.
388 out = p.communicate()[0]
390 out = str(out).split('\n')
394 lst = shlex.split(line)
403 """Check for ARMv7 instructions"""
404 cc_macros_cache = cc_macros()
405 return ('__ARM_ARCH_7__' in cc_macros_cache or
406 '__ARM_ARCH_7A__' in cc_macros_cache or
407 '__ARM_ARCH_7R__' in cc_macros_cache or
408 '__ARM_ARCH_7M__' in cc_macros_cache)
412 """Check for ARMv6 instructions"""
413 cc_macros_cache = cc_macros()
414 return ('__ARM_ARCH_6__' in cc_macros_cache or
415 '__ARM_ARCH_6M__' in cc_macros_cache)
418 def is_arm_hard_float_abi():
419 """Check for hardfloat or softfloat eabi on ARM"""
420 # GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
421 # the Floating Point ABI used (PCS stands for Procedure Call Standard).
422 # We use these as well as a couple of other defines to statically determine
425 return '__ARM_PCS_VFP' in cc_macros()
429 """Host architecture check using the CC command."""
434 '__x86_64__' : 'x64',
440 rtn = 'ia32' # default
443 if i in k and k[i] != '0':
451 """Host architecture check using environ vars (better way to do this?)"""
453 observed_arch = os.environ.get('PROCESSOR_ARCHITECTURE', 'x86')
454 arch = os.environ.get('PROCESSOR_ARCHITEW6432', observed_arch)
463 return matchup.get(arch, 'ia32')
466 def configure_arm(o):
467 if options.arm_float_abi:
468 arm_float_abi = options.arm_float_abi
469 elif is_arm_hard_float_abi():
470 arm_float_abi = 'hard'
472 arm_float_abi = 'default'
475 o['variables']['arm_fpu'] = 'vfpv3'
476 o['variables']['arm_version'] = '7'
478 o['variables']['arm_fpu'] = 'vfpv2'
479 o['variables']['arm_version'] = '6' if is_arch_armv6() else 'default'
481 o['variables']['arm_thumb'] = 0 # -marm
482 o['variables']['arm_float_abi'] = arm_float_abi
484 # Print warning when snapshot is enabled and building on armv6
485 if is_arch_armv6() and options.with_snapshot:
486 warn('when building on ARMv6, don\'t use --with-snapshot')
489 def configure_node(o):
490 if options.dest_os == 'android':
491 o['variables']['OS'] = 'android'
492 o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '')
493 o['variables']['node_install_npm'] = b(not options.without_npm)
494 o['default_configuration'] = 'Debug' if options.debug else 'Release'
496 host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
497 target_arch = options.dest_cpu or host_arch
498 o['variables']['host_arch'] = host_arch
499 o['variables']['target_arch'] = target_arch
501 if target_arch != host_arch and options.with_snapshot:
502 o['variables']['want_separate_host_toolset'] = 1
504 o['variables']['want_separate_host_toolset'] = 0
506 if target_arch == 'arm':
509 if flavor in ('solaris', 'mac', 'linux', 'freebsd'):
510 use_dtrace = not options.without_dtrace
511 # Don't enable by default on linux and freebsd
512 if flavor in ('linux', 'freebsd'):
513 use_dtrace = options.with_dtrace
515 if flavor == 'linux':
516 if options.systemtap_includes:
517 o['include_dirs'] += [options.systemtap_includes]
518 o['variables']['node_use_dtrace'] = b(use_dtrace)
519 o['variables']['uv_use_dtrace'] = b(use_dtrace)
520 o['variables']['uv_parent_path'] = '/deps/uv/'
521 elif options.with_dtrace:
523 'DTrace is currently only supported on SunOS, MacOS or Linux systems.')
525 o['variables']['node_use_dtrace'] = 'false'
527 # if we're on illumos based systems wrap the helper library into the
529 if flavor == 'solaris':
530 o['variables']['node_use_mdb'] = 'true'
532 o['variables']['node_use_mdb'] = 'false'
534 if options.no_ifaddrs:
535 o['defines'] += ['SUNOS_NO_IFADDRS']
537 # By default, enable ETW on Windows.
539 o['variables']['node_use_etw'] = b(not options.without_etw)
540 elif options.with_etw:
541 raise Exception('ETW is only supported on Windows.')
543 o['variables']['node_use_etw'] = 'false'
545 # By default, enable Performance counters on Windows.
547 o['variables']['node_use_perfctr'] = b(not options.without_perfctr)
548 elif options.with_perfctr:
549 raise Exception('Performance counter is only supported on Windows.')
551 o['variables']['node_use_perfctr'] = 'false'
554 o['variables']['node_tag'] = '-' + options.tag
556 o['variables']['node_tag'] = ''
558 if options.v8_options:
559 o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')
562 def configure_libz(o):
563 o['variables']['node_shared_zlib'] = b(options.shared_zlib)
565 # assume shared_zlib if one of these is set?
566 if options.shared_zlib_libpath:
567 o['libraries'] += ['-L%s' % options.shared_zlib_libpath]
568 if options.shared_zlib_libname:
569 o['libraries'] += ['-l%s' % options.shared_zlib_libname]
570 elif options.shared_zlib:
571 o['libraries'] += ['-lz']
572 if options.shared_zlib_includes:
573 o['include_dirs'] += [options.shared_zlib_includes]
576 def configure_http_parser(o):
577 o['variables']['node_shared_http_parser'] = b(options.shared_http_parser)
579 # assume shared http_parser if one of these is set?
580 if options.shared_http_parser_libpath:
581 o['libraries'] += ['-L%s' % options.shared_http_parser_libpath]
582 if options.shared_http_parser_libname:
583 o['libraries'] += ['-l%s' % options.shared_http_parser_libname]
584 elif options.shared_http_parser:
585 o['libraries'] += ['-lhttp_parser']
586 if options.shared_http_parser_includes:
587 o['include_dirs'] += [options.shared_http_parser_includes]
590 def configure_libuv(o):
591 o['variables']['node_shared_libuv'] = b(options.shared_libuv)
593 # assume shared libuv if one of these is set?
594 if options.shared_libuv_libpath:
595 o['libraries'] += ['-L%s' % options.shared_libuv_libpath]
597 o['variables']['uv_library'] = 'static_library'
599 if options.shared_libuv_libname:
600 o['libraries'] += ['-l%s' % options.shared_libuv_libname]
601 elif options.shared_libuv:
602 o['libraries'] += ['-luv']
603 if options.shared_libuv_includes:
604 o['include_dirs'] += [options.shared_libuv_includes]
608 o['variables']['node_shared_v8'] = b(options.shared_v8)
609 o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0
610 o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs.
611 o['variables']['v8_optimized_debug'] = 0 # Compile with -O0 in debug builds.
612 o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables.
613 o['variables']['v8_use_snapshot'] = b(options.with_snapshot)
615 # assume shared_v8 if one of these is set?
616 if options.shared_v8_libpath:
617 o['libraries'] += ['-L%s' % options.shared_v8_libpath]
618 if options.shared_v8_libname:
619 o['libraries'] += ['-l%s' % options.shared_v8_libname]
620 elif options.shared_v8:
621 o['libraries'] += ['-lv8']
622 if options.shared_v8_includes:
623 o['include_dirs'] += [options.shared_v8_includes]
626 def configure_openssl(o):
627 o['variables']['node_use_openssl'] = b(not options.without_ssl)
628 o['variables']['node_shared_openssl'] = b(options.shared_openssl)
629 o['variables']['openssl_no_asm'] = (
630 1 if options.openssl_no_asm else 0)
632 if options.without_ssl:
635 if options.shared_openssl:
636 (libs, cflags) = pkg_config('openssl') or ('-lssl -lcrypto', '')
638 if options.shared_openssl_libpath:
639 o['libraries'] += ['-L%s' % options.shared_openssl_libpath]
641 if options.shared_openssl_libname:
642 libnames = options.shared_openssl_libname.split(',')
643 o['libraries'] += ['-l%s' % s for s in libnames]
645 o['libraries'] += libs.split()
647 if options.shared_openssl_includes:
648 o['include_dirs'] += [options.shared_openssl_includes]
650 o['cflags'] += cflags.split()
653 def configure_fullystatic(o):
654 if options.fully_static:
655 o['libraries'] += ['-static']
657 print("Generation of static executable will not work on OSX "
658 "when using default compilation environment")
661 def configure_winsdk(o):
665 winsdk_dir = os.environ.get('WindowsSdkDir')
667 if winsdk_dir and os.path.isfile(winsdk_dir + '\\bin\\ctrpp.exe'):
668 print('Found ctrpp in WinSDK--will build generated files '
669 'into tools/msvs/genfiles.')
670 o['variables']['node_has_winsdk'] = 'true'
673 print('ctrpp not found in WinSDK path--using pre-gen files '
674 'from tools/msvs/genfiles.')
676 def write(filename, data):
677 filename = os.path.join(root_dir, filename)
678 print 'creating ', filename
679 f = open(filename, 'w+')
682 do_not_edit = '# Do not edit. Generated by the configure script.\n'
684 def glob_to_var(dir_base, dir_sub):
686 dir_all = os.path.join(dir_base, dir_sub)
687 files = os.walk(dir_all)
689 (path, dirs, files) = ent
691 if file.endswith('.cpp') or file.endswith('.c') or file.endswith('.h'):
692 list.append('%s/%s' % (dir_sub, file))
696 def configure_intl(o):
699 'url': 'http://download.icu-project.org/files/icu4c/54.1/icu4c-54_1-src.zip',
700 # from https://ssl.icu-project.org/files/icu4c/54.1/icu4c-src-54_1.md5:
701 'md5': '6b89d60e2f0e140898ae4d7f72323bca',
704 def icu_download(path):
705 # download ICU, if needed
709 local = url.split('/')[-1]
710 targetfile = os.path.join(root_dir, 'deps', local)
711 if not os.path.isfile(targetfile):
712 if nodedownload.candownload(auto_downloads, "icu"):
713 nodedownload.retrievefile(url, targetfile)
715 print ' Re-using existing %s' % targetfile
716 if os.path.isfile(targetfile):
717 sys.stdout.write(' Checking file integrity with MD5:\r')
718 gotmd5 = nodedownload.md5sum(targetfile)
719 print ' MD5: %s %s' % (gotmd5, targetfile)
723 print ' Expected: %s *MISMATCH*' % md5
724 print '\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile
729 icu_config_name = 'icu_config.gypi'
730 def write_config(data, name):
733 # write an empty file to start with
734 write(icu_config_name, do_not_edit +
735 pprint.pformat(icu_config, indent=2) + '\n')
737 # always set icu_small, node.gyp depends on it being defined.
738 o['variables']['icu_small'] = b(False)
740 with_intl = options.with_intl
741 with_icu_source = options.with_icu_source
742 have_icu_path = bool(options.with_icu_path)
743 if have_icu_path and with_intl:
744 print 'Error: Cannot specify both --with-icu-path and --with-intl'
747 # Chromium .gyp mode: --with-icu-path
748 o['variables']['v8_enable_i18n_support'] = 1
750 o['variables']['icu_gyp_path'] = options.with_icu_path
752 # --with-intl=<with_intl>
754 if with_intl is None:
755 with_intl = 'none' # The default mode of Intl
756 # sanity check localelist
757 if options.with_icu_locales and (with_intl != 'small-icu'):
758 print 'Error: --with-icu-locales only makes sense with --with-intl=small-icu'
760 if with_intl == 'none' or with_intl is None:
761 o['variables']['v8_enable_i18n_support'] = 0
763 elif with_intl == 'small-icu':
764 # small ICU (English only)
765 o['variables']['v8_enable_i18n_support'] = 1
766 o['variables']['icu_small'] = b(True)
767 with_icu_locales = options.with_icu_locales
768 if not with_icu_locales:
769 with_icu_locales = 'root,en'
770 locs = set(with_icu_locales.split(','))
771 locs.add('root') # must have root
772 o['variables']['icu_locales'] = string.join(locs,',')
773 elif with_intl == 'full-icu':
775 o['variables']['v8_enable_i18n_support'] = 1
776 elif with_intl == 'system-icu':
777 # ICU from pkg-config.
778 o['variables']['v8_enable_i18n_support'] = 1
779 pkgicu = pkg_config('icu-i18n')
781 print 'Error: could not load pkg-config data for "icu-i18n".'
782 print 'See above errors or the README.md.'
784 (libs, cflags) = pkgicu
785 o['libraries'] += libs.split()
786 o['cflags'] += cflags.split()
787 # use the "system" .gyp
788 o['variables']['icu_gyp_path'] = 'tools/icu/icu-system.gyp'
791 print 'Error: unknown value --with-intl=%s' % with_intl
793 # Note: non-ICU implementations could use other 'with_intl'
796 # this is just the 'deps' dir. Used for unpacking.
797 icu_parent_path = os.path.join(root_dir, 'deps')
799 # The full path to the ICU source directory.
800 icu_full_path = os.path.join(icu_parent_path, 'icu')
802 # icu-tmp is used to download and unpack the ICU tarball.
803 icu_tmp_path = os.path.join(icu_parent_path, 'icu-tmp')
805 # --with-icu-source processing
806 # first, check that they didn't pass --with-icu-source=deps/icu
807 if with_icu_source and os.path.abspath(icu_full_path) == os.path.abspath(with_icu_source):
808 print 'Ignoring redundant --with-icu-source=%s' % (with_icu_source)
809 with_icu_source = None
810 # if with_icu_source is still set, try to use it.
812 if os.path.isdir(icu_full_path):
813 print 'Deleting old ICU source: %s' % (icu_full_path)
814 shutil.rmtree(icu_full_path)
815 # now, what path was given?
816 if os.path.isdir(with_icu_source):
817 # it's a path. Copy it.
818 print '%s -> %s' % (with_icu_source, icu_full_path)
819 shutil.copytree(with_icu_source, icu_full_path)
821 # could be file or URL.
822 # Set up temporary area
823 if os.path.isdir(icu_tmp_path):
824 shutil.rmtree(icu_tmp_path)
825 os.mkdir(icu_tmp_path)
827 if os.path.isfile(with_icu_source):
828 # it's a file. Try to unpack it.
829 icu_tarball = with_icu_source
831 # Can we download it?
832 local = os.path.join(icu_tmp_path, with_icu_source.split('/')[-1]) # local part
833 icu_tarball = nodedownload.retrievefile(with_icu_source, local)
834 # continue with "icu_tarball"
835 nodedownload.unpack(icu_tarball, icu_tmp_path)
836 # Did it unpack correctly? Should contain 'icu'
837 tmp_icu = os.path.join(icu_tmp_path, 'icu')
838 if os.path.isdir(tmp_icu):
839 os.rename(tmp_icu, icu_full_path)
840 shutil.rmtree(icu_tmp_path)
842 print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
843 shutil.rmtree(icu_tmp_path)
846 # ICU mode. (icu-generic.gyp)
847 o['variables']['icu_gyp_path'] = 'tools/icu/icu-generic.gyp'
848 # ICU source dir relative to root
849 o['variables']['icu_path'] = icu_full_path
850 if not os.path.isdir(icu_full_path):
851 print '* ECMA-402 (Intl) support didn\'t find ICU in %s..' % (icu_full_path)
852 # can we download (or find) a zipfile?
853 localzip = icu_download(icu_full_path)
855 nodedownload.unpack(localzip, icu_parent_path)
856 if not os.path.isdir(icu_full_path):
857 print ' Cannot build Intl without ICU in %s.' % (icu_full_path)
858 print ' (Fix, or disable with "--with-intl=none" )'
861 print '* Using ICU in %s' % (icu_full_path)
862 # Now, what version of ICU is it? We just need the "major", such as 54.
863 # uvernum.h contains it as a #define.
864 uvernum_h = os.path.join(icu_full_path, 'source/common/unicode/uvernum.h')
865 if not os.path.isfile(uvernum_h):
866 print ' Error: could not load %s - is ICU installed?' % uvernum_h
869 matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
870 match_version = re.compile(matchVerExp)
871 for line in open(uvernum_h).readlines():
872 m = match_version.match(line)
874 icu_ver_major = m.group(1)
875 if not icu_ver_major:
876 print ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h
878 icu_endianness = sys.byteorder[0]; # TODO(srl295): EBCDIC should be 'e'
879 o['variables']['icu_ver_major'] = icu_ver_major
880 o['variables']['icu_endianness'] = icu_endianness
881 icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major, 'l')
882 icu_data_file = 'icudt%s%s.dat' % (icu_ver_major, icu_endianness)
883 # relative to configure
884 icu_data_path = os.path.join(icu_full_path,
888 icu_data_in = os.path.join('../../deps/icu/source/data/in', icu_data_file_l)
889 if not os.path.isfile(icu_data_path) and icu_endianness != 'l':
890 # use host endianness
891 icu_data_path = os.path.join(icu_full_path,
895 icu_data_in = os.path.join('icu/source/data/in',
897 # this is the input '.dat' file to use .. icudt*.dat
898 # may be little-endian if from a icu-project.org tarball
899 o['variables']['icu_data_in'] = icu_data_in
900 # this is the icudt*.dat file which node will be using (platform endianness)
901 o['variables']['icu_data_file'] = icu_data_file
902 if not os.path.isfile(icu_data_path):
903 print ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path
904 print ' See the README.md.'
905 # .. and we're not about to build it from .gyp!
907 # map from variable name to subdirs
909 'stubdata': 'stubdata',
913 'tools': 'tools/toolutil',
914 'genccode': 'tools/genccode',
915 'genrb': 'tools/genrb',
916 'icupkg': 'tools/icupkg',
918 # this creates a variable icu_src_XXX for each of the subdirs
919 # with a list of the src files to use
921 var = 'icu_src_%s' % i
922 path = '../../deps/icu/source/%s' % icu_src[i]
923 icu_config['variables'][var] = glob_to_var('tools/icu', path)
924 # write updated icu_config.gypi with a bunch of paths
925 write(icu_config_name, do_not_edit +
926 pprint.pformat(icu_config, indent=2) + '\n')
927 return # end of configure_intl
929 # Print a warning when the compiler is too old.
932 # determine the "flavor" (operating system) we're building for,
933 # leveraging gyp's GetFlavor function
935 if (options.dest_os):
936 flavor_params['flavor'] = options.dest_os
937 flavor = GetFlavor(flavor_params)
940 'variables': { 'python': sys.executable },
947 configure_node(output)
948 configure_libz(output)
949 configure_http_parser(output)
950 configure_libuv(output)
952 configure_openssl(output)
953 configure_winsdk(output)
954 configure_intl(output)
955 configure_fullystatic(output)
957 # variables should be a root level element,
958 # move everything else to target_defaults
959 variables = output['variables']
960 del output['variables']
962 'variables': variables,
963 'target_defaults': output
965 pprint.pprint(output, indent=2)
967 write('config.gypi', do_not_edit +
968 pprint.pformat(output, indent=2) + '\n')
971 'BUILDTYPE': 'Debug' if options.debug else 'Release',
972 'USE_XCODE': str(int(options.use_xcode or 0)),
973 'PYTHON': sys.executable,
977 config['PREFIX'] = options.prefix
979 config = '\n'.join(map('='.join, config.iteritems())) + '\n'
982 '# Do not edit. Generated by the configure script.\n' + config)
984 gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel']
986 if options.use_xcode:
987 gyp_args += ['-f', 'xcode']
988 elif flavor == 'win' and sys.platform != 'msys':
989 gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto']
991 gyp_args += ['-f', 'make-' + flavor]
996 warn('warnings were emitted in the configure phase')
998 sys.exit(subprocess.call(gyp_args))