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('--with-sslv2',
258 help='enable SSL v2')
260 parser.add_option('--without-dtrace',
262 dest='without_dtrace',
263 help='build without DTrace')
265 parser.add_option('--without-etw',
268 help='build without ETW')
270 parser.add_option('--without-npm',
273 help='don\'t install the bundled npm package manager')
275 parser.add_option('--without-perfctr',
277 dest='without_perfctr',
278 help='build without performance counters')
280 parser.add_option('--without-snapshot',
282 dest='without_snapshot',
283 help='build without snapshotting V8 libraries. You might want to set'
284 ' this for cross-compiling. [Default: False]')
286 parser.add_option('--without-ssl',
289 help='build without SSL')
291 parser.add_option('--xcode',
294 help='generate build files for use with xcode')
296 (options, args) = parser.parse_args()
298 # set up auto-download list
299 auto_downloads = nodedownload.parse(options.download_list)
302 """Returns the string 'true' if value is truthy, 'false' otherwise."""
310 cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
311 libs = cmd.readline().strip()
313 if (ret): return None
315 cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
316 cflags = cmd.readline().strip()
318 if (ret): return None
320 return (libs, cflags)
324 """Checks predefined macros using the CC command."""
327 p = subprocess.Popen(shlex.split(CC) + ['-dM', '-E', '-'],
328 stdin=subprocess.PIPE,
329 stdout=subprocess.PIPE,
330 stderr=subprocess.PIPE)
332 print '''Node.js configure error: No acceptable C compiler found!
334 Please make sure you have a C compiler installed on your system and/or
335 consider adjusting the CC environment variable if you installed
336 it in a non-standard prefix.
341 out = p.communicate()[0]
343 out = str(out).split('\n')
347 lst = shlex.split(line)
356 """Check for ARMv7 instructions"""
357 cc_macros_cache = cc_macros()
358 return ('__ARM_ARCH_7__' in cc_macros_cache or
359 '__ARM_ARCH_7A__' in cc_macros_cache or
360 '__ARM_ARCH_7R__' in cc_macros_cache or
361 '__ARM_ARCH_7M__' in cc_macros_cache)
365 """Check for ARMv6 instructions"""
366 cc_macros_cache = cc_macros()
367 return ('__ARM_ARCH_6__' in cc_macros_cache or
368 '__ARM_ARCH_6M__' in cc_macros_cache)
372 """Check for ARM NEON support"""
373 return '__ARM_NEON__' in cc_macros()
376 def is_arm_hard_float_abi():
377 """Check for hardfloat or softfloat eabi on ARM"""
378 # GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
379 # the Floating Point ABI used (PCS stands for Procedure Call Standard).
380 # We use these as well as a couple of other defines to statically determine
383 return '__ARM_PCS_VFP' in cc_macros()
387 """Host architecture check using the CC command."""
392 '__x86_64__' : 'x64',
398 rtn = 'ia32' # default
401 if i in k and k[i] != '0':
409 """Host architecture check using environ vars (better way to do this?)"""
411 observed_arch = os.environ.get('PROCESSOR_ARCHITECTURE', 'x86')
412 arch = os.environ.get('PROCESSOR_ARCHITEW6432', observed_arch)
421 return matchup.get(arch, 'ia32')
424 def configure_arm(o):
425 if options.arm_float_abi:
426 arm_float_abi = options.arm_float_abi
427 elif is_arm_hard_float_abi():
428 arm_float_abi = 'hard'
430 arm_float_abi = 'default'
433 o['variables']['arm_version'] = '7'
434 elif is_arch_armv6():
435 o['variables']['arm_version'] = '6'
437 o['variables']['arm_version'] = 'default'
439 o['variables']['arm_fpu'] = 'vfpv3' # V8 3.18 no longer supports VFP2.
440 o['variables']['arm_neon'] = int(is_arm_neon())
441 o['variables']['arm_thumb'] = 0 # -marm
442 o['variables']['arm_float_abi'] = arm_float_abi
445 def configure_node(o):
446 if options.dest_os == 'android':
447 o['variables']['OS'] = 'android'
448 o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '')
449 o['variables']['node_install_npm'] = b(not options.without_npm)
450 o['default_configuration'] = 'Debug' if options.debug else 'Release'
452 host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
453 target_arch = options.dest_cpu or host_arch
454 o['variables']['host_arch'] = host_arch
455 o['variables']['target_arch'] = target_arch
457 if target_arch != host_arch and not options.without_snapshot:
458 o['variables']['want_separate_host_toolset'] = 1
460 o['variables']['want_separate_host_toolset'] = 0
462 if target_arch == 'arm':
465 if flavor in ('solaris', 'mac', 'linux', 'freebsd'):
466 use_dtrace = not options.without_dtrace
467 # Don't enable by default on linux and freebsd
468 if flavor in ('linux', 'freebsd'):
469 use_dtrace = options.with_dtrace
471 if flavor == 'linux':
472 if options.systemtap_includes:
473 o['include_dirs'] += [options.systemtap_includes]
474 o['variables']['node_use_dtrace'] = b(use_dtrace)
475 o['variables']['uv_use_dtrace'] = b(use_dtrace)
476 o['variables']['uv_parent_path'] = '/deps/uv/'
477 elif options.with_dtrace:
479 'DTrace is currently only supported on SunOS, MacOS or Linux systems.')
481 o['variables']['node_use_dtrace'] = 'false'
483 # if we're on illumos based systems wrap the helper library into the
485 if flavor == 'solaris':
486 o['variables']['node_use_mdb'] = 'true'
488 o['variables']['node_use_mdb'] = 'false'
490 if options.no_ifaddrs:
491 o['defines'] += ['SUNOS_NO_IFADDRS']
493 # By default, enable ETW on Windows.
495 o['variables']['node_use_etw'] = b(not options.without_etw)
496 elif options.with_etw:
497 raise Exception('ETW is only supported on Windows.')
499 o['variables']['node_use_etw'] = 'false'
501 # By default, enable Performance counters on Windows.
503 o['variables']['node_use_perfctr'] = b(not options.without_perfctr)
504 elif options.with_perfctr:
505 raise Exception('Performance counter is only supported on Windows.')
507 o['variables']['node_use_perfctr'] = 'false'
510 o['variables']['node_tag'] = '-' + options.tag
512 o['variables']['node_tag'] = ''
514 if options.v8_options:
515 o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')
518 def configure_libz(o):
519 o['variables']['node_shared_zlib'] = b(options.shared_zlib)
521 # assume shared_zlib if one of these is set?
522 if options.shared_zlib_libpath:
523 o['libraries'] += ['-L%s' % options.shared_zlib_libpath]
524 if options.shared_zlib_libname:
525 o['libraries'] += ['-l%s' % options.shared_zlib_libname]
526 elif options.shared_zlib:
527 o['libraries'] += ['-lz']
528 if options.shared_zlib_includes:
529 o['include_dirs'] += [options.shared_zlib_includes]
532 def configure_http_parser(o):
533 o['variables']['node_shared_http_parser'] = b(options.shared_http_parser)
535 # assume shared http_parser if one of these is set?
536 if options.shared_http_parser_libpath:
537 o['libraries'] += ['-L%s' % options.shared_http_parser_libpath]
538 if options.shared_http_parser_libname:
539 o['libraries'] += ['-l%s' % options.shared_http_parser_libname]
540 elif options.shared_http_parser:
541 o['libraries'] += ['-lhttp_parser']
542 if options.shared_http_parser_includes:
543 o['include_dirs'] += [options.shared_http_parser_includes]
546 def configure_libuv(o):
547 o['variables']['node_shared_libuv'] = b(options.shared_libuv)
549 # assume shared libuv if one of these is set?
550 if options.shared_libuv_libpath:
551 o['libraries'] += ['-L%s' % options.shared_libuv_libpath]
553 o['variables']['uv_library'] = 'static_library'
555 if options.shared_libuv_libname:
556 o['libraries'] += ['-l%s' % options.shared_libuv_libname]
557 elif options.shared_libuv:
558 o['libraries'] += ['-luv']
559 if options.shared_libuv_includes:
560 o['include_dirs'] += [options.shared_libuv_includes]
564 o['variables']['node_shared_v8'] = b(options.shared_v8)
565 o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0
566 o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs.
567 o['variables']['v8_optimized_debug'] = 0 # Compile with -O0 in debug builds.
568 o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables.
569 o['variables']['v8_use_snapshot'] = b(not options.without_snapshot)
571 # assume shared_v8 if one of these is set?
572 if options.shared_v8_libpath:
573 o['libraries'] += ['-L%s' % options.shared_v8_libpath]
574 if options.shared_v8_libname:
575 o['libraries'] += ['-l%s' % options.shared_v8_libname]
576 elif options.shared_v8:
577 o['libraries'] += ['-lv8']
578 if options.shared_v8_includes:
579 o['include_dirs'] += [options.shared_v8_includes]
582 def configure_openssl(o):
583 o['variables']['node_use_openssl'] = b(not options.without_ssl)
584 o['variables']['node_shared_openssl'] = b(options.shared_openssl)
585 o['variables']['openssl_no_asm'] = (
586 1 if options.openssl_no_asm else 0)
588 if options.without_ssl:
591 # OpenSSL uses `#ifndef OPENSSL_NO_SSL2` checks so only define the
592 # macro when we want to _disable_ SSL2.
593 if not options.with_sslv2:
594 o['defines'] += ['OPENSSL_NO_SSL2=1']
596 if options.shared_openssl:
597 (libs, cflags) = pkg_config('openssl') or ('-lssl -lcrypto', '')
599 if options.shared_openssl_libpath:
600 o['libraries'] += ['-L%s' % options.shared_openssl_libpath]
602 if options.shared_openssl_libname:
603 libnames = options.shared_openssl_libname.split(',')
604 o['libraries'] += ['-l%s' % s for s in libnames]
606 o['libraries'] += libs.split()
608 if options.shared_openssl_includes:
609 o['include_dirs'] += [options.shared_openssl_includes]
611 o['cflags'] += cflags.split()
614 def configure_fullystatic(o):
615 if options.fully_static:
616 o['libraries'] += ['-static']
618 print("Generation of static executable will not work on OSX "
619 "when using default compilation environment")
622 def configure_winsdk(o):
626 winsdk_dir = os.environ.get('WindowsSdkDir')
628 if winsdk_dir and os.path.isfile(winsdk_dir + '\\bin\\ctrpp.exe'):
629 print('Found ctrpp in WinSDK--will build generated files '
630 'into tools/msvs/genfiles.')
631 o['variables']['node_has_winsdk'] = 'true'
634 print('ctrpp not found in WinSDK path--using pre-gen files '
635 'from tools/msvs/genfiles.')
637 def write(filename, data):
638 filename = os.path.join(root_dir, filename)
639 print 'creating ', filename
640 f = open(filename, 'w+')
643 do_not_edit = '# Do not edit. Generated by the configure script.\n'
645 def glob_to_var(dir_base, dir_sub):
647 dir_all = os.path.join(dir_base, dir_sub)
648 files = os.walk(dir_all)
650 (path, dirs, files) = ent
652 if file.endswith('.cpp') or file.endswith('.c') or file.endswith('.h'):
653 list.append('%s/%s' % (dir_sub, file))
657 def configure_intl(o):
660 'url': 'http://download.icu-project.org/files/icu4c/54.1/icu4c-54_1-src.zip',
661 # from https://ssl.icu-project.org/files/icu4c/54.1/icu4c-src-54_1.md5:
662 'md5': '6b89d60e2f0e140898ae4d7f72323bca',
665 def icu_download(path):
666 # download ICU, if needed
670 local = url.split('/')[-1]
671 targetfile = os.path.join(root_dir, 'deps', local)
672 if not os.path.isfile(targetfile):
673 if nodedownload.candownload(auto_downloads, "icu"):
674 nodedownload.retrievefile(url, targetfile)
676 print ' Re-using existing %s' % targetfile
677 if os.path.isfile(targetfile):
678 sys.stdout.write(' Checking file integrity with MD5:\r')
679 gotmd5 = nodedownload.md5sum(targetfile)
680 print ' MD5: %s %s' % (gotmd5, targetfile)
684 print ' Expected: %s *MISMATCH*' % md5
685 print '\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile
690 icu_config_name = 'icu_config.gypi'
691 def write_config(data, name):
694 # write an empty file to start with
695 write(icu_config_name, do_not_edit +
696 pprint.pformat(icu_config, indent=2) + '\n')
698 # always set icu_small, node.gyp depends on it being defined.
699 o['variables']['icu_small'] = b(False)
701 with_intl = options.with_intl
702 with_icu_source = options.with_icu_source
703 have_icu_path = bool(options.with_icu_path)
704 if have_icu_path and with_intl:
705 print 'Error: Cannot specify both --with-icu-path and --with-intl'
708 # Chromium .gyp mode: --with-icu-path
709 o['variables']['v8_enable_i18n_support'] = 1
711 o['variables']['icu_gyp_path'] = options.with_icu_path
713 # --with-intl=<with_intl>
715 if with_intl is None:
716 with_intl = 'none' # The default mode of Intl
717 # sanity check localelist
718 if options.with_icu_locales and (with_intl != 'small-icu'):
719 print 'Error: --with-icu-locales only makes sense with --with-intl=small-icu'
721 if with_intl == 'none' or with_intl is None:
722 o['variables']['v8_enable_i18n_support'] = 0
724 elif with_intl == 'small-icu':
725 # small ICU (English only)
726 o['variables']['v8_enable_i18n_support'] = 1
727 o['variables']['icu_small'] = b(True)
728 with_icu_locales = options.with_icu_locales
729 if not with_icu_locales:
730 with_icu_locales = 'root,en'
731 locs = set(with_icu_locales.split(','))
732 locs.add('root') # must have root
733 o['variables']['icu_locales'] = string.join(locs,',')
734 elif with_intl == 'full-icu':
736 o['variables']['v8_enable_i18n_support'] = 1
737 elif with_intl == 'system-icu':
738 # ICU from pkg-config.
739 o['variables']['v8_enable_i18n_support'] = 1
740 pkgicu = pkg_config('icu-i18n')
742 print 'Error: could not load pkg-config data for "icu-i18n".'
743 print 'See above errors or the README.md.'
745 (libs, cflags) = pkgicu
746 o['libraries'] += libs.split()
747 o['cflags'] += cflags.split()
748 # use the "system" .gyp
749 o['variables']['icu_gyp_path'] = 'tools/icu/icu-system.gyp'
752 print 'Error: unknown value --with-intl=%s' % with_intl
754 # Note: non-ICU implementations could use other 'with_intl'
757 # this is just the 'deps' dir. Used for unpacking.
758 icu_parent_path = os.path.join(root_dir, 'deps')
760 # The full path to the ICU source directory.
761 icu_full_path = os.path.join(icu_parent_path, 'icu')
763 # icu-tmp is used to download and unpack the ICU tarball.
764 icu_tmp_path = os.path.join(icu_parent_path, 'icu-tmp')
766 # --with-icu-source processing
767 # first, check that they didn't pass --with-icu-source=deps/icu
768 if with_icu_source and os.path.abspath(icu_full_path) == os.path.abspath(with_icu_source):
769 print 'Ignoring redundant --with-icu-source=%s' % (with_icu_source)
770 with_icu_source = None
771 # if with_icu_source is still set, try to use it.
773 if os.path.isdir(icu_full_path):
774 print 'Deleting old ICU source: %s' % (icu_full_path)
775 shutil.rmtree(icu_full_path)
776 # now, what path was given?
777 if os.path.isdir(with_icu_source):
778 # it's a path. Copy it.
779 print '%s -> %s' % (with_icu_source, icu_full_path)
780 shutil.copytree(with_icu_source, icu_full_path)
782 # could be file or URL.
783 # Set up temporary area
784 if os.path.isdir(icu_tmp_path):
785 shutil.rmtree(icu_tmp_path)
786 os.mkdir(icu_tmp_path)
788 if os.path.isfile(with_icu_source):
789 # it's a file. Try to unpack it.
790 icu_tarball = with_icu_source
792 # Can we download it?
793 local = os.path.join(icu_tmp_path, with_icu_source.split('/')[-1]) # local part
794 icu_tarball = nodedownload.retrievefile(with_icu_source, local)
795 # continue with "icu_tarball"
796 nodedownload.unpack(icu_tarball, icu_tmp_path)
797 # Did it unpack correctly? Should contain 'icu'
798 tmp_icu = os.path.join(icu_tmp_path, 'icu')
799 if os.path.isdir(tmp_icu):
800 os.rename(tmp_icu, icu_full_path)
801 shutil.rmtree(icu_tmp_path)
803 print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
804 shutil.rmtree(icu_tmp_path)
807 # ICU mode. (icu-generic.gyp)
808 byteorder = sys.byteorder
809 o['variables']['icu_gyp_path'] = 'tools/icu/icu-generic.gyp'
810 # ICU source dir relative to root
811 o['variables']['icu_path'] = icu_full_path
812 if not os.path.isdir(icu_full_path):
813 print '* ECMA-402 (Intl) support didn\'t find ICU in %s..' % (icu_full_path)
814 # can we download (or find) a zipfile?
815 localzip = icu_download(icu_full_path)
817 nodedownload.unpack(localzip, icu_parent_path)
818 if not os.path.isdir(icu_full_path):
819 print ' Cannot build Intl without ICU in %s.' % (icu_full_path)
820 print ' (Fix, or disable with "--with-intl=none" )'
823 print '* Using ICU in %s' % (icu_full_path)
824 # Now, what version of ICU is it? We just need the "major", such as 54.
825 # uvernum.h contains it as a #define.
826 uvernum_h = os.path.join(icu_full_path, 'source/common/unicode/uvernum.h')
827 if not os.path.isfile(uvernum_h):
828 print ' Error: could not load %s - is ICU installed?' % uvernum_h
831 matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
832 match_version = re.compile(matchVerExp)
833 for line in open(uvernum_h).readlines():
834 m = match_version.match(line)
836 icu_ver_major = m.group(1)
837 if not icu_ver_major:
838 print ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h
840 icu_endianness = sys.byteorder[0]; # TODO(srl295): EBCDIC should be 'e'
841 o['variables']['icu_ver_major'] = icu_ver_major
842 o['variables']['icu_endianness'] = icu_endianness
843 icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major, 'l')
844 icu_data_file = 'icudt%s%s.dat' % (icu_ver_major, icu_endianness)
845 # relative to configure
846 icu_data_path = os.path.join(icu_full_path,
850 icu_data_in = os.path.join('../../deps/icu/source/data/in', icu_data_file_l)
851 if not os.path.isfile(icu_data_path) and icu_endianness != 'l':
852 # use host endianness
853 icu_data_path = os.path.join(icu_full_path,
857 icu_data_in = os.path.join('icu/source/data/in',
859 # this is the input '.dat' file to use .. icudt*.dat
860 # may be little-endian if from a icu-project.org tarball
861 o['variables']['icu_data_in'] = icu_data_in
862 # this is the icudt*.dat file which node will be using (platform endianness)
863 o['variables']['icu_data_file'] = icu_data_file
864 if not os.path.isfile(icu_data_path):
865 print ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path
866 print ' See the README.md.'
867 # .. and we're not about to build it from .gyp!
869 # map from variable name to subdirs
871 'stubdata': 'stubdata',
875 'tools': 'tools/toolutil',
876 'genccode': 'tools/genccode',
877 'genrb': 'tools/genrb',
878 'icupkg': 'tools/icupkg',
880 # this creates a variable icu_src_XXX for each of the subdirs
881 # with a list of the src files to use
883 var = 'icu_src_%s' % i
884 path = '../../deps/icu/source/%s' % icu_src[i]
885 icu_config['variables'][var] = glob_to_var('tools/icu', path)
886 # write updated icu_config.gypi with a bunch of paths
887 write(icu_config_name, do_not_edit +
888 pprint.pformat(icu_config, indent=2) + '\n')
889 return # end of configure_intl
891 # determine the "flavor" (operating system) we're building for,
892 # leveraging gyp's GetFlavor function
894 if (options.dest_os):
895 flavor_params['flavor'] = options.dest_os
896 flavor = GetFlavor(flavor_params)
899 'variables': { 'python': sys.executable },
906 configure_node(output)
907 configure_libz(output)
908 configure_http_parser(output)
909 configure_libuv(output)
911 configure_openssl(output)
912 configure_winsdk(output)
913 configure_intl(output)
914 configure_fullystatic(output)
916 # variables should be a root level element,
917 # move everything else to target_defaults
918 variables = output['variables']
919 del output['variables']
921 'variables': variables,
922 'target_defaults': output
924 pprint.pprint(output, indent=2)
926 write('config.gypi', do_not_edit +
927 pprint.pformat(output, indent=2) + '\n')
930 'BUILDTYPE': 'Debug' if options.debug else 'Release',
931 'USE_NINJA': str(int(options.use_ninja or 0)),
932 'USE_XCODE': str(int(options.use_xcode or 0)),
933 'PYTHON': sys.executable,
937 config['PREFIX'] = options.prefix
939 config = '\n'.join(map('='.join, config.iteritems())) + '\n'
942 '# Do not edit. Generated by the configure script.\n' + config)
944 gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel']
946 if options.use_ninja:
947 gyp_args += ['-f', 'ninja-' + flavor]
948 elif options.use_xcode:
949 gyp_args += ['-f', 'xcode']
950 elif flavor == 'win' and sys.platform != 'msys':
951 gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto']
953 gyp_args += ['-f', 'make-' + flavor]
957 sys.exit(subprocess.call(gyp_args))