Skip to content

Commit

Permalink
Add support to build node.js with chakracore.
Browse files Browse the repository at this point in the history
Microsoft's chakracore engine is dependent on Windows SDK, and build
tools should know the version installed on user machine. This change
adds those dependencies in node-gyp tools. Below is the summary:

* 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).

These changes were originally made in nodejs/node#4765, but as @shigeki
mentioned, it was more sensible to send these changes as PR to node-gyp
repo.

PR-URL: #873
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
kunalspathak authored and bnoordhuis committed Feb 15, 2017
1 parent 93d7fa8 commit a04ea30
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
19 changes: 18 additions & 1 deletion addon.gypi
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
{
'variables' : {
'node_engine_include_dir%': 'deps/v8/include',
},
'target_defaults': {
'type': 'loadable_module',
'win_delay_load_hook': 'true',
'product_prefix': '',

'conditions': [
[ 'node_engine=="chakracore"', {
'variables': {
'node_engine_include_dir%': 'deps/chakrashim/include'
},
}]
],

'include_dirs': [
'<(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!': [
'BUILDING_UV_SHARED=1', # Inherited from common.gypi.
Expand Down Expand Up @@ -79,6 +90,12 @@
],
}],
[ 'OS=="win"', {
'conditions': [
['node_engine=="chakracore"', {
'library_dirs': [ '<(node_root_dir)/$(ConfigurationName)' ],
'libraries': [ '<@(node_engine_libs)' ],
}],
],
'libraries': [
'-lkernel32.lib',
'-luser32.lib',
Expand Down
5 changes: 5 additions & 0 deletions gyp/pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,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]

This comment has been minimized.

Copy link
@refack

refack Mar 21, 2017

Contributor

Causes #1151

# 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
Expand Down Expand Up @@ -3209,6 +3211,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'])
Expand Down
2 changes: 2 additions & 0 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ 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')

Expand Down

1 comment on commit a04ea30

@refack
Copy link
Contributor

@refack refack commented on a04ea30 Feb 15, 2017

Choose a reason for hiding this comment

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

I thought that when even we path actual GYP code we also add a .patch file, so we could rebase future versions...

Please sign in to comment.