11cb0ef41Sopenharmony_ci#include "node_metadata.h" 21cb0ef41Sopenharmony_ci#include "acorn_version.h" 31cb0ef41Sopenharmony_ci#include "ada.h" 41cb0ef41Sopenharmony_ci#include "ares.h" 51cb0ef41Sopenharmony_ci#include "base64_version.h" 61cb0ef41Sopenharmony_ci#include "brotli/encode.h" 71cb0ef41Sopenharmony_ci#include "cjs_module_lexer_version.h" 81cb0ef41Sopenharmony_ci#include "llhttp.h" 91cb0ef41Sopenharmony_ci#include "nghttp2/nghttp2ver.h" 101cb0ef41Sopenharmony_ci#include "node.h" 111cb0ef41Sopenharmony_ci#include "simdutf.h" 121cb0ef41Sopenharmony_ci#include "undici_version.h" 131cb0ef41Sopenharmony_ci#include "util.h" 141cb0ef41Sopenharmony_ci#include "uv.h" 151cb0ef41Sopenharmony_ci#include "uvwasi.h" 161cb0ef41Sopenharmony_ci#include "v8.h" 171cb0ef41Sopenharmony_ci#include "zlib.h" 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci#if HAVE_OPENSSL 201cb0ef41Sopenharmony_ci#include <openssl/opensslv.h> 211cb0ef41Sopenharmony_ci#if NODE_OPENSSL_HAS_QUIC 221cb0ef41Sopenharmony_ci#include <openssl/quic.h> 231cb0ef41Sopenharmony_ci#endif 241cb0ef41Sopenharmony_ci#endif // HAVE_OPENSSL 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci#ifdef OPENSSL_INFO_QUIC 271cb0ef41Sopenharmony_ci#include <ngtcp2/version.h> 281cb0ef41Sopenharmony_ci#include <nghttp3/version.h> 291cb0ef41Sopenharmony_ci#endif 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci#ifdef NODE_HAVE_I18N_SUPPORT 321cb0ef41Sopenharmony_ci#include <unicode/timezone.h> 331cb0ef41Sopenharmony_ci#include <unicode/ulocdata.h> 341cb0ef41Sopenharmony_ci#include <unicode/uvernum.h> 351cb0ef41Sopenharmony_ci#include <unicode/uversion.h> 361cb0ef41Sopenharmony_ci#endif // NODE_HAVE_I18N_SUPPORT 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_cinamespace node { 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_cinamespace per_process { 411cb0ef41Sopenharmony_ciMetadata metadata; 421cb0ef41Sopenharmony_ci} 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci#if HAVE_OPENSSL 451cb0ef41Sopenharmony_cistatic constexpr size_t search(const char* s, char c, size_t n = 0) { 461cb0ef41Sopenharmony_ci return *s == c ? n : search(s + 1, c, n + 1); 471cb0ef41Sopenharmony_ci} 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_cistatic inline std::string GetOpenSSLVersion() { 501cb0ef41Sopenharmony_ci // sample openssl version string format 511cb0ef41Sopenharmony_ci // for reference: "OpenSSL 1.1.0i 14 Aug 2018" 521cb0ef41Sopenharmony_ci constexpr size_t start = search(OPENSSL_VERSION_TEXT, ' ') + 1; 531cb0ef41Sopenharmony_ci constexpr size_t len = search(&OPENSSL_VERSION_TEXT[start], ' '); 541cb0ef41Sopenharmony_ci return std::string(OPENSSL_VERSION_TEXT, start, len); 551cb0ef41Sopenharmony_ci} 561cb0ef41Sopenharmony_ci#endif // HAVE_OPENSSL 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ci#ifdef NODE_HAVE_I18N_SUPPORT 591cb0ef41Sopenharmony_civoid Metadata::Versions::InitializeIntlVersions() { 601cb0ef41Sopenharmony_ci UErrorCode status = U_ZERO_ERROR; 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci const char* tz_version = icu::TimeZone::getTZDataVersion(status); 631cb0ef41Sopenharmony_ci if (U_SUCCESS(status)) { 641cb0ef41Sopenharmony_ci tz = tz_version; 651cb0ef41Sopenharmony_ci } 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ci char buf[U_MAX_VERSION_STRING_LENGTH]; 681cb0ef41Sopenharmony_ci UVersionInfo versionArray; 691cb0ef41Sopenharmony_ci ulocdata_getCLDRVersion(versionArray, &status); 701cb0ef41Sopenharmony_ci if (U_SUCCESS(status)) { 711cb0ef41Sopenharmony_ci u_versionToString(versionArray, buf); 721cb0ef41Sopenharmony_ci cldr = buf; 731cb0ef41Sopenharmony_ci } 741cb0ef41Sopenharmony_ci} 751cb0ef41Sopenharmony_ci#endif // NODE_HAVE_I18N_SUPPORT 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ciMetadata::Versions::Versions() { 781cb0ef41Sopenharmony_ci node = NODE_VERSION_STRING; 791cb0ef41Sopenharmony_ci v8 = v8::V8::GetVersion(); 801cb0ef41Sopenharmony_ci uv = uv_version_string(); 811cb0ef41Sopenharmony_ci zlib = ZLIB_VERSION; 821cb0ef41Sopenharmony_ci ares = ARES_VERSION_STR; 831cb0ef41Sopenharmony_ci modules = NODE_STRINGIFY(NODE_MODULE_VERSION); 841cb0ef41Sopenharmony_ci nghttp2 = NGHTTP2_VERSION; 851cb0ef41Sopenharmony_ci napi = NODE_STRINGIFY(NAPI_VERSION); 861cb0ef41Sopenharmony_ci llhttp = 871cb0ef41Sopenharmony_ci NODE_STRINGIFY(LLHTTP_VERSION_MAJOR) 881cb0ef41Sopenharmony_ci "." 891cb0ef41Sopenharmony_ci NODE_STRINGIFY(LLHTTP_VERSION_MINOR) 901cb0ef41Sopenharmony_ci "." 911cb0ef41Sopenharmony_ci NODE_STRINGIFY(LLHTTP_VERSION_PATCH); 921cb0ef41Sopenharmony_ci 931cb0ef41Sopenharmony_ci brotli = 941cb0ef41Sopenharmony_ci std::to_string(BrotliEncoderVersion() >> 24) + 951cb0ef41Sopenharmony_ci "." + 961cb0ef41Sopenharmony_ci std::to_string((BrotliEncoderVersion() & 0xFFF000) >> 12) + 971cb0ef41Sopenharmony_ci "." + 981cb0ef41Sopenharmony_ci std::to_string(BrotliEncoderVersion() & 0xFFF); 991cb0ef41Sopenharmony_ci#ifndef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH 1001cb0ef41Sopenharmony_ci undici = UNDICI_VERSION; 1011cb0ef41Sopenharmony_ci#endif 1021cb0ef41Sopenharmony_ci 1031cb0ef41Sopenharmony_ci acorn = ACORN_VERSION; 1041cb0ef41Sopenharmony_ci cjs_module_lexer = CJS_MODULE_LEXER_VERSION; 1051cb0ef41Sopenharmony_ci base64 = BASE64_VERSION; 1061cb0ef41Sopenharmony_ci uvwasi = UVWASI_VERSION_STRING; 1071cb0ef41Sopenharmony_ci 1081cb0ef41Sopenharmony_ci#if HAVE_OPENSSL 1091cb0ef41Sopenharmony_ci openssl = GetOpenSSLVersion(); 1101cb0ef41Sopenharmony_ci#endif 1111cb0ef41Sopenharmony_ci 1121cb0ef41Sopenharmony_ci#ifdef NODE_HAVE_I18N_SUPPORT 1131cb0ef41Sopenharmony_ci icu = U_ICU_VERSION; 1141cb0ef41Sopenharmony_ci unicode = U_UNICODE_VERSION; 1151cb0ef41Sopenharmony_ci#endif // NODE_HAVE_I18N_SUPPORT 1161cb0ef41Sopenharmony_ci 1171cb0ef41Sopenharmony_ci#ifdef OPENSSL_INFO_QUIC 1181cb0ef41Sopenharmony_ci ngtcp2 = NGTCP2_VERSION; 1191cb0ef41Sopenharmony_ci nghttp3 = NGHTTP3_VERSION; 1201cb0ef41Sopenharmony_ci#endif 1211cb0ef41Sopenharmony_ci 1221cb0ef41Sopenharmony_ci simdutf = SIMDUTF_VERSION; 1231cb0ef41Sopenharmony_ci ada = ADA_VERSION; 1241cb0ef41Sopenharmony_ci} 1251cb0ef41Sopenharmony_ci 1261cb0ef41Sopenharmony_ciMetadata::Release::Release() : name(NODE_RELEASE) { 1271cb0ef41Sopenharmony_ci#if NODE_VERSION_IS_LTS 1281cb0ef41Sopenharmony_ci lts = NODE_VERSION_LTS_CODENAME; 1291cb0ef41Sopenharmony_ci#endif // NODE_VERSION_IS_LTS 1301cb0ef41Sopenharmony_ci 1311cb0ef41Sopenharmony_ci#ifdef NODE_HAS_RELEASE_URLS 1321cb0ef41Sopenharmony_ci#define NODE_RELEASE_URLPFX NODE_RELEASE_URLBASE "v" NODE_VERSION_STRING "/" 1331cb0ef41Sopenharmony_ci#define NODE_RELEASE_URLFPFX NODE_RELEASE_URLPFX "node-v" NODE_VERSION_STRING 1341cb0ef41Sopenharmony_ci 1351cb0ef41Sopenharmony_ci source_url = NODE_RELEASE_URLFPFX ".tar.gz"; 1361cb0ef41Sopenharmony_ci headers_url = NODE_RELEASE_URLFPFX "-headers.tar.gz"; 1371cb0ef41Sopenharmony_ci#ifdef _WIN32 1381cb0ef41Sopenharmony_ci lib_url = strcmp(NODE_ARCH, "ia32") ? NODE_RELEASE_URLPFX "win-" NODE_ARCH 1391cb0ef41Sopenharmony_ci "/node.lib" 1401cb0ef41Sopenharmony_ci : NODE_RELEASE_URLPFX "win-x86/node.lib"; 1411cb0ef41Sopenharmony_ci#endif // _WIN32 1421cb0ef41Sopenharmony_ci 1431cb0ef41Sopenharmony_ci#endif // NODE_HAS_RELEASE_URLS 1441cb0ef41Sopenharmony_ci} 1451cb0ef41Sopenharmony_ci 1461cb0ef41Sopenharmony_ciMetadata::Metadata() : arch(NODE_ARCH), platform(NODE_PLATFORM) {} 1471cb0ef41Sopenharmony_ci 1481cb0ef41Sopenharmony_ci} // namespace node 149