Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for building io.js as a static library #1341

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ parser.add_option('--xcode',
dest='use_xcode',
help='generate build files for use with xcode')

parser.add_option('--enable-static',
action='store_true',
dest='enable_static',
help='build as static library')

(options, args) = parser.parse_args()

# set up auto-download list
Expand Down Expand Up @@ -609,6 +614,9 @@ def configure_node(o):
if options.v8_options:
o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')

if options.enable_static:
o['variables']['node_target_type'] = 'static_library'


def configure_libz(o):
o['variables']['node_shared_zlib'] = b(options.shared_zlib)
Expand Down
52 changes: 35 additions & 17 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'node_use_openssl%': 'true',
'node_shared_openssl%': 'false',
'node_v8_options%': '',
'node_target_type%': 'executable',
'library_files': [
'src/node.js',
'lib/_debug_agent.js',
Expand Down Expand Up @@ -77,7 +78,7 @@
'targets': [
{
'target_name': 'iojs',
'type': 'executable',
'type': '<(node_target_type)',

'dependencies': [
'node_js2c#host',
Expand Down Expand Up @@ -179,6 +180,12 @@
],

'conditions': [
# No node_main.cc for anything except executable
[ 'node_target_type!="executable"', {
'sources!': [
'src/node_main.cc',
],
}],
[ 'v8_enable_i18n_support==1', {
'defines': [ 'NODE_HAVE_I18N_SUPPORT=1' ],
'dependencies': [
Expand Down Expand Up @@ -211,19 +218,25 @@
'./deps/openssl/openssl.gyp:openssl-cli',
],
# Do not let unused OpenSSL symbols to slip away
'xcode_settings': {
'OTHER_LDFLAGS': [
'-Wl,-force_load,<(PRODUCT_DIR)/libopenssl.a',
],
},
'conditions': [
['OS in "linux freebsd"', {
'ldflags': [
'-Wl,--whole-archive <(PRODUCT_DIR)/libopenssl.a -Wl,--no-whole-archive',
# -force_load or --whole-archive are not applicable for the static library
[ 'node_target_type!="static_library"', {
'xcode_settings': {
'OTHER_LDFLAGS': [
'-Wl,-force_load,<(PRODUCT_DIR)/libopenssl.a',
],
},
'conditions': [
['OS in "linux freebsd"', {
'ldflags': [
'-Wl,--whole-archive <(PRODUCT_DIR)/libopenssl.a -Wl,--no-whole-archive',
],
} ],
],
}],
} ],
],
}]]
} ]
],
}, {
'defines': [ 'HAVE_OPENSSL=0' ]
}],
Expand Down Expand Up @@ -300,12 +313,17 @@
} ],
[ 'v8_postmortem_support=="true"', {
'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:postmortem-metadata' ],
'xcode_settings': {
'OTHER_LDFLAGS': [
'-Wl,-force_load,<(V8_BASE)',
],
},
}],
'conditions': [
# -force_load is not applicable for the static library
[ 'node_target_type!="static_library"', {
'xcode_settings': {
'OTHER_LDFLAGS': [
'-Wl,-force_load,<(V8_BASE)',
],
},
} ],
],
} ],
[ 'node_shared_v8=="false"', {
'sources': [
'deps/v8/include/v8.h',
Expand Down