-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: move version metadata into node_metadata{.h, .cc}
This patch moves the computation of version metadata from node.cc into node_metadata{.h, .cc}, and creates a macro that can be used to iterate over the available version keys (v8, uv, .etc). This makes the code clearer as now we no longer need to add all the headers in node.cc just to compute the versions, and makes it easier to reuse the version definitions. PR-URL: #24774 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
1 parent
53b59b4
commit 7c70b61
Showing
4 changed files
with
117 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "node_metadata.h" | ||
#include "ares.h" | ||
#include "nghttp2/nghttp2ver.h" | ||
#include "node.h" | ||
#include "util.h" | ||
#include "uv.h" | ||
#include "v8.h" | ||
#include "zlib.h" | ||
|
||
#if HAVE_OPENSSL | ||
#include "node_crypto.h" | ||
#endif | ||
|
||
#ifdef NODE_EXPERIMENTAL_HTTP | ||
#include "llhttp.h" | ||
#else /* !NODE_EXPERIMENTAL_HTTP */ | ||
#include "http_parser.h" | ||
#endif /* NODE_EXPERIMENTAL_HTTP */ | ||
|
||
namespace node { | ||
|
||
namespace per_process { | ||
Metadata metadata; | ||
} | ||
|
||
Metadata::Versions::Versions() { | ||
node = NODE_VERSION_STRING; | ||
v8 = v8::V8::GetVersion(); | ||
uv = uv_version_string(); | ||
zlib = ZLIB_VERSION; | ||
ares = ARES_VERSION_STR; | ||
modules = NODE_STRINGIFY(NODE_MODULE_VERSION); | ||
nghttp2 = NGHTTP2_VERSION; | ||
napi = NODE_STRINGIFY(NAPI_VERSION); | ||
|
||
#ifdef NODE_EXPERIMENTAL_HTTP | ||
llhttp = NODE_STRINGIFY(LLHTTP_VERSION_MAJOR) "." NODE_STRINGIFY( | ||
LLHTTP_VERSION_MINOR) "." NODE_STRINGIFY(LLHTTP_VERSION_PATCH); | ||
#else /* !NODE_EXPERIMENTAL_HTTP */ | ||
http_parser = NODE_STRINGIFY(HTTP_PARSER_VERSION_MAJOR) "." NODE_STRINGIFY( | ||
HTTP_PARSER_VERSION_MINOR) "." NODE_STRINGIFY(HTTP_PARSER_VERSION_PATCH); | ||
#endif /* NODE_EXPERIMENTAL_HTTP */ | ||
|
||
#if HAVE_OPENSSL | ||
openssl = crypto::GetOpenSSLVersion(); | ||
#endif | ||
} | ||
|
||
} // namespace node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef SRC_NODE_METADATA_H_ | ||
#define SRC_NODE_METADATA_H_ | ||
|
||
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | ||
|
||
#include <string> | ||
|
||
namespace node { | ||
|
||
#define NODE_VERSIONS_KEYS_BASE(V) \ | ||
V(node) \ | ||
V(v8) \ | ||
V(uv) \ | ||
V(zlib) \ | ||
V(ares) \ | ||
V(modules) \ | ||
V(nghttp2) \ | ||
V(napi) | ||
|
||
#ifdef NODE_EXPERIMENTAL_HTTP | ||
#define NODE_VERSIONS_KEY_HTTP(V) V(llhttp) | ||
#else /* !NODE_EXPERIMENTAL_HTTP */ | ||
#define NODE_VERSIONS_KEY_HTTP(V) V(http_parser) | ||
#endif /* NODE_EXPERIMENTAL_HTTP */ | ||
|
||
#if HAVE_OPENSSL | ||
#define NODE_VERSIONS_KEY_CRYPTO(V) V(openssl) | ||
#else | ||
#define NODE_VERSIONS_KEY_CRYPTO(V) | ||
#endif | ||
|
||
#define NODE_VERSIONS_KEYS(V) \ | ||
NODE_VERSIONS_KEYS_BASE(V) \ | ||
NODE_VERSIONS_KEY_HTTP(V) \ | ||
NODE_VERSIONS_KEY_CRYPTO(V) | ||
|
||
class Metadata { | ||
public: | ||
struct Versions { | ||
Versions(); | ||
#define V(key) std::string key; | ||
NODE_VERSIONS_KEYS(V) | ||
#undef V | ||
}; | ||
|
||
Versions versions; | ||
}; | ||
|
||
// Per-process global | ||
namespace per_process { | ||
extern Metadata metadata; | ||
} | ||
|
||
} // namespace node | ||
|
||
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | ||
#endif // SRC_NODE_METADATA_H_ |