Browse Source

Build node as shared library

Cheng Zhao 10 years ago
parent
commit
a400bb5997
5 changed files with 51 additions and 31 deletions
  1. 44 9
      atom.gyp
  2. 3 20
      common.gypi
  3. 2 0
      script/create-dist.py
  4. 1 1
      vendor/brightray
  5. 1 1
      vendor/node

+ 44 - 9
atom.gyp

@@ -120,9 +120,16 @@
               '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'
+                    ],
                   }],
                 ],
               },
@@ -159,9 +166,16 @@
               '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'
+                    ],
                   }],
                 ],
               },
@@ -192,7 +206,6 @@
         'atom_coffee2c',
         'vendor/brightray/brightray.gyp:brightray',
         'vendor/node/node.gyp:node',
-        'vendor/node/deps/openssl/openssl.gyp:openssl',
       ],
       'defines': [
         'PRODUCT_NAME="<(product_name)"',
@@ -221,11 +234,11 @@
         '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': [
@@ -236,6 +249,11 @@
         'vendor/brightray/brightray.gyp:brightray',
       ],
       'conditions': [
+        ['libchromiumcontent_component', {
+          'link_settings': {
+            'libraries': [ '<@(libchromiumcontent_v8_libraries)' ],
+          },
+        }],
         ['OS=="win"', {
           'sources': [
             '<@(lib_sources_win)',
@@ -398,9 +416,16 @@
               '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'
+                    ],
                   }],
                 ],
               },
@@ -429,6 +454,16 @@
                 '${BUILT_PRODUCTS_DIR}/<(product_name) Framework.framework/Versions/A/<(product_name) Framework',
               ],
             },
+            {
+              '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': [

+ 3 - 20
common.gypi

@@ -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': '',
@@ -92,30 +92,13 @@
               '-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': [

+ 2 - 0
script/create-dist.py

@@ -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',
   ],
 }

+ 1 - 1
vendor/brightray

@@ -1 +1 @@
-Subproject commit 21ab1efb09e8f7efa5591dc4c989f7012025a133
+Subproject commit 1b62aab98e1e79f6357bd156fc2a43068d4a3f49

+ 1 - 1
vendor/node

@@ -1 +1 @@
-Subproject commit b1cd6a5f5e0b18e666c1a27794c4f77992a96bb7
+Subproject commit bf5162b9042ff3e626a1adbd56b547801fda8cbf