Skip to content

Commit

Permalink
build: Abstract out shared library suffix
Browse files Browse the repository at this point in the history
Add getmoduleversion
  • Loading branch information
Stewart Addison committed Oct 31, 2016
1 parent 99071b9 commit ab55c53
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
6 changes: 6 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import nodedownload

# imports in tools/
sys.path.insert(0, os.path.join(root_dir, 'tools'))
import getmoduleversion

# parse our options
parser = optparse.OptionParser()
Expand Down Expand Up @@ -795,6 +796,11 @@ def configure_node(o):
o['variables']['node_shared'] = b(options.shared)
o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform)
o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8)
node_module_version = getmoduleversion.get_version()
shlib_suffix = '%s.dylib' if sys.platform == 'darwin' else 'so.%s'
shlib_suffix %= node_module_version
o['variables']['node_module_version'] = int(node_module_version)
o['variables']['shlib_suffix'] = shlib_suffix

if options.linked_module:
o['variables']['library_files'] = options.linked_module
Expand Down
4 changes: 2 additions & 2 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@
'NODE_SHARED_MODE',
],
'conditions': [
[ 'node_module_version!="" and OS!="win"', {
'product_extension': 'so.<(node_module_version)',
[ 'node_module_version!=""', {
'product_extension': '<(shlib_suffix)',
}]
],
}],
Expand Down
24 changes: 24 additions & 0 deletions tools/getmoduleversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from __future__ import print_function
import os
import re

def get_version():
node_version_h = os.path.join(
os.path.dirname(__file__),
'..',
'src',
'node_version.h')

f = open(node_version_h)

regex = '^#define NODE_MODULE_VERSION [0-9]+'

for line in f:
if re.match(regex, line):
major = line.split()[2]
return major

raise Exception('Could not find pattern matching %s' % regex)

if __name__ == '__main__':
print(get_version())
9 changes: 5 additions & 4 deletions tools/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ def files(action):
if is_windows:
output_file += '.dll'
else:
# GYP will output to lib.target, this is hardcoded in its source,
# see the _InstallablaeTargetInstallPath function.
output_prefix += 'lib.target/'
output_file = 'lib' + output_file + '.so'
output_file = 'lib' + output_file + '.' + variables.get('shlib_suffix')
# GYP will output to lib.target except on OS X, this is hardcoded
# in its source - see the _InstallableTargetInstallPath function.
if sys.platform != 'darwin':
output_prefix += 'lib.target/'

action([output_prefix + output_file], 'bin/' + output_file)

Expand Down

0 comments on commit ab55c53

Please sign in to comment.