Build node as shared library
authorCheng Zhao <zcbenz@gmail.com>
Thu, 9 Apr 2015 12:58:11 +0000 (20:58 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 9 Apr 2015 13:16:22 +0000 (21:16 +0800)
atom.gyp
common.gypi
script/create-dist.py
vendor/brightray
vendor/node

index c564f81..649e707 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
               'variables': {
                 'conditions': [
                   ['libchromiumcontent_component', {
-                    'copied_libraries': '<(libchromiumcontent_shared_libraries)',
+                    'copied_libraries': [
+                      '<(PRODUCT_DIR)/node.dll'
+                      '<@(libchromiumcontent_shared_libraries)',
+                      '<@(libchromiumcontent_shared_v8_libraries)',
+                    ],
                   }, {
-                    'copied_libraries': ['<(libchromiumcontent_dir)/boringssl.dll'],
+                    'copied_libraries': [
+                      '<(PRODUCT_DIR)/node.dll'
+                      '<(libchromiumcontent_dir)/boringssl.dll'
+                    ],
                   }],
                 ],
               },
               'variables': {
                 'conditions': [
                   ['libchromiumcontent_component', {
-                    'copied_libraries': '<(libchromiumcontent_shared_libraries)',
+                    'copied_libraries': [
+                      '<(PRODUCT_DIR)/libnode.so'
+                      '<@(libchromiumcontent_shared_libraries)',
+                      '<@(libchromiumcontent_shared_v8_libraries)',
+                    ],
                   }, {
-                    'copied_libraries': ['<(libchromiumcontent_dir)/libboringssl.so'],
+                    'copied_libraries': [
+                      '<(PRODUCT_DIR)/libnode.so'
+                      '<(libchromiumcontent_dir)/libboringssl.so'
+                    ],
                   }],
                 ],
               },
         'atom_coffee2c',
         'vendor/brightray/brightray.gyp:brightray',
         'vendor/node/node.gyp:node',
-        'vendor/node/deps/openssl/openssl.gyp:openssl',
       ],
       'defines': [
         'PRODUCT_NAME="<(product_name)"',
         'vendor/node/deps/http_parser',
         'vendor/node/deps/uv/include',
         # The `node.h` is using `#include"v8.h"`.
-        'vendor/brightray/vendor/download/libchromiumcontent/src/v8/include',
+        '<(libchromiumcontent_src_dir)/v8/include',
         # The `node.h` is using `#include"ares.h"`.
         'vendor/node/deps/cares/include',
         # The `third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h` is using `platform/PlatformExport.h`.
-        'vendor/brightray/vendor/download/libchromiumcontent/src/third_party/WebKit/Source',
+        '<(libchromiumcontent_src_dir)/third_party/WebKit/Source',
       ],
       'direct_dependent_settings': {
         'include_dirs': [
         'vendor/brightray/brightray.gyp:brightray',
       ],
       'conditions': [
+        ['libchromiumcontent_component', {
+          'link_settings': {
+            'libraries': [ '<@(libchromiumcontent_v8_libraries)' ],
+          },
+        }],
         ['OS=="win"', {
           'sources': [
             '<@(lib_sources_win)',
               'variables': {
                 'conditions': [
                   ['libchromiumcontent_component', {
-                    'copied_libraries': '<(libchromiumcontent_shared_libraries)',
+                    'copied_libraries': [
+                      '<(PRODUCT_DIR)/libnode.dylib',
+                      '<@(libchromiumcontent_shared_libraries)',
+                      '<@(libchromiumcontent_shared_v8_libraries)',
+                    ],
                   }, {
-                    'copied_libraries': ['<(libchromiumcontent_dir)/libboringssl.dylib'],
+                    'copied_libraries': [
+                      '<(PRODUCT_DIR)/libnode.dylib',
+                      '<(libchromiumcontent_dir)/libboringssl.dylib'
+                    ],
                   }],
                 ],
               },
               ],
             },
             {
+              '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': [
                 'tools/mac/create-framework-subdir-symlinks.sh',
index 8f0937e..087cd33 100644 (file)
@@ -14,7 +14,7 @@
     'node_shared_cares': 'false',
     'node_shared_http_parser': 'false',
     'node_shared_libuv': 'false',
-    'node_shared_openssl': 'true',
+    'node_shared_openssl': 'false',
     'node_shared_v8': 'true',
     'node_shared_zlib': 'false',
     'node_tag': '',
               '-Wno-unused-value',
               '-Wno-deprecated-declarations',
               '-Wno-return-type',
-              # Fix relocation error when compiling as shared library.
-              '-fPIC',
             ],
           }],
         ],
       }],
-      ['_target_name in ["node", "atom_lib"]', {
-        'include_dirs': [
-          '<(libchromiumcontent_src_dir)/v8/include',
-          'vendor/node/deps/openssl/openssl/include',
-        ],
-      }],
       ['_target_name=="node"', {
-        'conditions': [
-          ['OS=="mac"', {
-            'libraries': [ '-undefined dynamic_lookup' ],
-            'xcode_settings': {
-              'DYLIB_INSTALL_NAME_BASE': '@rpath'
-            },
-          }],
-          ['OS=="linux"', {
-            'cflags': [ '-fPIC' ],
-          }],
-        ]
+        'include_dirs': [ '<(libchromiumcontent_src_dir)/v8/include' ],
+        'libraries': [ '<@(libchromiumcontent_v8_libraries)' ],
       }],
       ['_target_name=="libuv"', {
         'conditions': [
index c2dc464..e345ed0 100755 (executable)
@@ -33,6 +33,7 @@ TARGET_BINARIES = {
     'icudtl.dat',
     'libEGL.dll',
     'libGLESv2.dll',
+    'node.dll',
     'content_resources_200_percent.pak',
     'ui_resources_200_percent.pak',
     'xinput1_3.dll',
@@ -46,6 +47,7 @@ TARGET_BINARIES = {
     'libboringssl.so',
     'libffmpegsumo.so',
     'natives_blob.bin',
+    'libnode.so',
     'snapshot_blob.bin',
   ],
 }
index 21ab1ef..1b62aab 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 21ab1efb09e8f7efa5591dc4c989f7012025a133
+Subproject commit 1b62aab98e1e79f6357bd156fc2a43068d4a3f49
index b1cd6a5..bf5162b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b1cd6a5f5e0b18e666c1a27794c4f77992a96bb7
+Subproject commit bf5162b9042ff3e626a1adbd56b547801fda8cbf