Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Node.js to run with Microsoft's ChakraCore engine #4765

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ _UpgradeReport_Files/
ipch/
*.sdf
*.opensdf
/.vs

/config.mk
/config.gypi
Expand Down
38 changes: 38 additions & 0 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: is node_engine established elsewhere? Maybe js_engine? This line and everywhere else for consistency

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually just prefix node stuff with node_ in here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, cool

'msvs_windows_target_platform_version': 'v10.0', # used for node_engine==chakracore

'node_tag%': '',
'uv_library%': 'static_library',
Expand Down Expand Up @@ -51,7 +53,37 @@
],
},

'conditions': [
['node_engine=="v8"', {
'target_defaults': {
'defines': [
'NODE_ENGINE_V8',
],
},
'variables': {
'node_engine_include_dir%': 'deps/v8/include'
},
}],
['node_engine=="chakracore"', {
'target_defaults': {
'defines': [
'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': {
'defines': ['NODE_ENGINE="<(node_engine)"'],
'default_configuration': 'Release',
'configurations': {
'Debug': {
Expand All @@ -64,6 +96,9 @@
['target_arch=="x64"', {
'msvs_configuration_platform': 'x64',
}],
['target_arch=="arm"', {
'msvs_configuration_platform': 'ARM',
}],
['OS=="aix"', {
'cflags': [ '-gxcoff' ],
'ldflags': [ '-Wl,-bbigtoc' ],
Expand Down Expand Up @@ -94,6 +129,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' ]
Expand Down
13 changes: 13 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ parser.add_option('--enable-static',
dest='enable_static',
help='build as static library')

parser.add_option('--engine',
action='store',
dest='engine',
default='v8',
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.
Expand Down Expand Up @@ -525,6 +532,8 @@ def check_compiler(o):
def cc_macros(cc=None):
"""Checks predefined macros using the C compiler command."""

if os.name == 'nt':
return {'__ARM_ARCH_7__': True, '__ARM_NEON__': True}
try:
p = subprocess.Popen(shlex.split(cc or CC) + ['-dM', '-E', '-'],
stdin=subprocess.PIPE,
Expand Down Expand Up @@ -1101,6 +1110,9 @@ def configure_intl(o):
pprint.pformat(icu_config, indent=2) + '\n')
return # end of configure_intl

def configure_engine(o):
o['variables']['node_engine'] = options.engine.lower()

output = {
'variables': { 'python': sys.executable },
'include_dirs': [],
Expand Down Expand Up @@ -1128,6 +1140,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
Expand Down
5 changes: 5 additions & 0 deletions deps/chakrashim/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
!core
!core/**/*.sln
!core/**/*.vcxproj
!core/**/*.vcxproj.filters
!core/**/Debug/
15 changes: 15 additions & 0 deletions deps/chakrashim/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Authors ordered by first contribution.

Paul Vick <paulv@microsoft.com>
Saar Yahalom <saary@microsoft.com>
Nadav Bar <nabar@microsoft.com>
Jianchun Xu <jianxu@microsoft.com>
Sandeep Agarwal <agarwal.sandeep@microsoft.com>
Curtis Man <curtism@microsoft.com>
Munyiri Kamau <munyirik@microsoft.com>
Kunal Pathak <Kunal.Pathak@microsoft.com>
Ryan Dawson <rdawson@microsoft.com>
mybios <mybios@qq.com>
Oguz Bastemur <obastemur@gmail.com>

# Generated by node tools/update-authors.js
19 changes: 19 additions & 0 deletions deps/chakrashim/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright Microsoft. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
77 changes: 77 additions & 0 deletions deps/chakrashim/chakracore.gyp
Original file line number Diff line number Diff line change
@@ -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
],
}
141 changes: 141 additions & 0 deletions deps/chakrashim/chakrashim.gyp
Original file line number Diff line number Diff line change
@@ -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
],
}
3 changes: 3 additions & 0 deletions deps/chakrashim/core/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.baseline -crlf
*.cmd -crlf
test/*.js -crlf
Loading