Skip to content

Commit c69590d

Browse files
danbevgibfahn
authored andcommitted
test: --enable-static linked executable
The motivation for this commit is to enable projects embedding Node.js and building with --enable-static to be able to run the test suite and linter. Currently when building with --enable-static no node executable will be created which means that the tests (apart from the cctest) and linter cannot be run. This is currently a work in progress and works on MacOS but I need to run the CI, and manually on different environments to verify that it works as expected. PR-URL: #14986 Refs: #14158 Refs: #14892 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent 0348dad commit c69590d

File tree

5 files changed

+87
-14
lines changed

5 files changed

+87
-14
lines changed

common.gypi

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a',
6161
}],
6262
['openssl_fips != ""', {
63-
'OPENSSL_PRODUCT': 'libcrypto.a',
63+
'OPENSSL_PRODUCT': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)',
6464
}, {
65-
'OPENSSL_PRODUCT': 'libopenssl.a',
65+
'OPENSSL_PRODUCT': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)',
6666
}],
6767
['OS=="mac"', {
6868
'clang%': 1,

node.gyp

+55-6
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,13 @@
324324
[ 'OS=="win"', {
325325
'sources': [
326326
'src/backtrace_win32.cc',
327-
'src/res/node.rc',
327+
],
328+
'conditions': [
329+
[ 'node_target_type!="static_library"', {
330+
'sources': [
331+
'src/res/node.rc',
332+
],
333+
}],
328334
],
329335
'defines!': [
330336
'NODE_PLATFORM="win"',
@@ -491,7 +497,7 @@
491497
'target_name': 'node_etw',
492498
'type': 'none',
493499
'conditions': [
494-
[ 'node_use_etw=="true"', {
500+
[ 'node_use_etw=="true" and node_target_type!="static_library"', {
495501
'actions': [
496502
{
497503
'action_name': 'node_etw',
@@ -512,7 +518,7 @@
512518
'target_name': 'node_perfctr',
513519
'type': 'none',
514520
'conditions': [
515-
[ 'node_use_perfctr=="true"', {
521+
[ 'node_use_perfctr=="true" and node_target_type!="static_library"', {
516522
'actions': [
517523
{
518524
'action_name': 'node_perfctr_man',
@@ -574,13 +580,15 @@
574580
'<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc',
575581
],
576582
'conditions': [
577-
[ 'node_use_dtrace=="false" and node_use_etw=="false"', {
583+
[ 'node_use_dtrace=="false" and node_use_etw=="false" or '
584+
'node_target_type=="static_library"', {
578585
'inputs': [ 'src/notrace_macros.py' ]
579586
}],
580-
['node_use_lttng=="false"', {
587+
['node_use_lttng=="false" or node_target_type=="static_library"', {
581588
'inputs': [ 'src/nolttng_macros.py' ]
582589
}],
583-
[ 'node_use_perfctr=="false"', {
590+
[ 'node_use_perfctr=="false" or '
591+
'node_target_type=="static_library"', {
584592
'inputs': [ 'src/noperfctr_macros.py' ]
585593
}]
586594
],
@@ -934,6 +942,47 @@
934942
], # end targets
935943

936944
'conditions': [
945+
[ 'node_target_type=="static_library"', {
946+
'targets': [
947+
{
948+
'target_name': 'static_node',
949+
'type': 'executable',
950+
'product_name': '<(node_core_target_name)',
951+
'dependencies': [
952+
'<(node_core_target_name)',
953+
],
954+
'sources+': [
955+
'src/node_main.cc',
956+
],
957+
'include_dirs': [
958+
'deps/v8/include',
959+
],
960+
'xcode_settings': {
961+
'OTHER_LDFLAGS': [
962+
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)'
963+
'<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
964+
],
965+
},
966+
'msvs_settings': {
967+
'VCLinkerTool': {
968+
'AdditionalOptions': [
969+
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/'
970+
'<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
971+
],
972+
},
973+
},
974+
'conditions': [
975+
['OS in "linux freebsd openbsd solaris android"', {
976+
'ldflags': [
977+
'-Wl,--whole-archive,<(OBJ_DIR)/<(STATIC_LIB_PREFIX)'
978+
'<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
979+
'-Wl,--no-whole-archive',
980+
],
981+
}],
982+
],
983+
},
984+
],
985+
}],
937986
['OS=="aix"', {
938987
'targets': [
939988
{

node.gypi

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
'src/node_lttng.cc'
8484
],
8585
} ],
86-
[ 'node_use_etw=="true"', {
86+
[ 'node_use_etw=="true" and node_target_type!="static_library"', {
8787
'defines': [ 'HAVE_ETW=1' ],
8888
'dependencies': [ 'node_etw' ],
8989
'sources': [
@@ -95,7 +95,7 @@
9595
'tools/msvs/genfiles/node_etw_provider.rc',
9696
]
9797
} ],
98-
[ 'node_use_perfctr=="true"', {
98+
[ 'node_use_perfctr=="true" and node_target_type!="static_library"', {
9999
'defines': [ 'HAVE_PERFCTR=1' ],
100100
'dependencies': [ 'node_perfctr' ],
101101
'sources': [

test/addons/openssl-binding/binding.gyp

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
{
2+
'includes': ['../../../config.gypi'],
3+
'variables': {
4+
'node_target_type%': '',
5+
},
26
'targets': [
37
{
48
'target_name': 'binding',
59
'conditions': [
6-
['node_use_openssl=="true"', {
7-
'sources': ['binding.cc'],
8-
'include_dirs': ['../../../deps/openssl/openssl/include'],
9-
}]
10+
['node_use_openssl=="true"', {
11+
'sources': ['binding.cc'],
12+
'include_dirs': ['../../../deps/openssl/openssl/include'],
13+
'conditions': [
14+
['OS=="win" and node_target_type=="static_library"', {
15+
'libraries': [
16+
'../../../../$(Configuration)/lib/<(OPENSSL_PRODUCT)'
17+
],
18+
}],
19+
],
20+
}]
1021
]
1122
},
1223
]

test/addons/zlib-binding/binding.gyp

+13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
{
2+
'includes': ['../../../config.gypi'],
3+
'variables': {
4+
'node_target_type%': '',
5+
},
26
'targets': [
37
{
48
'target_name': 'binding',
59
'sources': ['binding.cc'],
610
'include_dirs': ['../../../deps/zlib'],
11+
'conditions': [
12+
['node_target_type=="static_library"', {
13+
'conditions': [
14+
['OS=="win"', {
15+
'libraries': ['../../../../$(Configuration)/lib/zlib.lib'],
16+
}],
17+
],
18+
}],
19+
],
720
},
821
]
922
}

0 commit comments

Comments
 (0)