Skip to content

Commit 02ea0ee

Browse files
danbevevanlucas
authored andcommitted
build: fix cctest compilation
Currently the cctest target compiles sources files even though they are compiled for the node target. This is my fault as when I worked on the task of getting the cctest to use the object files from the node target I missed a few sources that were being included from node.gypi. This also effects the build time as these sources are compiled twice. This commit moves the conditions in question into the node target in node.gyp. With this commit there should be no object files in out/Release/obj.target/cctest/src/ (the path will vary depending on the operating system being used). PR-URL:#16887 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 6c0fd55 commit 02ea0ee

File tree

3 files changed

+229
-177
lines changed

3 files changed

+229
-177
lines changed

doc/guides/writing-tests.md

+5
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ Next add the test to the `sources` in the `cctest` target in node.gyp:
325325
...
326326
],
327327
```
328+
Note that the only sources that should be included in the cctest target are
329+
actual test or helper source files. There might be a need to include specific
330+
object files that are compiled by the `node` target and this can be done by
331+
adding them to the `libraries` section in the cctest target.
332+
328333
The test can be executed by running the `cctest` target:
329334
```console
330335
$ make cctest

node.gyp

+224-36
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,149 @@
309309
'V8_DEPRECATION_WARNINGS=1',
310310
'NODE_OPENSSL_SYSTEM_CERT_PATH="<(openssl_system_ca_path)"',
311311
],
312-
313-
'direct_dependent_settings': {
314-
'defines': [
315-
'NODE_OPENSSL_SYSTEM_CERT_PATH="<(openssl_system_ca_path)"',
316-
],
317-
},
318312
'conditions': [
319313
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
320314
'product_extension': '<(shlib_suffix)',
321-
}]
315+
}],
316+
[ 'v8_enable_inspector==1', {
317+
'defines': [
318+
'HAVE_INSPECTOR=1',
319+
],
320+
'sources': [
321+
'src/inspector_agent.cc',
322+
'src/inspector_io.cc',
323+
'src/inspector_js_api.cc',
324+
'src/inspector_socket.cc',
325+
'src/inspector_socket_server.cc',
326+
'src/inspector_agent.h',
327+
'src/inspector_io.h',
328+
'src/inspector_socket.h',
329+
'src/inspector_socket_server.h',
330+
],
331+
'dependencies': [
332+
'v8_inspector_compress_protocol_json#host',
333+
],
334+
'include_dirs': [
335+
'<(SHARED_INTERMEDIATE_DIR)/include', # for inspector
336+
'<(SHARED_INTERMEDIATE_DIR)',
337+
],
338+
}, {
339+
'defines': [ 'HAVE_INSPECTOR=0' ]
340+
}],
341+
[ 'OS=="win"', {
342+
'sources': [
343+
'src/backtrace_win32.cc',
344+
'src/res/node.rc',
345+
],
346+
'defines!': [
347+
'NODE_PLATFORM="win"',
348+
],
349+
'defines': [
350+
'FD_SETSIZE=1024',
351+
# we need to use node's preferred "win32" rather than gyp's preferred "win"
352+
'NODE_PLATFORM="win32"',
353+
'_UNICODE=1',
354+
],
355+
'libraries': [ '-lpsapi.lib' ]
356+
}, { # POSIX
357+
'defines': [ '__POSIX__' ],
358+
'sources': [ 'src/backtrace_posix.cc' ],
359+
}],
360+
[ 'node_use_dtrace=="true"', {
361+
'defines': [ 'HAVE_DTRACE=1' ],
362+
'dependencies': [
363+
'node_dtrace_header',
364+
'specialize_node_d',
365+
],
366+
'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
367+
#
368+
# DTrace is supported on linux, solaris, mac, and bsd. There are
369+
# three object files associated with DTrace support, but they're
370+
# not all used all the time:
371+
#
372+
# node_dtrace.o all configurations
373+
# node_dtrace_ustack.o not supported on mac and linux
374+
# node_dtrace_provider.o All except OS X. "dtrace -G" is not
375+
# used on OS X.
376+
#
377+
# Note that node_dtrace_provider.cc and node_dtrace_ustack.cc do not
378+
# actually exist. They're listed here to trick GYP into linking the
379+
# corresponding object files into the final "node" executable. These
380+
# object files are generated by "dtrace -G" using custom actions
381+
# below, and the GYP-generated Makefiles will properly build them when
382+
# needed.
383+
#
384+
'sources': [ 'src/node_dtrace.cc' ],
385+
'conditions': [
386+
[ 'OS=="linux"', {
387+
'sources': [
388+
'<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o'
389+
],
390+
}],
391+
[ 'OS!="mac" and OS!="linux"', {
392+
'sources': [
393+
'src/node_dtrace_ustack.cc',
394+
'src/node_dtrace_provider.cc',
395+
]
396+
}
397+
] ]
398+
} ],
399+
[ 'node_use_openssl=="true"', {
400+
'defines': [ 'HAVE_OPENSSL=1' ],
401+
'sources': [
402+
'src/node_crypto.cc',
403+
'src/node_crypto_bio.cc',
404+
'src/node_crypto_clienthello.cc',
405+
'src/node_crypto.h',
406+
'src/node_crypto_bio.h',
407+
'src/node_crypto_clienthello.h',
408+
'src/tls_wrap.cc',
409+
'src/tls_wrap.h'
410+
],
411+
'conditions': [
412+
['openssl_fips != ""', {
413+
'defines': [ 'NODE_FIPS_MODE' ],
414+
}],
415+
[ 'node_shared_openssl=="false"', {
416+
'dependencies': [
417+
'./deps/openssl/openssl.gyp:openssl',
418+
419+
# For tests
420+
'./deps/openssl/openssl.gyp:openssl-cli',
421+
],
422+
'conditions': [
423+
# -force_load or --whole-archive are not applicable for
424+
# the static library
425+
[ 'node_target_type!="static_library"', {
426+
'xcode_settings': {
427+
'OTHER_LDFLAGS': [
428+
'-Wl,-force_load,<(PRODUCT_DIR)/<(OPENSSL_PRODUCT)',
429+
],
430+
},
431+
'conditions': [
432+
['OS in "linux freebsd" and node_shared=="false"', {
433+
'ldflags': [
434+
'-Wl,--whole-archive,'
435+
'<(OBJ_DIR)/deps/openssl/'
436+
'<(OPENSSL_PRODUCT)',
437+
'-Wl,--no-whole-archive',
438+
],
439+
}],
440+
# openssl.def is based on zlib.def, zlib symbols
441+
# are always exported.
442+
['use_openssl_def==1', {
443+
'sources': ['<(SHARED_INTERMEDIATE_DIR)/openssl.def'],
444+
}],
445+
['OS=="win" and use_openssl_def==0', {
446+
'sources': ['deps/zlib/win32/zlib.def'],
447+
}],
448+
],
449+
}],
450+
],
451+
}]]
452+
}, {
453+
'defines': [ 'HAVE_OPENSSL=0' ]
454+
}],
322455
],
323456
},
324457
{
@@ -675,8 +808,6 @@
675808
'defines': [ 'NODE_WANT_INTERNALS=1' ],
676809

677810
'sources': [
678-
'src/node_platform.cc',
679-
'src/node_platform.h',
680811
'test/cctest/node_test_fixture.cc',
681812
'test/cctest/test_aliased_buffer.cc',
682813
'test/cctest/test_base64.cc',
@@ -692,14 +823,14 @@
692823
'conditions': [
693824
['node_target_type!="static_library"', {
694825
'libraries': [
695-
'<(OBJ_GEN_PATH)<(OBJ_SEPARATOR)node_javascript.<(OBJ_SUFFIX)',
696-
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_debug_options.<(OBJ_SUFFIX)',
697826
'<(OBJ_PATH)<(OBJ_SEPARATOR)async-wrap.<(OBJ_SUFFIX)',
698827
'<(OBJ_PATH)<(OBJ_SEPARATOR)env.<(OBJ_SUFFIX)',
699828
'<(OBJ_PATH)<(OBJ_SEPARATOR)node.<(OBJ_SUFFIX)',
700829
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_buffer.<(OBJ_SUFFIX)',
830+
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_debug_options.<(OBJ_SUFFIX)',
701831
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_i18n.<(OBJ_SUFFIX)',
702832
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_perf.<(OBJ_SUFFIX)',
833+
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_platform.<(OBJ_SUFFIX)',
703834
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_url.<(OBJ_SUFFIX)',
704835
'<(OBJ_PATH)<(OBJ_SEPARATOR)util.<(OBJ_SUFFIX)',
705836
'<(OBJ_PATH)<(OBJ_SEPARATOR)string_bytes.<(OBJ_SUFFIX)',
@@ -710,40 +841,46 @@
710841
'<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)node_trace_buffer.<(OBJ_SUFFIX)',
711842
'<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)node_trace_writer.<(OBJ_SUFFIX)',
712843
'<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)trace_event.<(OBJ_SUFFIX)',
844+
'<(OBJ_GEN_PATH)<(OBJ_SEPARATOR)node_javascript.<(OBJ_SUFFIX)',
845+
],
846+
}],
847+
[ 'node_use_openssl=="true"', {
848+
'libraries': [
849+
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_crypto.<(OBJ_SUFFIX)',
850+
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_crypto_bio.<(OBJ_SUFFIX)',
851+
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_crypto_clienthello.<(OBJ_SUFFIX)',
852+
'<(OBJ_PATH)<(OBJ_SEPARATOR)tls_wrap.<(OBJ_SUFFIX)',
713853
],
714854
}],
715855
['v8_enable_inspector==1', {
716856
'sources': [
717857
'test/cctest/test_inspector_socket.cc',
718858
'test/cctest/test_inspector_socket_server.cc'
719859
],
720-
'conditions': [
721-
[ 'node_shared_zlib=="false"', {
722-
'dependencies': [
723-
'deps/zlib/zlib.gyp:zlib',
724-
]
725-
}],
726-
[ 'node_shared_openssl=="false" and node_shared=="false"', {
727-
'dependencies': [
728-
'deps/openssl/openssl.gyp:openssl'
729-
]
730-
}],
731-
[ 'node_shared_http_parser=="false"', {
732-
'dependencies': [
733-
'deps/http_parser/http_parser.gyp:http_parser'
734-
]
735-
}],
736-
[ 'node_shared_libuv=="false"', {
737-
'dependencies': [
738-
'deps/uv/uv.gyp:libuv'
739-
]
740-
}]
860+
'libraries': [
861+
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_agent.<(OBJ_SUFFIX)',
862+
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_io.<(OBJ_SUFFIX)',
863+
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_js_api.<(OBJ_SUFFIX)',
864+
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_socket.<(OBJ_SUFFIX)',
865+
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_socket_server.<(OBJ_SUFFIX)',
866+
],
867+
'defines': [
868+
'HAVE_INSPECTOR=1',
869+
],
870+
}],
871+
[ 'node_use_dtrace=="true"', {
872+
'libraries': [
873+
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_dtrace.<(OBJ_SUFFIX)',
741874
]
742875
}],
743-
[ 'node_use_v8_platform=="true"', {
744-
'dependencies': [
745-
'deps/v8/src/v8.gyp:v8_libplatform',
746-
],
876+
[ 'OS=="win"', {
877+
'libraries': [
878+
'<(OBJ_PATH)<(OBJ_SEPARATOR)backtrace_win32.<(OBJ_SUFFIX)',
879+
],
880+
}, {
881+
'libraries': [
882+
'<(OBJ_PATH)<(OBJ_SEPARATOR)backtrace_posix.<(OBJ_SUFFIX)',
883+
],
747884
}],
748885
[ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
749886
'copies': [{
@@ -755,9 +892,60 @@
755892
]},
756893
],
757894
}],
895+
[ 'node_shared_zlib=="false"', {
896+
'dependencies': [
897+
'deps/zlib/zlib.gyp:zlib',
898+
]
899+
}],
900+
[ 'node_shared_openssl=="false" and node_shared=="false"', {
901+
'dependencies': [
902+
'deps/openssl/openssl.gyp:openssl'
903+
]
904+
}],
905+
[ 'node_shared_http_parser=="false"', {
906+
'dependencies': [
907+
'deps/http_parser/http_parser.gyp:http_parser'
908+
]
909+
}],
910+
[ 'node_shared_libuv=="false"', {
911+
'dependencies': [
912+
'deps/uv/uv.gyp:libuv'
913+
]
914+
}],
915+
[ 'node_use_v8_platform=="true"', {
916+
'dependencies': [
917+
'deps/v8/src/v8.gyp:v8_libplatform',
918+
],
919+
}],
758920
['OS=="solaris"', {
759921
'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ]
760922
}],
923+
[ 'node_use_openssl=="true"', {
924+
'conditions': [
925+
[ 'node_shared_openssl=="false"', {
926+
'conditions': [
927+
# -force_load or --whole-archive are not applicable for
928+
# the static library
929+
[ 'node_target_type!="static_library"', {
930+
'xcode_settings': {
931+
'OTHER_LDFLAGS': [
932+
'-Wl,-force_load,<(PRODUCT_DIR)/<(OPENSSL_PRODUCT)',
933+
],
934+
},
935+
'conditions': [
936+
['OS in "linux freebsd" and node_shared=="false"', {
937+
'ldflags': [
938+
'-Wl,--whole-archive,'
939+
'<(OBJ_DIR)/deps/openssl/'
940+
'<(OPENSSL_PRODUCT)',
941+
'-Wl,--no-whole-archive',
942+
],
943+
}],
944+
],
945+
}],
946+
],
947+
}]]
948+
}],
761949
]
762950
}
763951
], # end targets

0 commit comments

Comments
 (0)