Merge pull request #1343 from atom/node_lib

Build node as shared library
This commit is contained in:
Cheng Zhao 2015-04-02 13:03:57 +08:00
commit 5ff9588b48
7 changed files with 45 additions and 37 deletions

View file

@ -548,7 +548,7 @@
'dependencies': [ 'dependencies': [
'atom_coffee2c', 'atom_coffee2c',
'vendor/brightray/brightray.gyp:brightray', 'vendor/brightray/brightray.gyp:brightray',
'vendor/node/node.gyp:node_lib', 'vendor/node/node.gyp:node',
], ],
'defines': [ 'defines': [
'PRODUCT_NAME="<(product_name)"', 'PRODUCT_NAME="<(product_name)"',
@ -866,9 +866,6 @@
], ],
'xcode_settings': { 'xcode_settings': {
'INFOPLIST_FILE': 'atom/common/resources/mac/Info.plist', 'INFOPLIST_FILE': 'atom/common/resources/mac/Info.plist',
'LIBRARY_SEARCH_PATHS': [
'<(libchromiumcontent_library_dir)',
],
'LD_DYLIB_INSTALL_NAME': '@rpath/<(product_name) Framework.framework/<(product_name) Framework', 'LD_DYLIB_INSTALL_NAME': '@rpath/<(product_name) Framework.framework/<(product_name) Framework',
'LD_RUNPATH_SEARCH_PATHS': [ 'LD_RUNPATH_SEARCH_PATHS': [
'@loader_path/Libraries', '@loader_path/Libraries',
@ -883,6 +880,7 @@
'files': [ 'files': [
'<(libchromiumcontent_library_dir)/ffmpegsumo.so', '<(libchromiumcontent_library_dir)/ffmpegsumo.so',
'<(libchromiumcontent_library_dir)/libchromiumcontent.dylib', '<(libchromiumcontent_library_dir)/libchromiumcontent.dylib',
'<(PRODUCT_DIR)/libnode.dylib',
], ],
}, },
{ {
@ -894,6 +892,16 @@
}, },
], ],
'postbuilds': [ 'postbuilds': [
{
'postbuild_name': 'Fix path of libnode',
'action': [
'install_name_tool',
'-change',
'/usr/local/lib/libnode.dylib',
'@rpath/libnode.dylib',
'${BUILT_PRODUCTS_DIR}/<(product_name) Framework.framework/Versions/A/<(product_name) Framework',
],
},
{ {
'postbuild_name': 'Add symlinks for framework subdirectories', 'postbuild_name': 'Add symlinks for framework subdirectories',
'action': [ 'action': [
@ -965,7 +973,7 @@
{ {
'action_name': 'Create node.lib', 'action_name': 'Create node.lib',
'inputs': [ 'inputs': [
'<(PRODUCT_DIR)/<(project_name).lib', '<(PRODUCT_DIR)/node.dll.lib',
'<(libchromiumcontent_library_dir)/chromiumcontent.dll.lib', '<(libchromiumcontent_library_dir)/chromiumcontent.dll.lib',
], ],
'outputs': [ 'outputs': [

View file

@ -22,39 +22,11 @@
using content::BrowserThread; using content::BrowserThread;
// Forward declaration of internal node functions.
namespace node {
void Init(int*, const char**, int*, const char***);
}
// Force all builtin modules to be referenced so they can actually run their // Force all builtin modules to be referenced so they can actually run their
// DSO constructors, see http://git.io/DRIqCg. // DSO constructors, see http://git.io/DRIqCg.
#define REFERENCE_MODULE(name) \ #define REFERENCE_MODULE(name) \
extern "C" void _register_ ## name(void); \ extern "C" void _register_ ## name(void); \
void (*fp_register_ ## name)(void) = _register_ ## name void (*fp_register_ ## name)(void) = _register_ ## name
// Node's builtin modules.
REFERENCE_MODULE(cares_wrap);
REFERENCE_MODULE(fs_event_wrap);
REFERENCE_MODULE(buffer);
REFERENCE_MODULE(contextify);
REFERENCE_MODULE(crypto);
REFERENCE_MODULE(fs);
REFERENCE_MODULE(http_parser);
REFERENCE_MODULE(os);
REFERENCE_MODULE(v8);
REFERENCE_MODULE(zlib);
REFERENCE_MODULE(pipe_wrap);
REFERENCE_MODULE(process_wrap);
REFERENCE_MODULE(signal_wrap);
REFERENCE_MODULE(smalloc);
REFERENCE_MODULE(spawn_sync);
REFERENCE_MODULE(tcp_wrap);
REFERENCE_MODULE(timer_wrap);
REFERENCE_MODULE(tls_wrap);
REFERENCE_MODULE(tty_wrap);
REFERENCE_MODULE(udp_wrap);
REFERENCE_MODULE(uv);
REFERENCE_MODULE(js_stream);
// Atom Shell's builtin modules. // Atom Shell's builtin modules.
REFERENCE_MODULE(atom_browser_app); REFERENCE_MODULE(atom_browser_app);
REFERENCE_MODULE(atom_browser_auto_updater); REFERENCE_MODULE(atom_browser_auto_updater);

View file

@ -7,6 +7,8 @@
// Include common headers for using node APIs. // Include common headers for using node APIs.
#define BUILDING_NODE_EXTENSION
#undef ASSERT #undef ASSERT
#undef CHECK #undef CHECK
#undef CHECK_EQ #undef CHECK_EQ

View file

@ -1,4 +1,7 @@
{ {
'includes': [
'vendor/brightray/brightray.gypi',
],
'variables': { 'variables': {
'clang': 0, 'clang': 0,
'openssl_no_asm': 1, 'openssl_no_asm': 1,
@ -37,7 +40,7 @@
# Settings to compile node under Windows. # Settings to compile node under Windows.
'target_defaults': { 'target_defaults': {
'target_conditions': [ 'target_conditions': [
['_target_name in ["libuv", "http_parser", "cares", "openssl", "openssl-cli", "node_lib", "zlib"]', { ['_target_name in ["libuv", "http_parser", "cares", "openssl", "openssl-cli", "node", "zlib"]', {
'msvs_disabled_warnings': [ 'msvs_disabled_warnings': [
4703, # potentially uninitialized local pointer variable 'req' used 4703, # potentially uninitialized local pointer variable 'req' used
4013, # 'free' undefined; assuming extern returning int 4013, # 'free' undefined; assuming extern returning int
@ -92,15 +95,36 @@
'-Wno-unused-value', '-Wno-unused-value',
'-Wno-deprecated-declarations', '-Wno-deprecated-declarations',
'-Wno-return-type', '-Wno-return-type',
# Fix relocation error when compiling as shared library.
'-fPIC',
], ],
}], }],
], ],
}], }],
['_target_name in ["node_lib", "atom_lib"]', { ['_target_name in ["node", "atom_lib"]', {
'include_dirs': [ 'include_dirs': [
'vendor/brightray/vendor/download/libchromiumcontent/src/v8/include', 'vendor/brightray/vendor/download/libchromiumcontent/src/v8/include',
], ],
}], }],
['_target_name=="node"', {
'conditions': [
['OS=="linux"', {
'libraries': [
'<(libchromiumcontent_library_dir)/libchromiumcontent.so',
],
}],
['OS=="win"', {
'libraries': [
'<(libchromiumcontent_library_dir)/chromiumcontent.dll.lib',
],
}],
['OS=="mac"', {
'libraries': [
'<(libchromiumcontent_library_dir)/libchromiumcontent.dylib',
],
}],
],
}],
['_target_name=="libuv"', { ['_target_name=="libuv"', {
'conditions': [ 'conditions': [
['OS=="win"', { ['OS=="win"', {

View file

@ -33,6 +33,7 @@ TARGET_BINARIES = {
'chromiumcontent.dll', 'chromiumcontent.dll',
'content_shell.pak', 'content_shell.pak',
'd3dcompiler_47.dll', 'd3dcompiler_47.dll',
'node.dll',
'ffmpegsumo.dll', 'ffmpegsumo.dll',
'icudtl.dat', 'icudtl.dat',
'libEGL.dll', 'libEGL.dll',
@ -49,6 +50,7 @@ TARGET_BINARIES = {
'linux': [ 'linux': [
'atom', 'atom',
'content_shell.pak', 'content_shell.pak',
'libnode.so',
'icudtl.dat', 'icudtl.dat',
'libchromiumcontent.so', 'libchromiumcontent.so',
'libffmpegsumo.so', 'libffmpegsumo.so',

View file

@ -38,7 +38,7 @@ def update_gyp():
ret = subprocess.call([python, gyp, ret = subprocess.call([python, gyp,
'-f', 'ninja', '--depth', '.', 'atom.gyp', '-f', 'ninja', '--depth', '.', 'atom.gyp',
'-Icommon.gypi', '-Ivendor/brightray/brightray.gypi', '-Icommon.gypi',
'-Dlinux_clang=0', # Disable brightray's clang setting '-Dlinux_clang=0', # Disable brightray's clang setting
'-Dtarget_arch={0}'.format(arch), '-Dtarget_arch={0}'.format(arch),
'-Dlibrary=static_library']) '-Dlibrary=static_library'])

2
vendor/node vendored

@ -1 +1 @@
Subproject commit 6479eb98d5b3d9d25a86eff857af17dcc61f3bc4 Subproject commit 790c4a3af36144fcdd5fe39d0cb6cd622f282434