Skip to content

Commit b021403

Browse files
committed
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: nodejs#14986 Refs: nodejs#14158 Refs: nodejs#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 a0b1e2e commit b021403

File tree

5 files changed

+87
-14
lines changed

5 files changed

+87
-14
lines changed

common.gypi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a',
6565
}],
6666
['openssl_fips != ""', {
67-
'OPENSSL_PRODUCT': 'libcrypto.a',
67+
'OPENSSL_PRODUCT': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)',
6868
}, {
69-
'OPENSSL_PRODUCT': 'libopenssl.a',
69+
'OPENSSL_PRODUCT': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)',
7070
}],
7171
['OS=="mac"', {
7272
'clang%': 1,

node.gyp

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,13 @@
341341
[ 'OS=="win"', {
342342
'sources': [
343343
'src/backtrace_win32.cc',
344-
'src/res/node.rc',
344+
],
345+
'conditions': [
346+
[ 'node_target_type!="static_library"', {
347+
'sources': [
348+
'src/res/node.rc',
349+
],
350+
}],
345351
],
346352
'defines!': [
347353
'NODE_PLATFORM="win"',
@@ -508,7 +514,7 @@
508514
'target_name': 'node_etw',
509515
'type': 'none',
510516
'conditions': [
511-
[ 'node_use_etw=="true"', {
517+
[ 'node_use_etw=="true" and node_target_type!="static_library"', {
512518
'actions': [
513519
{
514520
'action_name': 'node_etw',
@@ -529,7 +535,7 @@
529535
'target_name': 'node_perfctr',
530536
'type': 'none',
531537
'conditions': [
532-
[ 'node_use_perfctr=="true"', {
538+
[ 'node_use_perfctr=="true" and node_target_type!="static_library"', {
533539
'actions': [
534540
{
535541
'action_name': 'node_perfctr_man',
@@ -591,13 +597,15 @@
591597
'<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc',
592598
],
593599
'conditions': [
594-
[ 'node_use_dtrace=="false" and node_use_etw=="false"', {
600+
[ 'node_use_dtrace=="false" and node_use_etw=="false" or '
601+
'node_target_type=="static_library"', {
595602
'inputs': [ 'src/notrace_macros.py' ]
596603
}],
597-
['node_use_lttng=="false"', {
604+
['node_use_lttng=="false" or node_target_type=="static_library"', {
598605
'inputs': [ 'src/nolttng_macros.py' ]
599606
}],
600-
[ 'node_use_perfctr=="false"', {
607+
[ 'node_use_perfctr=="false" or '
608+
'node_target_type=="static_library"', {
601609
'inputs': [ 'src/noperfctr_macros.py' ]
602610
}]
603611
],
@@ -952,6 +960,47 @@
952960
], # end targets
953961

954962
'conditions': [
963+
[ 'node_target_type=="static_library"', {
964+
'targets': [
965+
{
966+
'target_name': 'static_node',
967+
'type': 'executable',
968+
'product_name': '<(node_core_target_name)',
969+
'dependencies': [
970+
'<(node_core_target_name)',
971+
],
972+
'sources+': [
973+
'src/node_main.cc',
974+
],
975+
'include_dirs': [
976+
'deps/v8/include',
977+
],
978+
'xcode_settings': {
979+
'OTHER_LDFLAGS': [
980+
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)'
981+
'<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
982+
],
983+
},
984+
'msvs_settings': {
985+
'VCLinkerTool': {
986+
'AdditionalOptions': [
987+
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/'
988+
'<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
989+
],
990+
},
991+
},
992+
'conditions': [
993+
['OS in "linux freebsd openbsd solaris android"', {
994+
'ldflags': [
995+
'-Wl,--whole-archive,<(OBJ_DIR)/<(STATIC_LIB_PREFIX)'
996+
'<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
997+
'-Wl,--no-whole-archive',
998+
],
999+
}],
1000+
],
1001+
},
1002+
],
1003+
}],
9551004
['OS=="aix"', {
9561005
'targets': [
9571006
{

node.gypi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
'src/node_lttng.cc'
7979
],
8080
} ],
81-
[ 'node_use_etw=="true"', {
81+
[ 'node_use_etw=="true" and node_target_type!="static_library"', {
8282
'defines': [ 'HAVE_ETW=1' ],
8383
'dependencies': [ 'node_etw' ],
8484
'sources': [
@@ -90,7 +90,7 @@
9090
'tools/msvs/genfiles/node_etw_provider.rc',
9191
]
9292
} ],
93-
[ 'node_use_perfctr=="true"', {
93+
[ 'node_use_perfctr=="true" and node_target_type!="static_library"', {
9494
'defines': [ 'HAVE_PERFCTR=1' ],
9595
'dependencies': [ 'node_perfctr' ],
9696
'sources': [

test/addons/openssl-binding/binding.gyp

Lines changed: 15 additions & 4 deletions
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
]
Lines changed: 13 additions & 0 deletions
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)