|
25 | 25 | #include "node_context_data.h" |
26 | 26 | #include "node_errors.h" |
27 | 27 | #include "node_internals.h" |
| 28 | +#include "node_metadata.h" |
28 | 29 | #include "node_native_module.h" |
29 | 30 | #include "node_perf.h" |
30 | 31 | #include "node_platform.h" |
|
48 | 49 | #include "node_dtrace.h" |
49 | 50 | #endif |
50 | 51 |
|
51 | | -#include "ares.h" |
52 | 52 | #include "async_wrap-inl.h" |
53 | 53 | #include "env-inl.h" |
54 | 54 | #include "handle_wrap.h" |
55 | | -#ifdef NODE_EXPERIMENTAL_HTTP |
56 | | -# include "llhttp.h" |
57 | | -#else /* !NODE_EXPERIMENTAL_HTTP */ |
58 | | -# include "http_parser.h" |
59 | | -#endif /* NODE_EXPERIMENTAL_HTTP */ |
60 | | -#include "nghttp2/nghttp2ver.h" |
61 | 55 | #include "req_wrap-inl.h" |
62 | 56 | #include "string_bytes.h" |
63 | 57 | #include "tracing/agent.h" |
|
68 | 62 | #include "libplatform/libplatform.h" |
69 | 63 | #endif // NODE_USE_V8_PLATFORM |
70 | 64 | #include "v8-profiler.h" |
71 | | -#include "zlib.h" |
72 | 65 |
|
73 | 66 | #ifdef NODE_ENABLE_VTUNE_PROFILING |
74 | 67 | #include "../deps/v8/src/third_party/vtune/v8-vtune.h" |
@@ -158,22 +151,6 @@ using v8::Value; |
158 | 151 |
|
159 | 152 | static bool v8_is_profiling = false; |
160 | 153 |
|
161 | | -#ifdef NODE_EXPERIMENTAL_HTTP |
162 | | -static const char llhttp_version[] = |
163 | | - NODE_STRINGIFY(LLHTTP_VERSION_MAJOR) |
164 | | - "." |
165 | | - NODE_STRINGIFY(LLHTTP_VERSION_MINOR) |
166 | | - "." |
167 | | - NODE_STRINGIFY(LLHTTP_VERSION_PATCH); |
168 | | -#else /* !NODE_EXPERIMENTAL_HTTP */ |
169 | | -static const char http_parser_version[] = |
170 | | - NODE_STRINGIFY(HTTP_PARSER_VERSION_MAJOR) |
171 | | - "." |
172 | | - NODE_STRINGIFY(HTTP_PARSER_VERSION_MINOR) |
173 | | - "." |
174 | | - NODE_STRINGIFY(HTTP_PARSER_VERSION_PATCH); |
175 | | -#endif /* NODE_EXPERIMENTAL_HTTP */ |
176 | | - |
177 | 154 | // Bit flag used to track security reverts (see node_revert.h) |
178 | 155 | unsigned int reverted = 0; |
179 | 156 |
|
@@ -212,27 +189,12 @@ class NodeTraceStateObserver : |
212 | 189 | auto trace_process = tracing::TracedValue::Create(); |
213 | 190 | trace_process->BeginDictionary("versions"); |
214 | 191 |
|
215 | | -#ifdef NODE_EXPERIMENTAL_HTTP |
216 | | - trace_process->SetString("llhttp", llhttp_version); |
217 | | -#else /* !NODE_EXPERIMENTAL_HTTP */ |
218 | | - trace_process->SetString("http_parser", http_parser_version); |
219 | | -#endif /* NODE_EXPERIMENTAL_HTTP */ |
220 | | - |
221 | | - const char node_napi_version[] = NODE_STRINGIFY(NAPI_VERSION); |
222 | | - const char node_modules_version[] = NODE_STRINGIFY(NODE_MODULE_VERSION); |
| 192 | +#define V(key) \ |
| 193 | + trace_process->SetString(#key, per_process::metadata.versions.key.c_str()); |
223 | 194 |
|
224 | | - trace_process->SetString("node", NODE_VERSION_STRING); |
225 | | - trace_process->SetString("v8", V8::GetVersion()); |
226 | | - trace_process->SetString("uv", uv_version_string()); |
227 | | - trace_process->SetString("zlib", ZLIB_VERSION); |
228 | | - trace_process->SetString("ares", ARES_VERSION_STR); |
229 | | - trace_process->SetString("modules", node_modules_version); |
230 | | - trace_process->SetString("nghttp2", NGHTTP2_VERSION); |
231 | | - trace_process->SetString("napi", node_napi_version); |
| 195 | + NODE_VERSIONS_KEYS(V) |
| 196 | +#undef V |
232 | 197 |
|
233 | | -#if HAVE_OPENSSL |
234 | | - trace_process->SetString("openssl", crypto::GetOpenSSLVersion()); |
235 | | -#endif |
236 | 198 | trace_process->EndDictionary(); |
237 | 199 |
|
238 | 200 | trace_process->SetString("arch", NODE_ARCH); |
@@ -980,53 +942,10 @@ void SetupProcessObject(Environment* env, |
980 | 942 | Local<Object> versions = Object::New(env->isolate()); |
981 | 943 | READONLY_PROPERTY(process, "versions", versions); |
982 | 944 |
|
983 | | -#ifdef NODE_EXPERIMENTAL_HTTP |
984 | | - READONLY_PROPERTY(versions, |
985 | | - "llhttp", |
986 | | - FIXED_ONE_BYTE_STRING(env->isolate(), llhttp_version)); |
987 | | -#else /* !NODE_EXPERIMENTAL_HTTP */ |
988 | | - READONLY_PROPERTY(versions, |
989 | | - "http_parser", |
990 | | - FIXED_ONE_BYTE_STRING(env->isolate(), http_parser_version)); |
991 | | -#endif /* NODE_EXPERIMENTAL_HTTP */ |
992 | | - |
993 | | - // +1 to get rid of the leading 'v' |
994 | | - READONLY_PROPERTY(versions, |
995 | | - "node", |
996 | | - OneByteString(env->isolate(), NODE_VERSION + 1)); |
997 | | - READONLY_PROPERTY(versions, |
998 | | - "v8", |
999 | | - OneByteString(env->isolate(), V8::GetVersion())); |
1000 | | - READONLY_PROPERTY(versions, |
1001 | | - "uv", |
1002 | | - OneByteString(env->isolate(), uv_version_string())); |
1003 | | - READONLY_PROPERTY(versions, |
1004 | | - "zlib", |
1005 | | - FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION)); |
1006 | | - READONLY_PROPERTY(versions, |
1007 | | - "ares", |
1008 | | - FIXED_ONE_BYTE_STRING(env->isolate(), ARES_VERSION_STR)); |
1009 | | - |
1010 | | - const char node_modules_version[] = NODE_STRINGIFY(NODE_MODULE_VERSION); |
1011 | | - READONLY_PROPERTY( |
1012 | | - versions, |
1013 | | - "modules", |
1014 | | - FIXED_ONE_BYTE_STRING(env->isolate(), node_modules_version)); |
1015 | | - READONLY_PROPERTY(versions, |
1016 | | - "nghttp2", |
1017 | | - FIXED_ONE_BYTE_STRING(env->isolate(), NGHTTP2_VERSION)); |
1018 | | - const char node_napi_version[] = NODE_STRINGIFY(NAPI_VERSION); |
1019 | | - READONLY_PROPERTY( |
1020 | | - versions, |
1021 | | - "napi", |
1022 | | - FIXED_ONE_BYTE_STRING(env->isolate(), node_napi_version)); |
1023 | | - |
1024 | | -#if HAVE_OPENSSL |
1025 | | - READONLY_PROPERTY( |
1026 | | - versions, |
1027 | | - "openssl", |
1028 | | - OneByteString(env->isolate(), crypto::GetOpenSSLVersion().c_str())); |
1029 | | -#endif |
| 945 | +#define V(key) \ |
| 946 | + READONLY_STRING_PROPERTY(versions, #key, per_process::metadata.versions.key); |
| 947 | + NODE_VERSIONS_KEYS(V) |
| 948 | +#undef V |
1030 | 949 |
|
1031 | 950 | // process.arch |
1032 | 951 | READONLY_PROPERTY(process, "arch", OneByteString(env->isolate(), NODE_ARCH)); |
|
0 commit comments