• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SRC_NODE_METADATA_H_
2 #define SRC_NODE_METADATA_H_
3 
4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5 
6 #include <string>
7 #include "node_version.h"
8 
9 namespace node {
10 
11 // if this is a release build and no explicit base has been set
12 // substitute the standard release download URL
13 #ifndef NODE_RELEASE_URLBASE
14 #if NODE_VERSION_IS_RELEASE
15 #define NODE_RELEASE_URLBASE "https://nodejs.org/download/release/"
16 #endif  // NODE_VERSION_IS_RELEASE
17 #endif  // NODE_RELEASE_URLBASE
18 
19 #if defined(NODE_RELEASE_URLBASE)
20 #define NODE_HAS_RELEASE_URLS
21 #endif
22 
23 #define NODE_VERSIONS_KEYS_BASE(V)                                             \
24   V(node)                                                                      \
25   V(v8)                                                                        \
26   V(uv)                                                                        \
27   V(zlib)                                                                      \
28   V(brotli)                                                                    \
29   V(ares)                                                                      \
30   V(modules)                                                                   \
31   V(nghttp2)                                                                   \
32   V(napi)                                                                      \
33   V(llhttp)                                                                    \
34   V(http_parser)                                                               \
35 
36 #if HAVE_OPENSSL
37 #define NODE_VERSIONS_KEY_CRYPTO(V) V(openssl)
38 #else
39 #define NODE_VERSIONS_KEY_CRYPTO(V)
40 #endif
41 
42 #ifdef NODE_HAVE_I18N_SUPPORT
43 #define NODE_VERSIONS_KEY_INTL(V)                                              \
44   V(cldr)                                                                      \
45   V(icu)                                                                       \
46   V(tz)                                                                        \
47   V(unicode)
48 #else
49 #define NODE_VERSIONS_KEY_INTL(V)
50 #endif  // NODE_HAVE_I18N_SUPPORT
51 
52 #define NODE_VERSIONS_KEYS(V)                                                  \
53   NODE_VERSIONS_KEYS_BASE(V)                                                   \
54   NODE_VERSIONS_KEY_CRYPTO(V)                                                  \
55   NODE_VERSIONS_KEY_INTL(V)
56 
57 class Metadata {
58  public:
59   Metadata();
60   Metadata(Metadata&) = delete;
61   Metadata(Metadata&&) = delete;
62   Metadata operator=(Metadata&) = delete;
63   Metadata operator=(Metadata&&) = delete;
64 
65   struct Versions {
66     Versions();
67 
68 #ifdef NODE_HAVE_I18N_SUPPORT
69     // Must be called on the main thread after
70     // i18n::InitializeICUDirectory()
71     void InitializeIntlVersions();
72 #endif  // NODE_HAVE_I18N_SUPPORT
73 
74 #define V(key) std::string key;
75     NODE_VERSIONS_KEYS(V)
76 #undef V
77   };
78 
79   struct Release {
80     Release();
81 
82     std::string name;
83 #if NODE_VERSION_IS_LTS
84     std::string lts;
85 #endif  // NODE_VERSION_IS_LTS
86 
87 #ifdef NODE_HAS_RELEASE_URLS
88     std::string source_url;
89     std::string headers_url;
90 #ifdef _WIN32
91     std::string lib_url;
92 #endif  // _WIN32
93 #endif  // NODE_HAS_RELEASE_URLS
94   };
95 
96   Versions versions;
97   const Release release;
98   const std::string arch;
99   const std::string platform;
100 };
101 
102 // Per-process global
103 namespace per_process {
104 extern Metadata metadata;
105 extern const char* const llhttp_version;
106 extern const char* const http_parser_version;
107 }
108 
109 }  // namespace node
110 
111 #endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
112 #endif  // SRC_NODE_METADATA_H_
113