Skip to content

Commit

Permalink
build: fix cctest compilation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
danbev authored and evanlucas committed Nov 13, 2017
1 parent 6c0fd55 commit 02ea0ee
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 177 deletions.
5 changes: 5 additions & 0 deletions doc/guides/writing-tests.md
Expand Up @@ -325,6 +325,11 @@ Next add the test to the `sources` in the `cctest` target in node.gyp:
...
],
```
Note that the only sources that should be included in the cctest target are
actual test or helper source files. There might be a need to include specific
object files that are compiled by the `node` target and this can be done by
adding them to the `libraries` section in the cctest target.

The test can be executed by running the `cctest` target:
```console
$ make cctest
Expand Down
260 changes: 224 additions & 36 deletions node.gyp
Expand Up @@ -309,16 +309,149 @@
'V8_DEPRECATION_WARNINGS=1',
'NODE_OPENSSL_SYSTEM_CERT_PATH="<(openssl_system_ca_path)"',
],

'direct_dependent_settings': {
'defines': [
'NODE_OPENSSL_SYSTEM_CERT_PATH="<(openssl_system_ca_path)"',
],
},
'conditions': [
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
'product_extension': '<(shlib_suffix)',
}]
}],
[ 'v8_enable_inspector==1', {
'defines': [
'HAVE_INSPECTOR=1',
],
'sources': [
'src/inspector_agent.cc',
'src/inspector_io.cc',
'src/inspector_js_api.cc',
'src/inspector_socket.cc',
'src/inspector_socket_server.cc',
'src/inspector_agent.h',
'src/inspector_io.h',
'src/inspector_socket.h',
'src/inspector_socket_server.h',
],
'dependencies': [
'v8_inspector_compress_protocol_json#host',
],
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/include', # for inspector
'<(SHARED_INTERMEDIATE_DIR)',
],
}, {
'defines': [ 'HAVE_INSPECTOR=0' ]
}],
[ 'OS=="win"', {
'sources': [
'src/backtrace_win32.cc',
'src/res/node.rc',
],
'defines!': [
'NODE_PLATFORM="win"',
],
'defines': [
'FD_SETSIZE=1024',
# we need to use node's preferred "win32" rather than gyp's preferred "win"
'NODE_PLATFORM="win32"',
'_UNICODE=1',
],
'libraries': [ '-lpsapi.lib' ]
}, { # POSIX
'defines': [ '__POSIX__' ],
'sources': [ 'src/backtrace_posix.cc' ],
}],
[ 'node_use_dtrace=="true"', {
'defines': [ 'HAVE_DTRACE=1' ],
'dependencies': [
'node_dtrace_header',
'specialize_node_d',
],
'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
#
# DTrace is supported on linux, solaris, mac, and bsd. There are
# three object files associated with DTrace support, but they're
# not all used all the time:
#
# node_dtrace.o all configurations
# node_dtrace_ustack.o not supported on mac and linux
# node_dtrace_provider.o All except OS X. "dtrace -G" is not
# used on OS X.
#
# Note that node_dtrace_provider.cc and node_dtrace_ustack.cc do not
# actually exist. They're listed here to trick GYP into linking the
# corresponding object files into the final "node" executable. These
# object files are generated by "dtrace -G" using custom actions
# below, and the GYP-generated Makefiles will properly build them when
# needed.
#
'sources': [ 'src/node_dtrace.cc' ],
'conditions': [
[ 'OS=="linux"', {
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o'
],
}],
[ 'OS!="mac" and OS!="linux"', {
'sources': [
'src/node_dtrace_ustack.cc',
'src/node_dtrace_provider.cc',
]
}
] ]
} ],
[ 'node_use_openssl=="true"', {
'defines': [ 'HAVE_OPENSSL=1' ],
'sources': [
'src/node_crypto.cc',
'src/node_crypto_bio.cc',
'src/node_crypto_clienthello.cc',
'src/node_crypto.h',
'src/node_crypto_bio.h',
'src/node_crypto_clienthello.h',
'src/tls_wrap.cc',
'src/tls_wrap.h'
],
'conditions': [
['openssl_fips != ""', {
'defines': [ 'NODE_FIPS_MODE' ],
}],
[ 'node_shared_openssl=="false"', {
'dependencies': [
'./deps/openssl/openssl.gyp:openssl',

# For tests
'./deps/openssl/openssl.gyp:openssl-cli',
],
'conditions': [
# -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)/<(OPENSSL_PRODUCT)',
],
},
'conditions': [
['OS in "linux freebsd" and node_shared=="false"', {
'ldflags': [
'-Wl,--whole-archive,'
'<(OBJ_DIR)/deps/openssl/'
'<(OPENSSL_PRODUCT)',
'-Wl,--no-whole-archive',
],
}],
# openssl.def is based on zlib.def, zlib symbols
# are always exported.
['use_openssl_def==1', {
'sources': ['<(SHARED_INTERMEDIATE_DIR)/openssl.def'],
}],
['OS=="win" and use_openssl_def==0', {
'sources': ['deps/zlib/win32/zlib.def'],
}],
],
}],
],
}]]
}, {
'defines': [ 'HAVE_OPENSSL=0' ]
}],
],
},
{
Expand Down Expand Up @@ -675,8 +808,6 @@
'defines': [ 'NODE_WANT_INTERNALS=1' ],

'sources': [
'src/node_platform.cc',
'src/node_platform.h',
'test/cctest/node_test_fixture.cc',
'test/cctest/test_aliased_buffer.cc',
'test/cctest/test_base64.cc',
Expand All @@ -692,14 +823,14 @@
'conditions': [
['node_target_type!="static_library"', {
'libraries': [
'<(OBJ_GEN_PATH)<(OBJ_SEPARATOR)node_javascript.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_debug_options.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)async-wrap.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)env.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_buffer.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_debug_options.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_i18n.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_perf.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_platform.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_url.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)util.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)string_bytes.<(OBJ_SUFFIX)',
Expand All @@ -710,40 +841,46 @@
'<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)node_trace_buffer.<(OBJ_SUFFIX)',
'<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)node_trace_writer.<(OBJ_SUFFIX)',
'<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)trace_event.<(OBJ_SUFFIX)',
'<(OBJ_GEN_PATH)<(OBJ_SEPARATOR)node_javascript.<(OBJ_SUFFIX)',
],
}],
[ 'node_use_openssl=="true"', {
'libraries': [
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_crypto.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_crypto_bio.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_crypto_clienthello.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)tls_wrap.<(OBJ_SUFFIX)',
],
}],
['v8_enable_inspector==1', {
'sources': [
'test/cctest/test_inspector_socket.cc',
'test/cctest/test_inspector_socket_server.cc'
],
'conditions': [
[ 'node_shared_zlib=="false"', {
'dependencies': [
'deps/zlib/zlib.gyp:zlib',
]
}],
[ 'node_shared_openssl=="false" and node_shared=="false"', {
'dependencies': [
'deps/openssl/openssl.gyp:openssl'
]
}],
[ 'node_shared_http_parser=="false"', {
'dependencies': [
'deps/http_parser/http_parser.gyp:http_parser'
]
}],
[ 'node_shared_libuv=="false"', {
'dependencies': [
'deps/uv/uv.gyp:libuv'
]
}]
'libraries': [
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_agent.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_io.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_js_api.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_socket.<(OBJ_SUFFIX)',
'<(OBJ_PATH)<(OBJ_SEPARATOR)inspector_socket_server.<(OBJ_SUFFIX)',
],
'defines': [
'HAVE_INSPECTOR=1',
],
}],
[ 'node_use_dtrace=="true"', {
'libraries': [
'<(OBJ_PATH)<(OBJ_SEPARATOR)node_dtrace.<(OBJ_SUFFIX)',
]
}],
[ 'node_use_v8_platform=="true"', {
'dependencies': [
'deps/v8/src/v8.gyp:v8_libplatform',
],
[ 'OS=="win"', {
'libraries': [
'<(OBJ_PATH)<(OBJ_SEPARATOR)backtrace_win32.<(OBJ_SUFFIX)',
],
}, {
'libraries': [
'<(OBJ_PATH)<(OBJ_SEPARATOR)backtrace_posix.<(OBJ_SUFFIX)',
],
}],
[ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
'copies': [{
Expand All @@ -755,9 +892,60 @@
]},
],
}],
[ 'node_shared_zlib=="false"', {
'dependencies': [
'deps/zlib/zlib.gyp:zlib',
]
}],
[ 'node_shared_openssl=="false" and node_shared=="false"', {
'dependencies': [
'deps/openssl/openssl.gyp:openssl'
]
}],
[ 'node_shared_http_parser=="false"', {
'dependencies': [
'deps/http_parser/http_parser.gyp:http_parser'
]
}],
[ 'node_shared_libuv=="false"', {
'dependencies': [
'deps/uv/uv.gyp:libuv'
]
}],
[ 'node_use_v8_platform=="true"', {
'dependencies': [
'deps/v8/src/v8.gyp:v8_libplatform',
],
}],
['OS=="solaris"', {
'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ]
}],
[ 'node_use_openssl=="true"', {
'conditions': [
[ 'node_shared_openssl=="false"', {
'conditions': [
# -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)/<(OPENSSL_PRODUCT)',
],
},
'conditions': [
['OS in "linux freebsd" and node_shared=="false"', {
'ldflags': [
'-Wl,--whole-archive,'
'<(OBJ_DIR)/deps/openssl/'
'<(OPENSSL_PRODUCT)',
'-Wl,--no-whole-archive',
],
}],
],
}],
],
}]]
}],
]
}
], # end targets
Expand Down

0 comments on commit 02ea0ee

Please sign in to comment.