From 12cc5d95f143bc45f5a6a832a0335e9a8f9d152e Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Tue, 12 Jan 2016 11:36:24 -0800 Subject: [PATCH] build: build with chakrashim/chakracore Enable building Node.js with chakracore engine. Below are details: * Configure to build Node.js with "v8" (default) or "chakracore" JS engine with optional vcbuild.bat switch. * Support building on Windows on ARM. * chakrashim uses js2c with a namespace. * Configure msvs_windows_target_platform_version to use the right Windows SDK. * Configure msvs_use_library_dependency_inputs to export symbols correctly (otherwise functions not used by node.exe but might be needed by native addon modules could be optimized away by linker). * Configure WindowsSDKDesktopARMSupport for ARM. * Enables building native addon modules for Node.js with multiple node-engines. --- common.gypi | 45 +++++- configure | 16 ++ deps/chakrashim/chakracore.gyp | 77 ++++++++++ deps/chakrashim/chakrashim.gyp | 141 ++++++++++++++++++ deps/npm/node_modules/node-gyp/addon.gypi | 8 +- .../node-gyp/gyp/pylib/gyp/generator/msvs.py | 37 +++++ deps/npm/node_modules/node-gyp/lib/build.js | 4 +- .../node_modules/node-gyp/lib/configure.js | 1 + node.gyp | 43 +++++- tools/gyp/pylib/gyp/generator/msvs.py | 37 +++++ tools/js2c.py | 30 ++-- tools/test.py | 8 +- vcbuild.bat | 22 ++- 13 files changed, 444 insertions(+), 25 deletions(-) create mode 100644 deps/chakrashim/chakracore.gyp create mode 100644 deps/chakrashim/chakrashim.gyp diff --git a/common.gypi b/common.gypi index 5b8b2c09d6b..4f1d8d46976 100644 --- a/common.gypi +++ b/common.gypi @@ -10,6 +10,8 @@ 'component%': 'static_library', # NB. these names match with what V8 expects 'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way 'python%': 'python', + 'node_engine%': 'v8', + 'msvs_windows_target_platform_version': 'v10.0', # used for node_engine==chakracore 'node_tag%': '', 'uv_library%': 'static_library', @@ -51,6 +53,37 @@ ], }, + 'conditions': [ + ['node_engine=="v8"', { + 'target_defaults': { + 'defines': [ + 'NODE_ENGINE="<(node_engine)"', + 'NODE_ENGINE_V8', + ], + }, + 'variables': { + 'node_engine_include_dir%': 'deps/v8/include' + }, + }], + ['node_engine=="chakracore"', { + 'target_defaults': { + 'defines': [ + 'NODE_ENGINE="<(node_engine)"', + 'NODE_ENGINE_CHAKRACORE', + ], + 'conditions': [ + ['target_arch=="arm"', { + 'msvs_windows_target_platform_version': '<(msvs_windows_target_platform_version)', + }], + ], + }, + 'variables': { + 'node_engine_include_dir%': 'deps/chakrashim/include', + 'node_engine_libs': '-lchakracore.lib', + }, + }], + ], + 'target_defaults': { 'default_configuration': 'Release', 'configurations': { @@ -64,6 +97,9 @@ ['target_arch=="x64"', { 'msvs_configuration_platform': 'x64', }], + ['target_arch=="arm"', { + 'msvs_configuration_platform': 'ARM', + }], ['OS=="aix"', { 'cflags': [ '-gxcoff' ], 'ldflags': [ '-Wl,-bbigtoc' ], @@ -94,6 +130,9 @@ ['target_arch=="x64"', { 'msvs_configuration_platform': 'x64', }], + ['target_arch=="arm"', { + 'msvs_configuration_platform': 'ARM', + }], ['OS=="solaris"', { # pull in V8's postmortem metadata 'ldflags': [ '-Wl,-z,allextract' ] @@ -251,9 +290,9 @@ 'ldflags': [ '-m32' ], }], [ 'target_arch=="ppc64" and OS!="aix"', { - 'cflags': [ '-m64', '-mminimal-toc' ], - 'ldflags': [ '-m64' ], - }], + 'cflags': [ '-m64', '-mminimal-toc' ], + 'ldflags': [ '-m64' ], + }], [ 'OS=="solaris"', { 'cflags': [ '-pthreads' ], 'ldflags': [ '-pthreads' ], diff --git a/configure b/configure index 71dc467dce4..75cd7e696b0 100755 --- a/configure +++ b/configure @@ -375,6 +375,12 @@ parser.add_option('--enable-static', dest='enable_static', help='build as static library') +parser.add_option('--engine', + action='store', + dest='engine', + help='Use specified JS engine (default is V8)') + + (options, args) = parser.parse_args() # Expand ~ in the install prefix now, it gets written to multiple files. @@ -525,6 +531,11 @@ def check_compiler(o): def cc_macros(cc=None): """Checks predefined macros using the C compiler command.""" + if os.name == 'nt': + k = {} + k['__ARM_ARCH_7__'] = True + k['__ARM_NEON__'] = True + return k try: p = subprocess.Popen(shlex.split(cc or CC) + ['-dM', '-E', '-'], stdin=subprocess.PIPE, @@ -1101,6 +1112,10 @@ def configure_intl(o): pprint.pformat(icu_config, indent=2) + '\n') return # end of configure_intl +def configure_engine(o): + engine = options.engine or 'v8' + o['variables']['node_engine'] = engine.lower() + output = { 'variables': { 'python': sys.executable }, 'include_dirs': [], @@ -1128,6 +1143,7 @@ configure_openssl(output) configure_winsdk(output) configure_intl(output) configure_static(output) +configure_engine(output) # variables should be a root level element, # move everything else to target_defaults diff --git a/deps/chakrashim/chakracore.gyp b/deps/chakrashim/chakracore.gyp new file mode 100644 index 00000000000..3658f90f92c --- /dev/null +++ b/deps/chakrashim/chakracore.gyp @@ -0,0 +1,77 @@ +{ + 'variables': { + 'target_arch%': 'ia32', + 'library%': 'static_library', # build chakracore as static library or dll + 'component%': 'static_library', # link crt statically or dynamically + 'chakra_dir%': 'core', + 'msvs_windows_target_platform_version_prop': '', + + 'conditions': [ + ['target_arch=="ia32"', { 'Platform': 'x86' }], + ['target_arch=="x64"', { 'Platform': 'x64' }], + ['target_arch=="arm"', { + 'Platform': 'arm', + 'msvs_windows_target_platform_version_prop': + '/p:WindowsTargetPlatformVersion=$(WindowsTargetPlatformVersion)', + }], + ], + }, + + 'targets': [ + { + 'target_name': 'chakracore', + 'toolsets': ['host'], + 'type': 'none', + + 'variables': { + 'chakracore_sln': '<(chakra_dir)/build/Chakra.Core.sln', + 'chakracore_header': [ + '<(chakra_dir)/lib/jsrt/chakracore.h', + '<(chakra_dir)/lib/jsrt/chakracommon.h' + ], + 'chakracore_binaries': [ + '<(chakra_dir)/build/vcbuild/bin/<(Platform)_$(ConfigurationName)/chakracore.dll', + '<(chakra_dir)/build/vcbuild/bin/<(Platform)_$(ConfigurationName)/chakracore.pdb', + '<(chakra_dir)/build/vcbuild/bin/<(Platform)_$(ConfigurationName)/chakracore.lib', + ], + }, + + 'actions': [ + { + 'action_name': 'build_chakracore', + 'inputs': [ + '<(chakracore_sln)' + ], + 'outputs': [ + '<@(chakracore_binaries)', + ], + 'action': [ + 'msbuild', + '/p:Platform=<(Platform)', + '/p:Configuration=$(ConfigurationName)', + '/p:RuntimeLib=<(component)', + '<(msvs_windows_target_platform_version_prop)', + '/m', + '<@(_inputs)', + ], + }, + ], + + 'copies': [ + { + 'destination': 'include', + 'files': [ '<@(chakracore_header)' ], + }, + { + 'destination': '<(PRODUCT_DIR)', + 'files': [ '<@(chakracore_binaries)' ], + }, + ], + + 'direct_dependent_settings': { + 'library_dirs': [ '<(PRODUCT_DIR)' ], + }, + + }, # end chakracore + ], +} diff --git a/deps/chakrashim/chakrashim.gyp b/deps/chakrashim/chakrashim.gyp new file mode 100644 index 00000000000..129f0ff96c5 --- /dev/null +++ b/deps/chakrashim/chakrashim.gyp @@ -0,0 +1,141 @@ +{ + 'variables': { + 'library_files': [ + 'lib/chakra_shim.js', + ], + }, + + 'targets': [ + { + 'target_name': 'chakrashim', + 'type': '<(library)', + + 'dependencies': [ + 'chakra_js2c#host', + ], + + 'include_dirs': [ + 'include', + '<(SHARED_INTERMEDIATE_DIR)' + ], + 'defines': [ + 'BUILDING_CHAKRASHIM=1', + ], + 'conditions': [ + [ 'target_arch=="ia32"', { 'defines': [ '__i386__=1' ] } ], + [ 'target_arch=="x64"', { 'defines': [ '__x86_64__=1' ] } ], + [ 'target_arch=="arm"', { 'defines': [ '__arm__=1' ] } ], + ['node_engine=="chakracore"', { + 'dependencies': [ + 'chakracore.gyp:chakracore#host', + ], + 'export_dependent_settings': [ + 'chakracore.gyp:chakracore#host', + ], + }], + ], + 'msvs_use_library_dependency_inputs': 1, + + 'direct_dependent_settings': { + 'include_dirs': [ + 'include', + ], + 'defines': [ + 'BUILDING_CHAKRASHIM=1', + ], + 'libraries': [ + '-lole32.lib', + '-lversion.lib', + '<@(node_engine_libs)', + ], + 'conditions': [ + [ 'target_arch=="arm"', { + 'defines': [ '__arm__=1' ] + }], + ], + }, + + 'sources': [ + 'include/libplatform/libplatform.h', + 'include/v8.h', + 'include/v8config.h', + 'include/v8-debug.h', + 'include/v8-platform.h', + 'include/v8-profiler.h', + 'include/v8-version.h', + 'src/jsrtcachedpropertyidref.inc', + 'src/jsrtcontextcachedobj.inc', + 'src/jsrtcontextshim.cc', + 'src/jsrtcontextshim.h', + 'src/jsrtisolateshim.cc', + 'src/jsrtisolateshim.h', + 'src/jsrtpromise.cc', + 'src/jsrtproxyutils.cc', + 'src/jsrtproxyutils.h', + 'src/jsrtstringutils.cc', + 'src/jsrtstringutils.h', + 'src/jsrtutils.cc', + 'src/jsrtutils.h', + 'src/v8array.cc', + 'src/v8arraybuffer.cc', + 'src/v8boolean.cc', + 'src/v8booleanobject.cc', + 'src/v8chakra.h', + 'src/v8context.cc', + 'src/v8date.cc', + 'src/v8debug.cc', + 'src/v8exception.cc', + 'src/v8external.cc', + 'src/v8function.cc', + 'src/v8functiontemplate.cc', + 'src/v8global.cc', + 'src/v8handlescope.cc', + 'src/v8int32.cc', + 'src/v8integer.cc', + 'src/v8isolate.cc', + 'src/v8message.cc', + 'src/v8number.cc', + 'src/v8numberobject.cc', + 'src/v8object.cc', + 'src/v8objecttemplate.cc', + 'src/v8persistent.cc', + 'src/v8script.cc', + 'src/v8signature.cc', + 'src/v8stacktrace.cc', + 'src/v8string.cc', + 'src/v8stringobject.cc', + 'src/v8template.cc', + 'src/v8trycatch.cc', + 'src/v8typedarray.cc', + 'src/v8uint32.cc', + 'src/v8v8.cc', + 'src/v8value.cc', + ], + }, # end chakrashim + + { + 'target_name': 'chakra_js2c', + 'type': 'none', + 'toolsets': ['host'], + 'msvs_disabled_warnings': [4091], + 'actions': [ + { + 'action_name': 'chakra_js2c', + 'inputs': [ + '<@(library_files)' + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/chakra_natives.h', + ], + 'action': [ + '<(python)', + './../../tools/js2c.py', + '--namespace=jsrt', + '<@(_outputs)', + '<@(_inputs)', + ], + }, + ], + }, # end chakra_js2c + ], +} diff --git a/deps/npm/node_modules/node-gyp/addon.gypi b/deps/npm/node_modules/node-gyp/addon.gypi index 510b00c713f..3428fd7abe7 100644 --- a/deps/npm/node_modules/node-gyp/addon.gypi +++ b/deps/npm/node_modules/node-gyp/addon.gypi @@ -8,7 +8,7 @@ '<(node_root_dir)/include/node', '<(node_root_dir)/src', '<(node_root_dir)/deps/uv/include', - '<(node_root_dir)/deps/v8/include' + '<(node_root_dir)/<(node_engine_include_dir)' ], 'defines': [ 'NODE_GYP_MODULE_NAME=>(_target_name)' @@ -66,6 +66,12 @@ }, }], [ 'OS=="win"', { + 'conditions': [ + ['node_engine=="chakracore"', { + 'library_dirs': [ '<(node_root_dir)/$(ConfigurationName)' ], + 'libraries': [ '<@(node_engine_libs)' ], + }], + ], 'libraries': [ '-lkernel32.lib', '-luser32.lib', diff --git a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py index 8e6bd7ba0a0..c0625889a21 100644 --- a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +++ b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py @@ -282,6 +282,22 @@ def _ConfigFullName(config_name, config_data): return '%s|%s' % (_ConfigBaseName(config_name, platform_name), platform_name) +def _ConfigWindowsTargetPlatformVersion(config_data): + ver = config_data.get('msvs_windows_target_platform_version') + if not ver or re.match('^\d+', ver): + return ver + for key in [r'HKLM\Software\Microsoft\Microsoft SDKs\Windows\%s', + r'HKLM\Software\Wow6432Node\Microsoft\Microsoft SDKs\Windows\%s']: + sdkdir = MSVSVersion._RegistryGetValue(key % ver, 'InstallationFolder') + if not sdkdir: + continue + version = MSVSVersion._RegistryGetValue(key % ver, 'ProductVersion') or '' + # find a matching entry in sdkdir\include + names = sorted([x for x in os.listdir(r'%s\include' % sdkdir) \ + if x.startswith(version)], reverse = True) + return names[0] + + def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, quote_cmd, do_setup_env): @@ -335,6 +351,8 @@ def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, command = ['type'] else: command = [cmd[0].replace('/', '\\')] + if quote_cmd: + command = ['"%s"' % i for i in command] # Add call before command to ensure that commands can be tied together one # after the other without aborting in Incredibuild, since IB makes a bat # file out of the raw command string, and some commands (like python) are @@ -2641,6 +2659,22 @@ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name): else: properties[0].append(['ApplicationType', 'Windows Store']) + platform_name = None + msvs_windows_target_platform_version = None + for configuration in spec['configurations'].itervalues(): + platform_name = platform_name or _ConfigPlatform(configuration) + msvs_windows_target_platform_version = \ + msvs_windows_target_platform_version or \ + _ConfigWindowsTargetPlatformVersion(configuration) + if platform_name and msvs_windows_target_platform_version: + break + + if platform_name == 'ARM': + properties[0].append(['WindowsSDKDesktopARMSupport', 'true']) + if msvs_windows_target_platform_version: + properties[0].append(['WindowsTargetPlatformVersion', \ + str(msvs_windows_target_platform_version)]) + return properties def _GetMSBuildConfigurationDetails(spec, build_file): @@ -3188,6 +3222,9 @@ def _GetMSBuildProjectReferences(project): ['ReferenceOutputAssembly', 'false'] ] for config in dependency.spec.get('configurations', {}).itervalues(): + if config.get('msvs_use_library_dependency_inputs', 0): + project_ref.append(['UseLibraryDependencyInputs', 'true']) + break # If it's disabled in any config, turn it off in the reference. if config.get('msvs_2010_disable_uldi_when_referenced', 0): project_ref.append(['UseLibraryDependencyInputs', 'false']) diff --git a/deps/npm/node_modules/node-gyp/lib/build.js b/deps/npm/node_modules/node-gyp/lib/build.js index 198017b262a..6556d302b2f 100644 --- a/deps/npm/node_modules/node-gyp/lib/build.js +++ b/deps/npm/node_modules/node-gyp/lib/build.js @@ -220,7 +220,9 @@ function build (gyp, argv, callback) { // Specify the build type, Release by default if (win) { - var p = arch === 'x64' ? 'x64' : 'Win32' + var archLower = arch.toLowerCase() + var p = archLower === 'x64' ? 'x64' : + (archLower === 'arm' ? 'ARM' : 'Win32') argv.push('/p:Configuration=' + buildType + ';Platform=' + p) if (jobs) { var j = parseInt(jobs, 10) diff --git a/deps/npm/node_modules/node-gyp/lib/configure.js b/deps/npm/node_modules/node-gyp/lib/configure.js index 009935202af..39233ca451e 100644 --- a/deps/npm/node_modules/node-gyp/lib/configure.js +++ b/deps/npm/node_modules/node-gyp/lib/configure.js @@ -322,6 +322,7 @@ function configure (gyp, argv, callback) { argv.push('-Dnode_gyp_dir=' + nodeGypDir) argv.push('-Dnode_lib_file=' + release.name + '.lib') argv.push('-Dmodule_root_dir=' + process.cwd()) + argv.push('-Dnode_engine=' + (gyp.opts.node_engine || process.jsEngine || 'v8')) argv.push('--depth=.') argv.push('--no-parallel') diff --git a/node.gyp b/node.gyp index 672c3ce6691..76c88262bfe 100644 --- a/node.gyp +++ b/node.gyp @@ -14,6 +14,7 @@ 'node_v8_options%': '', 'node_enable_v8_vtunejit%': 'false', 'node_target_type%': 'executable', + 'node_engine%': 'v8', 'node_core_target_name%': 'node', 'library_files': [ 'src/node.js', @@ -102,8 +103,6 @@ 'dependencies': [ 'node_js2c#host', 'deps/cares/cares.gyp:cares', - 'deps/v8/tools/gyp/v8.gyp:v8', - 'deps/v8/tools/gyp/v8.gyp:v8_libplatform' ], 'include_dirs': [ @@ -111,7 +110,6 @@ 'tools/msvs/genfiles', 'deps/uv/src/ares', '<(SHARED_INTERMEDIATE_DIR)', # for node_natives.h - 'deps/v8' # include/v8_platform.h ], 'sources': [ @@ -372,6 +370,23 @@ }], ], }], + + [ 'node_engine=="v8"', { + 'include_dirs': [ + 'deps/v8' # include/v8_platform.h + ], + 'dependencies': [ + 'deps/v8/tools/gyp/v8.gyp:v8', + 'deps/v8/tools/gyp/v8.gyp:v8_libplatform' + ], + }], + ['node_engine=="chakracore"', { + 'include_dirs': [ + 'deps/chakrashim' # include/v8_platform.h + ], + 'dependencies': [ 'deps/chakrashim/chakrashim.gyp:chakrashim' ], + }], + [ 'node_shared_zlib=="false"', { 'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ], }], @@ -675,13 +690,29 @@ 'type': 'executable', 'dependencies': [ 'deps/gtest/gtest.gyp:gtest', - 'deps/v8/tools/gyp/v8.gyp:v8', - 'deps/v8/tools/gyp/v8.gyp:v8_libplatform' ], 'include_dirs': [ 'src', - 'deps/v8/include' ], + 'conditions': [ + [ 'node_engine=="v8"', { + 'include_dirs': [ + 'deps/v8/include' + ], + 'dependencies': [ + 'deps/v8/tools/gyp/v8.gyp:v8', + 'deps/v8/tools/gyp/v8.gyp:v8_libplatform' + ], + }], + ['node_engine=="chakracore"', { + 'dependencies': [ 'deps/chakrashim/chakrashim.gyp:chakrashim' ], + }], + ], + 'msvs_settings': { + 'VCLinkerTool': { + 'SubSystem': 1, # /subsystem:console + }, + }, 'defines': [ # gtest's ASSERT macros conflict with our own. 'GTEST_DONT_DEFINE_ASSERT_EQ=1', diff --git a/tools/gyp/pylib/gyp/generator/msvs.py b/tools/gyp/pylib/gyp/generator/msvs.py index 44cc1304a2e..c339a8de079 100644 --- a/tools/gyp/pylib/gyp/generator/msvs.py +++ b/tools/gyp/pylib/gyp/generator/msvs.py @@ -285,6 +285,22 @@ def _ConfigFullName(config_name, config_data): return '%s|%s' % (_ConfigBaseName(config_name, platform_name), platform_name) +def _ConfigWindowsTargetPlatformVersion(config_data): + ver = config_data.get('msvs_windows_target_platform_version') + if not ver or re.match('^\d+', ver): + return ver + for key in [r'HKLM\Software\Microsoft\Microsoft SDKs\Windows\%s', + r'HKLM\Software\Wow6432Node\Microsoft\Microsoft SDKs\Windows\%s']: + sdkdir = MSVSVersion._RegistryGetValue(key % ver, 'InstallationFolder') + if not sdkdir: + continue + version = MSVSVersion._RegistryGetValue(key % ver, 'ProductVersion') or '' + # find a matching entry in sdkdir\include + names = sorted([x for x in os.listdir(r'%s\include' % sdkdir) \ + if x.startswith(version)], reverse = True) + return names[0] + + def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, quote_cmd, do_setup_env): @@ -338,6 +354,8 @@ def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, command = ['type'] else: command = [cmd[0].replace('/', '\\')] + if quote_cmd: + command = ['"%s"' % i for i in command] # Add call before command to ensure that commands can be tied together one # after the other without aborting in Incredibuild, since IB makes a bat # file out of the raw command string, and some commands (like python) are @@ -2662,6 +2680,22 @@ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name): else: properties[0].append(['ApplicationType', 'Windows Store']) + platform_name = None + msvs_windows_target_platform_version = None + for configuration in spec['configurations'].itervalues(): + platform_name = platform_name or _ConfigPlatform(configuration) + msvs_windows_target_platform_version = \ + msvs_windows_target_platform_version or \ + _ConfigWindowsTargetPlatformVersion(configuration) + if platform_name and msvs_windows_target_platform_version: + break + + if platform_name == 'ARM': + properties[0].append(['WindowsSDKDesktopARMSupport', 'true']) + if msvs_windows_target_platform_version: + properties[0].append(['WindowsTargetPlatformVersion', \ + str(msvs_windows_target_platform_version)]) + return properties def _GetMSBuildConfigurationDetails(spec, build_file): @@ -3203,6 +3237,9 @@ def _GetMSBuildProjectReferences(project): ['ReferenceOutputAssembly', 'false'] ] for config in dependency.spec.get('configurations', {}).itervalues(): + if config.get('msvs_use_library_dependency_inputs', 0): + project_ref.append(['UseLibraryDependencyInputs', 'true']) + break # If it's disabled in any config, turn it off in the reference. if config.get('msvs_2010_disable_uldi_when_referenced', 0): project_ref.append(['UseLibraryDependencyInputs', 'false']) diff --git a/tools/js2c.py b/tools/js2c.py index ec9705ec6af..b0420eff179 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -212,9 +212,9 @@ def ReadMacros(lines): HEADER_TEMPLATE = """\ -#ifndef node_natives_h -#define node_natives_h -namespace node { +#ifndef %(namespace)s_natives_h +#define %(namespace)s_natives_h +namespace %(namespace)s { %(source_lines)s\ @@ -260,7 +260,7 @@ def ReadMacros(lines): if (index == %(i)i) return Vector("%(name)s", %(length)i); """ -def JS2C(source, target): +def JS2C(source, target, namespace): ids = [] delay_ids = [] modules = [] @@ -371,7 +371,8 @@ def JS2C(source, target): 'native_lines': "\n".join(native_lines), 'get_index_cases': "".join(get_index_cases), 'get_script_source_cases': "".join(get_script_source_cases), - 'get_script_name_cases': "".join(get_script_name_cases) + 'get_script_name_cases': "".join(get_script_name_cases), + 'namespace': namespace }) output.close() @@ -383,14 +384,25 @@ def JS2C(source, target): 'source_lines': "\n".join(source_lines_empty), 'get_index_cases': "".join(get_index_cases), 'get_script_source_cases': "".join(get_script_source_cases), - 'get_script_name_cases': "".join(get_script_name_cases) + 'get_script_name_cases': "".join(get_script_name_cases), + 'namespace': namespace }) output.close() + +NAMESPACE_SWITCH = "--namespace=" + def main(): - natives = sys.argv[1] - source_files = sys.argv[2:] - JS2C(source_files, [natives]) + i = 1 + if sys.argv[i].startswith(NAMESPACE_SWITCH): + namespace = sys.argv[i][len(NAMESPACE_SWITCH):] + i += 1 + else: + namespace = 'node' + + natives = sys.argv[i] + source_files = sys.argv[(i + 1):] + JS2C(source_files, [natives], namespace) if __name__ == "__main__": main() diff --git a/tools/test.py b/tools/test.py index 214d634fe5b..1d89af8db26 100755 --- a/tools/test.py +++ b/tools/test.py @@ -774,7 +774,7 @@ def GetTestStatus(self, context, sections, defs): class Context(object): - def __init__(self, workspace, buildspace, verbose, vm, timeout, processor, suppress_dialogs, store_unexpected_output): + def __init__(self, workspace, buildspace, verbose, vm, timeout, processor, suppress_dialogs, store_unexpected_output, engine): self.workspace = workspace self.buildspace = buildspace self.verbose = verbose @@ -783,6 +783,7 @@ def __init__(self, workspace, buildspace, verbose, vm, timeout, processor, suppr self.processor = processor self.suppress_dialogs = suppress_dialogs self.store_unexpected_output = store_unexpected_output + self.engine = engine def GetVm(self, arch, mode): if arch == 'none': @@ -1312,6 +1313,8 @@ def BuildOptions(): default="") result.add_option('--temp-dir', help='Optional path to change directory used for tests', default=False) + result.add_option("-e", "--engine", help="The javascript engine used by node.js", + default='v8') return result @@ -1471,7 +1474,8 @@ def Main(): options.timeout, processor, options.suppress_dialogs, - options.store_unexpected_output) + options.store_unexpected_output, + options.engine) # First build the required targets if not options.no_build: reqs = [ ] diff --git a/vcbuild.bat b/vcbuild.bat index 3c710c807a5..e3056b79123 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -35,6 +35,8 @@ set release_urls_arg= set build_release= set enable_vtune_profiling= set configure_flags= +set engine=v8 +set openssl_no_asm= :next-arg if "%1"=="" goto args-done @@ -44,6 +46,7 @@ if /i "%1"=="clean" set target=Clean&goto arg-ok if /i "%1"=="ia32" set target_arch=x86&goto arg-ok if /i "%1"=="x86" set target_arch=x86&goto arg-ok if /i "%1"=="x64" set target_arch=x64&goto arg-ok +if /i "%1"=="arm" set target_arch=arm&goto arg-ok if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok if /i "%1"=="nobuild" set nobuild=1&goto arg-ok if /i "%1"=="nosign" set nosign=1&goto arg-ok @@ -69,6 +72,9 @@ if /i "%1"=="intl-none" set i18n_arg=%1&goto arg-ok if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok if /i "%1"=="ignore-flaky" set test_args=%test_args% --flaky-tests=dontcare&goto arg-ok if /i "%1"=="enable-vtune" set enable_vtune_profiling="--enable-vtune-profiling"&goto arg-ok +if /i "%1"=="v8" set engine=v8&goto arg-ok +if /i "%1"=="chakracore" set engine=chakracore&set chakra_jslint=deps\chakrashim\lib&goto arg-ok +if /i "%1"=="openssl-no-asm" set openssl_no_asm=--openssl-no-asm&goto arg-ok echo Warning: ignoring invalid command line option `%1`. @@ -87,6 +93,10 @@ if defined build_release ( set i18n_arg=small-icu ) +if "%target_arch%"=="arm" ( + if not "%openssl_no_asm%"=="--openssl-no-asm" goto arm-requires-openssl-no-asm +) + if "%config%"=="Debug" set configure_flags=%configure_flags% --debug if defined nosnapshot set configure_flags=%configure_flags% --without-snapshot if defined noetw set configure_flags=%configure_flags% --without-etw& set noetw_msi_arg=/p:NoETW=1 @@ -169,8 +179,8 @@ goto run if defined noprojgen goto msbuild @rem Generate the VS project. -echo configure %configure_flags% %enable_vtune_profiling% --dest-cpu=%target_arch% --tag=%TAG% -python configure %configure_flags% %enable_vtune_profiling% --dest-cpu=%target_arch% --tag=%TAG% +echo configure %configure_flags% %enable_vtune_profiling% --engine=%engine% %openssl_no_asm% --dest-cpu=%target_arch% --tag=%TAG% +python configure %configure_flags% %enable_vtune_profiling% --engine=%engine% %openssl_no_asm% --dest-cpu=%target_arch% --tag=%TAG% if errorlevel 1 goto create-msvs-files-failed if not exist node.sln goto create-msvs-files-failed echo Project files generated. @@ -244,6 +254,7 @@ goto exit if "%test_args%"=="" goto jslint if "%config%"=="Debug" set test_args=--mode=debug %test_args% if "%config%"=="Release" set test_args=--mode=release %test_args% +set test_args=--engine %engine% %test_args% echo running 'cctest' "%config%\cctest" echo running 'python tools\test.py %test_args%' @@ -253,13 +264,18 @@ goto jslint :jslint if not defined jslint goto exit echo running jslint -%config%\node tools\eslint\bin\eslint.js src lib test tools\eslint-rules --rulesdir tools\eslint-rules --reset --quiet +%config%\node tools\eslint\bin\eslint.js src lib test %chakra_jslint% tools\eslint-rules --rulesdir tools\eslint-rules --reset --quiet goto exit :create-msvs-files-failed echo Failed to create vc project files. goto exit +:arm-requires-openssl-no-asm +echo openssl asm is currently not supported on arm +echo use 'openssl-no-asm' as additional argument +goto exit + :help echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [download-all] [enable-vtune] echo Examples: