13 CC = os.environ.get('CC', 'cc')
14 CXX = os.environ.get('CXX', 'c++')
16 root_dir = os.path.dirname(__file__)
17 sys.path.insert(0, os.path.join(root_dir, 'tools', 'gyp', 'pylib'))
18 from gyp.common import GetFlavor
20 # imports in tools/configure.d
21 sys.path.insert(0, os.path.join(root_dir, 'tools', 'configure.d'))
25 parser = optparse.OptionParser()
27 # Options should be in alphabetical order but keep --prefix at the top,
28 # that's arguably the one people will be looking for most.
29 parser.add_option('--prefix',
32 help='select the install prefix (defaults to /usr/local)')
34 parser.add_option('--debug',
37 help='also build debug build')
39 parser.add_option('--dest-cpu',
42 help='CPU architecture to build for. Valid values are: arm, ia32, x32, x64')
44 parser.add_option('--dest-os',
47 help='operating system to build for. Valid values are: '
48 'win, mac, solaris, freebsd, openbsd, linux, android')
50 parser.add_option('--gdb',
53 help='add gdb support')
55 parser.add_option('--no-ifaddrs',
58 help='use on deprecated SunOS systems that do not support ifaddrs.h')
60 parser.add_option("--fully-static",
63 help="Generate an executable without external dynamic libraries. This "
64 "will not work on OSX when using default compilation environment")
66 parser.add_option("--openssl-no-asm",
68 dest="openssl_no_asm",
69 help="Do not build optimized assembly for OpenSSL")
72 parser.add_option('--openssl-includes',
74 dest='shared_openssl_includes',
75 help=optparse.SUPPRESS_HELP)
78 parser.add_option('--openssl-libpath',
80 dest='shared_openssl_libpath',
81 help=optparse.SUPPRESS_HELP)
84 parser.add_option('--openssl-use-sys',
86 dest='shared_openssl',
87 help=optparse.SUPPRESS_HELP)
89 parser.add_option('--shared-http-parser',
91 dest='shared_http_parser',
92 help='link to a shared http_parser DLL instead of static linking')
94 parser.add_option('--shared-http-parser-includes',
96 dest='shared_http_parser_includes',
97 help='directory containing http_parser header files')
99 parser.add_option('--shared-http-parser-libname',
101 dest='shared_http_parser_libname',
102 help='alternative lib name to link to (default: \'http_parser\')')
104 parser.add_option('--shared-http-parser-libpath',
106 dest='shared_http_parser_libpath',
107 help='a directory to search for the shared http_parser DLL')
109 parser.add_option('--shared-libuv',
112 help='link to a shared libuv DLL instead of static linking')
114 parser.add_option('--shared-libuv-includes',
116 dest='shared_libuv_includes',
117 help='directory containing libuv header files')
119 parser.add_option('--shared-libuv-libname',
121 dest='shared_libuv_libname',
122 help='alternative lib name to link to (default: \'uv\')')
124 parser.add_option('--shared-libuv-libpath',
126 dest='shared_libuv_libpath',
127 help='a directory to search for the shared libuv DLL')
129 parser.add_option('--shared-openssl',
131 dest='shared_openssl',
132 help='link to a shared OpenSSl DLL instead of static linking')
134 parser.add_option('--shared-openssl-includes',
136 dest='shared_openssl_includes',
137 help='directory containing OpenSSL header files')
139 parser.add_option('--shared-openssl-libname',
141 dest='shared_openssl_libname',
142 help='alternative lib name to link to (default: \'crypto,ssl\')')
144 parser.add_option('--shared-openssl-libpath',
146 dest='shared_openssl_libpath',
147 help='a directory to search for the shared OpenSSL DLLs')
149 parser.add_option('--shared-v8',
152 help='link to a shared V8 DLL instead of static linking')
154 parser.add_option('--shared-v8-includes',
156 dest='shared_v8_includes',
157 help='directory containing V8 header files')
159 parser.add_option('--shared-v8-libname',
161 dest='shared_v8_libname',
162 help='alternative lib name to link to (default: \'v8\')')
164 parser.add_option('--shared-v8-libpath',
166 dest='shared_v8_libpath',
167 help='a directory to search for the shared V8 DLL')
169 parser.add_option('--shared-zlib',
172 help='link to a shared zlib DLL instead of static linking')
174 parser.add_option('--shared-zlib-includes',
176 dest='shared_zlib_includes',
177 help='directory containing zlib header files')
179 parser.add_option('--shared-zlib-libname',
181 dest='shared_zlib_libname',
182 help='alternative lib name to link to (default: \'z\')')
184 parser.add_option('--shared-zlib-libpath',
186 dest='shared_zlib_libpath',
187 help='a directory to search for the shared zlib DLL')
189 # TODO document when we've decided on what the tracing API and its options will
191 parser.add_option('--systemtap-includes',
193 dest='systemtap_includes',
194 help=optparse.SUPPRESS_HELP)
196 parser.add_option('--tag',
199 help='custom build tag')
201 parser.add_option('--v8-options',
204 help='v8 options to pass, see `node --v8-options` for examples.')
206 parser.add_option('--with-arm-float-abi',
208 dest='arm_float_abi',
209 help='specifies which floating-point ABI to use. Valid values are: '
210 'soft, softfp, hard')
212 parser.add_option('--with-dtrace',
215 help='build with DTrace (default is true on sunos)')
217 parser.add_option('--with-etw',
220 help='build with ETW (default is true on Windows)')
222 parser.add_option('--download',
224 dest='download_list',
225 help=nodedownload.help())
227 parser.add_option('--with-icu-path',
229 dest='with_icu_path',
230 help='Path to icu.gyp (ICU i18n, Chromium version only.)')
232 parser.add_option('--with-icu-locales',
234 dest='with_icu_locales',
235 help='Comma-separated list of locales for "small-icu". Default: "root,en". "root" is assumed.')
237 parser.add_option('--with-intl',
240 help='Intl mode: none, full-icu, small-icu (default is none)')
242 parser.add_option('--with-icu-source',
244 dest='with_icu_source',
245 help='Intl mode: optional local path to icu/ dir, or path/URL of icu source archive.')
247 parser.add_option('--with-perfctr',
250 help='build with performance counters (default is true on Windows)')
252 parser.add_option('--without-dtrace',
254 dest='without_dtrace',
255 help='build without DTrace')
257 parser.add_option('--without-etw',
260 help='build without ETW')
262 parser.add_option('--without-npm',
265 help='don\'t install the bundled npm package manager')
267 parser.add_option('--without-perfctr',
269 dest='without_perfctr',
270 help='build without performance counters')
272 parser.add_option('--with-snapshot',
274 dest='with_snapshot',
275 help=optparse.SUPPRESS_HELP)
277 # Dummy option for backwards compatibility.
278 parser.add_option('--without-snapshot',
280 dest='unused_without_snapshot',
281 help=optparse.SUPPRESS_HELP)
283 parser.add_option('--without-ssl',
286 help='build without SSL')
288 parser.add_option('--xcode',
291 help='generate build files for use with xcode')
293 (options, args) = parser.parse_args()
295 # set up auto-download list
296 auto_downloads = nodedownload.parse(options.download_list)
300 prefix = '\033[1m\033[91mWARNING\033[0m' if os.isatty(1) else 'WARNING'
301 print('%s: %s' % (prefix, msg))
305 """Returns the string 'true' if value is truthy, 'false' otherwise."""
313 cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
314 libs = cmd.readline().strip()
316 if (ret): return None
318 cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
319 cflags = cmd.readline().strip()
321 if (ret): return None
323 return (libs, cflags)
326 def try_check_compiler(cc, lang):
328 proc = subprocess.Popen(shlex.split(cc) + ['-E', '-P', '-x', lang, '-'],
329 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
331 return (False, False, '', '')
333 proc.stdin.write('__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
334 '__clang_major__ __clang_minor__ __clang_patchlevel__')
336 values = (proc.communicate()[0].split() + ['0'] * 7)[0:7]
337 is_clang = values[0] == '1'
338 gcc_version = '%s.%s.%s' % tuple(values[1:1+3])
339 clang_version = '%s.%s.%s' % tuple(values[4:4+3])
341 return (True, is_clang, clang_version, gcc_version)
344 # Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
345 # the version check more by accident than anything else but a more rigorous
346 # check involves checking the build number against a whitelist. I'm not
347 # quite prepared to go that far yet.
348 def check_compiler():
349 if sys.platform == 'win32':
352 ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, 'c++')
354 warn('failed to autodetect C++ compiler version (CXX=%s)' % CXX)
355 elif clang_version < '3.4.0' if is_clang else gcc_version < '4.8.0':
356 warn('C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=%s)' % CXX)
358 ok, is_clang, clang_version, gcc_version = try_check_compiler(CC, 'c')
360 warn('failed to autodetect C compiler version (CC=%s)' % CC)
361 elif not is_clang and gcc_version < '4.2.0':
362 # clang 3.2 is a little white lie because any clang version will probably
363 # do for the C bits. However, we might as well encourage people to upgrade
364 # to a version that is not completely ancient.
365 warn('C compiler too old, need gcc 4.2 or clang 3.2 (CC=%s)' % CC)
369 """Checks predefined macros using the CC command."""
372 p = subprocess.Popen(shlex.split(CC) + ['-dM', '-E', '-'],
373 stdin=subprocess.PIPE,
374 stdout=subprocess.PIPE,
375 stderr=subprocess.PIPE)
377 print '''Node.js configure error: No acceptable C compiler found!
379 Please make sure you have a C compiler installed on your system and/or
380 consider adjusting the CC environment variable if you installed
381 it in a non-standard prefix.
386 out = p.communicate()[0]
388 out = str(out).split('\n')
392 lst = shlex.split(line)
401 """Check for ARMv7 instructions"""
402 cc_macros_cache = cc_macros()
403 return ('__ARM_ARCH_7__' in cc_macros_cache or
404 '__ARM_ARCH_7A__' in cc_macros_cache or
405 '__ARM_ARCH_7R__' in cc_macros_cache or
406 '__ARM_ARCH_7M__' in cc_macros_cache)
410 """Check for ARMv6 instructions"""
411 cc_macros_cache = cc_macros()
412 return ('__ARM_ARCH_6__' in cc_macros_cache or
413 '__ARM_ARCH_6M__' in cc_macros_cache)
416 def is_arm_hard_float_abi():
417 """Check for hardfloat or softfloat eabi on ARM"""
418 # GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
419 # the Floating Point ABI used (PCS stands for Procedure Call Standard).
420 # We use these as well as a couple of other defines to statically determine
423 return '__ARM_PCS_VFP' in cc_macros()
427 """Host architecture check using the CC command."""
432 '__x86_64__' : 'x64',
438 rtn = 'ia32' # default
441 if i in k and k[i] != '0':
449 """Host architecture check using environ vars (better way to do this?)"""
451 observed_arch = os.environ.get('PROCESSOR_ARCHITECTURE', 'x86')
452 arch = os.environ.get('PROCESSOR_ARCHITEW6432', observed_arch)
461 return matchup.get(arch, 'ia32')
464 def configure_arm(o):
465 if options.arm_float_abi:
466 arm_float_abi = options.arm_float_abi
467 elif is_arm_hard_float_abi():
468 arm_float_abi = 'hard'
470 arm_float_abi = 'default'
473 o['variables']['arm_fpu'] = 'vfpv3'
474 o['variables']['arm_version'] = '7'
476 o['variables']['arm_fpu'] = 'vfpv2'
477 o['variables']['arm_version'] = '6' if is_arch_armv6() else 'default'
479 o['variables']['arm_thumb'] = 0 # -marm
480 o['variables']['arm_float_abi'] = arm_float_abi
482 # Print warning when snapshot is enabled and building on armv6
483 if is_arch_armv6() and options.with_snapshot:
484 warn('when building on ARMv6, don\'t use --with-snapshot')
487 def configure_node(o):
488 if options.dest_os == 'android':
489 o['variables']['OS'] = 'android'
490 o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '')
491 o['variables']['node_install_npm'] = b(not options.without_npm)
492 o['default_configuration'] = 'Debug' if options.debug else 'Release'
494 host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
495 target_arch = options.dest_cpu or host_arch
496 o['variables']['host_arch'] = host_arch
497 o['variables']['target_arch'] = target_arch
499 if target_arch != host_arch and options.with_snapshot:
500 o['variables']['want_separate_host_toolset'] = 1
502 o['variables']['want_separate_host_toolset'] = 0
504 if target_arch == 'arm':
507 if flavor in ('solaris', 'mac', 'linux', 'freebsd'):
508 use_dtrace = not options.without_dtrace
509 # Don't enable by default on linux and freebsd
510 if flavor in ('linux', 'freebsd'):
511 use_dtrace = options.with_dtrace
513 if flavor == 'linux':
514 if options.systemtap_includes:
515 o['include_dirs'] += [options.systemtap_includes]
516 o['variables']['node_use_dtrace'] = b(use_dtrace)
517 o['variables']['uv_use_dtrace'] = b(use_dtrace)
518 o['variables']['uv_parent_path'] = '/deps/uv/'
519 elif options.with_dtrace:
521 'DTrace is currently only supported on SunOS, MacOS or Linux systems.')
523 o['variables']['node_use_dtrace'] = 'false'
525 # if we're on illumos based systems wrap the helper library into the
527 if flavor == 'solaris':
528 o['variables']['node_use_mdb'] = 'true'
530 o['variables']['node_use_mdb'] = 'false'
532 if options.no_ifaddrs:
533 o['defines'] += ['SUNOS_NO_IFADDRS']
535 # By default, enable ETW on Windows.
537 o['variables']['node_use_etw'] = b(not options.without_etw)
538 elif options.with_etw:
539 raise Exception('ETW is only supported on Windows.')
541 o['variables']['node_use_etw'] = 'false'
543 # By default, enable Performance counters on Windows.
545 o['variables']['node_use_perfctr'] = b(not options.without_perfctr)
546 elif options.with_perfctr:
547 raise Exception('Performance counter is only supported on Windows.')
549 o['variables']['node_use_perfctr'] = 'false'
552 o['variables']['node_tag'] = '-' + options.tag
554 o['variables']['node_tag'] = ''
556 if options.v8_options:
557 o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')
560 def configure_libz(o):
561 o['variables']['node_shared_zlib'] = b(options.shared_zlib)
563 # assume shared_zlib if one of these is set?
564 if options.shared_zlib_libpath:
565 o['libraries'] += ['-L%s' % options.shared_zlib_libpath]
566 if options.shared_zlib_libname:
567 o['libraries'] += ['-l%s' % options.shared_zlib_libname]
568 elif options.shared_zlib:
569 o['libraries'] += ['-lz']
570 if options.shared_zlib_includes:
571 o['include_dirs'] += [options.shared_zlib_includes]
574 def configure_http_parser(o):
575 o['variables']['node_shared_http_parser'] = b(options.shared_http_parser)
577 # assume shared http_parser if one of these is set?
578 if options.shared_http_parser_libpath:
579 o['libraries'] += ['-L%s' % options.shared_http_parser_libpath]
580 if options.shared_http_parser_libname:
581 o['libraries'] += ['-l%s' % options.shared_http_parser_libname]
582 elif options.shared_http_parser:
583 o['libraries'] += ['-lhttp_parser']
584 if options.shared_http_parser_includes:
585 o['include_dirs'] += [options.shared_http_parser_includes]
588 def configure_libuv(o):
589 o['variables']['node_shared_libuv'] = b(options.shared_libuv)
591 # assume shared libuv if one of these is set?
592 if options.shared_libuv_libpath:
593 o['libraries'] += ['-L%s' % options.shared_libuv_libpath]
595 o['variables']['uv_library'] = 'static_library'
597 if options.shared_libuv_libname:
598 o['libraries'] += ['-l%s' % options.shared_libuv_libname]
599 elif options.shared_libuv:
600 o['libraries'] += ['-luv']
601 if options.shared_libuv_includes:
602 o['include_dirs'] += [options.shared_libuv_includes]
606 o['variables']['node_shared_v8'] = b(options.shared_v8)
607 o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0
608 o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs.
609 o['variables']['v8_optimized_debug'] = 0 # Compile with -O0 in debug builds.
610 o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables.
611 o['variables']['v8_use_snapshot'] = b(options.with_snapshot)
613 # assume shared_v8 if one of these is set?
614 if options.shared_v8_libpath:
615 o['libraries'] += ['-L%s' % options.shared_v8_libpath]
616 if options.shared_v8_libname:
617 o['libraries'] += ['-l%s' % options.shared_v8_libname]
618 elif options.shared_v8:
619 o['libraries'] += ['-lv8']
620 if options.shared_v8_includes:
621 o['include_dirs'] += [options.shared_v8_includes]
624 def configure_openssl(o):
625 o['variables']['node_use_openssl'] = b(not options.without_ssl)
626 o['variables']['node_shared_openssl'] = b(options.shared_openssl)
627 o['variables']['openssl_no_asm'] = (
628 1 if options.openssl_no_asm else 0)
630 if options.without_ssl:
633 if options.shared_openssl:
634 (libs, cflags) = pkg_config('openssl') or ('-lssl -lcrypto', '')
636 if options.shared_openssl_libpath:
637 o['libraries'] += ['-L%s' % options.shared_openssl_libpath]
639 if options.shared_openssl_libname:
640 libnames = options.shared_openssl_libname.split(',')
641 o['libraries'] += ['-l%s' % s for s in libnames]
643 o['libraries'] += libs.split()
645 if options.shared_openssl_includes:
646 o['include_dirs'] += [options.shared_openssl_includes]
648 o['cflags'] += cflags.split()
651 def configure_fullystatic(o):
652 if options.fully_static:
653 o['libraries'] += ['-static']
655 print("Generation of static executable will not work on OSX "
656 "when using default compilation environment")
659 def configure_winsdk(o):
663 winsdk_dir = os.environ.get('WindowsSdkDir')
665 if winsdk_dir and os.path.isfile(winsdk_dir + '\\bin\\ctrpp.exe'):
666 print('Found ctrpp in WinSDK--will build generated files '
667 'into tools/msvs/genfiles.')
668 o['variables']['node_has_winsdk'] = 'true'
671 print('ctrpp not found in WinSDK path--using pre-gen files '
672 'from tools/msvs/genfiles.')
674 def write(filename, data):
675 filename = os.path.join(root_dir, filename)
676 print 'creating ', filename
677 f = open(filename, 'w+')
680 do_not_edit = '# Do not edit. Generated by the configure script.\n'
682 def glob_to_var(dir_base, dir_sub):
684 dir_all = os.path.join(dir_base, dir_sub)
685 files = os.walk(dir_all)
687 (path, dirs, files) = ent
689 if file.endswith('.cpp') or file.endswith('.c') or file.endswith('.h'):
690 list.append('%s/%s' % (dir_sub, file))
694 def configure_intl(o):
697 'url': 'http://download.icu-project.org/files/icu4c/54.1/icu4c-54_1-src.zip',
698 # from https://ssl.icu-project.org/files/icu4c/54.1/icu4c-src-54_1.md5:
699 'md5': '6b89d60e2f0e140898ae4d7f72323bca',
702 def icu_download(path):
703 # download ICU, if needed
707 local = url.split('/')[-1]
708 targetfile = os.path.join(root_dir, 'deps', local)
709 if not os.path.isfile(targetfile):
710 if nodedownload.candownload(auto_downloads, "icu"):
711 nodedownload.retrievefile(url, targetfile)
713 print ' Re-using existing %s' % targetfile
714 if os.path.isfile(targetfile):
715 sys.stdout.write(' Checking file integrity with MD5:\r')
716 gotmd5 = nodedownload.md5sum(targetfile)
717 print ' MD5: %s %s' % (gotmd5, targetfile)
721 print ' Expected: %s *MISMATCH*' % md5
722 print '\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile
727 icu_config_name = 'icu_config.gypi'
728 def write_config(data, name):
731 # write an empty file to start with
732 write(icu_config_name, do_not_edit +
733 pprint.pformat(icu_config, indent=2) + '\n')
735 # always set icu_small, node.gyp depends on it being defined.
736 o['variables']['icu_small'] = b(False)
738 with_intl = options.with_intl
739 with_icu_source = options.with_icu_source
740 have_icu_path = bool(options.with_icu_path)
741 if have_icu_path and with_intl:
742 print 'Error: Cannot specify both --with-icu-path and --with-intl'
745 # Chromium .gyp mode: --with-icu-path
746 o['variables']['v8_enable_i18n_support'] = 1
748 o['variables']['icu_gyp_path'] = options.with_icu_path
750 # --with-intl=<with_intl>
752 if with_intl is None:
753 with_intl = 'none' # The default mode of Intl
754 # sanity check localelist
755 if options.with_icu_locales and (with_intl != 'small-icu'):
756 print 'Error: --with-icu-locales only makes sense with --with-intl=small-icu'
758 if with_intl == 'none' or with_intl is None:
759 o['variables']['v8_enable_i18n_support'] = 0
761 elif with_intl == 'small-icu':
762 # small ICU (English only)
763 o['variables']['v8_enable_i18n_support'] = 1
764 o['variables']['icu_small'] = b(True)
765 with_icu_locales = options.with_icu_locales
766 if not with_icu_locales:
767 with_icu_locales = 'root,en'
768 locs = set(with_icu_locales.split(','))
769 locs.add('root') # must have root
770 o['variables']['icu_locales'] = string.join(locs,',')
771 elif with_intl == 'full-icu':
773 o['variables']['v8_enable_i18n_support'] = 1
774 elif with_intl == 'system-icu':
775 # ICU from pkg-config.
776 o['variables']['v8_enable_i18n_support'] = 1
777 pkgicu = pkg_config('icu-i18n')
779 print 'Error: could not load pkg-config data for "icu-i18n".'
780 print 'See above errors or the README.md.'
782 (libs, cflags) = pkgicu
783 o['libraries'] += libs.split()
784 o['cflags'] += cflags.split()
785 # use the "system" .gyp
786 o['variables']['icu_gyp_path'] = 'tools/icu/icu-system.gyp'
789 print 'Error: unknown value --with-intl=%s' % with_intl
791 # Note: non-ICU implementations could use other 'with_intl'
794 # this is just the 'deps' dir. Used for unpacking.
795 icu_parent_path = os.path.join(root_dir, 'deps')
797 # The full path to the ICU source directory.
798 icu_full_path = os.path.join(icu_parent_path, 'icu')
800 # icu-tmp is used to download and unpack the ICU tarball.
801 icu_tmp_path = os.path.join(icu_parent_path, 'icu-tmp')
803 # --with-icu-source processing
804 # first, check that they didn't pass --with-icu-source=deps/icu
805 if with_icu_source and os.path.abspath(icu_full_path) == os.path.abspath(with_icu_source):
806 print 'Ignoring redundant --with-icu-source=%s' % (with_icu_source)
807 with_icu_source = None
808 # if with_icu_source is still set, try to use it.
810 if os.path.isdir(icu_full_path):
811 print 'Deleting old ICU source: %s' % (icu_full_path)
812 shutil.rmtree(icu_full_path)
813 # now, what path was given?
814 if os.path.isdir(with_icu_source):
815 # it's a path. Copy it.
816 print '%s -> %s' % (with_icu_source, icu_full_path)
817 shutil.copytree(with_icu_source, icu_full_path)
819 # could be file or URL.
820 # Set up temporary area
821 if os.path.isdir(icu_tmp_path):
822 shutil.rmtree(icu_tmp_path)
823 os.mkdir(icu_tmp_path)
825 if os.path.isfile(with_icu_source):
826 # it's a file. Try to unpack it.
827 icu_tarball = with_icu_source
829 # Can we download it?
830 local = os.path.join(icu_tmp_path, with_icu_source.split('/')[-1]) # local part
831 icu_tarball = nodedownload.retrievefile(with_icu_source, local)
832 # continue with "icu_tarball"
833 nodedownload.unpack(icu_tarball, icu_tmp_path)
834 # Did it unpack correctly? Should contain 'icu'
835 tmp_icu = os.path.join(icu_tmp_path, 'icu')
836 if os.path.isdir(tmp_icu):
837 os.rename(tmp_icu, icu_full_path)
838 shutil.rmtree(icu_tmp_path)
840 print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
841 shutil.rmtree(icu_tmp_path)
844 # ICU mode. (icu-generic.gyp)
845 o['variables']['icu_gyp_path'] = 'tools/icu/icu-generic.gyp'
846 # ICU source dir relative to root
847 o['variables']['icu_path'] = icu_full_path
848 if not os.path.isdir(icu_full_path):
849 print '* ECMA-402 (Intl) support didn\'t find ICU in %s..' % (icu_full_path)
850 # can we download (or find) a zipfile?
851 localzip = icu_download(icu_full_path)
853 nodedownload.unpack(localzip, icu_parent_path)
854 if not os.path.isdir(icu_full_path):
855 print ' Cannot build Intl without ICU in %s.' % (icu_full_path)
856 print ' (Fix, or disable with "--with-intl=none" )'
859 print '* Using ICU in %s' % (icu_full_path)
860 # Now, what version of ICU is it? We just need the "major", such as 54.
861 # uvernum.h contains it as a #define.
862 uvernum_h = os.path.join(icu_full_path, 'source/common/unicode/uvernum.h')
863 if not os.path.isfile(uvernum_h):
864 print ' Error: could not load %s - is ICU installed?' % uvernum_h
867 matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
868 match_version = re.compile(matchVerExp)
869 for line in open(uvernum_h).readlines():
870 m = match_version.match(line)
872 icu_ver_major = m.group(1)
873 if not icu_ver_major:
874 print ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h
876 icu_endianness = sys.byteorder[0]; # TODO(srl295): EBCDIC should be 'e'
877 o['variables']['icu_ver_major'] = icu_ver_major
878 o['variables']['icu_endianness'] = icu_endianness
879 icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major, 'l')
880 icu_data_file = 'icudt%s%s.dat' % (icu_ver_major, icu_endianness)
881 # relative to configure
882 icu_data_path = os.path.join(icu_full_path,
886 icu_data_in = os.path.join('../../deps/icu/source/data/in', icu_data_file_l)
887 if not os.path.isfile(icu_data_path) and icu_endianness != 'l':
888 # use host endianness
889 icu_data_path = os.path.join(icu_full_path,
893 icu_data_in = os.path.join('icu/source/data/in',
895 # this is the input '.dat' file to use .. icudt*.dat
896 # may be little-endian if from a icu-project.org tarball
897 o['variables']['icu_data_in'] = icu_data_in
898 # this is the icudt*.dat file which node will be using (platform endianness)
899 o['variables']['icu_data_file'] = icu_data_file
900 if not os.path.isfile(icu_data_path):
901 print ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path
902 print ' See the README.md.'
903 # .. and we're not about to build it from .gyp!
905 # map from variable name to subdirs
907 'stubdata': 'stubdata',
911 'tools': 'tools/toolutil',
912 'genccode': 'tools/genccode',
913 'genrb': 'tools/genrb',
914 'icupkg': 'tools/icupkg',
916 # this creates a variable icu_src_XXX for each of the subdirs
917 # with a list of the src files to use
919 var = 'icu_src_%s' % i
920 path = '../../deps/icu/source/%s' % icu_src[i]
921 icu_config['variables'][var] = glob_to_var('tools/icu', path)
922 # write updated icu_config.gypi with a bunch of paths
923 write(icu_config_name, do_not_edit +
924 pprint.pformat(icu_config, indent=2) + '\n')
925 return # end of configure_intl
927 # Print a warning when the compiler is too old.
930 # determine the "flavor" (operating system) we're building for,
931 # leveraging gyp's GetFlavor function
933 if (options.dest_os):
934 flavor_params['flavor'] = options.dest_os
935 flavor = GetFlavor(flavor_params)
938 'variables': { 'python': sys.executable },
945 configure_node(output)
946 configure_libz(output)
947 configure_http_parser(output)
948 configure_libuv(output)
950 configure_openssl(output)
951 configure_winsdk(output)
952 configure_intl(output)
953 configure_fullystatic(output)
955 # variables should be a root level element,
956 # move everything else to target_defaults
957 variables = output['variables']
958 del output['variables']
960 'variables': variables,
961 'target_defaults': output
963 print textwrap.fill(str(output), 78)
965 write('config.gypi', do_not_edit +
966 pprint.pformat(output, indent=2) + '\n')
969 'BUILDTYPE': 'Debug' if options.debug else 'Release',
970 'USE_XCODE': str(int(options.use_xcode or 0)),
971 'PYTHON': sys.executable,
975 config['PREFIX'] = options.prefix
977 config = '\n'.join(map('='.join, config.iteritems())) + '\n'
980 '# Do not edit. Generated by the configure script.\n' + config)
982 gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel']
984 if options.use_xcode:
985 gyp_args += ['-f', 'xcode']
986 elif flavor == 'win' and sys.platform != 'msys':
987 gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto']
989 gyp_args += ['-f', 'make-' + flavor]
993 sys.exit(subprocess.call(gyp_args))