From 7e49645998b2f0b21ca228d54872872cc0edbe18 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 1 Apr 2015 20:26:46 +0800 Subject: [PATCH] Build node as shared library --- atom.gyp | 18 ++++++++++++++---- common.gypi | 26 ++++++++++++++++++++++++-- script/update.py | 2 +- vendor/node | 2 +- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/atom.gyp b/atom.gyp index 7b77e6408c..86b95e3978 100644 --- a/atom.gyp +++ b/atom.gyp @@ -504,6 +504,7 @@ '<(libchromiumcontent_resources_dir)/ui_resources_200_percent.pak', '<(libchromiumcontent_resources_dir)/natives_blob.bin', '<(libchromiumcontent_resources_dir)/snapshot_blob.bin', + '<(PRODUCT_DIR)/node.dll', 'external_binaries/d3dcompiler_47.dll', 'external_binaries/msvcp120.dll', 'external_binaries/msvcr120.dll', @@ -530,6 +531,7 @@ '<(libchromiumcontent_resources_dir)/content_shell.pak', '<(libchromiumcontent_resources_dir)/natives_blob.bin', '<(libchromiumcontent_resources_dir)/snapshot_blob.bin', + '<(PRODUCT_DIR)/libnode.so', ], }, { @@ -548,7 +550,7 @@ 'dependencies': [ 'atom_coffee2c', 'vendor/brightray/brightray.gyp:brightray', - 'vendor/node/node.gyp:node_lib', + 'vendor/node/node.gyp:node', ], 'defines': [ 'PRODUCT_NAME="<(product_name)"', @@ -866,9 +868,6 @@ ], 'xcode_settings': { '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_RUNPATH_SEARCH_PATHS': [ '@loader_path/Libraries', @@ -883,6 +882,7 @@ 'files': [ '<(libchromiumcontent_library_dir)/ffmpegsumo.so', '<(libchromiumcontent_library_dir)/libchromiumcontent.dylib', + '<(PRODUCT_DIR)/libnode.dylib', ], }, { @@ -894,6 +894,16 @@ }, ], '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', 'action': [ diff --git a/common.gypi b/common.gypi index fae82aaf21..17e9fd9ff0 100644 --- a/common.gypi +++ b/common.gypi @@ -1,4 +1,7 @@ { + 'includes': [ + 'vendor/brightray/brightray.gypi', + ], 'variables': { 'clang': 0, 'openssl_no_asm': 1, @@ -37,7 +40,7 @@ # Settings to compile node under Windows. 'target_defaults': { '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': [ 4703, # potentially uninitialized local pointer variable 'req' used 4013, # 'free' undefined; assuming extern returning int @@ -96,11 +99,30 @@ }], ], }], - ['_target_name in ["node_lib", "atom_lib"]', { + ['_target_name in ["node", "atom_lib"]', { 'include_dirs': [ '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"', { 'conditions': [ ['OS=="win"', { diff --git a/script/update.py b/script/update.py index 61eb4088be..2fe52e7f3a 100755 --- a/script/update.py +++ b/script/update.py @@ -38,7 +38,7 @@ def update_gyp(): ret = subprocess.call([python, gyp, '-f', 'ninja', '--depth', '.', 'atom.gyp', - '-Icommon.gypi', '-Ivendor/brightray/brightray.gypi', + '-Icommon.gypi', '-Dlinux_clang=0', # Disable brightray's clang setting '-Dtarget_arch={0}'.format(arch), '-Dlibrary=static_library']) diff --git a/vendor/node b/vendor/node index 6479eb98d5..ea394ef897 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 6479eb98d5b3d9d25a86eff857af17dcc61f3bc4 +Subproject commit ea394ef8974a06918af0c6f104a07bff3f4e627f