From 2d25fcfdda7b50486bbf751da7c1e04fc33ef38b Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Mon, 8 Apr 2019 10:42:53 -0400 Subject: [PATCH 1/2] build: fold dtrace targets into actions --- dtrace.gypi | 185 +++++++++++++++++++++++++++++++++++++++++ node.gyp | 235 +++++----------------------------------------------- 2 files changed, 208 insertions(+), 212 deletions(-) create mode 100644 dtrace.gypi diff --git a/dtrace.gypi b/dtrace.gypi new file mode 100644 index 00000000000000..5a5e6a2f1b5b4d --- /dev/null +++ b/dtrace.gypi @@ -0,0 +1,185 @@ +{ + 'defines': ['HAVE_DTRACE=1'], + 'variables': { + 'generated_node_dtrace_header': '<(INTERMEDIATE_DIR)/node_dtrace_header', + }, + 'include_dirs': [ + '<(generated_node_dtrace_header)' + ], + # + # 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.h', + 'src/node_dtrace.cc', + ], + 'conditions': [ + ['OS=="linux"', { + 'actions': [ + { + 'action_name': 'node_dtrace_header', + 'process_outputs_as_sources': 1, + 'inputs': [ + 'src/node_provider.d' + ], + 'outputs': [ + '<(generated_node_dtrace_header)/node_provider.h' + ], + 'action': [ + 'dtrace', '-h', + '-s', '<@(_inputs)', + '-o', '<@(_outputs)', + ] + }, + { + 'action_name': 'node_dtrace_provider_o', + 'process_outputs_as_sources': 1, + 'inputs': [ + 'src/node_provider.d' + ], + 'outputs': [ + '<(generated_node_dtrace_header)/node_dtrace_provider.o' + ], + 'action': [ + 'dtrace', '-C', '-G', + '-s', '<@(_inputs)', + '-o', '<@(_outputs)', + ], + }, + ], + }], + ['node_use_dtrace=="true" and OS!="linux"', { + 'actions': [ + { + 'action_name': 'node_dtrace_header', + 'process_outputs_as_sources': 1, + 'inputs': ['src/node_provider.d'], + 'outputs': ['<(generated_node_dtrace_header)/node_provider.h'], + 'action': ['dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)', + '-o', '<@(_outputs)'] + } + ] + }], + ['node_use_dtrace=="true" and OS=="linux"', { + 'actions': [ + { + 'action_name': 'node_dtrace_header', + 'process_outputs_as_sources': 1, + 'inputs': ['src/node_provider.d'], + 'outputs': ['<(generated_node_dtrace_header)/node_provider.h'], + 'action': ['dtrace', '-h', '-s', '<@(_inputs)', + '-o', '<@(_outputs)'] + } + ] + }], + ['node_use_dtrace=="true" and OS!="mac" and OS!="linux"', { + 'actions': [ + { + 'action_name': 'node_dtrace_provider_o', + 'process_outputs_as_sources': 1, + 'inputs': [ + '<(obj_dir)/<(node_lib_target_name)/src/node_dtrace.o', + ], + 'outputs': [ + '<(obj_dir)/<(node_lib_target_name)/src/node_dtrace_provider.o' + ], + 'action': ['dtrace', '-G', '-xnolibs', '-s', 'src/node_provider.d', + '<@(_inputs)', '-o', '<@(_outputs)'] + } + ] + }], + ['node_use_dtrace=="true" and OS=="linux"', { + 'actions': [ + { + 'action_name': 'node_dtrace_provider_o', + 'process_outputs_as_sources': 1, + 'inputs': ['src/node_provider.d'], + 'outputs': [ + '<(generated_node_dtrace_header)/node_dtrace_provider.o' + ], + 'action': [ + 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)' + ], + } + ], + }], + ['node_use_dtrace=="true" and OS!="mac" and OS!="linux"', { + 'actions': [ + { + 'action_name': 'node_dtrace_ustack_constants', + 'process_outputs_as_sources': 1, + 'inputs': [ + '<(v8_base)' + ], + 'outputs': [ + '<(generated_node_dtrace_header)/v8constants.h' + ], + 'action': [ + 'tools/genv8constants.py', + '<@(_outputs)', + '<@(_inputs)' + ] + }, + { + 'action_name': 'node_dtrace_ustack', + 'process_outputs_as_sources': 1, + 'inputs': [ + 'src/v8ustack.d', + '<(generated_node_dtrace_header)/v8constants.h' + ], + 'outputs': [ + '<(obj_dir)/<(node_lib_target_name)/src/node_dtrace_ustack.o' + ], + 'conditions': [ + ['target_arch=="ia32" or target_arch=="arm"', { + 'action': [ + 'dtrace', '-32', '-I<(generated_node_dtrace_header)', '-Isrc', + '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)', + ] + }], + ['target_arch=="x64"', { + 'action': [ + 'dtrace', '-64', '-I<(generated_node_dtrace_header)', '-Isrc', + '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)', + ] + }], + ] + }, + ] + }], + ['node_use_dtrace=="true"', { + 'actions': [ + { + 'action_name': 'specialize_node_d', + 'inputs': [ + 'src/node.d' + ], + 'outputs': [ + '<(PRODUCT_DIR)/node.d', + ], + 'action': [ + 'tools/specialize_node_d.py', + '<@(_outputs)', + '<@(_inputs)', + '<@(OS)', + '<@(target_arch)', + ], + }, + ], + }], + ], +} diff --git a/node.gyp b/node.gyp index 2ad76020f5784c..d3f574b1e8e4af 100644 --- a/node.gyp +++ b/node.gyp @@ -263,7 +263,7 @@ ], 'include_dirs': [ 'src', - 'deps/v8/include' + 'deps/v8/include', ], 'dependencies': [ 'deps/histogram/histogram.gyp:histogram' ], @@ -295,8 +295,8 @@ [ 'node_intermediate_lib_type=="static_library" and node_shared=="false"', { 'xcode_settings': { 'OTHER_LDFLAGS': [ - '-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)' - '<(node_core_target_name)<(STATIC_LIB_SUFFIX)', + '-Wl,-force_load,' + '<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)', ], }, 'msvs_settings': { @@ -309,8 +309,8 @@ 'conditions': [ ['OS!="aix"', { 'ldflags': [ - '-Wl,--whole-archive,<(obj_dir)/<(STATIC_LIB_PREFIX)' - '<(node_core_target_name)<(STATIC_LIB_SUFFIX)', + '-Wl,--whole-archive,' + '<(obj_dir)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)', '-Wl,--no-whole-archive', ], }], @@ -385,7 +385,7 @@ 'type': '<(node_intermediate_lib_type)', 'product_name': '<(node_core_target_name)', 'includes': [ - 'node.gypi' + 'node.gypi', ], 'include_dirs': [ @@ -586,6 +586,11 @@ 'msvs_disabled_warnings!': [4244], 'conditions': [ + [ 'node_use_dtrace=="true"', { + 'includes': [ + 'dtrace.gypi', + ], + }], [ 'node_code_cache_path!=""', { 'sources': [ '<(node_code_cache_path)' ] }, { @@ -621,11 +626,9 @@ }], [ 'node_use_etw=="true"', { 'defines': [ 'HAVE_ETW=1' ], - 'dependencies': [ 'node_etw' ], 'include_dirs': [ 'src', 'tools/msvs/genfiles', - '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h ], 'sources': [ 'src/node_win32_etw_provider.h', @@ -642,49 +645,19 @@ ], }], ], - }], - [ '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.h', - 'src/node_dtrace.cc', - ], - 'conditions': [ - [ 'OS=="linux"', { - 'sources': [ - '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o' + 'actions': [ + { + 'action_name': 'node_etw', + 'inputs': [ 'src/res/node_etw_provider.man' ], + 'outputs': [ + 'tools/msvs/genfiles/node_etw_provider.rc', + 'tools/msvs/genfiles/node_etw_provider.h', + 'tools/msvs/genfiles/node_etw_providerTEMP.BIN', ], - }], - [ 'OS!="mac" and OS!="linux"', { - 'sources': [ - 'src/node_dtrace_ustack.cc', - 'src/node_dtrace_provider.cc', - ] - } - ] ] - } ], + 'action': [ 'mc <@(_inputs) -h tools/msvs/genfiles -r tools/msvs/genfiles' ] + }, # node_etw + ], + }], [ 'node_use_openssl=="true"', { 'sources': [ 'src/node_crypto.cc', @@ -802,164 +775,6 @@ }, ], }, # node_lib_target_name - { - # generate ETW header and resource files - 'target_name': 'node_etw', - 'type': 'none', - 'conditions': [ - [ 'node_use_etw=="true"', { - 'actions': [ - { - 'action_name': 'node_etw', - 'inputs': [ 'src/res/node_etw_provider.man' ], - 'outputs': [ - 'tools/msvs/genfiles/node_etw_provider.rc', - 'tools/msvs/genfiles/node_etw_provider.h', - 'tools/msvs/genfiles/node_etw_providerTEMP.BIN', - ], - 'action': [ 'mc <@(_inputs) -h tools/msvs/genfiles -r tools/msvs/genfiles' ] - } - ] - } ] - ] - }, # node_etw - { - 'target_name': 'node_dtrace_header', - 'type': 'none', - 'conditions': [ - [ 'node_use_dtrace=="true" and OS!="linux"', { - 'actions': [ - { - 'action_name': 'node_dtrace_header', - 'inputs': [ 'src/node_provider.d' ], - 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ], - 'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)', - '-o', '<@(_outputs)' ] - } - ] - } ], - [ 'node_use_dtrace=="true" and OS=="linux"', { - 'actions': [ - { - 'action_name': 'node_dtrace_header', - 'inputs': [ 'src/node_provider.d' ], - 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ], - 'action': [ 'dtrace', '-h', '-s', '<@(_inputs)', - '-o', '<@(_outputs)' ] - } - ] - } ], - ] - }, # node_dtrace_header - { - 'target_name': 'node_dtrace_provider', - 'type': 'none', - 'conditions': [ - [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', { - 'actions': [ - { - 'action_name': 'node_dtrace_provider_o', - 'inputs': [ - '<(obj_dir)/<(node_lib_target_name)/src/node_dtrace.o', - ], - 'outputs': [ - '<(obj_dir)/<(node_lib_target_name)/src/node_dtrace_provider.o' - ], - 'action': [ 'dtrace', '-G', '-xnolibs', '-s', 'src/node_provider.d', - '<@(_inputs)', '-o', '<@(_outputs)' ] - } - ] - }], - [ 'node_use_dtrace=="true" and OS=="linux"', { - 'actions': [ - { - 'action_name': 'node_dtrace_provider_o', - 'inputs': [ 'src/node_provider.d' ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o' - ], - 'action': [ - 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)' - ], - } - ], - }], - ] - }, # node_dtrace_provider - { - 'target_name': 'node_dtrace_ustack', - 'type': 'none', - 'conditions': [ - [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', { - 'actions': [ - { - 'action_name': 'node_dtrace_ustack_constants', - 'inputs': [ - '<(v8_base)' - ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/v8constants.h' - ], - 'action': [ - 'tools/genv8constants.py', - '<@(_outputs)', - '<@(_inputs)' - ] - }, - { - 'action_name': 'node_dtrace_ustack', - 'inputs': [ - 'src/v8ustack.d', - '<(SHARED_INTERMEDIATE_DIR)/v8constants.h' - ], - 'outputs': [ - '<(obj_dir)/<(node_lib_target_name)/src/node_dtrace_ustack.o' - ], - 'conditions': [ - [ 'target_arch=="ia32" or target_arch=="arm"', { - 'action': [ - 'dtrace', '-32', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc', - '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)', - ] - } ], - [ 'target_arch=="x64"', { - 'action': [ - 'dtrace', '-64', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc', - '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)', - ] - } ], - ] - }, - ] - } ], - ] - }, # node_dtrace_ustack - { - 'target_name': 'specialize_node_d', - 'type': 'none', - 'conditions': [ - [ 'node_use_dtrace=="true"', { - 'actions': [ - { - 'action_name': 'specialize_node_d', - 'inputs': [ - 'src/node.d' - ], - 'outputs': [ - '<(PRODUCT_DIR)/node.d', - ], - 'action': [ - 'tools/specialize_node_d.py', - '<@(_outputs)', - '<@(_inputs)', - '<@(OS)', - '<@(target_arch)', - ], - }, - ], - } ], - ] - }, # specialize_node_d { # When using shared lib to build executable in Windows, in order to avoid # filename collision, the executable name is node-win.exe. Need to rename @@ -997,9 +812,6 @@ 'rename_node_bin_win', 'deps/gtest/gtest.gyp:gtest', 'deps/histogram/histogram.gyp:histogram', - 'node_dtrace_header', - 'node_dtrace_ustack', - 'node_dtrace_provider', ], 'includes': [ @@ -1012,7 +824,6 @@ 'deps/v8/include', 'deps/cares/include', 'deps/uv/include', - '<(SHARED_INTERMEDIATE_DIR)', # for node_natives.h ], 'defines': [ 'NODE_WANT_INTERNALS=1' ], From 380d1a6b9ce4436635e02a65d32198699b0fdb07 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Sun, 7 Apr 2019 12:07:15 -0400 Subject: [PATCH 2/2] build: fix gtest build for C++17 * Remove use of `tr1` namespace * Sync file list --- deps/gtest/gtest.gyp | 37 ++++++++++++++++++++++++++++++++++--- node.gyp | 14 +++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/deps/gtest/gtest.gyp b/deps/gtest/gtest.gyp index c7c850c52cb83f..fdac53ded31294 100644 --- a/deps/gtest/gtest.gyp +++ b/deps/gtest/gtest.gyp @@ -3,11 +3,22 @@ { 'target_name': 'gtest', 'type': 'static_library', - 'cflags': ['-Wno-missing-field-initializers'], + 'cflags': [ + '-Wno-missing-field-initializers', + ], 'direct_dependent_settings': { - 'include_dirs': ['include'], + 'include_dirs': [ + 'include', + ], }, - 'include_dirs': ['.', 'include'], + 'defines': [ + 'GTEST_LANG_CXX11=1', + 'GTEST_HAS_TR1_TUPLE=0', + ], + 'include_dirs': [ + '.', + 'include', + ], 'sources': [ 'src/gtest-death-test.cc', 'src/gtest-filepath.cc', @@ -18,6 +29,26 @@ 'src/gtest-typed-test.cc', 'src/gtest.cc', 'src/gtest_main.cc', + 'include/gtest/internal/gtest-death-test-internal.h', + 'include/gtest/internal/gtest-filepath.h', + 'include/gtest/internal/gtest-internal.h', + 'include/gtest/internal/gtest-linked_ptr.h', + 'include/gtest/internal/gtest-param-util.h', + 'include/gtest/internal/gtest-param-util-generated.h', + 'include/gtest/internal/gtest-port.h', + 'include/gtest/internal/gtest-string.h', + 'include/gtest/internal/gtest-tuple.h', + 'include/gtest/internal/gtest-type-util.h', + 'include/gtest/gtest.h', + 'include/gtest/gtest-death-test.h', + 'include/gtest/gtest-message.h', + 'include/gtest/gtest-param-test.h', + 'include/gtest/gtest-printers.h', + 'include/gtest/gtest-spi.h', + 'include/gtest/gtest-test-part.h', + 'include/gtest/gtest-typed-test.h', + 'include/gtest/gtest_pred_impl.h', + 'include/gtest/gtest_prod.h', ], } ], diff --git a/node.gyp b/node.gyp index d3f574b1e8e4af..50319c92834573 100644 --- a/node.gyp +++ b/node.gyp @@ -826,20 +826,28 @@ 'deps/uv/include', ], - 'defines': [ 'NODE_WANT_INTERNALS=1' ], + 'defines': [ + 'NODE_WANT_INTERNALS=1', + 'GTEST_LANG_CXX11=1', + 'GTEST_HAS_TR1_TUPLE=0', + ], 'sources': [ 'test/cctest/node_test_fixture.cc', 'test/cctest/test_aliased_buffer.cc', 'test/cctest/test_base64.cc', - 'test/cctest/test_node_postmortem_metadata.cc', 'test/cctest/test_environment.cc', + # Listed here for completeness. Actual inclusion is conditional. + # 'test/cctest/test_inspector_socket.cc', + # 'test/cctest/test_inspector_socket_server.cc', 'test/cctest/test_linked_binding.cc', + 'test/cctest/test_node_postmortem_metadata.cc', 'test/cctest/test_platform.cc', 'test/cctest/test_report_util.cc', 'test/cctest/test_traced_value.cc', + 'test/cctest/test_url.cc', 'test/cctest/test_util.cc', - 'test/cctest/test_url.cc' + 'test/cctest/node_test_fixture.h', ], 'conditions': [