03afae
From a3e5296fcb14cf3e00f31864f305fb40720e8718 Mon Sep 17 00:00:00 2001
03afae
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
03afae
Date: Tue, 19 Mar 2019 23:22:40 -0400
03afae
Subject: [PATCH 3/3] Install both binaries and use libdir.
03afae
03afae
This allows us to build with a shared library for other users while
03afae
still providing the normal executable.
03afae
03afae
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
03afae
---
03afae
 configure.py     |  7 +++++++
03afae
 tools/install.py | 29 +++++++++++++----------------
03afae
 2 files changed, 20 insertions(+), 16 deletions(-)
03afae
03afae
diff --git a/configure.py b/configure.py
03afae
index 15ea5687cf1cd8e4ebe449ea2fc39eea95fb29b6..a738e300d6098bef4975930422b3fa55b3f5421d 100755
03afae
--- a/configure.py
03afae
+++ b/configure.py
03afae
@@ -534,10 +534,16 @@ parser.add_option('--shared',
03afae
     action='store_true',
03afae
     dest='shared',
03afae
     help='compile shared library for embedding node in another project. ' +
03afae
          '(This mode is not officially supported for regular applications)')
03afae
 
03afae
+parser.add_option('--libdir',
03afae
+    action='store',
03afae
+    dest='libdir',
03afae
+    default='lib',
03afae
+    help='a directory to install the shared library into')
03afae
+
03afae
 parser.add_option('--without-v8-platform',
03afae
     action='store_true',
03afae
     dest='without_v8_platform',
03afae
     default=False,
03afae
     help='do not initialize v8 platform during node.js startup. ' +
03afae
@@ -1065,10 +1071,11 @@ def configure_node(o):
03afae
   o['variables']['node_no_browser_globals'] = b(options.no_browser_globals)
03afae
   # TODO(refack): fix this when implementing embedded code-cache when cross-compiling.
03afae
   if o['variables']['want_separate_host_toolset'] == 0:
03afae
     o['variables']['node_code_cache_path'] = 'yes'
03afae
   o['variables']['node_shared'] = b(options.shared)
03afae
+  o['variables']['libdir'] = options.libdir
03afae
   node_module_version = getmoduleversion.get_version()
03afae
 
03afae
   if sys.platform == 'darwin':
03afae
     shlib_suffix = '%s.dylib'
03afae
   elif sys.platform.startswith('aix'):
03afae
diff --git a/tools/install.py b/tools/install.py
03afae
index 655802980a6ea94d1d4ca1dc63c8c8e905fbb83a..fe4723bf15012c8aacacb0393dc8294c049b0503 100755
03afae
--- a/tools/install.py
03afae
+++ b/tools/install.py
03afae
@@ -119,30 +119,27 @@ def subdir_files(path, dest, action):
03afae
   for subdir, files_in_path in ret.items():
03afae
     action(files_in_path, subdir + '/')
03afae
 
03afae
 def files(action):
03afae
   is_windows = sys.platform == 'win32'
03afae
-  output_file = 'node'
03afae
   output_prefix = 'out/Release/'
03afae
+  output_libprefix = output_prefix
03afae
 
03afae
-  if 'false' == variables.get('node_shared'):
03afae
-    if is_windows:
03afae
-      output_file += '.exe'
03afae
+  if is_windows:
03afae
+    output_bin = 'node.exe'
03afae
+    output_lib = 'node.dll'
03afae
   else:
03afae
-    if is_windows:
03afae
-      output_file += '.dll'
03afae
-    else:
03afae
-      output_file = 'lib' + output_file + '.' + variables.get('shlib_suffix')
03afae
-      # GYP will output to lib.target except on OS X, this is hardcoded
03afae
-      # in its source - see the _InstallableTargetInstallPath function.
03afae
-      if sys.platform != 'darwin':
03afae
-        output_prefix += 'lib.target/'
03afae
+    output_bin = 'node'
03afae
+    output_lib = 'libnode.' + variables.get('shlib_suffix')
03afae
+    # GYP will output to lib.target except on OS X, this is hardcoded
03afae
+    # in its source - see the _InstallableTargetInstallPath function.
03afae
+    if sys.platform != 'darwin':
03afae
+      output_libprefix += 'lib.target/'
03afae
 
03afae
-  if 'false' == variables.get('node_shared'):
03afae
-    action([output_prefix + output_file], 'bin/' + output_file)
03afae
-  else:
03afae
-    action([output_prefix + output_file], 'lib/' + output_file)
03afae
+  action([output_prefix + output_bin], 'bin/' + output_bin)
03afae
+  if 'true' == variables.get('node_shared'):
03afae
+    action([output_libprefix + output_lib], variables.get('libdir') + '/' + output_lib)
03afae
 
03afae
   if 'true' == variables.get('node_use_dtrace'):
03afae
     action(['out/Release/node.d'], 'lib/dtrace/node.d')
03afae
 
03afae
   # behave similarly for systemtap
03afae
-- 
03afae
2.21.0
03afae